예제 #1
0
 def compareFunction(self, model, iter0, iter1, column):
     """ Multi-column sort. """
     val0 = model.get_value(iter0, column)
     val1 = model.get_value(iter1, column)
     rval = cmp(val0, val1)
     # If rval is 1 or -1, no need for a multi-column sort.
     if rval == 0:
         this_order = self.tv.get_model().get_sort_column_id()[1]
         cmp_factor = 1
         if this_order == Gtk.SortType.DESCENDING:
             # We need to de-invert the sort order for multi sorting.
             cmp_factor = -1
     i = 0
     while rval == 0 and i < len(self.prev_sort_column_id):
         next_id, next_order = self.prev_sort_column_id[i]
         if next_id == column:
             i += 1
             continue
         next_cmp_factor = cmp_factor * 1
         if next_order == Gtk.SortType.DESCENDING:
             # Set the correct order for multi sorting.
             next_cmp_factor = cmp_factor * -1
         val0 = model.get_value(iter0, next_id)
         val1 = model.get_value(iter1, next_id)
         rval = next_cmp_factor * cmp(val0, val1)
         i += 1
     return rval
예제 #2
0
 def compareFunction(self, model, iter0, iter1, column):
     """ Multi-column sort. """
     val0 = model.get_value(iter0, column)
     val1 = model.get_value(iter1, column)
     rval = cmp(val0, val1)
     # If rval is 1 or -1, no need for a multi-column sort.
     if rval == 0:
         this_order = self.tv.get_model().get_sort_column_id()[1]
         cmp_factor = 1
         if this_order == Gtk.SortType.DESCENDING:
             # We need to de-invert the sort order for multi sorting.
             cmp_factor = -1
     i = 0
     while rval == 0 and i < len(self.prev_sort_column_id):
         next_id, next_order = self.prev_sort_column_id[i]
         if next_id == column:
             i += 1
             continue
         next_cmp_factor = cmp_factor * 1
         if next_order == Gtk.SortType.DESCENDING:
             # Set the correct order for multi sorting.
             next_cmp_factor = cmp_factor * -1
         val0 = model.get_value(iter0, next_id)
         val1 = model.get_value(iter1, next_id)
         rval = next_cmp_factor * cmp(val0, val1)
         i += 1
     return rval
예제 #3
0
 def compareFunction(self, model, iter0, iter1, column):
     row0 = list(model[model.get_path(iter0)])
     row1 = list(model[model.get_path(iter1)])
     is_ascending = True if self.tv.get_column(column - 1).get_sort_order() is \
         Gtk.SortType.ASCENDING else False
     if self.__isAChallengeOrOurSeek(
             row0) and not self.__isAChallengeOrOurSeek(row1):
         if is_ascending:
             return -1
         else:
             return 1
     elif self.__isAChallengeOrOurSeek(
             row1) and not self.__isAChallengeOrOurSeek(row0):
         if is_ascending:
             return 1
         else:
             return -1
     elif column is 7:
         return self.timeCompareFunction(model, iter0, iter1, column)
     else:
         value0 = row0[column]
         value0 = value0.lower() if isinstance(value0, str) else value0
         value1 = row1[column]
         value1 = value1.lower() if isinstance(value1, str) else value1
         return cmp(value0, value1)
예제 #4
0
 def compareFunction(self, treemodel, iter0, iter1, column):
     (minute0, minute1) = (treemodel.get_value(iter0, 10),
                           treemodel.get_value(iter1, 10))
     return cmp(minute0, minute1)
 def compareFunction(self, treemodel, iter0, iter1, column):
     (minute0, minute1) = (
         treemodel.get_value(iter0, 10),
         treemodel.get_value(iter1, 10),
     )
     return cmp(minute0, minute1)