diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-08 23:33:49 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-08 23:33:49 +0000 |
commit | baf6ad1f48ef08187f50247115c09a3612ebeec3 (patch) | |
tree | c3c81f530c09b027f9880c8434df82a033a33323 /src/ui/listview.cc | |
parent | 106d0cb0cf884dd7a2920564852c001e13af1568 (diff) |
added sorting of listview items
Diffstat (limited to 'src/ui/listview.cc')
-rw-r--r-- | src/ui/listview.cc | 18 |
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; + } + } + } +} + } |