Changed DataBase to BusinessModel
This commit is contained in:
@@ -113,7 +113,7 @@ Item {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
columnSpacing: 1
|
columnSpacing: 1
|
||||||
rowSpacing: 2
|
rowSpacing: 2
|
||||||
model: dbm
|
model: bm
|
||||||
alternatingRows: true
|
alternatingRows: true
|
||||||
resizableColumns: true // @disable-check M16
|
resizableColumns: true // @disable-check M16
|
||||||
selectionBehavior: TableView.SelectRows
|
selectionBehavior: TableView.SelectRows
|
||||||
|
|||||||
42
Gui/main.qml
42
Gui/main.qml
@@ -12,6 +12,7 @@ ApplicationWindow
|
|||||||
height: Screen.height * .7
|
height: Screen.height * .7
|
||||||
visible: true
|
visible: true
|
||||||
title: "PYQCRM"
|
title: "PYQCRM"
|
||||||
|
property string confile: ""
|
||||||
|
|
||||||
TopBar
|
TopBar
|
||||||
{
|
{
|
||||||
@@ -71,10 +72,45 @@ ApplicationWindow
|
|||||||
{
|
{
|
||||||
|
|
||||||
id: settingsFiledialog
|
id: settingsFiledialog
|
||||||
title: qsTr("pyqcrm Einstellungen")
|
title: qsTr("PYQCRM Einstellungen")
|
||||||
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
|
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
|
||||||
modality: "ApplicationModal"
|
modality: "ApplicationModal"
|
||||||
nameFilters: ["pyqcrm Einstellungen (*.toml)"]
|
nameFilters: [qsTr("PYQCRM Einstellungen (*.pyqcrm)")]
|
||||||
onAccepted: config.importConfig(selectedFile)
|
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):
|
def __init__(self, con):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
from PySide6.QtCore import QObject, Slot
|
from PySide6.QtCore import QObject, Slot
|
||||||
from .Vermasseln import Vermasseln
|
from .Vermasseln import Vermasseln
|
||||||
import shutil
|
import shutil
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
class ConfigLoader(QObject):
|
class ConfigLoader(QObject):
|
||||||
__config = None
|
__config = None
|
||||||
@@ -20,11 +20,14 @@ class ConfigLoader(QObject):
|
|||||||
else:
|
else:
|
||||||
config_dir.mkdir(0o750, True, True)
|
config_dir.mkdir(0o750, True, True)
|
||||||
|
|
||||||
@Slot(str)
|
@Slot(str, str)
|
||||||
def importConfig(self, confile):
|
def importConfig(self, confile, password):
|
||||||
print(confile)
|
print(password)
|
||||||
confile= confile.replace('file:///','')
|
|
||||||
shutil.copyfile(confile, self.config_dir+ '/pyqcrm.toml')
|
confile = urlparse(confile)
|
||||||
|
print(confile.path)
|
||||||
|
#confile= confile.replace('file://','')
|
||||||
|
shutil.copyfile(confile.path, self.config_dir+ '/pyqcrm.toml')
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def setConfig(self, app_config):
|
def setConfig(self, app_config):
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
from .ConfigLoader import ConfigLoader
|
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.QtQml import QQmlApplicationEngine
|
||||||
from PySide6.QtCore import QResource
|
from PySide6.QtCore import QResource
|
||||||
from lib.ConfigLoader import ConfigLoader
|
from lib.ConfigLoader import ConfigLoader
|
||||||
from lib.DataBase import DataBase
|
from lib.BusinessModel import BusinessModel
|
||||||
import rc_pyqcrm
|
import rc_pyqcrm
|
||||||
import rc_qml
|
import rc_qml
|
||||||
import sqlite3
|
import sqlite3
|
||||||
@@ -56,13 +56,13 @@ if __name__ == "__main__":
|
|||||||
config = ConfigLoader()
|
config = ConfigLoader()
|
||||||
|
|
||||||
con = testConnection()
|
con = testConnection()
|
||||||
dbm = DataBase(con)
|
bm = BusinessModel(con)
|
||||||
|
|
||||||
if not config.getConfig():
|
if not config.getConfig():
|
||||||
bad_config = True
|
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("bad_config", bad_config) # print(f"Fehler: {i}")
|
||||||
engine.rootContext().setContextProperty("config", config)
|
engine.rootContext().setContextProperty("config", config)
|
||||||
engine.load(qml_file)
|
engine.load(qml_file)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"Gui/CustomerTables.qml",
|
"Gui/CustomerTables.qml",
|
||||||
"Gui/SearchBar.qml",
|
"Gui/SearchBar.qml",
|
||||||
"Gui/test.qml",
|
"Gui/test.qml",
|
||||||
"lib/DataBase.py",
|
"lib/BusinessModel.py",
|
||||||
"Gui/EmployeTables.qml",
|
"Gui/EmployeTables.qml",
|
||||||
"Gui/AddCustomer.qml",
|
"Gui/AddCustomer.qml",
|
||||||
"pyqcrm.qrc",
|
"pyqcrm.qrc",
|
||||||
|
|||||||
Reference in New Issue
Block a user