From c88b7c5da8dde6c4f7bdd85743378ec46f3a30fc Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Mon, 5 Apr 2010 13:48:27 +0100
Subject: Merged roster status types for sorting in the same way as the status
 icons.

Resolves: #270

diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
index 5bd7d1e..c7d2ee6 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
@@ -34,12 +34,12 @@ void QtTreeWidgetItem::setStatusShow(StatusShow::Type show) {
 	statusShowType_ = show;
 	int color = 0;
 	switch (show) {
-	 	case StatusShow::Online: color = 0x000000;break;
-	 	case StatusShow::Away: color = 0x336699;break;
-	 	case StatusShow::XA: color = 0x336699;break;
-	 	case StatusShow::FFC: color = 0x000000;break;
-	 	case StatusShow::DND: color = 0x990000;break;
-	 	case StatusShow::None: color = 0x7F7F7F;break;
+		case StatusShow::Online: color = 0x000000; mergedShowType_ = StatusShow::Online; break;
+		case StatusShow::Away: color = 0x336699; mergedShowType_ = StatusShow::Away; break;
+	 	case StatusShow::XA: color = 0x336699; mergedShowType_ = StatusShow::Away; break;
+		case StatusShow::FFC: color = 0x000000; mergedShowType_ = StatusShow::Online; break;
+		case StatusShow::DND: color = 0x990000; mergedShowType_ = show; break;
+		case StatusShow::None: color = 0x7F7F7F; mergedShowType_ = show; break;
 	}
 	setTextColor(color);
 	emit changed(this);
@@ -220,7 +220,7 @@ bool QtTreeWidgetItem::operator<(const QtTreeWidgetItem& item) const {
 		if (!item.isContact()) {
 			return false;
 		}
-		return getStatusShow() == item.getStatusShow() ? getLowerName() < item.getLowerName() : getStatusShow() < item.getStatusShow();
+		return getStatusShowMerged() == item.getStatusShowMerged() ? getLowerName() < item.getLowerName() : getStatusShowMerged() < item.getStatusShowMerged();
 	} else {
 		if (item.isContact()) {
 			return true;
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h
index 4f4e28f..00b7d9d 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.h
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h
@@ -53,6 +53,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
 			const QString& getName() const {return displayName_;};
 			const QString& getLowerName() const {return displayNameLower_;};
 			StatusShow::Type getStatusShow() const {return statusShowType_;};
+			StatusShow::Type getStatusShowMerged() const {return mergedShowType_;};
 
 			QWidget* getCollapsedRosterWidget();
 			QWidget* getExpandedRosterWidget();
@@ -76,6 +77,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
 			bool shown_;
 			bool expanded_;
 			StatusShow::Type statusShowType_;
+			StatusShow::Type mergedShowType_;
 };
 
 bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right);
-- 
cgit v0.10.2-6-g49f6