From 356a2f03e8c7e4cc1b2852fc7b530357c3213787 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Tue, 30 Mar 2010 08:49:03 +0100 Subject: Roster rendering of the test down from 2:11 to 0:10 on my desktop diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index 0b90c54..5bd7d1e 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -3,6 +3,7 @@ #include <qdebug.h> #include <QtAlgorithms> +#include <algorithm> namespace Swift { @@ -140,7 +141,8 @@ void bubbleSort(QList<QtTreeWidgetItem*>& list) { void QtTreeWidgetItem::handleChanged(QtTreeWidgetItem* child) { /*We don't use the much faster qStableSort because it causes changed(child) and all sorts of nasty recursion*/ //qStableSort(children_.begin(), children_.end(), itemLessThan); - bubbleSort(children_); + //bubbleSort(children_); + std::stable_sort(children_.begin(), children_.end(), itemLessThan); shownChildren_.clear(); for (int i = 0; i < children_.size(); i++) { if (children_[i]->isShown()) { @@ -227,8 +229,8 @@ bool QtTreeWidgetItem::operator<(const QtTreeWidgetItem& item) const { } } -//bool itemLessThan(const QtTreeWidgetItem& left, const QtTreeWidgetItem& right) { -// return left < right; -//} +bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right) { + return *left < *right; +} } diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index d243115..4f4e28f 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -78,7 +78,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { StatusShow::Type statusShowType_; }; -//bool itemLessThan(const QtTreeWidgetItem& left, const QtTreeWidgetItem& right); +bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right); } #endif -- cgit v0.10.2-6-g49f6