From f948f047401021f3afc8a015991fc81e7d69d6ce Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 8 Aug 2009 15:39:06 +0100
Subject: Group expandedness in roster persists between roster changes.


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);
-- 
cgit v0.10.2-6-g49f6