eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py

changeset 8143
2c730d5fd177
parent 8108
a42ae6be4cc3
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
32 @param vcs reference to the vcs object 32 @param vcs reference to the vcs object
33 @param parent parent widget (QWidget) 33 @param parent parent widget (QWidget)
34 """ 34 """
35 super(HgBookmarksListDialog, self).__init__(parent) 35 super(HgBookmarksListDialog, self).__init__(parent)
36 self.setupUi(self) 36 self.setupUi(self)
37 self.setWindowFlags(Qt.Window) 37 self.setWindowFlags(Qt.WindowType.Window)
38 38
39 self.refreshButton = self.buttonBox.addButton( 39 self.refreshButton = self.buttonBox.addButton(
40 self.tr("Refresh"), QDialogButtonBox.ActionRole) 40 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
41 self.refreshButton.setToolTip( 41 self.refreshButton.setToolTip(
42 self.tr("Press to refresh the bookmarks display")) 42 self.tr("Press to refresh the bookmarks display"))
43 self.refreshButton.setEnabled(False) 43 self.refreshButton.setEnabled(False)
44 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 44 self.buttonBox.button(
45 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 45 QDialogButtonBox.StandardButton.Close).setEnabled(False)
46 self.buttonBox.button(
47 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
46 48
47 self.vcs = vcs 49 self.vcs = vcs
48 self.__bookmarksList = None 50 self.__bookmarksList = None
49 self.__hgClient = vcs.getClient() 51 self.__hgClient = vcs.getClient()
50 self.__bookmarksDefined = False 52 self.__bookmarksDefined = False
51 self.__currentRevision = "" 53 self.__currentRevision = ""
52 54
53 self.bookmarksList.headerItem().setText( 55 self.bookmarksList.headerItem().setText(
54 self.bookmarksList.columnCount(), "") 56 self.bookmarksList.columnCount(), "")
55 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) 57 self.bookmarksList.header().setSortIndicator(
58 3, Qt.SortOrder.AscendingOrder)
56 59
57 self.show() 60 self.show()
58 QCoreApplication.processEvents() 61 QCoreApplication.processEvents()
59 62
60 def closeEvent(self, e): 63 def closeEvent(self, e):
105 Private slot called when the process finished or the user pressed 108 Private slot called when the process finished or the user pressed
106 the button. 109 the button.
107 """ 110 """
108 self.refreshButton.setEnabled(True) 111 self.refreshButton.setEnabled(True)
109 112
110 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 113 self.buttonBox.button(
111 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 114 QDialogButtonBox.StandardButton.Close).setEnabled(True)
112 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 115 self.buttonBox.button(
113 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 116 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
114 Qt.OtherFocusReason) 117 self.buttonBox.button(
118 QDialogButtonBox.StandardButton.Close).setDefault(True)
119 self.buttonBox.button(
120 QDialogButtonBox.StandardButton.Close).setFocus(
121 Qt.FocusReason.OtherFocusReason)
115 122
116 if self.bookmarksList.topLevelItemCount() == 0: 123 if self.bookmarksList.topLevelItemCount() == 0:
117 # no bookmarks defined 124 # no bookmarks defined
118 self.__generateItem( 125 self.__generateItem(
119 self.tr("no bookmarks defined"), "", "", "") 126 self.tr("no bookmarks defined"), "", "", "")
125 self.__resort() 132 self.__resort()
126 133
127 # restore current item 134 # restore current item
128 if self.__currentRevision: 135 if self.__currentRevision:
129 items = self.bookmarksList.findItems( 136 items = self.bookmarksList.findItems(
130 self.__currentRevision, Qt.MatchExactly, 0) 137 self.__currentRevision, Qt.MatchFlag.MatchExactly, 0)
131 if items: 138 if items:
132 self.bookmarksList.setCurrentItem(items[0]) 139 self.bookmarksList.setCurrentItem(items[0])
133 self.__currentRevision = "" 140 self.__currentRevision = ""
134 self.bookmarksList.setFocus(Qt.OtherFocusReason) 141 self.bookmarksList.setFocus(Qt.FocusReason.OtherFocusReason)
135 142
136 def on_buttonBox_clicked(self, button): 143 def on_buttonBox_clicked(self, button):
137 """ 144 """
138 Private slot called by a button of the button box clicked. 145 Private slot called by a button of the button box clicked.
139 146
140 @param button button that was clicked (QAbstractButton) 147 @param button button that was clicked (QAbstractButton)
141 """ 148 """
142 if button == self.buttonBox.button(QDialogButtonBox.Close): 149 if button == self.buttonBox.button(
150 QDialogButtonBox.StandardButton.Close
151 ):
143 self.close() 152 self.close()
144 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 153 elif button == self.buttonBox.button(
154 QDialogButtonBox.StandardButton.Cancel
155 ):
145 if self.__hgClient: 156 if self.__hgClient:
146 self.__hgClient.cancel() 157 self.__hgClient.cancel()
147 else: 158 else:
148 self.__finish() 159 self.__finish()
149 elif button == self.refreshButton: 160 elif button == self.refreshButton:
160 def __resizeColumns(self): 171 def __resizeColumns(self):
161 """ 172 """
162 Private method to resize the list columns. 173 Private method to resize the list columns.
163 """ 174 """
164 self.bookmarksList.header().resizeSections( 175 self.bookmarksList.header().resizeSections(
165 QHeaderView.ResizeToContents) 176 QHeaderView.ResizeMode.ResizeToContents)
166 self.bookmarksList.header().setStretchLastSection(True) 177 self.bookmarksList.header().setStretchLastSection(True)
167 178
168 def __generateItem(self, revision, changeset, status, name): 179 def __generateItem(self, revision, changeset, status, name):
169 """ 180 """
170 Private method to generate a bookmark item in the bookmarks list. 181 Private method to generate a bookmark item in the bookmarks list.
175 @param name name of the bookmark (string) 186 @param name name of the bookmark (string)
176 """ 187 """
177 itm = QTreeWidgetItem(self.bookmarksList) 188 itm = QTreeWidgetItem(self.bookmarksList)
178 if revision[0].isdecimal(): 189 if revision[0].isdecimal():
179 # valid bookmark entry 190 # valid bookmark entry
180 itm.setData(0, Qt.DisplayRole, int(revision)) 191 itm.setData(0, Qt.ItemDataRole.DisplayRole, int(revision))
181 itm.setData(1, Qt.DisplayRole, changeset) 192 itm.setData(1, Qt.ItemDataRole.DisplayRole, changeset)
182 itm.setData(2, Qt.DisplayRole, status) 193 itm.setData(2, Qt.ItemDataRole.DisplayRole, status)
183 itm.setData(3, Qt.DisplayRole, name) 194 itm.setData(3, Qt.ItemDataRole.DisplayRole, name)
184 itm.setTextAlignment(0, Qt.AlignRight) 195 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
185 itm.setTextAlignment(1, Qt.AlignRight) 196 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight)
186 itm.setTextAlignment(2, Qt.AlignHCenter) 197 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignHCenter)
187 else: 198 else:
188 # error message 199 # error message
189 itm.setData(0, Qt.DisplayRole, revision) 200 itm.setData(0, Qt.ItemDataRole.DisplayRole, revision)
190 201
191 def __processOutputLine(self, line): 202 def __processOutputLine(self, line):
192 """ 203 """
193 Private method to process the lines of output. 204 Private method to process the lines of output.
194 205
323 newName, ok = QInputDialog.getText( 334 newName, ok = QInputDialog.getText(
324 self, 335 self,
325 self.tr("Rename Bookmark"), 336 self.tr("Rename Bookmark"),
326 self.tr("<p>Enter the new name for bookmark <b>{0}</b>:</p>") 337 self.tr("<p>Enter the new name for bookmark <b>{0}</b>:</p>")
327 .format(bookmark), 338 .format(bookmark),
328 QLineEdit.Normal) 339 QLineEdit.EchoMode.Normal)
329 if ok and bool(newName): 340 if ok and bool(newName):
330 self.vcs.hgBookmarkRename((bookmark, newName)) 341 self.vcs.hgBookmarkRename((bookmark, newName))
331 self.on_refreshButton_clicked() 342 self.on_refreshButton_clicked()
332 343
333 def __pullBookmark(self): 344 def __pullBookmark(self):

eric ide

mercurial