Changed DataBase to BusinessModel
This commit is contained in:
@@ -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
|
||||
|
||||
42
Gui/main.qml
42
Gui/main.qml
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot
|
||||
|
||||
|
||||
|
||||
class DataBase(QAbstractTableModel):
|
||||
class BusinessModel(QAbstractTableModel):
|
||||
|
||||
def __init__(self, con):
|
||||
super().__init__()
|
||||
@@ -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):
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from .ConfigLoader import ConfigLoader
|
||||
from .BusinessModel import BusinessModel
|
||||
|
||||
6
main.py
6
main.py
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user