Skip to content

Commit

Permalink
Namecoin: Enabling deleting records in DNS dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Dec 12, 2019
1 parent ae7438a commit 334fe48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions electrum_nmc/electrum/gui/qt/configure_dns_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(self, value, parent):
self.ui.btnSRVCreate.clicked.connect(self.create_srv_record)
self.ui.btnIMPORTCreate.clicked.connect(self.create_import_record)

self.ui.btnDeleteRecord.clicked.connect(self.delete_selected_records)
self.ui.btnEditRecord.clicked.connect(self.edit_selected_record)

self.ui.dialogButtons.accepted.connect(self.accept)
Expand Down Expand Up @@ -623,6 +624,27 @@ def force_one_tab(self, tab):
else:
self.ui.tabRecords.setTabEnabled(tab_index, False)

def delete_selected_records(self):
table = self.ui.listDNSRecords

# Get all selected cells
cell_indexes = table.selectionModel().selectedIndexes()

# Get the rows of all selected cells
rows = set([cell.row() for cell in cell_indexes])

# Sort the rows in reverse
rows = sorted(rows, reverse=True)

# Get the model
model = table.model()

# Remove the rows
for row in rows:
model.removeRow(row)

self.update_byte_usage()

def get_records(self):
model = self.ui.listDNSRecords.model()

Expand Down
7 changes: 7 additions & 0 deletions electrum_nmc/electrum/gui/qt/forms/dnsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnDeleteRecord">
<property name="text">
<string>Delete Record</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnEditRecord">
<property name="text">
Expand Down

0 comments on commit 334fe48

Please sign in to comment.