Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py

changeset 4126
c28d0cf3b639
parent 4021
195a471c327b
child 4212
530b953eb623
equal deleted inserted replaced
4125:056d98a54dd4 4126:c28d0cf3b639
36 @param parent parent widget (QWidget) 36 @param parent parent widget (QWidget)
37 """ 37 """
38 super(HgBookmarksListDialog, self).__init__(parent) 38 super(HgBookmarksListDialog, self).__init__(parent)
39 self.setupUi(self) 39 self.setupUi(self)
40 40
41
42 self.refreshButton = self.buttonBox.addButton(
43 self.tr("Refresh"), QDialogButtonBox.ActionRole)
44 self.refreshButton.setToolTip(
45 self.tr("Press to refresh the bookmarks display"))
46 self.refreshButton.setEnabled(False)
41 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 47 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
42 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 48 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
43 49
44 self.process = QProcess() 50 self.process = QProcess()
45 self.vcs = vcs 51 self.vcs = vcs
46 self.__bookmarksList = None 52 self.__bookmarksList = None
53 self.__path = None
47 self.__hgClient = vcs.getClient() 54 self.__hgClient = vcs.getClient()
48 55
49 self.bookmarksList.headerItem().setText( 56 self.bookmarksList.headerItem().setText(
50 self.bookmarksList.columnCount(), "") 57 self.bookmarksList.columnCount(), "")
51 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) 58 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
81 88
82 @param path name of directory to be listed (string) 89 @param path name of directory to be listed (string)
83 @param bookmarksList reference to string list receiving the bookmarks 90 @param bookmarksList reference to string list receiving the bookmarks
84 (list of strings) 91 (list of strings)
85 """ 92 """
93 self.bookmarksList.clear()
94
86 self.errorGroup.hide() 95 self.errorGroup.hide()
87 96
88 self.intercept = False 97 self.intercept = False
89 self.activateWindow() 98 self.activateWindow()
90 99
91 self.__bookmarksList = bookmarksList 100 self.__bookmarksList = bookmarksList
101 del self.__bookmarksList[:] # clear the list
102 self.__path = path
103
92 dname, fname = self.vcs.splitPath(path) 104 dname, fname = self.vcs.splitPath(path)
93 105
94 # find the root of the repo 106 # find the root of the repo
95 repodir = dname 107 repodir = dname
96 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 108 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
101 args = self.vcs.initCommand("bookmarks") 113 args = self.vcs.initCommand("bookmarks")
102 114
103 if self.__hgClient: 115 if self.__hgClient:
104 self.inputGroup.setEnabled(False) 116 self.inputGroup.setEnabled(False)
105 self.inputGroup.hide() 117 self.inputGroup.hide()
118 self.refreshButton.setEnabled(False)
106 119
107 out, err = self.__hgClient.runcommand(args) 120 out, err = self.__hgClient.runcommand(args)
108 if err: 121 if err:
109 self.__showError(err) 122 self.__showError(err)
110 if out: 123 if out:
128 self.tr( 141 self.tr(
129 'The process {0} could not be started. ' 142 'The process {0} could not be started. '
130 'Ensure, that it is in the search path.' 143 'Ensure, that it is in the search path.'
131 ).format('hg')) 144 ).format('hg'))
132 else: 145 else:
146 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
147 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
148 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
149
133 self.inputGroup.setEnabled(True) 150 self.inputGroup.setEnabled(True)
134 self.inputGroup.show() 151 self.inputGroup.show()
152 self.refreshButton.setEnabled(False)
135 153
136 def __finish(self): 154 def __finish(self):
137 """ 155 """
138 Private slot called when the process finished or the user pressed 156 Private slot called when the process finished or the user pressed
139 the button. 157 the button.
144 QTimer.singleShot(2000, self.process.kill) 162 QTimer.singleShot(2000, self.process.kill)
145 self.process.waitForFinished(3000) 163 self.process.waitForFinished(3000)
146 164
147 self.inputGroup.setEnabled(False) 165 self.inputGroup.setEnabled(False)
148 self.inputGroup.hide() 166 self.inputGroup.hide()
167 self.refreshButton.setEnabled(True)
149 168
150 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 169 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
151 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 170 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
152 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 171 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
153 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 172 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
154 Qt.OtherFocusReason) 173 Qt.OtherFocusReason)
155
156 self.process = None
157 174
158 if self.bookmarksList.topLevelItemCount() == 0: 175 if self.bookmarksList.topLevelItemCount() == 0:
159 # no bookmarks defined 176 # no bookmarks defined
160 self.__generateItem( 177 self.__generateItem(
161 self.tr("no bookmarks defined"), "", "", "") 178 self.tr("no bookmarks defined"), "", "", "")
173 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 190 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
174 if self.__hgClient: 191 if self.__hgClient:
175 self.__hgClient.cancel() 192 self.__hgClient.cancel()
176 else: 193 else:
177 self.__finish() 194 self.__finish()
195 elif button == self.refreshButton:
196 self.on_refreshButton_clicked()
178 197
179 def __procFinished(self, exitCode, exitStatus): 198 def __procFinished(self, exitCode, exitStatus):
180 """ 199 """
181 Private slot connected to the finished signal. 200 Private slot connected to the finished signal.
182 201
328 if self.intercept: 347 if self.intercept:
329 self.intercept = False 348 self.intercept = False
330 evt.accept() 349 evt.accept()
331 return 350 return
332 super(HgBookmarksListDialog, self).keyPressEvent(evt) 351 super(HgBookmarksListDialog, self).keyPressEvent(evt)
352
353 @pyqtSlot()
354 def on_refreshButton_clicked(self):
355 """
356 Private slot to refresh the status display.
357 """
358 self.start(self.__path, self.__bookmarksList)

eric ide

mercurial