Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py

changeset 4126
c28d0cf3b639
parent 4021
195a471c327b
child 4212
530b953eb623
--- a/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py	Sun Feb 22 12:16:32 2015 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py	Sun Feb 22 19:21:55 2015 +0100
@@ -38,12 +38,19 @@
         super(HgBookmarksListDialog, self).__init__(parent)
         self.setupUi(self)
         
+        
+        self.refreshButton = self.buttonBox.addButton(
+            self.tr("Refresh"), QDialogButtonBox.ActionRole)
+        self.refreshButton.setToolTip(
+            self.tr("Press to refresh the bookmarks display"))
+        self.refreshButton.setEnabled(False)
         self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
         self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
         
         self.process = QProcess()
         self.vcs = vcs
         self.__bookmarksList = None
+        self.__path = None
         self.__hgClient = vcs.getClient()
         
         self.bookmarksList.headerItem().setText(
@@ -83,12 +90,17 @@
         @param bookmarksList reference to string list receiving the bookmarks
             (list of strings)
         """
+        self.bookmarksList.clear()
+        
         self.errorGroup.hide()
         
         self.intercept = False
         self.activateWindow()
         
         self.__bookmarksList = bookmarksList
+        del self.__bookmarksList[:]     # clear the list
+        self.__path = path
+        
         dname, fname = self.vcs.splitPath(path)
         
         # find the root of the repo
@@ -103,6 +115,7 @@
         if self.__hgClient:
             self.inputGroup.setEnabled(False)
             self.inputGroup.hide()
+            self.refreshButton.setEnabled(False)
             
             out, err = self.__hgClient.runcommand(args)
             if err:
@@ -130,8 +143,13 @@
                         'Ensure, that it is in the search path.'
                     ).format('hg'))
             else:
+                self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
+                self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
+                self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
+                
                 self.inputGroup.setEnabled(True)
                 self.inputGroup.show()
+                self.refreshButton.setEnabled(False)
     
     def __finish(self):
         """
@@ -146,6 +164,7 @@
         
         self.inputGroup.setEnabled(False)
         self.inputGroup.hide()
+        self.refreshButton.setEnabled(True)
         
         self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
         self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
@@ -153,8 +172,6 @@
         self.buttonBox.button(QDialogButtonBox.Close).setFocus(
             Qt.OtherFocusReason)
         
-        self.process = None
-        
         if self.bookmarksList.topLevelItemCount() == 0:
             # no bookmarks defined
             self.__generateItem(
@@ -175,6 +192,8 @@
                 self.__hgClient.cancel()
             else:
                 self.__finish()
+        elif button == self.refreshButton:
+            self.on_refreshButton_clicked()
     
     def __procFinished(self, exitCode, exitStatus):
         """
@@ -330,3 +349,10 @@
             evt.accept()
             return
         super(HgBookmarksListDialog, self).keyPressEvent(evt)
+    
+    @pyqtSlot()
+    def on_refreshButton_clicked(self):
+        """
+        Private slot to refresh the status display.
+        """
+        self.start(self.__path, self.__bookmarksList)

eric ide

mercurial