From ed5594802ff437fe2be161a931441646b0c02770 Mon Sep 17 00:00:00 2001 From: thomahl <thomahl@stud.ntnu.no> Date: Fri, 1 May 2020 11:48:21 +0200 Subject: [PATCH] #96 fjernet 'rows' som valg i resize_table i module_base --- soitool/modules/code_table_base.py | 6 +++--- soitool/modules/module_authentication_board.py | 4 ++-- soitool/modules/module_base.py | 14 ++++---------- soitool/modules/module_predefined_codes.py | 2 +- soitool/modules/module_subtractorcodes.py | 4 ++-- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/soitool/modules/code_table_base.py b/soitool/modules/code_table_base.py index 0f26f31..0119fcd 100644 --- a/soitool/modules/code_table_base.py +++ b/soitool/modules/code_table_base.py @@ -45,7 +45,7 @@ class CodeTableBase(ModuleBase, QTableWidget, metaclass=Meta): # Resize table when headline changes self.cellChanged.connect( lambda: resize_table( - self, rows=False, columns=False, has_headline=True, + self, columns=False, has_headline=True, ) ) # If parameters are None, launch settings-dialog and generate new table @@ -81,7 +81,7 @@ class CodeTableBase(ModuleBase, QTableWidget, metaclass=Meta): self.insert_headline(self.start_headline) resize_table( - self, columns=False, rows=False, has_headline=True, + self, columns=False, has_headline=True, ) else: self.code_length = data["code_length"] @@ -108,7 +108,7 @@ class CodeTableBase(ModuleBase, QTableWidget, metaclass=Meta): self.insert_headline(cells[0]) resize_table( - self, columns=False, rows=False, has_headline=True, + self, columns=False, has_headline=True, ) self.setFixedWidth(size["width"]) self.setFixedHeight(size["height"]) diff --git a/soitool/modules/module_authentication_board.py b/soitool/modules/module_authentication_board.py index 06ba84f..2e3619b 100644 --- a/soitool/modules/module_authentication_board.py +++ b/soitool/modules/module_authentication_board.py @@ -151,7 +151,7 @@ class AuthenticationBoardModule(CodeTableBase): self.resizeRowToContents(selected_row_index + 1) - resize_table(self, columns=False, rows=False, has_headline=True) + resize_table(self, columns=False, has_headline=True) def remove_row(self, row_index): """Remove selected row. @@ -168,7 +168,7 @@ class AuthenticationBoardModule(CodeTableBase): for i in range(row_index, self.rowCount()): self.item(i, 0).setText(self.code_characters[i - 1]) self.item(i, 1).setText(str(i - 1)) - resize_table(self, columns=False, rows=False, has_headline=True) + resize_table(self, columns=False, has_headline=True) def generate_authentication_numbers(self): """Generate two non-equal numbers between 1 and self.code_length. diff --git a/soitool/modules/module_base.py b/soitool/modules/module_base.py index c137556..325572d 100644 --- a/soitool/modules/module_base.py +++ b/soitool/modules/module_base.py @@ -62,15 +62,16 @@ class ModuleBase(ABC): raise NotImplementedError -def resize_table(table, rows=True, columns=True, has_headline=False): +def resize_table(table, columns=True, has_headline=False): """Resize a given QTableWidget. + On purpose not resizing rows, as this causes different heights from screen + to screen. + Parameters ---------- table : QTableWidget QTablewidget-instance to resize. - rows : bool - Resizes rows to contents if True, by default True. columns : bool Resizes columns to contents if True, by default True. has_headline : bool @@ -79,13 +80,6 @@ def resize_table(table, rows=True, columns=True, has_headline=False): """ if columns: table.resizeColumnsToContents() - if rows: - # This causes rowHeight to return a height dependant on screen size, - # which we dont' want. Commenting it out to see if we can live without - # it. - # TODO: remove the row parameter, if it's not used in the end.. - #table.resizeRowsToContents() - pass # If table has a headline, make sure table is wide enough to fit it. if has_headline: diff --git a/soitool/modules/module_predefined_codes.py b/soitool/modules/module_predefined_codes.py index 7c9ce9b..7c92bbc 100644 --- a/soitool/modules/module_predefined_codes.py +++ b/soitool/modules/module_predefined_codes.py @@ -507,7 +507,7 @@ class PredefinedCodesTable(QTableWidget): # Insert headline and resize table self.insert_headline(headline) - resize_table(self, rows=False, columns=False, has_headline=True) + resize_table(self, columns=False, has_headline=True) def insert_headline(self, text): """Insert headline. diff --git a/soitool/modules/module_subtractorcodes.py b/soitool/modules/module_subtractorcodes.py index 89d3f5c..8f3e052 100644 --- a/soitool/modules/module_subtractorcodes.py +++ b/soitool/modules/module_subtractorcodes.py @@ -130,7 +130,7 @@ class SubtractorcodesModule(CodeTableBase): self.setItem(selected_row_index + 1, 2, item_code) self.resizeRowToContents(selected_row_index + 1) - resize_table(self, columns=False, rows=False, has_headline=True) + resize_table(self, columns=False, has_headline=True) def remove_row(self, row_index): """Remove the selected row. @@ -143,7 +143,7 @@ class SubtractorcodesModule(CodeTableBase): self.removeRow(row_index) self.insert_row_identifiers(has_headline=True) - resize_table(self, columns=False, rows=False, has_headline=True) + resize_table(self, columns=False, has_headline=True) @staticmethod def get_user_friendly_name(): -- GitLab