Adding more filtering options
authorEd Page <eopage@byu.net>
Thu, 25 Mar 2010 01:17:34 +0000 (20:17 -0500)
committerEd Page <eopage@byu.net>
Thu, 25 Mar 2010 01:17:34 +0000 (20:17 -0500)
src/libliststorehandler.py
src/libview.py
src/multilist_gtk.py
support/builddeb.py

index 04fe392..835c4a6 100644 (file)
@@ -38,8 +38,10 @@ _moduleLogger = logging.getLogger(__name__)
 class Liststorehandler(object):
 
        SHOW_ALL = "all"
-       SHOW_ACTIVE = "active"
-       ALL_FILTERS = (SHOW_ALL, SHOW_ACTIVE)
+       SHOW_NEW = "-1"
+       SHOW_ACTIVE = "0"
+       SHOW_COMPLETE = "1"
+       ALL_FILTERS = (SHOW_ALL, SHOW_NEW, SHOW_ACTIVE, SHOW_COMPLETE)
 
        def __init__(self, db, selection):
                self.db = db
@@ -65,7 +67,7 @@ class Liststorehandler(object):
                return self.__filter
 
        def get_unitsstore(self):
-               if (self.unitsstore == None):
+               if self.unitsstore is None:
                        self.unitsstore = gtk.ListStore(str, str, str, str, str,  str, str, str, str, str, str, str, str)
                self.unitsstore.clear()
                #row(3) quantities
@@ -86,10 +88,10 @@ class Liststorehandler(object):
                return self.unitsstore
 
        def __calculate_status(self):
-               if self.__filter == self.SHOW_ACTIVE:
-                       status = "0"
+               if self.__filter == self.SHOW_ALL:
+                       status = self.SHOW_NEW
                else:
-                       status = "-1"
+                       status = self.__filter
                return status
 
        def get_liststore(self, titlesearch = ""):
@@ -99,7 +101,7 @@ class Liststorehandler(object):
 
                titlesearch = titlesearch+"%"
 
-               if self.__filter == self.SHOW_ACTIVE:
+               if self.__filter != self.SHOW_ALL:
                        status = self.__calculate_status()
                        sql = "SELECT uid, status, title, quantitiy, unit, price, priority, date, private, stores, note, custom1, custom2 FROM items WHERE list = ? AND category LIKE ? AND status = ? AND title like ? ORDER BY category, status, title"
                        rows = self.db.ladeSQL(sql, (self.selection.get_list(), self.selection.get_category(True), status, titlesearch))
@@ -137,10 +139,10 @@ class Liststorehandler(object):
 
        def checkout_rows(self):
                sql = "UPDATE items SET status = ? WHERE list = ? AND category LIKE ? AND status = ?"
-               self.db.speichereSQL(sql, ("-1", self.selection.get_list(), self.selection.get_category(True), "1"))
+               self.db.speichereSQL(sql, (self.SHOW_NEW, self.selection.get_list(), self.selection.get_category(True), self.SHOW_COMPLETE))
                for i in range(len(self.liststore)):
-                       if self.liststore[i][1] == "1":
-                               self.liststore[i][1] = "-1"
+                       if self.liststore[i][1] == self.SHOW_COMPLETE:
+                               self.liststore[i][1] = self.SHOW_NEW
 
        def add_row(self, title = ""):
                status = self.__calculate_status()
index 6bc827a..7ded416 100644 (file)
@@ -26,6 +26,7 @@ import gtk
 import gobject
 
 import gtk_toolbox
+import libliststorehandler
 
 
 try:
@@ -52,7 +53,7 @@ class TripleToggleCellRenderer(gtk.CellRendererToggle):
                gtk.CellRendererToggle.__init__(self)
                self.set_property("activatable", True)
                self.connect('toggled', self._on_toggled)
-               self.status = -1
+               self.status = libliststorehandler.Liststorehandler.SHOW_NEW
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def do_set_property(self, property, value):
@@ -63,9 +64,9 @@ class TripleToggleCellRenderer(gtk.CellRendererToggle):
 
                if property.name == "status":
                        active, inconsistent = {
-                               "-1": (False, True),
-                               "0": (False, False),
-                               "1": (True, False),
+                               libliststorehandler.Liststorehandler.SHOW_NEW: (False, False),
+                               libliststorehandler.Liststorehandler.SHOW_ACTIVE: (False, True),
+                               libliststorehandler.Liststorehandler.SHOW_COMPLETE: (True, False),
                        }[value]
                        self.set_property("active", active)
                        self.set_property("inconsistent", inconsistent)
@@ -148,7 +149,6 @@ class View(gtk.VBox):
                                        self.cell[i].connect("edited", self._on_col_edited, i)
                                        self.tvcolumn[i].set_attributes(self.cell[i], text = i)
 
-                               self.cell[i].set_property('cell-background', 'lightgray')
                                self.tvcolumn[i].set_sort_column_id(i)
                                self.tvcolumn[i].set_resizable(True)
                                self.treeview.append_column(self.tvcolumn[i])
index 171d1e6..4cf649c 100755 (executable)
@@ -208,11 +208,23 @@ class Multilist(hildonize.get_app_class()):
                        filterGroup = button
 
                        button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup)
+                       button.set_label("New")
+                       menuBar.add_filter(button)
+                       button.connect("clicked", self._on_click_menu_filter, self.liststorehandler.SHOW_NEW)
+                       button.set_mode(False)
+
+                       button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup)
                        button.set_label("Active")
                        menuBar.add_filter(button)
                        button.connect("clicked", self._on_click_menu_filter, self.liststorehandler.SHOW_ACTIVE)
                        button.set_mode(False)
 
+                       button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup)
+                       button.set_label("Done")
+                       menuBar.add_filter(button)
+                       button.connect("clicked", self._on_click_menu_filter, self.liststorehandler.SHOW_COMPLETE)
+                       button.set_mode(False)
+
                        renameListButton= gtk.Button(_("Rename List"))
                        renameListButton.connect("clicked", self.bottombar.rename_list)
                        menuBar.append(renameListButton)
index 80bf16f..72f777c 100755 (executable)
@@ -21,6 +21,9 @@ __email__ = "n800@axique.net"
 __version__ = constants.__version__
 __build__ = constants.__build__
 __changelog__ = """
+0.3.6
+* Adding filtering for new and complete in addition to all and active
+
 0.3.5
 * Bugfix: Fixing the application launcher