diff --git a/Gui/AddObject.qml b/Gui/AddObject.qml
index 092b882..9961bb3 100644
--- a/Gui/AddObject.qml
+++ b/Gui/AddObject.qml
@@ -95,7 +95,10 @@ ColumnLayout
Layout.fillHeight: true
}
-
+ Component.onCompleted:
+ {
+ object_model.objectAdded.connect(onObjectAdded)
+ }
// Connections
// {
diff --git a/Gui/CompanyConf.qml b/Gui/CompanyConf.qml
new file mode 100644
index 0000000..52aa97e
--- /dev/null
+++ b/Gui/CompanyConf.qml
@@ -0,0 +1,17 @@
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+
+Item
+{
+ property string name: "company"
+ anchors.fill: parent
+
+ Label
+ {
+ text: qsTr("Das Unternehmen")
+ anchors.centerIn: parent
+ font.pixelSize: 57
+ font.bold: true
+ }
+}
diff --git a/Gui/ObjectAddOnContactPerson.qml b/Gui/ObjectAddOnContactPerson.qml
index 7d99aae..fa5755c 100644
--- a/Gui/ObjectAddOnContactPerson.qml
+++ b/Gui/ObjectAddOnContactPerson.qml
@@ -231,6 +231,25 @@ GridLayout
}
}
+ Component
+ {
+ id: highlight
+ Rectangle
+ {
+ width: 230; height: 15
+ color: "lightsteelblue"; radius: 5
+ y: contactView.currentItem.y
+ Behavior on y
+ {
+ SpringAnimation
+ {
+ spring: 3
+ damping: 0.2
+ }
+ }
+ }
+ }
+
Rectangle
{
id: mainRect
@@ -248,7 +267,6 @@ GridLayout
header: headline
highlight: Rectangle { color: "grey"}
highlightFollowsCurrentItem: false
-
onActiveFocusChanged: if(!focus) currentIndex = -1
delegate: Item
{
@@ -263,6 +281,17 @@ GridLayout
contactView.highlightFollowsCurrentItem = true
}
}
+ MouseArea
+ {
+ id: clickedRow
+ anchors.fill: parent
+ onClicked:
+ {
+ //var currentIndex = index
+ console.log(index)
+ console.log(contactView.currentItem.y)
+ }
+ }
Row
{
@@ -297,6 +326,8 @@ GridLayout
}
}
}
+
+
}
}
}
diff --git a/Gui/ObjectDetails.qml b/Gui/ObjectDetails.qml
index 7f19e8e..eaff8f0 100644
--- a/Gui/ObjectDetails.qml
+++ b/Gui/ObjectDetails.qml
@@ -15,13 +15,13 @@ Item
Button
{
- text: qsTr("Objekts zeigen")
- onClicked: customersStack.pop()
+ text: qsTr("Zurück zu den Objekten")
+ onClicked: objectsStack.pop()
}
}
Component.onCompleted:
{
- business_model.onRowClicked(selectedObject)
+ object_model.onRowClicked(selectedObject)
}
}
diff --git a/Gui/ObjectsTable.qml b/Gui/ObjectsTable.qml
index 04b2372..5937100 100644
--- a/Gui/ObjectsTable.qml
+++ b/Gui/ObjectsTable.qml
@@ -39,7 +39,7 @@ Item
id: horizontalHeaderview
Layout.fillWidth: true
implicitHeight: 40
- visible: false
+ //visible: false
movableColumns: true //@disable-check M16
syncView: objectTable
@@ -68,36 +68,22 @@ Item
id: objectTable
Layout.fillHeight: true
Layout.fillWidth: true
+ columnSpacing: 1
+ rowSpacing: 2
+ model: object_model
+ alternatingRows: true
+ resizableColumns: true // @disable-check M16
+ selectionBehavior: TableView.SelectRows
ScrollBar.vertical: ScrollBar
{
policy: objectTable.contentHeight > objectTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}
- columnSpacing: 1
- rowSpacing: 2
- //model: object_model
- alternatingRows: true
- resizableColumns: true // @disable-check M16
- selectionBehavior: TableView.SelectRows
selectionModel: ItemSelectionModel
{
id: obmodel
model: objectTable.model
}
- // Timer
- // {
- // id: redrawTable
- // running: true
- // interval: 1
- // repeat: false
- // onTriggered:
- // {
- // objectTable.forceLayout();
- // }
- // }
-
-
-
delegate:Rectangle
{
required property bool selected
@@ -112,7 +98,7 @@ Item
Text
{
- text: model.display === null? "": model.display
+ text: (model.display === null || model.display === undefined)? "": model.display
elide: Text.ElideRight
width: parent.width
height: parent.height
diff --git a/Gui/PyqcrmConf.qml b/Gui/PyqcrmConf.qml
new file mode 100644
index 0000000..2527b3e
--- /dev/null
+++ b/Gui/PyqcrmConf.qml
@@ -0,0 +1,95 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Item
+{
+ anchors.fill: parent
+ TabBar
+ {
+ id: bar
+ width: parent.width
+ TabButton
+ {
+ text: qsTr("Benutzer")
+ }
+ TabButton
+ {
+ text: qsTr("Datenbank")
+ }
+ TabButton
+ {
+ text: qsTr("Das Unternehmen")
+ }
+ }
+
+ StackLayout
+ {
+ id: confContainer
+ anchors.fill: parent
+ currentIndex: bar.currentIndex
+ Item
+ {
+ id: userTab
+ UsersPage
+ {
+ id: usersPage
+ anchors.fill: parent
+ }
+ }
+ Item
+ {
+ id: dbTab
+ DbConfiguration
+ {
+ id: dbConf
+ anchors.fill: parent
+ }
+ }
+ Item
+ {
+ id: companyTab
+ CompanyConf
+ {
+ id: companyConf
+ anchors.fill: parent
+ }
+ }
+ }
+
+ RowLayout
+ {
+ width: parent.width
+ anchors.bottom: parent.bottom
+ Item
+ {
+ Layout.fillWidth: true
+ }
+
+ Button
+ {
+ text: qsTr("Ablehnen")
+ onClicked: appLoader.source = "Dashboard.qml"
+ }
+
+ Button
+ {
+ text: qsTr("Speichern")
+ onClicked:
+ {
+ switch (confContainer.currentIndex)
+ {
+ case 1:
+ console.log("Need to update DB paramenters")
+ break
+
+ case 2:
+ console.log("Need to update company's info.")
+ break
+ default:
+ console.log("Need to handle users")
+ }
+ }
+ }
+ }
+}
diff --git a/Gui/TopBar.qml b/Gui/TopBar.qml
index 758dfb0..16bf968 100644
--- a/Gui/TopBar.qml
+++ b/Gui/TopBar.qml
@@ -178,8 +178,15 @@ RowLayout
id: mainMenu
MenuItem
{
- text: qsTr("Benutzer-Verwaltung")
- onTriggered: appLoader.source = "UsersPage.qml"
+ //text: qsTr("Benutzer-Verwaltung")
+ //onTriggered: appLoader.source = "UsersPage.qml"
+ text: qsTr("Einstellungen")
+ onTriggered:
+ {
+ // TODO: Check if logged-in user is admin first!!
+
+ appLoader.source = "PyqcrmConf.qml"
+ }
}
MenuSeparator {}
MenuItem { text: qsTr("Als PDF exportieren") }
diff --git a/Gui/UsersPage.qml b/Gui/UsersPage.qml
index 31d8c59..e9a9ec2 100644
--- a/Gui/UsersPage.qml
+++ b/Gui/UsersPage.qml
@@ -4,6 +4,7 @@ import QtQuick.Controls
Item
{
+ property string name: "users"
anchors.fill: parent
Label
diff --git a/lib/DB/ObjectDAO.py b/lib/DB/ObjectDAO.py
index c9e8400..3d964c6 100644
--- a/lib/DB/ObjectDAO.py
+++ b/lib/DB/ObjectDAO.py
@@ -6,7 +6,7 @@ from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
class ObjectDAO(QObject):
- newObjectAdded = Signal()
+ newObjectAdded = Signal(bool)
def __init__(self):
super().__init__()
@@ -20,7 +20,18 @@ class ObjectDAO(QObject):
if self.__cur:
self.__cur.callproc("addObject", (json.dumps(new_object), json.dumps(new_objcontact), enc_key,))
self.__con.commit()
- # self.newEmployeeAdded.emit()
+ self.newObjectAdded.emit(True)
+ except mariadb.Error as e:
+ self.newObjectAdded.emit(False)
+ print(str(e))
+ def getObjects(self, criterion, enc_key = None):
+ try:
+ if self.__cur:
+ self.__cur.callproc("getObjects", (criterion, enc_key,))
+ self.__all_cols = [desc[0] for desc in self.__cur.description]
+ return self.__cur.fetchall(), self.__all_cols
+ else:
+ return None, None
except mariadb.Error as e:
print(str(e))
diff --git a/lib/DB/ObjectModel.py b/lib/DB/ObjectModel.py
index abc99f6..0d19825 100644
--- a/lib/DB/ObjectModel.py
+++ b/lib/DB/ObjectModel.py
@@ -6,6 +6,8 @@ import re
import json
class ObjectModel(QAbstractTableModel):
+ objectAdded = Signal(bool)
+
__data = None
__object_dao = None
__visible_index = None
@@ -22,7 +24,8 @@ class ObjectModel(QAbstractTableModel):
self.__object_dao.newObjectAdded.connect(self.__refreshView)
self.__conf = ConfigLoader().getConfig()
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
- #self.__getData()
+ self.__object_dao.newObjectAdded.connect(self.objectAdded)
+ self.__getData()
@Slot(dict, list, bool)
def addObject(self, new_object, new_objcontact = None, new_contact = False):
@@ -30,7 +33,6 @@ class ObjectModel(QAbstractTableModel):
print(new_objcontact)
-
self.__object_dao.addObject(new_object, new_objcontact, self.__key)
# @Slot(str)
@@ -41,54 +43,45 @@ class ObjectModel(QAbstractTableModel):
def __refreshView(self):
self.__getData()
- # def __getData(self, criterion = "Alle", processed = False, fired = False, every_state = True):
- # self.beginResetModel()
- # rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired, every_state)
- # self.__data = rows
- # self.endResetModel()
+ def __getData(self, criterion = "Alle"):
+ self.beginResetModel()
+ rows, self.__visible_columns = self.__object_dao.getObjects(criterion, self.__key)
+ self.__data = rows
+ self.endResetModel()
- # def rowCount(self, parent= QModelIndex()):
- # return len (self.__data)
+ def rowCount(self, parent= QModelIndex()):
+ return len (self.__data)
- # def columnCount(self, parent= QModelIndex()):
- # return len(self.__visible_columns) - self.__col_skip
+ def columnCount(self, parent= QModelIndex()):
+ return len(self.__visible_columns) - self.__col_skip
- # @Slot(str, bool, bool, bool)
- # def viewCriterion(self, criterion, processed, fired, every_state):
- # self.__everyone = True if criterion == 'Alle' else False
- # if self.__everyone and criterion != "Alle":
- # self.__col_skip = 2
- # else:
- # self.__col_skip = 2
- # self.__getData(criterion, processed, fired, every_state)
+ @Slot(str)
+ def viewCriterion(self, criterion):
+ self.__getData(criterion)
- # def data(self, index, role= Qt.DisplayRole):
- # if role == Qt.DisplayRole:
- # row = self.__data[index.row()]
- # applicant_col = index.column() + self.__col_skip
- # tr = row[applicant_col] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
- # if applicant_col == 2 and self.__everyone:
- # tr = 'Ja' if tr == 1 else 'Nein'
- # else:
- # tr = re.sub("Keine Angabe ","", tr)
- # #print(f"Data: {tr}")
- # # return row[index.column() + 2]
- # return tr
- # return None
+ def data(self, index, role= Qt.DisplayRole):
+ if role == Qt.DisplayRole:
+ row = self.__data[index.row()]
+ applicant_col = index.column() + self.__col_skip
+ tr = row[applicant_col] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
+ #print(f"Data: {tr}")
+ # return row[index.column() + 2]
+ return tr
+ return None
- # def headerData(self, section, orientation, role = Qt.DisplayRole):
- # if orientation == Qt.Horizontal and role == Qt.DisplayRole:
- # self.__col_name = self.__visible_columns[section + self.__col_skip]
- # return self.__col_name
- # return super().headerData(section, orientation, role)
+ def headerData(self, section, orientation, role = Qt.DisplayRole):
+ if orientation == Qt.Horizontal and role == Qt.DisplayRole:
+ self.__col_name = self.__visible_columns[section + self.__col_skip]
+ return self.__col_name
+ return super().headerData(section, orientation, role)
- # @Slot(int)
- # def onRowClicked(self, row):
- # #print(self.__data)
- # print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
- # #if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
- # #self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
- # #print(self.__business)
- # #self.__getEmployeeInfo()
- # # self.__getContactInfo()
- # # print(self.__business_dict)
+ @Slot(int)
+ def onRowClicked(self, row):
+ #print(self.__data)
+ print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
+ #if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
+ #self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
+ #print(self.__business)
+ #self.__getEmployeeInfo()
+ # self.__getContactInfo()
+ # print(self.__business_dict)
diff --git a/lib/Vermasseln.py b/lib/Vermasseln.py
index 7857100..72e3190 100644
--- a/lib/Vermasseln.py
+++ b/lib/Vermasseln.py
@@ -20,7 +20,7 @@ class Vermasseln:
return storable_data
- def entschluesseln(self, data, local= True):
+ def entschluesseln(self, data, local = True):
try:
data_list = data.split(".")
encoded_data = [b64decode(x) for x in data_list]
@@ -37,7 +37,7 @@ class Vermasseln:
return decrypted_data
- def __vermasslungsKobold(self, local= True):
+ def __vermasslungsKobold(self, local = True):
key = platform.processor().encode("utf-8") if local else b"(==daniishtverhaftetwegensexy#)"
key = key[0:31]
hash_key = SHA256.new(key)
diff --git a/qml.qrc b/qml.qrc
index 1e6ca28..7996b66 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -42,5 +42,7 @@
Gui/CustomerDetailsView.qml
Gui/ReadMe.qml
Gui/UsersPage.qml
+ Gui/PyqcrmConf.qml
+ Gui/CompanyConf.qml