Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 20, 2024
1 parent 3dfe87f commit 6a71815
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pg_service_parser/core/copy_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def data(self, index, role=Qt.DisplayRole):
if not index.isValid:
return None

if role == Qt.DisplayRole:
if role == Qt.DisplayRole or role == Qt.EditRole:
if index.column() == 0:
return self.shortcuts[index.row()].name
if index.column() == 1:
Expand Down
10 changes: 6 additions & 4 deletions pg_service_parser/gui/dlg_pg_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,13 @@ def __initialize_copy_services(self):
self.cboSourceService.setCurrentText(current_text)

self.shortcutsTableView.setModel(self.__shortcuts_model)
self.shortcutsTableView.resizeColumnsToContents()
self.shortcutsTableView.horizontalHeader().setSectionResizeMode(0, QHeaderView.Interactive)
self.shortcutsTableView.horizontalHeader().setSectionResizeMode(1, QHeaderView.Interactive)
self.shortcutsTableView.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
self.shortcutsTableView.selectionModel().selectionChanged.connect(
self.__shortcuts_selection_changed
)
self.shortcutsTableView.resizeColumnsToContents()

def __initialize_edit_services(self):
self.__edit_model = None
Expand Down Expand Up @@ -217,12 +220,11 @@ def __copy_service(self):
def __create_copy_shortcut(self):
target_service = self.cboTargetService.currentText()

if not self.cboTargetService.currentText():
if not target_service:
self.bar.pushInfo("PG service", "Select a valid target service and try again.")
return
self.__shortcuts_model.add_shortcut(self.cboSourceService.currentText(), target_service)
if self.__shortcuts_model.rowCount() == 1:
self.shortcutsTableView.resizeColumnsToContents()
self.shortcutsTableView.resizeColumnsToContents()

@pyqtSlot()
def __remove_copy_shortcut(self):
Expand Down
7 changes: 3 additions & 4 deletions pg_service_parser/pg_service_parser_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initGui(self):
self.button = QToolButton(self.iface.mainWindow())
self.button.setIcon(icon)

self.menu = self.iface.pluginMenu().addMenu(icon, "PG service parser")
self.menu = self.iface.databaseMenu().addMenu(icon, "PG service parser")
self.menu.setToolTipsVisible(True)

self.default_action = QAction(
Expand Down Expand Up @@ -98,18 +98,17 @@ def build_menus(self):
def unload(self):
self.iface.removeToolBarIcon(self.action)
self.iface.removePluginDatabaseMenu("PG service parser", self.action)
self.iface.pluginMenu().removeAction(self.menu.menuAction())
self.iface.databaseMenu().removeAction(self.menu.menuAction())
QgsSettingsTree.unregisterPluginTreeNode(PLUGIN_NAME)

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

def copy_service(self, service_from: str, service_to: str):
print(service_from, service_to)
_conf_path = conf_path()
if _conf_path.exists():
copy_service_settings(service_from, service_to, _conf_path)
self.iface.messageBar().pushMessage(
"PG service", f"PG service copied to '{service_to}'!"
"PG service", f"PG service copied from '{service_from}' to '{service_to}'!"
)
16 changes: 14 additions & 2 deletions pg_service_parser/ui/pg_service_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>693</width>
<height>574</height>
<width>575</width>
<height>419</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -253,19 +253,28 @@
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sortcuts allow to copy services directly from the plugin icon in the toolbar or from the menu entry.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="title">
<string>Shortcuts</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="QToolButton" name="shortcutAddButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a shortcut to the plugin toolbar button and to the menu entry&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="shortcutRemoveButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remove shortcut&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
Expand All @@ -292,6 +301,9 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 6a71815

Please sign in to comment.