summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-10-05 20:17:27 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-10-05 20:17:42 (GMT)
commitcbaa100229b5001f41f13912fba2125213ab3d1f (patch)
treef2bda1dc5536155adf73d0defb2a514e65c50623 /Swift/QtUI/Roster
parent8f00ac5023dd91c707b648c8f9af6e03ff89c9de (diff)
downloadswift-contrib-cbaa100229b5001f41f13912fba2125213ab3d1f.zip
swift-contrib-cbaa100229b5001f41f13912fba2125213ab3d1f.tar.bz2
Early terminate completed bubblesorts in the roster
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
index 487dbb6..b237929 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
@@ -121,9 +121,12 @@ void QtTreeWidgetItem::removeChild(QtTreeWidgetItem* child) {
}
void bubbleSort(QList<QtTreeWidgetItem*>& list) {
- for (int i = 0; i < list.size(); i++) {
+ bool done = true;
+ for (int i = 0; i < list.size() - 1 && !done; i++) {
+ done = true;
for (int j = i + 1; j < list.size(); j++) {
if (*(list[j]) < *(list[j - 1])) {
+ done = false;
QtTreeWidgetItem* lower = list[j];
list[j] = list[j - 1];
list[j - 1] = lower;
@@ -135,7 +138,7 @@ 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_);
shownChildren_.clear();
for (int i = 0; i < children_.size(); i++) {
if (children_[i]->isShown()) {