mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
ui,stats: improved restoring columns
This commit is contained in:
parent
eab75b8a48
commit
843f537000
1 changed files with 22 additions and 14 deletions
|
@ -1845,7 +1845,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
cur_idx = self.tabWidget.currentIndex()
|
||||
self.IN_DETAIL_VIEW[cur_idx] = False
|
||||
|
||||
self._set_active_widgets(False)
|
||||
self._set_active_widgets(cur_idx, False)
|
||||
if cur_idx == StatsDialog.TAB_RULES:
|
||||
self._restore_rules_tab_widgets(True)
|
||||
return
|
||||
|
@ -1872,6 +1872,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._restore_last_selected_row()
|
||||
|
||||
def _cb_main_table_double_clicked(self, row):
|
||||
prev_idx = self.tabWidget.currentIndex()
|
||||
data = row.data()
|
||||
idx = row.column()
|
||||
cur_idx = 1
|
||||
|
@ -1881,7 +1882,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.IN_DETAIL_VIEW[cur_idx] = True
|
||||
self.LAST_SELECTED_ITEM = row.model().index(row.row(), self.COL_NODE).data()
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, str(data))
|
||||
self._set_active_widgets(prev_idx, True, str(data))
|
||||
self._set_nodes_query(data)
|
||||
|
||||
elif idx == StatsDialog.COL_RULES:
|
||||
|
@ -1889,7 +1890,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.IN_DETAIL_VIEW[cur_idx] = True
|
||||
self.LAST_SELECTED_ITEM = row.model().index(row.row(), self.COL_RULES).data()
|
||||
r_name, node = self._set_rules_tab_active(row, cur_idx, self.COL_RULES, self.COL_NODE)
|
||||
self._set_active_widgets(True, str(data))
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(prev_idx, True, str(data))
|
||||
self._set_rules_query(r_name, node)
|
||||
|
||||
elif idx == StatsDialog.COL_DSTIP:
|
||||
|
@ -1899,7 +1901,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
ip = rowdata
|
||||
self.LAST_SELECTED_ITEM = ip
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, ip)
|
||||
self._set_active_widgets(prev_idx, True, ip)
|
||||
self._set_addrs_query(ip)
|
||||
|
||||
elif idx == StatsDialog.COL_DSTHOST:
|
||||
|
@ -1911,7 +1913,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
return
|
||||
self.LAST_SELECTED_ITEM = host
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, host)
|
||||
self._set_active_widgets(prev_idx, True, host)
|
||||
self._set_hosts_query(host)
|
||||
|
||||
elif idx == StatsDialog.COL_DSTPORT:
|
||||
|
@ -1921,7 +1923,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
port = rowdata
|
||||
self.LAST_SELECTED_ITEM = port
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, port)
|
||||
self._set_active_widgets(prev_idx, True, port)
|
||||
self._set_ports_query(port)
|
||||
|
||||
elif idx == StatsDialog.COL_UID:
|
||||
|
@ -1931,7 +1933,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
uid = rowdata
|
||||
self.LAST_SELECTED_ITEM = uid
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, uid)
|
||||
self._set_active_widgets(prev_idx, True, uid)
|
||||
self._set_users_query(uid)
|
||||
|
||||
else:
|
||||
|
@ -1939,7 +1941,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.IN_DETAIL_VIEW[cur_idx] = True
|
||||
self.LAST_SELECTED_ITEM = row.model().index(row.row(), self.COL_PROCS).data()
|
||||
self.tabWidget.setCurrentIndex(cur_idx)
|
||||
self._set_active_widgets(True, self.LAST_SELECTED_ITEM)
|
||||
self._set_active_widgets(prev_idx, True, self.LAST_SELECTED_ITEM)
|
||||
self._set_process_query(self.LAST_SELECTED_ITEM)
|
||||
|
||||
self._restore_details_view_columns(
|
||||
|
@ -1996,7 +1998,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
return
|
||||
|
||||
rule_name = row.model().index(row.row(), self.COL_R_NAME).data()
|
||||
self._set_active_widgets(True, rule_name)
|
||||
self._set_active_widgets(cur_idx, True, rule_name)
|
||||
r_name, node = self._set_rules_tab_active(row, cur_idx, self.COL_R_NAME, self.COL_R_NODE)
|
||||
self.LAST_SELECTED_ITEM = row.model().index(row.row(), self.COL_R_NAME).data()
|
||||
self._set_rules_query(r_name, node)
|
||||
|
@ -2013,7 +2015,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
data = row.model().index(row.row(), self.COL_WHAT).data()
|
||||
|
||||
|
||||
self._set_active_widgets(True, str(data))
|
||||
self._set_active_widgets(cur_idx, True, str(data))
|
||||
|
||||
if cur_idx == StatsDialog.TAB_NODES:
|
||||
self._set_nodes_query(data)
|
||||
|
@ -2452,7 +2454,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
return self.TABLES[self.tabWidget.currentIndex()]['view']
|
||||
|
||||
def _set_active_widgets(self, state, label_txt=""):
|
||||
def _set_active_widgets(self, prev_idx, state, label_txt=""):
|
||||
cur_idx = self.tabWidget.currentIndex()
|
||||
self._clear_rows_selection()
|
||||
self.TABLES[cur_idx]['label'].setVisible(state)
|
||||
|
@ -2473,10 +2475,10 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
header = self.TABLES[cur_idx]['view'].horizontalHeader()
|
||||
if state == True:
|
||||
# going to normal state
|
||||
self._cfg.setSettings("{0}{1}".format(Config.STATS_VIEW_COL_STATE, cur_idx), header.saveState())
|
||||
else:
|
||||
# going to details state
|
||||
self._cfg.setSettings("{0}{1}".format(Config.STATS_VIEW_COL_STATE, prev_idx), header.saveState())
|
||||
else:
|
||||
# going to normal state
|
||||
self._cfg.setSettings("{0}{1}".format(Config.STATS_VIEW_DETAILS_COL_STATE, cur_idx), header.saveState())
|
||||
|
||||
def _restore_last_selected_row(self):
|
||||
|
@ -2498,6 +2500,12 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
def _restore_details_view_columns(self, header, settings_key):
|
||||
header.blockSignals(True);
|
||||
# In order to resize the last column of a view, we firstly force a
|
||||
# resizeToContens call.
|
||||
# Secondly set resizeMode to Interactive (allow to move columns by
|
||||
# users + programmatically)
|
||||
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
||||
header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive)
|
||||
|
||||
col_state = self._cfg.getSettings(settings_key)
|
||||
if type(col_state) == QtCore.QByteArray:
|
||||
|
|
Loading…
Add table
Reference in a new issue