src/eric7/Preferences/ConfigurationPages/DebuggerGeneralPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
28 28
29 class DebuggerGeneralPage(ConfigurationPageBase, Ui_DebuggerGeneralPage): 29 class DebuggerGeneralPage(ConfigurationPageBase, Ui_DebuggerGeneralPage):
30 """ 30 """
31 Class implementing the Debugger General configuration page. 31 Class implementing the Debugger General configuration page.
32 """ 32 """
33
33 def __init__(self): 34 def __init__(self):
34 """ 35 """
35 Constructor 36 Constructor
36 """ 37 """
37 super().__init__() 38 super().__init__()
38 self.setupUi(self) 39 self.setupUi(self)
39 self.setObjectName("DebuggerGeneralPage") 40 self.setObjectName("DebuggerGeneralPage")
40 41
41 t = self.execLineEdit.whatsThis() 42 t = self.execLineEdit.whatsThis()
42 if t: 43 if t:
43 t += Utilities.getPercentReplacementHelp() 44 t += Utilities.getPercentReplacementHelp()
44 self.execLineEdit.setWhatsThis(t) 45 self.execLineEdit.setWhatsThis(t)
45 46
46 try: 47 try:
47 backends = ( 48 backends = ericApp().getObject("DebugServer").getSupportedLanguages()
48 ericApp().getObject("DebugServer").getSupportedLanguages()
49 )
50 for backend in sorted(backends): 49 for backend in sorted(backends):
51 self.passiveDbgBackendCombo.addItem(backend) 50 self.passiveDbgBackendCombo.addItem(backend)
52 except KeyError: 51 except KeyError:
53 self.passiveDbgGroup.setEnabled(False) 52 self.passiveDbgGroup.setEnabled(False)
54 53
55 t = self.consoleDbgEdit.whatsThis() 54 t = self.consoleDbgEdit.whatsThis()
56 if t: 55 if t:
57 t += Utilities.getPercentReplacementHelp() 56 t += Utilities.getPercentReplacementHelp()
58 self.consoleDbgEdit.setWhatsThis(t) 57 self.consoleDbgEdit.setWhatsThis(t)
59 58
60 self.consoleDbgCompleter = EricFileCompleter(self.consoleDbgEdit) 59 self.consoleDbgCompleter = EricFileCompleter(self.consoleDbgEdit)
61 self.dbgTranslationLocalCompleter = EricDirCompleter( 60 self.dbgTranslationLocalCompleter = EricDirCompleter(
62 self.dbgTranslationLocalEdit) 61 self.dbgTranslationLocalEdit
63 62 )
63
64 # set initial values 64 # set initial values
65 interfaces = [] 65 interfaces = []
66 networkInterfaces = QNetworkInterface.allInterfaces() 66 networkInterfaces = QNetworkInterface.allInterfaces()
67 for networkInterface in networkInterfaces: 67 for networkInterface in networkInterfaces:
68 addressEntries = networkInterface.addressEntries() 68 addressEntries = networkInterface.addressEntries()
69 if len(addressEntries) > 0: 69 if len(addressEntries) > 0:
70 for addressEntry in addressEntries: 70 for addressEntry in addressEntries:
71 if ( 71 if ":" in addressEntry.ip().toString() and not socket.has_ipv6:
72 ":" in addressEntry.ip().toString() and 72 continue # IPv6 not supported by Python
73 not socket.has_ipv6
74 ):
75 continue # IPv6 not supported by Python
76 interfaces.append( 73 interfaces.append(
77 "{0} ({1})".format( 74 "{0} ({1})".format(
78 networkInterface.humanReadableName(), 75 networkInterface.humanReadableName(),
79 addressEntry.ip().toString())) 76 addressEntry.ip().toString(),
77 )
78 )
80 self.interfacesCombo.addItems(interfaces) 79 self.interfacesCombo.addItems(interfaces)
81 interface = Preferences.getDebugger("NetworkInterface") 80 interface = Preferences.getDebugger("NetworkInterface")
82 if not socket.has_ipv6: 81 if not socket.has_ipv6:
83 # IPv6 not supported by Python 82 # IPv6 not supported by Python
84 self.all6InterfacesButton.setEnabled(False) 83 self.all6InterfacesButton.setEnabled(False)
90 self.all6InterfacesButton.setChecked(True) 89 self.all6InterfacesButton.setChecked(True)
91 else: 90 else:
92 self.selectedInterfaceButton.setChecked(True) 91 self.selectedInterfaceButton.setChecked(True)
93 index = -1 92 index = -1
94 for i in range(len(interfaces)): 93 for i in range(len(interfaces)):
95 if ( 94 if re.fullmatch(".*{0}.*".format(interface), interfaces[i]):
96 re.fullmatch(".*{0}.*".format(interface), interfaces[i])
97 ):
98 index = i 95 index = i
99 break 96 break
100 self.interfacesCombo.setCurrentIndex(index) 97 self.interfacesCombo.setCurrentIndex(index)
101 98
102 self.allowedHostsList.addItems( 99 self.allowedHostsList.addItems(Preferences.getDebugger("AllowedHosts"))
103 Preferences.getDebugger("AllowedHosts")) 100
104 101 self.remoteDebuggerGroup.setChecked(Preferences.getDebugger("RemoteDbgEnabled"))
105 self.remoteDebuggerGroup.setChecked( 102 self.hostLineEdit.setText(Preferences.getDebugger("RemoteHost"))
106 Preferences.getDebugger("RemoteDbgEnabled")) 103 self.execLineEdit.setText(Preferences.getDebugger("RemoteExecution"))
107 self.hostLineEdit.setText( 104
108 Preferences.getDebugger("RemoteHost"))
109 self.execLineEdit.setText(
110 Preferences.getDebugger("RemoteExecution"))
111
112 if self.passiveDbgGroup.isEnabled(): 105 if self.passiveDbgGroup.isEnabled():
113 self.passiveDbgCheckBox.setChecked( 106 self.passiveDbgCheckBox.setChecked(
114 Preferences.getDebugger("PassiveDbgEnabled")) 107 Preferences.getDebugger("PassiveDbgEnabled")
108 )
115 self.passiveDbgPortSpinBox.setValue( 109 self.passiveDbgPortSpinBox.setValue(
116 Preferences.getDebugger("PassiveDbgPort")) 110 Preferences.getDebugger("PassiveDbgPort")
111 )
117 index = self.passiveDbgBackendCombo.findText( 112 index = self.passiveDbgBackendCombo.findText(
118 Preferences.getDebugger("PassiveDbgType")) 113 Preferences.getDebugger("PassiveDbgType")
114 )
119 if index == -1: 115 if index == -1:
120 index = 0 116 index = 0
121 self.passiveDbgBackendCombo.setCurrentIndex(index) 117 self.passiveDbgBackendCombo.setCurrentIndex(index)
122 118
123 self.debugEnvironReplaceCheckBox.setChecked( 119 self.debugEnvironReplaceCheckBox.setChecked(
124 Preferences.getDebugger("DebugEnvironmentReplace")) 120 Preferences.getDebugger("DebugEnvironmentReplace")
125 self.debugEnvironEdit.setText( 121 )
126 Preferences.getDebugger("DebugEnvironment")) 122 self.debugEnvironEdit.setText(Preferences.getDebugger("DebugEnvironment"))
127 self.automaticResetCheckBox.setChecked( 123 self.automaticResetCheckBox.setChecked(
128 Preferences.getDebugger("AutomaticReset")) 124 Preferences.getDebugger("AutomaticReset")
125 )
129 self.debugAutoSaveScriptsCheckBox.setChecked( 126 self.debugAutoSaveScriptsCheckBox.setChecked(
130 Preferences.getDebugger("Autosave")) 127 Preferences.getDebugger("Autosave")
128 )
131 self.consoleDebuggerGroup.setChecked( 129 self.consoleDebuggerGroup.setChecked(
132 Preferences.getDebugger("ConsoleDbgEnabled")) 130 Preferences.getDebugger("ConsoleDbgEnabled")
133 self.consoleDbgEdit.setText( 131 )
134 Preferences.getDebugger("ConsoleDbgCommand")) 132 self.consoleDbgEdit.setText(Preferences.getDebugger("ConsoleDbgCommand"))
135 self.dbgPathTranslationGroup.setChecked( 133 self.dbgPathTranslationGroup.setChecked(
136 Preferences.getDebugger("PathTranslation")) 134 Preferences.getDebugger("PathTranslation")
135 )
137 self.dbgTranslationRemoteEdit.setText( 136 self.dbgTranslationRemoteEdit.setText(
138 Preferences.getDebugger("PathTranslationRemote")) 137 Preferences.getDebugger("PathTranslationRemote")
138 )
139 self.dbgTranslationLocalEdit.setText( 139 self.dbgTranslationLocalEdit.setText(
140 Preferences.getDebugger("PathTranslationLocal")) 140 Preferences.getDebugger("PathTranslationLocal")
141 )
141 self.multiprocessCheckBox.setChecked( 142 self.multiprocessCheckBox.setChecked(
142 Preferences.getDebugger("MultiProcessEnabled")) 143 Preferences.getDebugger("MultiProcessEnabled")
144 )
143 self.debugThreeStateBreakPoint.setChecked( 145 self.debugThreeStateBreakPoint.setChecked(
144 Preferences.getDebugger("ThreeStateBreakPoints")) 146 Preferences.getDebugger("ThreeStateBreakPoints")
147 )
145 self.intelligentBreakPointCheckBox.setChecked( 148 self.intelligentBreakPointCheckBox.setChecked(
146 Preferences.getDebugger("IntelligentBreakpoints")) 149 Preferences.getDebugger("IntelligentBreakpoints")
147 self.recentFilesSpinBox.setValue( 150 )
148 Preferences.getDebugger("RecentNumber")) 151 self.recentFilesSpinBox.setValue(Preferences.getDebugger("RecentNumber"))
149 self.exceptionBreakCheckBox.setChecked( 152 self.exceptionBreakCheckBox.setChecked(Preferences.getDebugger("BreakAlways"))
150 Preferences.getDebugger("BreakAlways"))
151 self.exceptionShellCheckBox.setChecked( 153 self.exceptionShellCheckBox.setChecked(
152 Preferences.getDebugger("ShowExceptionInShell")) 154 Preferences.getDebugger("ShowExceptionInShell")
153 self.maxSizeSpinBox.setValue( 155 )
154 Preferences.getDebugger("MaxVariableSize")) 156 self.maxSizeSpinBox.setValue(Preferences.getDebugger("MaxVariableSize"))
155 # Set the colours for debug viewer backgrounds 157 # Set the colours for debug viewer backgrounds
156 self.previewMdl = PreviewModel() 158 self.previewMdl = PreviewModel()
157 self.preView.setModel(self.previewMdl) 159 self.preView.setModel(self.previewMdl)
158 self.colourChanged.connect(self.previewMdl.setColor) 160 self.colourChanged.connect(self.previewMdl.setColor)
159 self.initColour("BgColorNew", self.backgroundNewButton, 161 self.initColour(
160 Preferences.getDebugger, hasAlpha=True) 162 "BgColorNew",
161 self.initColour("BgColorChanged", self.backgroundChangedButton, 163 self.backgroundNewButton,
162 Preferences.getDebugger, hasAlpha=True) 164 Preferences.getDebugger,
163 165 hasAlpha=True,
166 )
167 self.initColour(
168 "BgColorChanged",
169 self.backgroundChangedButton,
170 Preferences.getDebugger,
171 hasAlpha=True,
172 )
173
164 self.autoViewSourcecodeCheckBox.setChecked( 174 self.autoViewSourcecodeCheckBox.setChecked(
165 Preferences.getDebugger("AutoViewSourceCode")) 175 Preferences.getDebugger("AutoViewSourceCode")
166 176 )
177
167 def save(self): 178 def save(self):
168 """ 179 """
169 Public slot to save the Debugger General (1) configuration. 180 Public slot to save the Debugger General (1) configuration.
170 """ 181 """
171 Preferences.setDebugger( 182 Preferences.setDebugger(
172 "RemoteDbgEnabled", 183 "RemoteDbgEnabled", self.remoteDebuggerGroup.isChecked()
173 self.remoteDebuggerGroup.isChecked()) 184 )
174 Preferences.setDebugger( 185 Preferences.setDebugger("RemoteHost", self.hostLineEdit.text())
175 "RemoteHost", 186 Preferences.setDebugger("RemoteExecution", self.execLineEdit.text())
176 self.hostLineEdit.text()) 187
177 Preferences.setDebugger( 188 Preferences.setDebugger(
178 "RemoteExecution", 189 "PassiveDbgEnabled", self.passiveDbgCheckBox.isChecked()
179 self.execLineEdit.text()) 190 )
180 191 Preferences.setDebugger("PassiveDbgPort", self.passiveDbgPortSpinBox.value())
181 Preferences.setDebugger( 192 Preferences.setDebugger(
182 "PassiveDbgEnabled", 193 "PassiveDbgType", self.passiveDbgBackendCombo.currentText()
183 self.passiveDbgCheckBox.isChecked()) 194 )
184 Preferences.setDebugger( 195
185 "PassiveDbgPort",
186 self.passiveDbgPortSpinBox.value())
187 Preferences.setDebugger(
188 "PassiveDbgType",
189 self.passiveDbgBackendCombo.currentText())
190
191 if self.allInterfacesButton.isChecked(): 196 if self.allInterfacesButton.isChecked():
192 Preferences.setDebugger("NetworkInterface", "all") 197 Preferences.setDebugger("NetworkInterface", "all")
193 elif self.all6InterfacesButton.isChecked(): 198 elif self.all6InterfacesButton.isChecked():
194 Preferences.setDebugger("NetworkInterface", "allv6") 199 Preferences.setDebugger("NetworkInterface", "allv6")
195 else: 200 else:
197 interface = interface.split("(")[1].split(")")[0] 202 interface = interface.split("(")[1].split(")")[0]
198 if not interface: 203 if not interface:
199 Preferences.setDebugger("NetworkInterface", "all") 204 Preferences.setDebugger("NetworkInterface", "all")
200 else: 205 else:
201 Preferences.setDebugger("NetworkInterface", interface) 206 Preferences.setDebugger("NetworkInterface", interface)
202 207
203 allowedHosts = [] 208 allowedHosts = []
204 for row in range(self.allowedHostsList.count()): 209 for row in range(self.allowedHostsList.count()):
205 allowedHosts.append(self.allowedHostsList.item(row).text()) 210 allowedHosts.append(self.allowedHostsList.item(row).text())
206 Preferences.setDebugger("AllowedHosts", allowedHosts) 211 Preferences.setDebugger("AllowedHosts", allowedHosts)
207 212
208 Preferences.setDebugger( 213 Preferences.setDebugger(
209 "DebugEnvironmentReplace", 214 "DebugEnvironmentReplace", self.debugEnvironReplaceCheckBox.isChecked()
210 self.debugEnvironReplaceCheckBox.isChecked()) 215 )
211 Preferences.setDebugger( 216 Preferences.setDebugger("DebugEnvironment", self.debugEnvironEdit.text())
212 "DebugEnvironment", 217 Preferences.setDebugger(
213 self.debugEnvironEdit.text()) 218 "AutomaticReset", self.automaticResetCheckBox.isChecked()
214 Preferences.setDebugger( 219 )
215 "AutomaticReset", 220 Preferences.setDebugger(
216 self.automaticResetCheckBox.isChecked()) 221 "Autosave", self.debugAutoSaveScriptsCheckBox.isChecked()
217 Preferences.setDebugger( 222 )
218 "Autosave", 223 Preferences.setDebugger(
219 self.debugAutoSaveScriptsCheckBox.isChecked()) 224 "ConsoleDbgEnabled", self.consoleDebuggerGroup.isChecked()
220 Preferences.setDebugger( 225 )
221 "ConsoleDbgEnabled", 226 Preferences.setDebugger("ConsoleDbgCommand", self.consoleDbgEdit.text())
222 self.consoleDebuggerGroup.isChecked()) 227 Preferences.setDebugger(
223 Preferences.setDebugger( 228 "PathTranslation", self.dbgPathTranslationGroup.isChecked()
224 "ConsoleDbgCommand", 229 )
225 self.consoleDbgEdit.text()) 230 Preferences.setDebugger(
226 Preferences.setDebugger( 231 "PathTranslationRemote", self.dbgTranslationRemoteEdit.text()
227 "PathTranslation", 232 )
228 self.dbgPathTranslationGroup.isChecked()) 233 Preferences.setDebugger(
229 Preferences.setDebugger( 234 "PathTranslationLocal", self.dbgTranslationLocalEdit.text()
230 "PathTranslationRemote", 235 )
231 self.dbgTranslationRemoteEdit.text()) 236 Preferences.setDebugger(
232 Preferences.setDebugger( 237 "MultiProcessEnabled", self.multiprocessCheckBox.isChecked()
233 "PathTranslationLocal", 238 )
234 self.dbgTranslationLocalEdit.text()) 239 Preferences.setDebugger(
235 Preferences.setDebugger( 240 "ThreeStateBreakPoints", self.debugThreeStateBreakPoint.isChecked()
236 "MultiProcessEnabled", 241 )
237 self.multiprocessCheckBox.isChecked()) 242 Preferences.setDebugger(
238 Preferences.setDebugger( 243 "IntelligentBreakpoints", self.intelligentBreakPointCheckBox.isChecked()
239 "ThreeStateBreakPoints", 244 )
240 self.debugThreeStateBreakPoint.isChecked()) 245 Preferences.setDebugger("RecentNumber", self.recentFilesSpinBox.value())
241 Preferences.setDebugger( 246 Preferences.setDebugger("BreakAlways", self.exceptionBreakCheckBox.isChecked())
242 "IntelligentBreakpoints", 247 Preferences.setDebugger(
243 self.intelligentBreakPointCheckBox.isChecked()) 248 "ShowExceptionInShell", self.exceptionShellCheckBox.isChecked()
244 Preferences.setDebugger( 249 )
245 "RecentNumber", 250 Preferences.setDebugger("MaxVariableSize", self.maxSizeSpinBox.value())
246 self.recentFilesSpinBox.value())
247 Preferences.setDebugger(
248 "BreakAlways",
249 self.exceptionBreakCheckBox.isChecked())
250 Preferences.setDebugger(
251 "ShowExceptionInShell",
252 self.exceptionShellCheckBox.isChecked())
253 Preferences.setDebugger(
254 "MaxVariableSize",
255 self.maxSizeSpinBox.value())
256 # Store background colors for debug viewer 251 # Store background colors for debug viewer
257 self.saveColours(Preferences.setDebugger) 252 self.saveColours(Preferences.setDebugger)
258 253
259 Preferences.setDebugger( 254 Preferences.setDebugger(
260 "AutoViewSourceCode", 255 "AutoViewSourceCode", self.autoViewSourcecodeCheckBox.isChecked()
261 self.autoViewSourcecodeCheckBox.isChecked()) 256 )
262 257
263 def on_allowedHostsList_currentItemChanged(self, current, previous): 258 def on_allowedHostsList_currentItemChanged(self, current, previous):
264 """ 259 """
265 Private method set the state of the edit and delete button. 260 Private method set the state of the edit and delete button.
266 261
267 @param current new current item (QListWidgetItem) 262 @param current new current item (QListWidgetItem)
268 @param previous previous current item (QListWidgetItem) 263 @param previous previous current item (QListWidgetItem)
269 """ 264 """
270 self.editAllowedHostButton.setEnabled(current is not None) 265 self.editAllowedHostButton.setEnabled(current is not None)
271 self.deleteAllowedHostButton.setEnabled(current is not None) 266 self.deleteAllowedHostButton.setEnabled(current is not None)
272 267
273 @pyqtSlot() 268 @pyqtSlot()
274 def on_addAllowedHostButton_clicked(self): 269 def on_addAllowedHostButton_clicked(self):
275 """ 270 """
276 Private slot called to add a new allowed host. 271 Private slot called to add a new allowed host.
277 """ 272 """
278 allowedHost, ok = QInputDialog.getText( 273 allowedHost, ok = QInputDialog.getText(
279 None, 274 None,
280 self.tr("Add allowed host"), 275 self.tr("Add allowed host"),
281 self.tr("Enter the IP address of an allowed host"), 276 self.tr("Enter the IP address of an allowed host"),
282 QLineEdit.EchoMode.Normal) 277 QLineEdit.EchoMode.Normal,
278 )
283 if ok and allowedHost: 279 if ok and allowedHost:
284 if QHostAddress(allowedHost).protocol() in [ 280 if QHostAddress(allowedHost).protocol() in [
285 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol, 281 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol,
286 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol 282 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol,
287 ]: 283 ]:
288 self.allowedHostsList.addItem(allowedHost) 284 self.allowedHostsList.addItem(allowedHost)
289 else: 285 else:
290 EricMessageBox.critical( 286 EricMessageBox.critical(
291 self, 287 self,
292 self.tr("Add allowed host"), 288 self.tr("Add allowed host"),
293 self.tr( 289 self.tr(
294 """<p>The entered address <b>{0}</b> is not""" 290 """<p>The entered address <b>{0}</b> is not"""
295 """ a valid IP v4 or IP v6 address.""" 291 """ a valid IP v4 or IP v6 address."""
296 """ Aborting...</p>""") 292 """ Aborting...</p>"""
297 .format(allowedHost)) 293 ).format(allowedHost),
298 294 )
295
299 @pyqtSlot() 296 @pyqtSlot()
300 def on_deleteAllowedHostButton_clicked(self): 297 def on_deleteAllowedHostButton_clicked(self):
301 """ 298 """
302 Private slot called to delete an allowed host. 299 Private slot called to delete an allowed host.
303 """ 300 """
304 self.allowedHostsList.takeItem(self.allowedHostsList.currentRow()) 301 self.allowedHostsList.takeItem(self.allowedHostsList.currentRow())
305 302
306 @pyqtSlot() 303 @pyqtSlot()
307 def on_editAllowedHostButton_clicked(self): 304 def on_editAllowedHostButton_clicked(self):
308 """ 305 """
309 Private slot called to edit an allowed host. 306 Private slot called to edit an allowed host.
310 """ 307 """
312 allowedHost, ok = QInputDialog.getText( 309 allowedHost, ok = QInputDialog.getText(
313 None, 310 None,
314 self.tr("Edit allowed host"), 311 self.tr("Edit allowed host"),
315 self.tr("Enter the IP address of an allowed host"), 312 self.tr("Enter the IP address of an allowed host"),
316 QLineEdit.EchoMode.Normal, 313 QLineEdit.EchoMode.Normal,
317 allowedHost) 314 allowedHost,
315 )
318 if ok and allowedHost: 316 if ok and allowedHost:
319 if QHostAddress(allowedHost).protocol() in [ 317 if QHostAddress(allowedHost).protocol() in [
320 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol, 318 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol,
321 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol 319 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol,
322 ]: 320 ]:
323 self.allowedHostsList.currentItem().setText(allowedHost) 321 self.allowedHostsList.currentItem().setText(allowedHost)
324 else: 322 else:
325 EricMessageBox.critical( 323 EricMessageBox.critical(
326 self, 324 self,
327 self.tr("Edit allowed host"), 325 self.tr("Edit allowed host"),
328 self.tr( 326 self.tr(
329 """<p>The entered address <b>{0}</b> is not""" 327 """<p>The entered address <b>{0}</b> is not"""
330 """ a valid IP v4 or IP v6 address.""" 328 """ a valid IP v4 or IP v6 address."""
331 """ Aborting...</p>""") 329 """ Aborting...</p>"""
332 .format(allowedHost)) 330 ).format(allowedHost),
331 )
333 332
334 333
335 class PreviewModel(QAbstractItemModel): 334 class PreviewModel(QAbstractItemModel):
336 """ 335 """
337 Class to show an example of the selected background colours for the debug 336 Class to show an example of the selected background colours for the debug
338 viewer. 337 viewer.
339 """ 338 """
339
340 def __init__(self): 340 def __init__(self):
341 """ 341 """
342 Constructor 342 Constructor
343 """ 343 """
344 super().__init__() 344 super().__init__()
345 self.bgColorNew = QBrush(QColor('#FFFFFF')) 345 self.bgColorNew = QBrush(QColor("#FFFFFF"))
346 self.bgColorChanged = QBrush(QColor('#FFFFFF')) 346 self.bgColorChanged = QBrush(QColor("#FFFFFF"))
347 347
348 def setColor(self, key, bgcolour): 348 def setColor(self, key, bgcolour):
349 """ 349 """
350 Public slot to update the background colour indexed by key. 350 Public slot to update the background colour indexed by key.
351 351
352 @param key the name of background 352 @param key the name of background
353 @type str 353 @type str
354 @param bgcolour the new background colour 354 @param bgcolour the new background colour
355 @type QColor 355 @type QColor
356 """ 356 """
357 if key == 'BgColorNew': 357 if key == "BgColorNew":
358 self.bgColorNew = QBrush(bgcolour) 358 self.bgColorNew = QBrush(bgcolour)
359 else: 359 else:
360 self.bgColorChanged = QBrush(bgcolour) 360 self.bgColorChanged = QBrush(bgcolour)
361 361
362 # Force update of preview view 362 # Force update of preview view
363 idxStart = self.index(0, 0, QModelIndex()) 363 idxStart = self.index(0, 0, QModelIndex())
364 idxEnd = self.index(0, 2, QModelIndex()) 364 idxEnd = self.index(0, 2, QModelIndex())
365 self.dataChanged.emit(idxStart, idxEnd) 365 self.dataChanged.emit(idxStart, idxEnd)
366 366
367 def index(self, row, column, parent=QModelIndex()): 367 def index(self, row, column, parent=QModelIndex()):
368 """ 368 """
369 Public Qt slot to get the index of item at row:column of parent. 369 Public Qt slot to get the index of item at row:column of parent.
370 370
371 @param row number of rows 371 @param row number of rows
372 @type int 372 @type int
373 @param column number of columns 373 @param column number of columns
374 @type int 374 @type int
375 @param parent the model parent 375 @param parent the model parent
377 @return new model index for child 377 @return new model index for child
378 @rtype QModelIndex 378 @rtype QModelIndex
379 """ 379 """
380 if not self.hasIndex(row, column, parent): 380 if not self.hasIndex(row, column, parent):
381 return QModelIndex() 381 return QModelIndex()
382 382
383 return self.createIndex(row, column, None) 383 return self.createIndex(row, column, None)
384 384
385 def parent(self, child): 385 def parent(self, child):
386 """ 386 """
387 Public Qt slot to get the parent of the given child. 387 Public Qt slot to get the parent of the given child.
388 388
389 @param child the model child node 389 @param child the model child node
390 @type QModelIndex 390 @type QModelIndex
391 @return new model index for parent 391 @return new model index for parent
392 @rtype QModelIndex 392 @rtype QModelIndex
393 """ 393 """
394 return QModelIndex() 394 return QModelIndex()
395 395
396 def columnCount(self, parent=QModelIndex()): 396 def columnCount(self, parent=QModelIndex()):
397 """ 397 """
398 Public Qt slot to get the column count. 398 Public Qt slot to get the column count.
399 399
400 @param parent the model parent 400 @param parent the model parent
401 @type QModelIndex 401 @type QModelIndex
402 @return number of columns 402 @return number of columns
403 @rtype int 403 @rtype int
404 """ 404 """
405 return 1 405 return 1
406 406
407 def rowCount(self, parent=QModelIndex()): 407 def rowCount(self, parent=QModelIndex()):
408 """ 408 """
409 Public Qt slot to get the row count. 409 Public Qt slot to get the row count.
410 410
411 @param parent the model parent 411 @param parent the model parent
412 @type QModelIndex 412 @type QModelIndex
413 @return number of rows 413 @return number of rows
414 @rtype int 414 @rtype int
415 """ 415 """
416 return 4 416 return 4
417 417
418 def flags(self, index): 418 def flags(self, index):
419 """ 419 """
420 Public Qt slot to get the item flags. 420 Public Qt slot to get the item flags.
421 421
422 @param index of item 422 @param index of item
423 @type QModelIndex 423 @type QModelIndex
424 @return item flags 424 @return item flags
425 @rtype QtCore.Qt.ItemFlag 425 @rtype QtCore.Qt.ItemFlag
426 """ 426 """
427 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable 427 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
428 428
429 def data(self, index, role=Qt.ItemDataRole.DisplayRole): 429 def data(self, index, role=Qt.ItemDataRole.DisplayRole):
430 """ 430 """
431 Public Qt slot get the role data of item. 431 Public Qt slot get the role data of item.
432 432
433 @param index the model index 433 @param index the model index
434 @type QModelIndex 434 @type QModelIndex
435 @param role the requested data role 435 @param role the requested data role
436 @type QtCore.Qt.ItemDataRole 436 @type QtCore.Qt.ItemDataRole
437 @return role data of item 437 @return role data of item
442 elif role == Qt.ItemDataRole.BackgroundRole: 442 elif role == Qt.ItemDataRole.BackgroundRole:
443 if index.row() >= 2: 443 if index.row() >= 2:
444 return self.bgColorChanged 444 return self.bgColorChanged
445 else: 445 else:
446 return self.bgColorNew 446 return self.bgColorNew
447 447
448 return None 448 return None
449 449
450 450
451 def create(dlg): 451 def create(dlg):
452 """ 452 """
453 Module function to create the configuration page. 453 Module function to create the configuration page.
454 454
455 @param dlg reference to the configuration dialog 455 @param dlg reference to the configuration dialog
456 @return reference to the instantiated page (ConfigurationPageBase) 456 @return reference to the instantiated page (ConfigurationPageBase)
457 """ 457 """
458 return DebuggerGeneralPage() 458 return DebuggerGeneralPage()
459 459
460
460 # 461 #
461 # eflag: noqa = M822 462 # eflag: noqa = M822

eric ide

mercurial