Clean-up and rename variables

This commit is contained in:
2024-12-10 21:46:33 +01:00
parent 8830e277ec
commit 7c61b2a532
8 changed files with 25 additions and 32 deletions

View File

@@ -90,7 +90,7 @@ ColumnLayout
onCurrentTextChanged: isEmptyField() onCurrentTextChanged: isEmptyField()
onEditTextChanged: isEmptyField() onEditTextChanged: isEmptyField()
onActivated: currentValue onActivated: currentValue
model: am model: address_model
textRole: "display" textRole: "display"
popup.height: 300 popup.height: 300
popup.y: postcode.y + 5 - (postcode.height * 2) popup.y: postcode.y + 5 - (postcode.height * 2)
@@ -111,7 +111,7 @@ ColumnLayout
editable: true editable: true
onEditTextChanged: isEmptyField() onEditTextChanged: isEmptyField()
onCurrentTextChanged: isEmptyField() onCurrentTextChanged: isEmptyField()
model: am model: address_model
textRole: "city" textRole: "city"
popup.height: 300 popup.height: 300
popup.y: postcode.y + 5 - (postcode.height * 2) popup.y: postcode.y + 5 - (postcode.height * 2)
@@ -189,7 +189,7 @@ ColumnLayout
id: typeid id: typeid
Layout.fillWidth: true Layout.fillWidth: true
editable: false editable: false
model: btm model: business_type
textRole: "display" textRole: "display"
} }
Label Label

View File

@@ -104,7 +104,7 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
columnSpacing: 1 columnSpacing: 1
rowSpacing: 2 rowSpacing: 2
model: bm model: business_model
alternatingRows: true alternatingRows: true
resizableColumns: true // @disable-check M16 resizableColumns: true // @disable-check M16
selectionBehavior: TableView.SelectRows selectionBehavior: TableView.SelectRows
@@ -174,7 +174,7 @@ Item {
hoverEnabled: true hoverEnabled: true
onClicked: onClicked:
{ {
bm.onRowClicked(row) business_model.onRowClicked(row)
} }
onEntered: onEntered:
{ {

View File

@@ -72,7 +72,7 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
columnSpacing: 1 columnSpacing: 1
rowSpacing: 2 rowSpacing: 2
model: bm model: business_model
selectionBehavior: TableView.SelectRows selectionBehavior: TableView.SelectRows
selectionModel: ItemSelectionModel selectionModel: ItemSelectionModel
@@ -109,7 +109,7 @@ Item {
onClicked: onClicked:
{ {
bm.onRowClicked(row) business_model.onRowClicked(row)
testTable.selectionModel.select(testTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows) testTable.selectionModel.select(testTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows)

View File

@@ -38,7 +38,7 @@ RowLayout
onClicked: onClicked:
{ {
// TODO: here we should call the model // TODO: here we should call the model
appLoader.source = "CustomerTables.qml" appLoader.source = "CustomerTable.qml"
} }
} }
@@ -59,7 +59,7 @@ RowLayout
implicitWidth: mitarbeiter.implicitContentWidth + 10 implicitWidth: mitarbeiter.implicitContentWidth + 10
onClicked: onClicked:
{ {
appLoader.source = "EmployeTables.qml" appLoader.source = "EmployeeTable.qml"
} }
} }

View File

@@ -2,19 +2,16 @@ from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot
from .ContactDAO import ContactDAO from .ContactDAO import ContactDAO
import logging import logging
logger = logging.getLogger()
print(__name__)
class ContactModel: class ContactModel:
def __init__(self): def __init__(self):
print(f"*** File: {__file__}, __init__()")
super().__init__() super().__init__()
#self.logger = logging.getLogger()
print(f"*** File: {__file__}, __init__()")
self.__data = self.__getData() self.__data = self.__getData()
def getContacts(self): def getContacts(self):
print(f"*** File: {__file__}, getContacts()") print(f"*** File: {__file__}, getContacts()")
logger.debug("A debug message") logging.debug("No debug message")
return self.__data return self.__data
def __getData(self): def __getData(self):

24
main.py
View File

@@ -26,38 +26,36 @@ from lib.DB.ContactModel import ContactModel
# password="" # password=""
# name="" # name=""
# type="" # type=""
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
bad_config = False bad_config = False
am = None address_model = None
bm = None business_model = None
btm = None business_type = None
contact_model = None contact_model = None
user = None user = None
def initializeProgram(): def initializeProgram():
# print(f"In {__file__} file, 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: if not bad_config:
dbconf = config.getConfig()['database'] dbconf = config.getConfig()['database']
DbManager(dbconf) DbManager(dbconf)
bad_config = False bad_config = False
bm = BusinessModel() business_model = BusinessModel()
user = UserManager() user = UserManager()
am = AddressModel() address_model = AddressModel()
btm = BTypeModel() business_type = BTypeModel()
contact_model = ContactModel() contact_model = ContactModel()
publishContext() publishContext()
def publishContext(): def publishContext():
# print(f"In {__file__} file, 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("loggedin_user", user)
engine.rootContext().setContextProperty("bm", bm) engine.rootContext().setContextProperty("business_model", business_model)
engine.rootContext().setContextProperty("am", am) engine.rootContext().setContextProperty("address_model", address_model)
engine.rootContext().setContextProperty("btm", btm) engine.rootContext().setContextProperty("business_type", business_type)
engine.rootContext().setContextProperty("contact_model", contact_model) engine.rootContext().setContextProperty("contact_model", contact_model)
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -8,10 +8,8 @@
"Gui/Dashboard.qml", "Gui/Dashboard.qml",
"js/qmldict.js", "js/qmldict.js",
"lib/Vermasseln.py", "lib/Vermasseln.py",
"Gui/CustomerTables.qml",
"Gui/SearchBar.qml", "Gui/SearchBar.qml",
"lib/DB/BusinessModel.py", "lib/DB/BusinessModel.py",
"Gui/EmployeTables.qml",
"Gui/AddCustomer.qml", "Gui/AddCustomer.qml",
"pyqcrm.qrc", "pyqcrm.qrc",
"Gui/TopBar.qml", "Gui/TopBar.qml",

View File

@@ -7,9 +7,9 @@
<file>Gui/LoginScreen.qml</file> <file>Gui/LoginScreen.qml</file>
<file>Gui/AddContact.qml</file> <file>Gui/AddContact.qml</file>
<file>Gui/AddCustomer.qml</file> <file>Gui/AddCustomer.qml</file>
<file>Gui/CustomerTables.qml</file> <file>Gui/CustomerTable.qml</file>
<file>Gui/Dashboard.qml</file> <file>Gui/Dashboard.qml</file>
<file>Gui/EmployeTables.qml</file> <file>Gui/EmployeeTable.qml</file>
<file>Gui/firststart.qml</file> <file>Gui/firststart.qml</file>
<file>Gui/main.qml</file> <file>Gui/main.qml</file>
<file>Gui/SearchBar.qml</file> <file>Gui/SearchBar.qml</file>