summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-08 14:18:43 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-08 14:18:43 (GMT)
commit47d75bf5a3f58ce582e5715a9d5ba6e89a38b033 (patch)
tree20345d9b84af4650076440e6a2f57a4661143ca4 /Swift/QtUI/Roster/RosterModel.cpp
parent40d35626023f12d8ebea3a53672968b1b80f5974 (diff)
downloadswift-47d75bf5a3f58ce582e5715a9d5ba6e89a38b033.zip
swift-47d75bf5a3f58ce582e5715a9d5ba6e89a38b033.tar.bz2
Plumbing in place for roster group expansion. \nDoesn't work.
Diffstat (limited to 'Swift/QtUI/Roster/RosterModel.cpp')
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index f322792..30d8135 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -11,16 +11,23 @@ RosterModel::~RosterModel() {
void RosterModel::setRoot(QtTreeWidgetItem* root) {
tree_ = root;
- connect(tree_, SIGNAL(changed()), this, SLOT(handleItemChanged()));
+ connect(tree_, SIGNAL(changed(QtTreeWidgetItem*)), this, SLOT(handleItemChanged(QtTreeWidgetItem*)));
}
-void RosterModel::handleItemChanged() {
- //FIXME: This is just a lazy hack to cause the view to refresh until it works.
- // Then I'll replace it with the proper implementation.
- //printf("Changed\n");
+void RosterModel::handleItemChanged(QtTreeWidgetItem* item) {
+ if (!item->isShown()) {
+ return;
+ }
+ //these two lines should be redundant, but...
reset();
emit layoutChanged();
+ //These lines don't seem to be enough
+ Q_ASSERT(item);
+ QModelIndex modelIndex = index(item);
+ emit itemExpanded(modelIndex, item->isExpanded());
+ emit dataChanged(modelIndex, modelIndex);
+
}
int RosterModel::columnCount(const QModelIndex& parent) const {
@@ -40,6 +47,19 @@ QModelIndex RosterModel::index(int row, int column, const QModelIndex& parent) c
return row < parentItem->rowCount() ? createIndex(row, column, parentItem->getItem(row)) : QModelIndex();
}
+QModelIndex RosterModel::index(QtTreeWidgetItem* item) const {
+ QtTreeWidgetItem* parentItem = item->getParentItem();
+ Q_ASSERT(parentItem);
+ QModelIndex parentIndex = parent(item);
+ return index(item->row(), 0, parentIndex);
+}
+
+QModelIndex RosterModel::parent(QtTreeWidgetItem* item) const {
+ QtTreeWidgetItem* parentItem = item->getParentItem();
+ return parentItem == tree_ ? QModelIndex() : index(parentItem->row(), 0, parent(parentItem));
+}
+
+
QModelIndex RosterModel::parent(const QModelIndex& index) const {
if (!index.isValid()) {
return QModelIndex();