Fixed first start configuration load and add city model in add customer
This commit is contained in:
@@ -95,6 +95,7 @@ ColumnLayout
|
||||
popup.height: 300
|
||||
popup.y: postcode.y + 5 - (postcode.height * 2)
|
||||
currentIndex: -1
|
||||
onCurrentIndexChanged: city.currentIndex = postcode.currentIndex
|
||||
}
|
||||
|
||||
Label
|
||||
@@ -110,7 +111,12 @@ ColumnLayout
|
||||
editable: true
|
||||
onEditTextChanged: isEmptyField()
|
||||
onCurrentTextChanged: isEmptyField()
|
||||
model: ["", "MarcosDorf", "OschkarsLand"]
|
||||
model: am
|
||||
textRole: "city"
|
||||
popup.height: 300
|
||||
popup.y: postcode.y + 5 - (postcode.height * 2)
|
||||
currentIndex: -1
|
||||
onCurrentIndexChanged: postcode.currentIndex = city.currentIndex
|
||||
}
|
||||
|
||||
Label
|
||||
|
||||
@@ -9,7 +9,7 @@ from urllib.parse import urlparse
|
||||
from .DB.DbManager import DbManager
|
||||
import os
|
||||
from Crypto.Random import get_random_bytes
|
||||
from base64 import b64encode, b64decode
|
||||
from base64 import b64encode
|
||||
from .DB.UserManager import UserManager
|
||||
from .PyqcrmFlags import PyqcrmFlags
|
||||
|
||||
@@ -24,6 +24,7 @@ class ConfigLoader(QObject):
|
||||
dbConnectionError = Signal(str, bool)
|
||||
adminUserError = Signal(str, bool)
|
||||
usernameNotAvailable = Signal()
|
||||
configurationReady = Signal()
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -64,6 +65,9 @@ class ConfigLoader(QObject):
|
||||
self.__config = toml.loads(app_config)
|
||||
self.__saveConfig()
|
||||
conf = self.__checkAdminUser()
|
||||
if conf:
|
||||
self.configurationReady.emit()
|
||||
|
||||
|
||||
|
||||
def __configLoad(self):
|
||||
@@ -95,7 +99,7 @@ class ConfigLoader(QObject):
|
||||
return True
|
||||
else:
|
||||
self.dbConnectionError.emit("Connection fehlgeschlagen", False)
|
||||
return False
|
||||
return False
|
||||
|
||||
def __checkAdminUser(self):
|
||||
con = DbManager().getConnection()
|
||||
@@ -105,9 +109,10 @@ class ConfigLoader(QObject):
|
||||
if not result:
|
||||
#if not result[0][0] == 1:
|
||||
self.adminUserError.emit("Kein Admin vorhanden", False)
|
||||
return False
|
||||
else:
|
||||
self.adminUserError.emit("Admin vorhanden", True)
|
||||
|
||||
return True
|
||||
|
||||
@Slot(str)
|
||||
def setEncyrptKey(self, key):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PySide6.QtCore import QAbstractListModel, Qt, Slot, QModelIndex
|
||||
from .AddressDAO import AddressDAO
|
||||
|
||||
from ..PyqcrmDataRoles import PyqcrmDataRoles
|
||||
|
||||
class AddressModel(QAbstractListModel):
|
||||
|
||||
@@ -16,8 +16,17 @@ class AddressModel(QAbstractListModel):
|
||||
if role == Qt.DisplayRole:
|
||||
data= self.__address_data[row][2]
|
||||
return data
|
||||
elif role == PyqcrmDataRoles.CITY_ROLE:
|
||||
data= self.__address_data[row][3]
|
||||
return data
|
||||
return None
|
||||
|
||||
def roleNames(self):
|
||||
return {
|
||||
Qt.DisplayRole: b"display",
|
||||
PyqcrmDataRoles.CITY_ROLE: b"city",
|
||||
}
|
||||
|
||||
def setData(self):
|
||||
pass
|
||||
|
||||
|
||||
8
lib/PyqcrmDataRoles.py
Normal file
8
lib/PyqcrmDataRoles.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from enum import IntEnum
|
||||
|
||||
class PyqcrmDataRoles(IntEnum):
|
||||
CITY_ROLE = Qt.UserRole + 1
|
||||
|
||||
34
main.py
34
main.py
@@ -26,6 +26,26 @@ from lib.DB.AddressModel import AddressModel
|
||||
# name=""
|
||||
# type=""
|
||||
|
||||
am = None
|
||||
bm = None
|
||||
user = None
|
||||
|
||||
def initializeProgram():
|
||||
global am, bad_config, bm, user
|
||||
dbconf = config.getConfig()['database']
|
||||
DbManager(dbconf)
|
||||
bad_config = False
|
||||
bm = BusinessModel()
|
||||
user = UserManager()
|
||||
am = AddressModel()
|
||||
|
||||
publishContext()
|
||||
|
||||
def publishContext():
|
||||
global engine
|
||||
engine.rootContext().setContextProperty("loggedin_user", user)
|
||||
engine.rootContext().setContextProperty("bm", bm)
|
||||
engine.rootContext().setContextProperty("am", am)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#QResource.registerResource("rc_qml.py")
|
||||
@@ -50,21 +70,13 @@ if __name__ == "__main__":
|
||||
|
||||
if not config.getConfig():
|
||||
bad_config = True
|
||||
bm = False
|
||||
config.configurationReady.connect(initializeProgram)
|
||||
|
||||
else:
|
||||
dbconf = config.getConfig()['database']
|
||||
DbManager(dbconf)
|
||||
bm = BusinessModel()
|
||||
user = UserManager()
|
||||
am = AddressModel()
|
||||
initializeProgram()
|
||||
|
||||
#print(con is con2)
|
||||
|
||||
engine.rootContext().setContextProperty("bm", bm)
|
||||
engine.rootContext().setContextProperty("am", am)
|
||||
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
|
||||
engine.rootContext().setContextProperty("config", config)
|
||||
engine.rootContext().setContextProperty("loggedin_user", user)
|
||||
engine.load(qml_file)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user