Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/listview.cc')
-rw-r--r--src/ui/listview.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ui/listview.cc b/src/ui/listview.cc
index fc75806..70ecf8f 100644
--- a/src/ui/listview.cc
+++ b/src/ui/listview.cc
@@ -97,4 +97,22 @@ bool ListView::on_emit(Widget *sender, const Event event, void *data)
return false;
}
+void ListView::sort()
+{
+ // bubble sort - there's a reason for using it here
+ for (Children::iterator low = children().begin(); low != children().end(); low++) {
+ Children::iterator high = low;
+ for (high++; high != children().end(); high++) {
+ ListItem *lowitem = dynamic_cast<ListItem *>(*low);
+ ListItem *highitem = dynamic_cast<ListItem *>(*high);
+ assert(lowitem && highitem);
+ if (highitem->sortkey() < lowitem->sortkey()) {
+ Widget *t = (*low);
+ (*low) = (*high);
+ (*high) = t;
+ }
+ }
+ }
+}
+
}