Skip to content
Snippets Groups Projects
Commit f838f425 authored by Thomas Holene Løkkeborg's avatar Thomas Holene Løkkeborg
Browse files

Merge branch 'module-phonebook' into 'master'

#96 Telefonliste-bugs

See merge request !88
parents 54e4bc58 bb7d57c5
No related branches found
No related tags found
1 merge request!88#96 Telefonliste-bugs
Pipeline #83911 passed with stages
in 2 minutes and 24 seconds
......@@ -120,7 +120,9 @@ class PhonebookModule(ModuleBase, QWidget, metaclass=Meta):
# Table structure
with open(
"soitool/modules/config/module_phonebook.json", "r"
"soitool/modules/config/module_phonebook.json",
"r",
encoding="utf-8",
) as config_file:
self.selected_columns = load(config_file)
......@@ -280,16 +282,15 @@ class PhonebookModule(ModuleBase, QWidget, metaclass=Meta):
def set_columns(self):
"""Update table columns visibility based on selected_columns."""
selected_item = self.table.currentItem()
for header in self.selected_columns.keys():
self.table.setColumnHidden(
self.get_column_index_by_header(header),
not (self.selected_columns[header]),
)
# Restore selected item, because the above operation sets the current
# selected item to the item in the last column of the first row.
self.table.setCurrentItem(selected_item)
self.resize()
# setColumnHidden makes the next added row appear above the title, so
# forcing a valid cell here
self.table.setCurrentCell(1, 0)
def get_column_index_by_header(self, header):
"""Get index for column containing a spesific header.
......@@ -361,9 +362,8 @@ class PhonebookModule(ModuleBase, QWidget, metaclass=Meta):
)
self.table.setItem(row_index, column_index, current_item)
# To stop the last column of the first row to be selected, which looks
# strange on windows
self.table.clearSelection()
# Select first cell
self.table.setCurrentCell(1, 0)
def open_popup(self):
"""Open dialog for editing columns."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment