From 7c61b2a532263098dfcbd9266c1066ea6a434b0b1304d32c803c0c69797ebde8 Mon Sep 17 00:00:00 2001 From: linuxero Date: Tue, 10 Dec 2024 21:46:33 +0100 Subject: [PATCH] Clean-up and rename variables --- Gui/AddCustomer.qml | 6 ++--- Gui/{CustomerTables.qml => CustomerTable.qml} | 4 ++-- Gui/{EmployeTables.qml => EmployeeTable.qml} | 4 ++-- Gui/TopBar.qml | 4 ++-- lib/DB/ContactModel.py | 9 +++---- main.py | 24 +++++++++---------- pyqcrm.pyproject | 2 -- qml.qrc | 4 ++-- 8 files changed, 25 insertions(+), 32 deletions(-) rename Gui/{CustomerTables.qml => CustomerTable.qml} (98%) rename Gui/{EmployeTables.qml => EmployeeTable.qml} (96%) diff --git a/Gui/AddCustomer.qml b/Gui/AddCustomer.qml index b0373c8..324b4d7 100644 --- a/Gui/AddCustomer.qml +++ b/Gui/AddCustomer.qml @@ -90,7 +90,7 @@ ColumnLayout onCurrentTextChanged: isEmptyField() onEditTextChanged: isEmptyField() onActivated: currentValue - model: am + model: address_model textRole: "display" popup.height: 300 popup.y: postcode.y + 5 - (postcode.height * 2) @@ -111,7 +111,7 @@ ColumnLayout editable: true onEditTextChanged: isEmptyField() onCurrentTextChanged: isEmptyField() - model: am + model: address_model textRole: "city" popup.height: 300 popup.y: postcode.y + 5 - (postcode.height * 2) @@ -189,7 +189,7 @@ ColumnLayout id: typeid Layout.fillWidth: true editable: false - model: btm + model: business_type textRole: "display" } Label diff --git a/Gui/CustomerTables.qml b/Gui/CustomerTable.qml similarity index 98% rename from Gui/CustomerTables.qml rename to Gui/CustomerTable.qml index 7a27ee5..05515e5 100644 --- a/Gui/CustomerTables.qml +++ b/Gui/CustomerTable.qml @@ -104,7 +104,7 @@ Item { Layout.fillWidth: true columnSpacing: 1 rowSpacing: 2 - model: bm + model: business_model alternatingRows: true resizableColumns: true // @disable-check M16 selectionBehavior: TableView.SelectRows @@ -174,7 +174,7 @@ Item { hoverEnabled: true onClicked: { - bm.onRowClicked(row) + business_model.onRowClicked(row) } onEntered: { diff --git a/Gui/EmployeTables.qml b/Gui/EmployeeTable.qml similarity index 96% rename from Gui/EmployeTables.qml rename to Gui/EmployeeTable.qml index fd1017b..9123ad4 100644 --- a/Gui/EmployeTables.qml +++ b/Gui/EmployeeTable.qml @@ -72,7 +72,7 @@ Item { Layout.fillWidth: true columnSpacing: 1 rowSpacing: 2 - model: bm + model: business_model selectionBehavior: TableView.SelectRows selectionModel: ItemSelectionModel @@ -109,7 +109,7 @@ Item { onClicked: { - bm.onRowClicked(row) + business_model.onRowClicked(row) testTable.selectionModel.select(testTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows) diff --git a/Gui/TopBar.qml b/Gui/TopBar.qml index f75dadd..6b51f3c 100644 --- a/Gui/TopBar.qml +++ b/Gui/TopBar.qml @@ -38,7 +38,7 @@ RowLayout onClicked: { // TODO: here we should call the model - appLoader.source = "CustomerTables.qml" + appLoader.source = "CustomerTable.qml" } } @@ -59,7 +59,7 @@ RowLayout implicitWidth: mitarbeiter.implicitContentWidth + 10 onClicked: { - appLoader.source = "EmployeTables.qml" + appLoader.source = "EmployeeTable.qml" } } diff --git a/lib/DB/ContactModel.py b/lib/DB/ContactModel.py index 0368a78..18b660c 100644 --- a/lib/DB/ContactModel.py +++ b/lib/DB/ContactModel.py @@ -2,19 +2,16 @@ from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot from .ContactDAO import ContactDAO import logging -logger = logging.getLogger() -print(__name__) - class ContactModel: def __init__(self): - print(f"*** File: {__file__}, __init__()") super().__init__() + #self.logger = logging.getLogger() + print(f"*** File: {__file__}, __init__()") self.__data = self.__getData() - def getContacts(self): print(f"*** File: {__file__}, getContacts()") - logger.debug("A debug message") + logging.debug("No debug message") return self.__data def __getData(self): diff --git a/main.py b/main.py index 4035195..42424f0 100644 --- a/main.py +++ b/main.py @@ -26,38 +26,36 @@ from lib.DB.ContactModel import ContactModel # password="" # name="" # type="" -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.DEBUG) bad_config = False -am = None -bm = None -btm = None +address_model = None +business_model = None +business_type = None contact_model = None user = None def initializeProgram(): # print(f"In {__file__} file, initializeProgram()") - global am, bad_config, bm, user, btm, contact_model + global address_model, bad_config, business_model, user, business_type, contact_model if not bad_config: dbconf = config.getConfig()['database'] DbManager(dbconf) bad_config = False - bm = BusinessModel() + business_model = BusinessModel() user = UserManager() - am = AddressModel() - btm = BTypeModel() + address_model = AddressModel() + business_type = BTypeModel() contact_model = ContactModel() publishContext() def publishContext(): # print(f"In {__file__} file, publishContext()") - global engine, am, bad_config, bm, user, btm, contact_model + global engine, address_model, bad_config, business_model, user, business_type, contact_model engine.rootContext().setContextProperty("loggedin_user", user) - engine.rootContext().setContextProperty("bm", bm) - engine.rootContext().setContextProperty("am", am) - engine.rootContext().setContextProperty("btm", btm) + engine.rootContext().setContextProperty("business_model", business_model) + engine.rootContext().setContextProperty("address_model", address_model) + engine.rootContext().setContextProperty("business_type", business_type) engine.rootContext().setContextProperty("contact_model", contact_model) if __name__ == "__main__": diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index a3a77b8..d605242 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -8,10 +8,8 @@ "Gui/Dashboard.qml", "js/qmldict.js", "lib/Vermasseln.py", - "Gui/CustomerTables.qml", "Gui/SearchBar.qml", "lib/DB/BusinessModel.py", - "Gui/EmployeTables.qml", "Gui/AddCustomer.qml", "pyqcrm.qrc", "Gui/TopBar.qml", diff --git a/qml.qrc b/qml.qrc index 1ca1881..b3843d5 100644 --- a/qml.qrc +++ b/qml.qrc @@ -7,9 +7,9 @@ Gui/LoginScreen.qml Gui/AddContact.qml Gui/AddCustomer.qml - Gui/CustomerTables.qml + Gui/CustomerTable.qml Gui/Dashboard.qml - Gui/EmployeTables.qml + Gui/EmployeeTable.qml Gui/firststart.qml Gui/main.qml Gui/SearchBar.qml