[Sugar-devel] [RFC PATCH 6/8] Add sort_by method to the journal list view.
Andrés Ambrois
andresambrois at gmail.com
Sat May 1 15:33:54 EDT 2010
This method triggers the actual sorting. This is done by placing a 'order_by'
value in the query, and calling the datastore to retrieve the sorted data set.
The sort_column is also modified to display the property we are sorting by.
Signed-off-by: Andrés Ambrois <andresambrois at gmail.com>
---
src/jarabe/journal/listview.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 375a8ee..ad0390a 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -250,6 +250,18 @@ class BaseListView(gtk.Bin):
metadata['keep'] = '1'
model.write(metadata, update_mtime=False)
+ def sort_by(self, property, order):
+ cell_text = self.sort_column.get_cell_renderers()[0]
+ self.sort_column.set_attributes(cell_text,
+ text=getattr(ListModel, 'COLUMN_' + property.upper(),
+ ListModel.COLUMN_TIMESTAMP))
+ if order == gtk.SORT_ASCENDING:
+ sign = '+'
+ else:
+ sign = '-'
+ self._query['order_by'] = [sign + property]
+ self.refresh()
+
def update_with_query(self, query_dict):
logging.debug('ListView.update_with_query')
self._query = query_dict
--
1.6.3.3
More information about the Sugar-devel
mailing list