Skip to content

Commit

Permalink
Merge pull request #21 from imubit/delete-connection-not-working
Browse files Browse the repository at this point in the history
connections management touchup
  • Loading branch information
cloud-rocket authored Nov 28, 2023
2 parents a957e0c + 8f2cde2 commit f1e3ebe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/qt_data_extractor/design/copy-prompt.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<item>
<widget class="QCheckBox" name="checkboxAttributesOnly">
<property name="text">
<string>Extract Attributes Only</string>
<string>Extract Tag Metadata Only</string>
</property>
</widget>
</item>
Expand Down
4 changes: 2 additions & 2 deletions src/qt_data_extractor/design/main-window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Sample Rate </string>
<string>Data Frequency</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -624,7 +624,7 @@
<item>
<widget class="QCheckBox" name="checkboxExtractAttributesOnly">
<property name="text">
<string>Extract Attributes Only</string>
<string>Extract Tag Metadata Only</string>
</property>
</widget>
</item>
Expand Down
11 changes: 3 additions & 8 deletions src/qt_data_extractor/design/manage-connections.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<bool>false</bool>
</property>
<property name="columnCount">
<number>4</number>
<number>3</number>
</property>
<column>
<property name="text">
Expand All @@ -49,12 +49,7 @@
</column>
<column>
<property name="text">
<string>Parameters</string>
</property>
</column>
<column>
<property name="text">
<string>Enable</string>
<string>Enabled</string>
</property>
</column>
</widget>
Expand All @@ -65,7 +60,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
<set>QDialogButtonBox::Close</set>
</property>
<property name="centerButtons">
<bool>false</bool>
Expand Down
34 changes: 21 additions & 13 deletions src/qt_data_extractor/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,37 +158,45 @@ def on_manage_connections(self):
self._dialogManageConnections.tableConnections.setItem(
i, 0, QTableWidgetItem(conn["name"])
)
itemType = QTableWidgetItem(conn["type"])
itemType.setFlags(itemType.flags() & ~QtCore.Qt.ItemIsEditable)
self._dialogManageConnections.tableConnections.setItem(i, 1, itemType)
itemEnabled = QTableWidgetItem(conn["enabled"])
itemEnabled.setCheckState(
item_type = QTableWidgetItem(conn["type"])
item_type.setFlags(item_type.flags() & ~QtCore.Qt.ItemIsEditable)
self._dialogManageConnections.tableConnections.setItem(i, 1, item_type)
item_enabled = QTableWidgetItem(conn["enabled"])
item_enabled.setFlags(item_enabled.flags() & ~QtCore.Qt.ItemIsEditable)
item_enabled.setCheckState(
QtCore.Qt.Checked if conn["enabled"] else QtCore.Qt.Unchecked
)
self._dialogManageConnections.tableConnections.setItem(i, 3, itemEnabled)
self._dialogManageConnections.tableConnections.setItem(i, 2, item_enabled)

if len(self._existing_connections) > 0:

@QtCore.Slot()
def onDeleteConnection():
item = self._dialogManageConnections.tableConnections.currentItem()
def on_delete_connection():
item = self._dialogManageConnections.tableConnections.item(
self._dialogManageConnections.tableConnections.currentRow(), 0
)

if not item:
return

conn_name = item.text()

if (
item
and QMessageBox.question(
QMessageBox.question(
self._w,
self._w.windowTitle(),
f"Delete {item.text()} connection? (this operation cannot be undone)",
f'Delete "{conn_name}" connection? (this operation cannot be undone)',
QMessageBox.Yes | QMessageBox.No,
)
== QMessageBox.StandardButton.Yes
):
self._api.delete_connection(item.text())
self._api.delete_connection(conn_name)
self._dialogManageConnections.tableConnections.removeRow(
self._dialogManageConnections.tableConnections.currentRow()
)
self._refresh_connections()

delete_button.clicked.connect(onDeleteConnection)
delete_button.clicked.connect(on_delete_connection)
self._dialogManageConnections.buttonBox.addButton(
delete_button, QDialogButtonBox.ResetRole
)
Expand Down

0 comments on commit f1e3ebe

Please sign in to comment.