[GRASS-SVN] r57993 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 14 02:05:51 PDT 2013


Author: martinl
Date: 2013-10-14 02:05:51 -0700 (Mon, 14 Oct 2013)
New Revision: 57993

Modified:
   grass/trunk/gui/wxpython/gui_core/widgets.py
Log:
wxGUI: fix on search module widget (zero-length string to reset)
       sort commands in the choice widget (modeler)


Modified: grass/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py	2013-10-14 08:45:26 UTC (rev 57992)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py	2013-10-14 09:05:51 UTC (rev 57993)
@@ -860,9 +860,13 @@
         """!Search module by keywords or description"""
         value = self._search.GetValue()
         if len(value) <= 2:
-            self.showNotification.emit(message=_("Searching, please type more characters."))
-            return
-        commands = self._searchModule(keys=self._searchKeys, value=value)
+            if len(value) == 0: # reset
+                commands = self._searchModule(keys=['command'], value='')
+            else:
+                self.showNotification.emit(message=_("Searching, please type more characters."))
+                return
+        else:
+            commands = self._searchModule(keys=self._searchKeys, value=value)
         if self._showChoice:
             self._searchChoice.SetItems(commands)
             if commands:
@@ -877,16 +881,24 @@
         event.Skip()
 
     def _searchModule(self, keys, value):
+        """!Search modules by keys
+
+        @param keys list of keys
+        @param value patter to match
+        """
         nodes = set()
         for key in keys:
             nodes.update(self._model.SearchNodes(key=key, value=value))
-
+        
         nodes = list(nodes)
         nodes.sort(key=lambda node: self._model.GetIndexOfNode(node))
         self._results = nodes
         self._resultIndex = -1
-        return [node.data['command'] for node in nodes if node.data['command']]
+        commands = [node.data['command'] for node in nodes if node.data['command']]
+        commands.sort() # return sorted list of commands (TODO: sort in better way)
         
+        return commands
+        
     def OnSelectModule(self, event):
         """!Module selected from choice, update command prompt"""
         cmd  = self._searchChoice.GetStringSelection()



More information about the grass-commit mailing list