Skip to content

Commit

Permalink
First run of the migration script (QGIS Python bindings enabled) (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor authored May 27, 2024
1 parent a19d57a commit 5ba8d98
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions pg_service_parser/core/item_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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

Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions pg_service_parser/gui/dlg_pg_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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}
Expand All @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion pg_service_parser/pg_service_parser_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def unload(self):

def run(self):
dlg = PgServiceDialog(self.iface.mainWindow())
dlg.exec_()
dlg.exec()

0 comments on commit 5ba8d98

Please sign in to comment.