From b8f1f4ba3362065e555e1b4f7599a4ef9523a055 Mon Sep 17 00:00:00 2001
From: "Anders H. Rebner" <anderhre@stud.ntnu.no>
Date: Fri, 3 Apr 2020 16:23:30 +0200
Subject: [PATCH] #87 Flyttet felles kodelinje til parent

---
 soitool/modules/code_table_base.py             |  9 +++++++++
 soitool/modules/module_authentication_board.py | 14 ++------------
 soitool/modules/module_subtractorcodes.py      | 14 ++------------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/soitool/modules/code_table_base.py b/soitool/modules/code_table_base.py
index 95ed2cf..0124328 100644
--- a/soitool/modules/code_table_base.py
+++ b/soitool/modules/code_table_base.py
@@ -45,6 +45,15 @@ class CodeTableBase(ModuleBase, QTableWidget, metaclass=Meta):
         self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
         self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
 
+        # Resize table when headline changes
+        self.cellChanged.connect(
+            lambda: resize_table(
+                self,
+                resize_rows=False,
+                resize_columns=False,
+                has_headline=True,
+            )
+        )
         # If parameters are None, generate new table
         if size is None and data is None:
             self.generate_table()
diff --git a/soitool/modules/module_authentication_board.py b/soitool/modules/module_authentication_board.py
index f2ac91a..e1dc999 100644
--- a/soitool/modules/module_authentication_board.py
+++ b/soitool/modules/module_authentication_board.py
@@ -45,8 +45,8 @@ class AuthenticationBoardModule(CodeTableBase):
     The widget does not use more room than needed, and resizes dynamically.
     It has shortcuts for adding and removing rows.
 
-    Codes are not horizontally centered because 'BGD' is wider than 'III'
-    (example) in certain fonts.
+    Codes are not horizontally centered for readability because 'BGD' is wider
+    than 'III' (example) in certain fonts.
     """
 
     def __init__(self, size=None, data=None):
@@ -63,7 +63,6 @@ class AuthenticationBoardModule(CodeTableBase):
                 "Invalid value for CONSTANT 'CODE_CHARACTER_TYPE': "
                 "'{}'".format(CODE_CHARACTER_TYPE)
             )
-
         self.start_no_of_codes = START_NO_OF_CODES
         self.code_length = CODE_LENGTH
         self.space_interval = SPACE_INTERVAL
@@ -72,15 +71,6 @@ class AuthenticationBoardModule(CodeTableBase):
         self.headline = HEADLINE_TEXT
 
         CodeTableBase.__init__(self, size, data)
-        # Resize table when headline changes
-        self.cellChanged.connect(
-            lambda: resize_table(
-                self,
-                resize_rows=False,
-                resize_columns=False,
-                has_headline=True,
-            )
-        )
 
     def insert_row_identifiers(self):
         """Insert values in column one and two."""
diff --git a/soitool/modules/module_subtractorcodes.py b/soitool/modules/module_subtractorcodes.py
index e045503..3b04ab2 100644
--- a/soitool/modules/module_subtractorcodes.py
+++ b/soitool/modules/module_subtractorcodes.py
@@ -48,24 +48,14 @@ class SubtractorcodesModule(CodeTableBase):
                 "Invalid value for CONSTANT 'START_NO_OF_CODES': "
                 "'{}'".format(START_NO_OF_CODES)
             )
-        # pylint: disable=R0801
-        self.start_no_of_codes = START_NO_OF_CODES
+        self.headline = HEADLINE_TEXT
         self.code_length = CODE_LENGTH
+        self.start_no_of_codes = START_NO_OF_CODES
         self.space_interval = SPACE_INTERVAL
         self.space_amount = SPACE_AMOUNT
         self.code_character_type = "digits"
-        self.headline = HEADLINE_TEXT
 
         CodeTableBase.__init__(self, size, data)
-        # Resize table when headline changes
-        self.cellChanged.connect(
-            lambda: resize_table(
-                self,
-                resize_rows=False,
-                resize_columns=False,
-                has_headline=True,
-            )
-        )
 
     def insert_row_identifiers(self, has_headline=False):
         """Insert row identifiers in first and second column.
-- 
GitLab