[GRASS-CVS] [addons] r1252 - trunk/grassaddons/gui/gui_modules

grass-commit-addons at grass.itc.it grass-commit-addons at grass.itc.it
Fri Dec 7 05:27:46 EST 2007


Author: landa
Date: 2007-12-07 11:27:46 +0100 (Fri, 07 Dec 2007)
New Revision: 1252

Modified:
   trunk/grassaddons/gui/gui_modules/dbm.py
   trunk/grassaddons/gui/gui_modules/menudata.py
Log:
Fix items sorting

Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py	2007-12-07 09:33:12 UTC (rev 1251)
+++ trunk/grassaddons/gui/gui_modules/dbm.py	2007-12-07 10:27:46 UTC (rev 1252)
@@ -82,8 +82,8 @@
         self.columns              = {} # <- LoadData()
         self.itemCatsMap          = {} # <- LoadData() (first call)
 
-        self.selectedCats         = []
-        self.lastTurnSelectedCats = [] # just temporary, for comparation
+        # self.selectedCats         = []
+        # self.lastTurnSelectedCats = [] # just temporary, for comparation
 
         #
         # add some attributes (colourful background for each item rows)
@@ -197,7 +197,7 @@
                     self.itemDataMap[i].append(self.columns[columnNames[j]]['ctype'] (value))
                 except:
                     self.itemDataMap[i].append('')
-                
+
                 if keyId > -1 and keyId == j:
                     cat = self.columns[columnNames[j]]['ctype'] (value)
                 j += 1
@@ -230,19 +230,19 @@
 
     def OnItemSelected(self, event):
         """Item selected. Add item to selected cats..."""
-        cat = int(self.GetItemText(event.m_itemIndex))
-        if cat not in self.selectedCats:
-            self.selectedCats.append(cat)
-            self.selectedCats.sort()
+        #         cat = int(self.GetItemText(event.m_itemIndex))
+        #         if cat not in self.selectedCats:
+        #             self.selectedCats.append(cat)
+        #             self.selectedCats.sort()
         
         event.Skip()
 
     def OnItemDeselected(self, event):
         """Item deselected. Remove item from selected cats..."""
-        cat = int(self.GetItemText(event.m_itemIndex))
-        if cat in self.selectedCats:
-            self.selectedCats.remove(cat)
-            self.selectedCats.sort()
+        #         cat = int(self.GetItemText(event.m_itemIndex))
+        #         if cat in self.selectedCats:
+        #             self.selectedCats.remove(cat)
+        #             self.selectedCats.sort()
 
         event.Skip()
 
@@ -268,7 +268,7 @@
     def OnGetItemText(self, item, col):
         """Get item text"""
         index = self.itemIndexMap[item]
-        s = self.itemDataMap[index][col]
+        s = str(self.itemDataMap[index][col])
         return s
 
     def OnGetItemAttr(self, item):
@@ -287,28 +287,18 @@
     def SortItems(self, sorter=cmp):
         """Sort items"""
         items = list(self.itemDataMap.keys())
-        #         for i in range(len(items)):
-        #             items[i] =  self.columns[0]["type"](items[i]) # FIXME
         items.sort(self.Sorter)
-        #         for i in range(len(items)):
-        #             items[i] =  str(items[i])
         self.itemIndexMap = items
 
         # redraw the list
         self.Refresh()
 
     def Sorter(self, key1, key2):
-        col = self._col
-        ascending = self._colSortFlag[col]
+        colName = self.GetColumn(self._col).GetText()
+        ascending = self._colSortFlag[self._col]
         # convert always string
-        try:
-            item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
-        except:
-            item1 = ''
-        try:
-            item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
-        except:
-            item2 = ''
+        item1 = self.columns[colName]["ctype"](self.itemDataMap[key1][self._col])
+        item2 = self.columns[colName]["ctype"](self.itemDataMap[key2][self._col])
 
         if type(item1) == type('') or type(item2) == type(''):
             cmpVal = locale.strcoll(str(item1), str(item2))
@@ -318,7 +308,7 @@
 
         # If the items are equal then pick something else to make the sort v    ->alue unique
         if cmpVal == 0:
-            cmpVal = apply(cmp, self.GetSecondarySortValues(col, key1, key2))
+            cmpVal = apply(cmp, self.GetSecondarySortValues(self._col, key1, key2))
 
         if ascending:
             return cmpVal
@@ -329,11 +319,6 @@
         """Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py"""
         return (self.sm_dn, self.sm_up)
 
-    def getColumnText(self, index, col):
-        """Get column/item"""
-        item = self.GetItem(index, col)
-        return item.GetText()
-
     def SetVirtualData(self, row, col, data):
         pass
 

Modified: trunk/grassaddons/gui/gui_modules/menudata.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menudata.py	2007-12-07 09:33:12 UTC (rev 1251)
+++ trunk/grassaddons/gui/gui_modules/menudata.py	2007-12-07 10:27:46 UTC (rev 1252)
@@ -534,7 +534,6 @@
                 ("Rename column", "Rename a column", "self.OnMenuCmd", "v.db.renamecol"),
                 ("","","", ""),
                 ("Test", "Test database", "self.OnMenuCmd", "db.test"),
-                ("","","", "")
                 )),
               ("Query", (
                 ("Query any table", "Query data in any table", "self.OnMenuCmd", "db.select"),



More information about the grass-commit mailing list