Commits

Yuya Nishihara committed 24b929d

reporegistry: unify boolean flag and QAction of subrepo settings

  • Participants
  • Parent commits 7bb6949

Comments (0)

Files changed (1)

File tortoisehg/hgqt/reporegistry.py

     removeRepo = pyqtSignal(QString)
     progressReceived = pyqtSignal(QString, object, QString, QString, object)
 
-    def __init__(self, parent, showSubrepos=False, showNetworkSubrepos=False,
-            showShortPaths=False):
+    def __init__(self, parent, showShortPaths=False):
         QDockWidget.__init__(self, parent)
 
         self.watcher = None
-        self.showSubrepos = showSubrepos
-        self.showNetworkSubrepos = showNetworkSubrepos
         self.showShortPaths = showShortPaths
         self._setupSettingActions()
 
 
         sfile = settingsfilename()
         tv.setModel(repotreemodel.RepoTreeModel(sfile, self,
-            showSubrepos=self.showSubrepos,
-            showNetworkSubrepos=self.showNetworkSubrepos))
+            showSubrepos=self._isSettingEnabled('showSubrepos'),
+            showNetworkSubrepos=self._isSettingEnabled('showNetworkSubrepos')))
 
         mainframe.layout().addWidget(tv)
 
             defaultValue=QVariant(True)).toBool()
         ssp = s.value(wb + 'showShortPaths',
             defaultValue=QVariant(True)).toBool()
-        self.setShowSubrepos(ssr, False)
-        self.setShowNetworkSubrepos(snsr, False)
         self.setShowShortPaths(ssp)
 
         sact = self._settingactions
     def _setupSettingActions(self):
         settingtable = [
             ('showPaths', _('Show Paths'), self.showPaths),
-            ('showSubrepos', _('Show Subrepos on Registry'),
-             self.setShowSubrepos),
+            ('showSubrepos', _('Show Subrepos on Registry'), self.reloadModel),
             ('showNetworkSubrepos', _('Show Subrepos for remote repositories'),
-             self.setShowNetworkSubrepos),
+             self.reloadModel),
             ('showShortPaths', _('Show Short Paths'), self.setShowShortPaths),
             ]
         self._settingactions = {}
         return sorted(self._settingactions.itervalues(),
                       key=lambda a: a.data().toInt())
 
-    def setShowSubrepos(self, show, reloadModel=True):
-        if self.showSubrepos != show:
-            self.showSubrepos = show
-            if reloadModel:
-                self.reloadModel()
-
-    def setShowNetworkSubrepos(self, show, reloadModel=True):
-        if self.showNetworkSubrepos != show:
-            self.showNetworkSubrepos = show
-            if reloadModel:
-                self.reloadModel()
+    def _isSettingEnabled(self, key):
+        return self._settingactions[key].isChecked()
 
     def setShowShortPaths(self, show):
         if self.showShortPaths != show:
             self._pendingReloadModel = True
             QTimer.singleShot(1000 * UPDATE_DELAY, self.reloadModel)
 
+    @pyqtSlot()
     def reloadModel(self):
         activeroot = None
         if self._activeTabRepo:
         oldmodel = self.tview.model()
         self.tview.setModel(
             repotreemodel.RepoTreeModel(settingsfilename(), self,
-                self.showSubrepos, self.showNetworkSubrepos,
+                self._isSettingEnabled('showSubrepos'),
+                self._isSettingEnabled('showNetworkSubrepos'),
                 self.showShortPaths))
         oldmodel.deleteLater()
         self.expand()