瀏覽代碼

catalog: first load and display tree with locations for responsiveness, then load everything (#1043)

Also fix loading everything after tab change, instead load automatically after GUI start.
Anna Petrasova 4 年之前
父節點
當前提交
99629545f1
共有 2 個文件被更改,包括 20 次插入2 次删除
  1. 19 0
      gui/wxpython/datacatalog/tree.py
  2. 1 2
      gui/wxpython/lmgr/frame.py

+ 19 - 0
gui/wxpython/datacatalog/tree.py

@@ -543,9 +543,28 @@ class DataCatalogTree(TreeView):
     def ReloadTreeItems(self):
         """Reload dbs, locations, mapsets and layers in the tree."""
         self.busy = wx.BusyCursor()
+        self._quickLoading()
         self.thread.Run(callable=self._reloadTreeItems,
                         ondone=self._loadItemsDone)
 
+    def _quickLoading(self):
+        """Quick loading of locations to show
+        something when loading for the first time"""
+        if self._model.root.children:
+            return
+        gisenv = gscript.gisenv()
+        for grassdatabase in self.grassdatabases:
+            grassdb_node = self._model.AppendNode(parent=self._model.root,
+                                                  data=dict(type='grassdb',
+                                                            name=grassdatabase))
+            for location in GetListOfLocations(grassdatabase):
+                self._model.AppendNode(parent=grassdb_node,
+                                       data=dict(type='location',
+                                                 name=location))
+            self.RefreshItems()
+            if grassdatabase == gisenv['GISDBASE']:
+                self.ExpandNode(grassdb_node, recursive=False)
+
     def _loadItemsDone(self, event):
         Debug.msg(1, "Tree filled")
         del self.busy

+ 1 - 2
gui/wxpython/lmgr/frame.py

@@ -413,6 +413,7 @@ class GMFrame(wx.Frame):
             FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,
             self.OnCBPageClosing)
 
+        wx.CallAfter(self.datacatalog.LoadItems)
         return self.notebook
 
     def AddNvizTools(self, firstTime):
@@ -649,8 +650,6 @@ class GMFrame(wx.Frame):
         page = event.GetSelection()
         if page == self.notebook.GetPageIndexByName('output'):
             wx.CallAfter(self.goutput.ResetFocus)
-        elif page == self.notebook.GetPageIndexByName('catalog'):
-            wx.CallAfter(self.datacatalog.LoadItems)
         self.SetStatusText('', 0)
 
         event.Skip()