diff --git a/pg_service_parser/core/item_models.py b/pg_service_parser/core/item_models.py index cc05d0a..f4191d2 100644 --- a/pg_service_parser/core/item_models.py +++ b/pg_service_parser/core/item_models.py @@ -45,19 +45,19 @@ def remove_setting(self, index: QModelIndex): if self.__model_data == self.__original_data: self.__set_dirty_status(False) - def data(self, index, role=Qt.DisplayRole): + def data(self, index, role=Qt.ItemDataRole.DisplayRole): if not index.isValid(): return None key = list(self.__model_data.keys())[index.row()] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if index.column() == self.KEY_COL: return key elif index.column() == self.VALUE_COL: return self.__model_data[key] - elif role == Qt.EditRole and index.column() == self.VALUE_COL: + elif role == Qt.ItemDataRole.EditRole and index.column() == self.VALUE_COL: return self.__model_data[key] - elif role == Qt.FontRole: + elif role == Qt.ItemDataRole.FontRole: if index.column() == self.KEY_COL: font = QFont() font.setBold(True) @@ -69,7 +69,7 @@ def data(self, index, role=Qt.DisplayRole): font = QFont() font.setItalic(True) return font - elif role == Qt.ForegroundRole and index.column() == self.VALUE_COL: + elif role == Qt.ItemDataRole.ForegroundRole and index.column() == self.VALUE_COL: if ( key not in self.__original_data or self.__model_data[key] != self.__original_data[key] @@ -78,7 +78,7 @@ def data(self, index, role=Qt.DisplayRole): return None - def setData(self, index, value, role=Qt.EditRole) -> bool: + def setData(self, index, value, role=Qt.ItemDataRole.EditRole) -> bool: if not index.isValid(): return False @@ -98,13 +98,13 @@ def setData(self, index, value, role=Qt.EditRole) -> bool: def flags(self, idx): if not idx.isValid(): - return ~Qt.ItemIsSelectable & ~Qt.ItemIsEnabled + return ~Qt.ItemFlag.ItemIsSelectable & ~Qt.ItemFlag.ItemIsEnabled - _flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled + _flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled if idx.column() == self.KEY_COL: return _flags elif idx.column() == self.VALUE_COL: - return _flags | Qt.ItemIsEditable + return _flags | Qt.ItemFlag.ItemIsEditable def is_dirty(self): return self.__dirty diff --git a/pg_service_parser/gui/dlg_pg_service.py b/pg_service_parser/gui/dlg_pg_service.py index ecf3f75..c4f55d1 100644 --- a/pg_service_parser/gui/dlg_pg_service.py +++ b/pg_service_parser/gui/dlg_pg_service.py @@ -77,14 +77,14 @@ def __initialize_dialog(self): self.__update_target_controls(True) self.bar = QgsMessageBar() - self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) + self.bar.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed) self.layout().insertWidget(0, self.bar) @pyqtSlot() def __create_file_clicked(self): dlg = ServiceNameDialog(self) - dlg.exec_() - if dlg.result() == QDialog.Accepted: + dlg.exec() + if dlg.result() == QDialog.DialogCode.Accepted: Path.touch(self.__conf_file_path) add_new_service(dlg.service_name) @@ -109,7 +109,7 @@ def __source_service_changed(self, index): model = self.cboTargetService.model() item = model.item(index + 1) # Account for the first (empty) item - item.setFlags(item.flags() & ~Qt.ItemIsEnabled) # Disable mirror item + item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEnabled) # Disable mirror item self.cboTargetService.setCurrentText(current_text) @@ -182,10 +182,10 @@ def __edit_service_changed(self, index): "There are pending edits for service '{}'. Are you sure you want to discard them?".format( self.__edit_model.service_name() ), - QMessageBox.Yes | QMessageBox.No, - QMessageBox.No, + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, ) - == QMessageBox.Yes + == QMessageBox.StandardButton.Yes ): self.cboEditService.blockSignals(True) @@ -208,7 +208,7 @@ def __edit_service_changed(self, index): @pyqtSlot() def __add_settings_clicked(self): dlg = ServiceSettingsDialog(self, self.__edit_model.current_setting_keys()) - dlg.exec_() + dlg.exec() if dlg.settings_to_add: settings = {k: v for k, v in SERVICE_SETTINGS.items() if k in dlg.settings_to_add} @@ -224,10 +224,10 @@ def __remove_setting_clicked(self): self, "Remove service setting", f"Are you sure you want to remove the '{setting_key}' setting?", - QMessageBox.Yes | QMessageBox.No, - QMessageBox.No, + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, ) - == QMessageBox.Yes + == QMessageBox.StandardButton.Yes ): self.__edit_model.remove_setting(selected_indexes[0]) diff --git a/pg_service_parser/pg_service_parser_plugin.py b/pg_service_parser/pg_service_parser_plugin.py index 92a987d..36f5cde 100644 --- a/pg_service_parser/pg_service_parser_plugin.py +++ b/pg_service_parser/pg_service_parser_plugin.py @@ -27,4 +27,4 @@ def unload(self): def run(self): dlg = PgServiceDialog(self.iface.mainWindow()) - dlg.exec_() + dlg.exec()