mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
ui: fixed acting on selected rows
When selecting rows with CTRL we were not copying/deleting rules correctly. Closes #1245
This commit is contained in:
parent
422a2dd82d
commit
337b81a89b
2 changed files with 17 additions and 13 deletions
|
@ -337,16 +337,19 @@ class GenericTableView(QTableView):
|
|||
self.selectionModel().clearCurrentIndex()
|
||||
|
||||
def copySelection(self):
|
||||
selection = self.selectedIndexes()
|
||||
if selection:
|
||||
rows = sorted(index.row() for index in selection)
|
||||
rowcount = rows[-1] - rows[0] + 1
|
||||
table = self.model().copySelectedRows(
|
||||
selection[0].row() + self.vScrollBar.value() - 1,
|
||||
rowcount)
|
||||
return table
|
||||
model = self.selectionModel()
|
||||
curModel = self.model()
|
||||
selection = model.selectedRows()
|
||||
if not selection:
|
||||
return None
|
||||
|
||||
return None
|
||||
rows = []
|
||||
for idx in selection:
|
||||
row = []
|
||||
for col in range(0, curModel.columnCount()):
|
||||
row.append(curModel.index(idx.row(), col).data())
|
||||
rows.append(row)
|
||||
return rows
|
||||
|
||||
def getCurrentIndex(self):
|
||||
return self.selectionModel().currentIndex().internalId()
|
||||
|
|
|
@ -1066,6 +1066,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
cur_idx = self.tabWidget.currentIndex()
|
||||
if self.tabWidget.currentIndex() == self.TAB_RULES and self.fwTable.isVisible():
|
||||
cur_idx = self.TAB_FIREWALL
|
||||
elif self.tabWidget.currentIndex() == self.TAB_RULES and not self.fwTable.isVisible():
|
||||
cur_idx = self.TAB_RULES
|
||||
selection = self.TABLES[cur_idx]['view'].copySelection()
|
||||
if selection:
|
||||
stream = io.StringIO()
|
||||
|
@ -1564,10 +1566,9 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._notifications_sent[nid] = noti
|
||||
|
||||
elif cur_idx == self.TAB_RULES and self.rulesTable.isVisible():
|
||||
selection = self.TABLES[cur_idx]['view'].copySelection()
|
||||
for row in selection:
|
||||
name = row[self.COL_R_NAME]
|
||||
node = row[self.COL_R_NODE]
|
||||
for idx in selection:
|
||||
name = model.index(idx.row(), self.COL_R_NAME).data()
|
||||
node = model.index(idx.row(), self.COL_R_NODE).data()
|
||||
self._del_rule(name, node)
|
||||
|
||||
elif cur_idx == self.TAB_RULES and self.alertsTable.isVisible():
|
||||
|
|
Loading…
Add table
Reference in a new issue