diff options
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r-- | Swift/QtUI/Roster/RosterModel.cpp | 18 | ||||
-rw-r--r-- | Swift/QtUI/Roster/RosterModel.h | 1 |
2 files changed, 3 insertions, 16 deletions
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 30d8135..1df2117 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -19,15 +19,12 @@ 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); + Q_ASSERT(modelIndex.isValid()); emit itemExpanded(modelIndex, item->isExpanded()); emit dataChanged(modelIndex, modelIndex); - + emit layoutChanged(); } int RosterModel::columnCount(const QModelIndex& parent) const { @@ -48,18 +45,9 @@ QModelIndex RosterModel::index(int row, int column, const QModelIndex& parent) c } QModelIndex RosterModel::index(QtTreeWidgetItem* item) const { - QtTreeWidgetItem* parentItem = item->getParentItem(); - Q_ASSERT(parentItem); - QModelIndex parentIndex = parent(item); - return index(item->row(), 0, parentIndex); + return createIndex(item->row(), 0, item); } -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(); diff --git a/Swift/QtUI/Roster/RosterModel.h b/Swift/QtUI/Roster/RosterModel.h index c1d998c..fc9b1f3 100644 --- a/Swift/QtUI/Roster/RosterModel.h +++ b/Swift/QtUI/Roster/RosterModel.h @@ -17,7 +17,6 @@ public: QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; QModelIndex index(QtTreeWidgetItem* item) const; QModelIndex parent(const QModelIndex& index) const; - QModelIndex parent(QtTreeWidgetItem* item) const; int rowCount(const QModelIndex& parent = QModelIndex()) const; signals: void itemExpanded(const QModelIndex& item, bool expanded); |