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.height: 300
|
||||||
popup.y: postcode.y + 5 - (postcode.height * 2)
|
popup.y: postcode.y + 5 - (postcode.height * 2)
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
onCurrentIndexChanged: city.currentIndex = postcode.currentIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
@@ -110,7 +111,12 @@ ColumnLayout
|
|||||||
editable: true
|
editable: true
|
||||||
onEditTextChanged: isEmptyField()
|
onEditTextChanged: isEmptyField()
|
||||||
onCurrentTextChanged: 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
|
Label
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from urllib.parse import urlparse
|
|||||||
from .DB.DbManager import DbManager
|
from .DB.DbManager import DbManager
|
||||||
import os
|
import os
|
||||||
from Crypto.Random import get_random_bytes
|
from Crypto.Random import get_random_bytes
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode
|
||||||
from .DB.UserManager import UserManager
|
from .DB.UserManager import UserManager
|
||||||
from .PyqcrmFlags import PyqcrmFlags
|
from .PyqcrmFlags import PyqcrmFlags
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ class ConfigLoader(QObject):
|
|||||||
dbConnectionError = Signal(str, bool)
|
dbConnectionError = Signal(str, bool)
|
||||||
adminUserError = Signal(str, bool)
|
adminUserError = Signal(str, bool)
|
||||||
usernameNotAvailable = Signal()
|
usernameNotAvailable = Signal()
|
||||||
|
configurationReady = Signal()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -64,6 +65,9 @@ class ConfigLoader(QObject):
|
|||||||
self.__config = toml.loads(app_config)
|
self.__config = toml.loads(app_config)
|
||||||
self.__saveConfig()
|
self.__saveConfig()
|
||||||
conf = self.__checkAdminUser()
|
conf = self.__checkAdminUser()
|
||||||
|
if conf:
|
||||||
|
self.configurationReady.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __configLoad(self):
|
def __configLoad(self):
|
||||||
@@ -105,9 +109,10 @@ class ConfigLoader(QObject):
|
|||||||
if not result:
|
if not result:
|
||||||
#if not result[0][0] == 1:
|
#if not result[0][0] == 1:
|
||||||
self.adminUserError.emit("Kein Admin vorhanden", False)
|
self.adminUserError.emit("Kein Admin vorhanden", False)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
self.adminUserError.emit("Admin vorhanden", True)
|
self.adminUserError.emit("Admin vorhanden", True)
|
||||||
|
return True
|
||||||
|
|
||||||
@Slot(str)
|
@Slot(str)
|
||||||
def setEncyrptKey(self, key):
|
def setEncyrptKey(self, key):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from PySide6.QtCore import QAbstractListModel, Qt, Slot, QModelIndex
|
from PySide6.QtCore import QAbstractListModel, Qt, Slot, QModelIndex
|
||||||
from .AddressDAO import AddressDAO
|
from .AddressDAO import AddressDAO
|
||||||
|
from ..PyqcrmDataRoles import PyqcrmDataRoles
|
||||||
|
|
||||||
class AddressModel(QAbstractListModel):
|
class AddressModel(QAbstractListModel):
|
||||||
|
|
||||||
@@ -16,8 +16,17 @@ class AddressModel(QAbstractListModel):
|
|||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
data= self.__address_data[row][2]
|
data= self.__address_data[row][2]
|
||||||
return data
|
return data
|
||||||
|
elif role == PyqcrmDataRoles.CITY_ROLE:
|
||||||
|
data= self.__address_data[row][3]
|
||||||
|
return data
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def roleNames(self):
|
||||||
|
return {
|
||||||
|
Qt.DisplayRole: b"display",
|
||||||
|
PyqcrmDataRoles.CITY_ROLE: b"city",
|
||||||
|
}
|
||||||
|
|
||||||
def setData(self):
|
def setData(self):
|
||||||
pass
|
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=""
|
# name=""
|
||||||
# type=""
|
# 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__":
|
if __name__ == "__main__":
|
||||||
#QResource.registerResource("rc_qml.py")
|
#QResource.registerResource("rc_qml.py")
|
||||||
@@ -50,21 +70,13 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if not config.getConfig():
|
if not config.getConfig():
|
||||||
bad_config = True
|
bad_config = True
|
||||||
bm = False
|
config.configurationReady.connect(initializeProgram)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
dbconf = config.getConfig()['database']
|
initializeProgram()
|
||||||
DbManager(dbconf)
|
|
||||||
bm = BusinessModel()
|
|
||||||
user = UserManager()
|
|
||||||
am = AddressModel()
|
|
||||||
|
|
||||||
#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("bad_config", bad_config) # print(f"Fehler: {i}")
|
||||||
engine.rootContext().setContextProperty("config", config)
|
engine.rootContext().setContextProperty("config", config)
|
||||||
engine.rootContext().setContextProperty("loggedin_user", user)
|
|
||||||
engine.load(qml_file)
|
engine.load(qml_file)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user