eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListDialog.py

changeset 8143
2c730d5fd177
parent 7971
ff2971513d6d
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
27 @param vcs reference to the vcs object 27 @param vcs reference to the vcs object
28 @param parent parent widget (QWidget) 28 @param parent parent widget (QWidget)
29 """ 29 """
30 super(HgQueuesListDialog, self).__init__(parent) 30 super(HgQueuesListDialog, self).__init__(parent)
31 self.setupUi(self) 31 self.setupUi(self)
32 self.setWindowFlags(Qt.Window) 32 self.setWindowFlags(Qt.WindowType.Window)
33 33
34 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 34 self.buttonBox.button(
35 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 35 QDialogButtonBox.StandardButton.Close).setEnabled(False)
36 self.buttonBox.button(
37 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
36 38
37 self.vcs = vcs 39 self.vcs = vcs
38 self.__hgClient = vcs.getClient() 40 self.__hgClient = vcs.getClient()
39 41
40 self.patchesList.header().setSortIndicator(0, Qt.AscendingOrder) 42 self.patchesList.header().setSortIndicator(
43 0, Qt.SortOrder.AscendingOrder)
41 44
42 self.__statusDict = { 45 self.__statusDict = {
43 "A": self.tr("applied"), 46 "A": self.tr("applied"),
44 "U": self.tr("not applied"), 47 "U": self.tr("not applied"),
45 "G": self.tr("guarded"), 48 "G": self.tr("guarded"),
125 def __finish(self): 128 def __finish(self):
126 """ 129 """
127 Private slot called when the process finished or the user pressed 130 Private slot called when the process finished or the user pressed
128 the button. 131 the button.
129 """ 132 """
130 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 133 self.buttonBox.button(
131 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 134 QDialogButtonBox.StandardButton.Close).setEnabled(True)
132 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 135 self.buttonBox.button(
133 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 136 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
134 Qt.OtherFocusReason) 137 self.buttonBox.button(
138 QDialogButtonBox.StandardButton.Close).setDefault(True)
139 self.buttonBox.button(
140 QDialogButtonBox.StandardButton.Close).setFocus(
141 Qt.FocusReason.OtherFocusReason)
135 142
136 if self.patchesList.topLevelItemCount() == 0: 143 if self.patchesList.topLevelItemCount() == 0:
137 # no patches present 144 # no patches present
138 self.__generateItem( 145 self.__generateItem(
139 0, "", self.tr("no patches found"), "", True) 146 0, "", self.tr("no patches found"), "", True)
144 """ 151 """
145 Private slot called by a button of the button box clicked. 152 Private slot called by a button of the button box clicked.
146 153
147 @param button button that was clicked (QAbstractButton) 154 @param button button that was clicked (QAbstractButton)
148 """ 155 """
149 if button == self.buttonBox.button(QDialogButtonBox.Close): 156 if button == self.buttonBox.button(
157 QDialogButtonBox.StandardButton.Close
158 ):
150 self.close() 159 self.close()
151 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 160 elif button == self.buttonBox.button(
161 QDialogButtonBox.StandardButton.Cancel
162 ):
152 self.__mode = "" 163 self.__mode = ""
153 self.__hgClient.cancel() 164 self.__hgClient.cancel()
154 165
155 def __resort(self): 166 def __resort(self):
156 """ 167 """
162 173
163 def __resizeColumns(self): 174 def __resizeColumns(self):
164 """ 175 """
165 Private method to resize the list columns. 176 Private method to resize the list columns.
166 """ 177 """
167 self.patchesList.header().resizeSections(QHeaderView.ResizeToContents) 178 self.patchesList.header().resizeSections(
179 QHeaderView.ResizeMode.ResizeToContents)
168 self.patchesList.header().setStretchLastSection(True) 180 self.patchesList.header().setStretchLastSection(True)
169 181
170 def __generateItem(self, index, status, name, summary, error=False): 182 def __generateItem(self, index, status, name, summary, error=False):
171 """ 183 """
172 Private method to generate a patch item in the list of patches. 184 Private method to generate a patch item in the list of patches.
190 try: 202 try:
191 statusStr = self.__statusDict[status] 203 statusStr = self.__statusDict[status]
192 except KeyError: 204 except KeyError:
193 statusStr = self.tr("unknown") 205 statusStr = self.tr("unknown")
194 itm = QTreeWidgetItem(self.patchesList) 206 itm = QTreeWidgetItem(self.patchesList)
195 itm.setData(0, Qt.DisplayRole, index) 207 itm.setData(0, Qt.ItemDataRole.DisplayRole, index)
196 itm.setData(1, Qt.DisplayRole, name) 208 itm.setData(1, Qt.ItemDataRole.DisplayRole, name)
197 itm.setData(2, Qt.DisplayRole, statusStr) 209 itm.setData(2, Qt.ItemDataRole.DisplayRole, statusStr)
198 itm.setData(3, Qt.DisplayRole, summary) 210 itm.setData(3, Qt.ItemDataRole.DisplayRole, summary)
199 if status == "A": 211 if status == "A":
200 # applied 212 # applied
201 for column in range(itm.columnCount()): 213 for column in range(itm.columnCount()):
202 itm.setForeground(column, Qt.blue) 214 itm.setForeground(column, Qt.GlobalColor.blue)
203 elif status == "D": 215 elif status == "D":
204 # missing 216 # missing
205 for column in range(itm.columnCount()): 217 for column in range(itm.columnCount()):
206 itm.setForeground(column, Qt.red) 218 itm.setForeground(column, Qt.GlobalColor.red)
207 219
208 itm.setTextAlignment(0, Qt.AlignRight) 220 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
209 itm.setTextAlignment(2, Qt.AlignHCenter) 221 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignHCenter)
210 222
211 def __markTopItem(self, name): 223 def __markTopItem(self, name):
212 """ 224 """
213 Private slot to mark the top patch entry. 225 Private slot to mark the top patch entry.
214 226
215 @param name name of the patch (string) 227 @param name name of the patch (string)
216 """ 228 """
217 items = self.patchesList.findItems(name, Qt.MatchCaseSensitive, 1) 229 items = self.patchesList.findItems(
230 name, Qt.MatchFlag.MatchCaseSensitive, 1)
218 if items: 231 if items:
219 itm = items[0] 232 itm = items[0]
220 for column in range(itm.columnCount()): 233 for column in range(itm.columnCount()):
221 font = itm.font(column) 234 font = itm.font(column)
222 font.setBold(True) 235 font.setBold(True)

eric ide

mercurial