Fixing ObjectAddOnContactPerson.qml conflict

This commit is contained in:
2025-02-27 14:28:27 +01:00
12 changed files with 226 additions and 80 deletions

View File

@@ -95,7 +95,10 @@ ColumnLayout
Layout.fillHeight: true
}
Component.onCompleted:
{
object_model.objectAdded.connect(onObjectAdded)
}
// Connections
// {

17
Gui/CompanyConf.qml Normal file
View File

@@ -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
}
}

View File

@@ -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
}
}
}
}
}
}

View File

@@ -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)
}
}

View File

@@ -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

95
Gui/PyqcrmConf.qml Normal file
View File

@@ -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")
}
}
}
}
}

View File

@@ -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") }

View File

@@ -4,6 +4,7 @@ import QtQuick.Controls
Item
{
property string name: "users"
anchors.fill: parent
Label

View File

@@ -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))

View File

@@ -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)

View File

@@ -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)

View File

@@ -42,5 +42,7 @@
<file>Gui/CustomerDetailsView.qml</file>
<file>Gui/ReadMe.qml</file>
<file>Gui/UsersPage.qml</file>
<file>Gui/PyqcrmConf.qml</file>
<file>Gui/CompanyConf.qml</file>
</qresource>
</RCC>