270 """ |
270 """ |
271 allowedHost, ok = QInputDialog.getText( |
271 allowedHost, ok = QInputDialog.getText( |
272 None, |
272 None, |
273 self.tr("Add allowed host"), |
273 self.tr("Add allowed host"), |
274 self.tr("Enter the IP address of an allowed host"), |
274 self.tr("Enter the IP address of an allowed host"), |
275 QLineEdit.Normal) |
275 QLineEdit.EchoMode.Normal) |
276 if ok and allowedHost: |
276 if ok and allowedHost: |
277 if QHostAddress(allowedHost).protocol() in [ |
277 if QHostAddress(allowedHost).protocol() in [ |
278 QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol |
278 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol, |
|
279 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol |
279 ]: |
280 ]: |
280 self.allowedHostsList.addItem(allowedHost) |
281 self.allowedHostsList.addItem(allowedHost) |
281 else: |
282 else: |
282 E5MessageBox.critical( |
283 E5MessageBox.critical( |
283 self, |
284 self, |
303 allowedHost = self.allowedHostsList.currentItem().text() |
304 allowedHost = self.allowedHostsList.currentItem().text() |
304 allowedHost, ok = QInputDialog.getText( |
305 allowedHost, ok = QInputDialog.getText( |
305 None, |
306 None, |
306 self.tr("Edit allowed host"), |
307 self.tr("Edit allowed host"), |
307 self.tr("Enter the IP address of an allowed host"), |
308 self.tr("Enter the IP address of an allowed host"), |
308 QLineEdit.Normal, |
309 QLineEdit.EchoMode.Normal, |
309 allowedHost) |
310 allowedHost) |
310 if ok and allowedHost: |
311 if ok and allowedHost: |
311 if QHostAddress(allowedHost).protocol() in [ |
312 if QHostAddress(allowedHost).protocol() in [ |
312 QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol |
313 QAbstractSocket.NetworkLayerProtocol.IPv4Protocol, |
|
314 QAbstractSocket.NetworkLayerProtocol.IPv6Protocol |
313 ]: |
315 ]: |
314 self.allowedHostsList.currentItem().setText(allowedHost) |
316 self.allowedHostsList.currentItem().setText(allowedHost) |
315 else: |
317 else: |
316 E5MessageBox.critical( |
318 E5MessageBox.critical( |
317 self, |
319 self, |
413 @param index of item |
415 @param index of item |
414 @type QModelIndex |
416 @type QModelIndex |
415 @return item flags |
417 @return item flags |
416 @rtype QtCore.Qt.ItemFlag |
418 @rtype QtCore.Qt.ItemFlag |
417 """ |
419 """ |
418 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
420 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
419 |
421 |
420 def data(self, index, role=Qt.DisplayRole): |
422 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
421 """ |
423 """ |
422 Public Qt slot get the role data of item. |
424 Public Qt slot get the role data of item. |
423 |
425 |
424 @param index the model index |
426 @param index the model index |
425 @type QModelIndex |
427 @type QModelIndex |
426 @param role the requested data role |
428 @param role the requested data role |
427 @type QtCore.Qt.ItemDataRole |
429 @type QtCore.Qt.ItemDataRole |
428 @return role data of item |
430 @return role data of item |
429 @rtype str, QBrush or None |
431 @rtype str, QBrush or None |
430 """ |
432 """ |
431 if role == Qt.DisplayRole: |
433 if role == Qt.ItemDataRole.DisplayRole: |
432 return self.tr("Variable Name") |
434 return self.tr("Variable Name") |
433 elif role == Qt.BackgroundRole: |
435 elif role == Qt.ItemDataRole.BackgroundRole: |
434 if index.row() >= 2: |
436 if index.row() >= 2: |
435 return self.bgColorChanged |
437 return self.bgColorChanged |
436 else: |
438 else: |
437 return self.bgColorNew |
439 return self.bgColorNew |
438 |
440 |