Changed DataBase to BusinessModel

This commit is contained in:
2024-11-20 12:39:20 +01:00
parent a89fe6e1d5
commit 0e8e03dc5d
7 changed files with 55 additions and 15 deletions

View File

@@ -113,7 +113,7 @@ Item {
Layout.fillWidth: true
columnSpacing: 1
rowSpacing: 2
model: dbm
model: bm
alternatingRows: true
resizableColumns: true // @disable-check M16
selectionBehavior: TableView.SelectRows

View File

@@ -12,6 +12,7 @@ ApplicationWindow
height: Screen.height * .7
visible: true
title: "PYQCRM"
property string confile: ""
TopBar
{
@@ -71,10 +72,45 @@ ApplicationWindow
{
id: settingsFiledialog
title: qsTr("pyqcrm Einstellungen")
title: qsTr("PYQCRM Einstellungen")
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
modality: "ApplicationModal"
nameFilters: ["pyqcrm Einstellungen (*.toml)"]
onAccepted: config.importConfig(selectedFile)
nameFilters: [qsTr("PYQCRM Einstellungen (*.pyqcrm)")]
onAccepted:
{
encryptPwDialog.open()
confile = selectedFile
}
}
Dialog
{
id: encryptPwDialog
modal: true
title: qsTr("PYQCRM Einstellungen")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: config.importConfig(confile, encryptPassword.text)
ColumnLayout
{
RowLayout
{
Label
{
text: qsTr("Passwort eingeben:")
}
TextField
{
id: encryptPassword
echoMode: TextInput.Password
implicitWidth: 300
}
}
}
}
}

View File

@@ -4,7 +4,7 @@ from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot
class DataBase(QAbstractTableModel):
class BusinessModel(QAbstractTableModel):
def __init__(self, con):
super().__init__()

View File

@@ -5,7 +5,7 @@ from pathlib import Path
from PySide6.QtCore import QObject, Slot
from .Vermasseln import Vermasseln
import shutil
from urllib.parse import urlparse
class ConfigLoader(QObject):
__config = None
@@ -20,11 +20,14 @@ class ConfigLoader(QObject):
else:
config_dir.mkdir(0o750, True, True)
@Slot(str)
def importConfig(self, confile):
print(confile)
confile= confile.replace('file:///','')
shutil.copyfile(confile, self.config_dir+ '/pyqcrm.toml')
@Slot(str, str)
def importConfig(self, confile, password):
print(password)
confile = urlparse(confile)
print(confile.path)
#confile= confile.replace('file://','')
shutil.copyfile(confile.path, self.config_dir+ '/pyqcrm.toml')
@Slot(dict)
def setConfig(self, app_config):

View File

@@ -1 +1,2 @@
from .ConfigLoader import ConfigLoader
from .BusinessModel import BusinessModel

View File

@@ -5,7 +5,7 @@ from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtCore import QResource
from lib.ConfigLoader import ConfigLoader
from lib.DataBase import DataBase
from lib.BusinessModel import BusinessModel
import rc_pyqcrm
import rc_qml
import sqlite3
@@ -56,13 +56,13 @@ if __name__ == "__main__":
config = ConfigLoader()
con = testConnection()
dbm = DataBase(con)
bm = BusinessModel(con)
if not config.getConfig():
bad_config = True
engine.rootContext().setContextProperty("dbm", dbm)
engine.rootContext().setContextProperty("bm", bm)
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
engine.rootContext().setContextProperty("config", config)
engine.load(qml_file)

View File

@@ -11,7 +11,7 @@
"Gui/CustomerTables.qml",
"Gui/SearchBar.qml",
"Gui/test.qml",
"lib/DataBase.py",
"lib/BusinessModel.py",
"Gui/EmployeTables.qml",
"Gui/AddCustomer.qml",
"pyqcrm.qrc",