From 80a269a72965ed0a23261ce138dbed9bf23b4c6a31e8801600c1f108b8651b1d Mon Sep 17 00:00:00 2001 From: linuxero Date: Tue, 14 Jan 2025 14:39:35 +0100 Subject: [PATCH 1/3] Add contact person in GUI and get the dictionary ready to pass to python --- Gui/ObjectAddOnContactPerson.qml | 158 ++++++++++++++++++++++++++++--- Gui/ObjectAddOnEmployee.qml | 72 +++++++++----- Gui/ObjectView.qml | 8 +- Gui/main.qml | 4 +- 4 files changed, 199 insertions(+), 43 deletions(-) diff --git a/Gui/ObjectAddOnContactPerson.qml b/Gui/ObjectAddOnContactPerson.qml index 4f4ab07..7b39aaf 100644 --- a/Gui/ObjectAddOnContactPerson.qml +++ b/Gui/ObjectAddOnContactPerson.qml @@ -4,6 +4,7 @@ import QtQuick.Controls GridLayout { + property var contacts: null columns: 2 CheckBox @@ -11,14 +12,6 @@ GridLayout id: contactperson text: qsTr("Ansprechpartner") Layout.columnSpan: 2 - onCheckStateChanged: - { - title.enabled = contactperson.checked - firstname.enabled = contactperson.checked - lastname.enabled = contactperson.checked - phonenumber.enabled = contactperson.checked - posizion.enabled = contactperson.checked - } } Label { @@ -30,7 +23,7 @@ GridLayout id: title model: [qsTr("Herr"),qsTr("Frau")] Layout.fillWidth: true - enabled: false + enabled: contactperson.checked } Label { @@ -43,7 +36,7 @@ GridLayout Layout.fillWidth: true placeholderText: "Pflichtfeld" placeholderTextColor: "red" - enabled: false + enabled: contactperson.checked } Label { @@ -56,7 +49,7 @@ GridLayout Layout.fillWidth: true placeholderText: "Pflichtfeld" placeholderTextColor: "red" - enabled: false + enabled: contactperson.checked } Label { @@ -69,7 +62,7 @@ GridLayout Layout.fillWidth: true placeholderText: "Pflichtfeld" placeholderTextColor: "red" - enabled: false + enabled: contactperson.checked } Label { @@ -82,8 +75,147 @@ GridLayout Layout.fillWidth: true placeholderText: "Pflichtfeld" placeholderTextColor: "red" - enabled: false + enabled: contactperson.checked } + RowLayout + { + Layout.fillWidth: true + Layout.columnSpan: 2 + + Item + { + Layout.fillWidth: true + } + + Button + { + id: removeContact + text: qsTr("Entfernen") + enabled: contactperson.checked + } + + Button + { + id: addContact + text: qsTr("Hinzufügen") + enabled: contactperson.checked + onClicked: + { + var num_contacts = 0 + if (contacts !== null && contacts !== undefined) num_contacts = Object.keys(contacts).length + else contacts = {} + if (num_contacts < 3 && firstname.text.trim() !== "" && lastname.text.trim() !== "" && phonenumber.text.trim() !== "" && posizion.text.trim() !== "") + { + contacts[num_contacts] = {} + contacts[num_contacts]["title"] = title.currentText + contacts[num_contacts]["fname"] = firstname.text.trim() + contacts[num_contacts]["lname"] = lastname.text.trim() + contacts[num_contacts]["phone"] = phonenumber.text.trim() + contacts[num_contacts]["position"] = posizion.text.trim() + + contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), posizion: posizion.text.trim()}) + + firstname.text = "" + lastname.text = "" + phonenumber.text = "" + posizion.text = "" + } + } + } + } + + Label + { + text: qsTr("Ansprechpartner") + Layout.alignment: Qt.AlignRight | Qt.AlignTop + } + + ListModel + { + id: contactModel + } + + Component + { + id: headline + Row + { + Text + { + id: cpname + text: qsTr("Name") + width: 175 + font.bold: true + horizontalAlignment: Text.AlignHCenter + color: "yellow" + } + + Text + { + id: cpphone + text: qsTr("Telefon") + width: 100 + font.bold: true + horizontalAlignment: Text.AlignHCenter + color: "yellow" + } + + Text + { + id: cppos + text: qsTr("Position") + width: 150 + font.bold: true + horizontalAlignment: Text.AlignHCenter + color: "yellow" + } + } + } + + Rectangle + { + Layout.fillWidth: true + implicitHeight: 100 + color: firstname.palette.base + border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base + ListView + { + id: contactView + //Layout.fillWidth: true + implicitHeight: parent.height + model: contactModel + + header: headline + + delegate: Item + { + width: parent.width + //color: firstname.palette.base + //border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base + height: 15 + + Row + { + spacing: 9 + Text + { + text: model.name + width: 175 + } + Text + { + text: model.phone + width: 100 + } + Text + { + text: model.posizion + width: 150 + } + } + } + } + } } diff --git a/Gui/ObjectAddOnEmployee.qml b/Gui/ObjectAddOnEmployee.qml index 28660d4..6bec906 100644 --- a/Gui/ObjectAddOnEmployee.qml +++ b/Gui/ObjectAddOnEmployee.qml @@ -4,47 +4,75 @@ import QtQuick.Controls GridLayout { + property var employeens: null id: oaoemployee columns: 2 rows: 4 Label { text: qsTr("Mitarbeiter") + Layout.alignment: Qt.AlignRight | Qt.AlignTop } - ScrollView - { - Layout.rowSpan: 3 - Layout.fillWidth: true - TextArea + ListModel + { + id: employeeModel + } + + Rectangle + { + Layout.fillWidth: true + implicitHeight: 75 + Layout.rowSpan: 2 + color: mitarbeiterhin.palette.base + border.color: mitarbeiterhin.activeFocus? mitarbeiterhin.palette.highlight: mitarbeiterhin.palette.base + ListView { id: mitarbeitertext - implicitWidth: parent.width - implicitHeight: 100 - wrapMode: TextEdit.Wrap - background: Rectangle + model: ListModel{ListElement {name: "Mitarbeiter1"} ListElement{name: "Mitarbeiter2"}} + delegate: Item { - color: mitarbeiterhin.palette.base - border.color: mitarbeiterhin.activeFocus? mitarbeiterhin.palette.highlight: mitarbeiterhin.palette.base + Text + { + text: model.name + } } + // wrapMode: TextEdit.Wrap + // background: Rectangle + // { + // color: mitarbeiterhin.palette.base + // border.color: mitarbeiterhin.activeFocus? mitarbeiterhin.palette.highlight: mitarbeiterhin.palette.base + // } } } - Button + RowLayout { - id: mitarbeiterhin - property var neuermitarbeiter: undefined - text: qsTr("Mitarbeiter hinzufügen") Layout.columnSpan: 2 Layout.fillWidth: true - Layout.alignment: Qt.AlignRight - Layout.maximumWidth: mitarbeitertext.width - onClicked: + Item { - var nm = Qt.createComponent("AddObjectEmployee.qml") - if (nm.status === Component.Ready) + Layout.fillWidth: true + } + + Button + { + id: mitarbeiterraus + text: qsTr("Mitarbeiter entfernen") + } + + Button + { + id: mitarbeiterhin + property var neuermitarbeiter: undefined + text: qsTr("Mitarbeiter hinzufügen") + onClicked: { - neuermitarbeiter = nm.createObject (appWindow, {width: 600, height: 400}) - neuermitarbeiter.show() + var nm = Qt.createComponent("AddObjectEmployee.qml") + if (nm.status === Component.Ready) + { + neuermitarbeiter = nm.createObject (appWindow, {width: 600, height: 400}) + neuermitarbeiter.show() + } } } } diff --git a/Gui/ObjectView.qml b/Gui/ObjectView.qml index 1bb9a92..31bacd6 100644 --- a/Gui/ObjectView.qml +++ b/Gui/ObjectView.qml @@ -164,10 +164,8 @@ GridLayout { id: infoview Layout.fillWidth: true - Layout.preferredHeight: 200 - //Layout.columnSpan: 3 + Layout.preferredHeight: 110 ScrollBar.horizontal: ScrollBar - { policy: ScrollBar.AlwaysOn } @@ -176,9 +174,7 @@ GridLayout { id: objectInfo property string name: "objectinfo" - Layout.fillWidth: true - Layout.fillHeight: true - + implicitWidth: parent.width wrapMode: TextEdit.Wrap background: Rectangle { diff --git a/Gui/main.qml b/Gui/main.qml index 543f8d6..593cf2b 100644 --- a/Gui/main.qml +++ b/Gui/main.qml @@ -7,8 +7,8 @@ import QtCore ApplicationWindow { id: appWindow - width: Screen.width * .6 - height: Screen.height * .75 + width: Screen.width * .75 + height: Screen.height * .85 visible: true title: "PYQCRM" property string confile: "" From 3eadad5d5b7e4463eb1472f39b3da75e00fd7f41dc04933c7fcfd55044d68007 Mon Sep 17 00:00:00 2001 From: linuxero Date: Wed, 15 Jan 2025 09:35:54 +0100 Subject: [PATCH 2/3] Add employee in GUI and set up a dictionary for it --- Gui/AddObjectEmployee.qml | 27 +++++++++++- Gui/ObjectAddOnContactPerson.qml | 3 -- Gui/ObjectAddOnEmployee.qml | 75 ++++++++++++++++++++++++++------ 3 files changed, 87 insertions(+), 18 deletions(-) diff --git a/Gui/AddObjectEmployee.qml b/Gui/AddObjectEmployee.qml index f78a74d..52a68e6 100644 --- a/Gui/AddObjectEmployee.qml +++ b/Gui/AddObjectEmployee.qml @@ -3,7 +3,7 @@ import QtQuick.Layouts import QtQuick.Controls ApplicationWindow { - id: addmitarbeiter + id: addMitarbeiter title: qsTr("Objekt - Neuer Mitarbeiter") ColumnLayout @@ -31,6 +31,7 @@ ApplicationWindow } TextField { + id: assignee Layout.fillWidth: true } Label @@ -40,6 +41,7 @@ ApplicationWindow } TextField { + id: wage Layout.fillWidth: true } Label @@ -49,6 +51,7 @@ ApplicationWindow } TextField { + id: duration Layout.fillWidth: true } Label @@ -58,6 +61,7 @@ ApplicationWindow } TextField { + id: cleanDays Layout.fillWidth: true } Label @@ -67,6 +71,7 @@ ApplicationWindow } TextField { + id: tasks Layout.fillWidth: true } Label @@ -76,6 +81,7 @@ ApplicationWindow } TextField { + id: output Layout.fillWidth: true } } @@ -90,11 +96,30 @@ ApplicationWindow Button { text: qsTr("Abbrechen") + onClicked: addMitarbeiter.close() } Button { text: qsTr("Hinzufügen") + onClicked: + { + if (assignee.text.trim() !== "" && duration.text.trim() !== "" && wage.text.trim() !== "" && cleanDays.text.trim() !== "" && tasks.text.trim() !== "" && output.text.trim() !== "") + { + var ne = { + "assignee": assignee.text.trim(), + "duration": duration.text.trim(), + "wage": wage.text.trim(), + "cleandays": cleanDays.text.trim(), + "tasks": tasks.text.trim(), + "output": output.text.trim(), + }; + addMitarbeiter.addNewEmployee(ne) + addMitarbeiter.close() + } + } } } } + + signal addNewEmployee(var new_employee) } diff --git a/Gui/ObjectAddOnContactPerson.qml b/Gui/ObjectAddOnContactPerson.qml index 7b39aaf..7740599 100644 --- a/Gui/ObjectAddOnContactPerson.qml +++ b/Gui/ObjectAddOnContactPerson.qml @@ -182,7 +182,6 @@ GridLayout ListView { id: contactView - //Layout.fillWidth: true implicitHeight: parent.height model: contactModel @@ -191,8 +190,6 @@ GridLayout delegate: Item { width: parent.width - //color: firstname.palette.base - //border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base height: 15 Row diff --git a/Gui/ObjectAddOnEmployee.qml b/Gui/ObjectAddOnEmployee.qml index 6bec906..990dd7f 100644 --- a/Gui/ObjectAddOnEmployee.qml +++ b/Gui/ObjectAddOnEmployee.qml @@ -4,7 +4,8 @@ import QtQuick.Controls GridLayout { - property var employeens: null + property var employeeForm: null + property var employees: null id: oaoemployee columns: 2 rows: 4 @@ -19,6 +20,23 @@ GridLayout id: employeeModel } + Component + { + id: employeesHeader + Row + { + Text + { + id: empName + text: qsTr("Mitarbeiter") + width: 175 + font.bold: true + horizontalAlignment: Text.AlignHCenter + color: "yellow" + } + } + } + Rectangle { Layout.fillWidth: true @@ -28,21 +46,26 @@ GridLayout border.color: mitarbeiterhin.activeFocus? mitarbeiterhin.palette.highlight: mitarbeiterhin.palette.base ListView { - id: mitarbeitertext - model: ListModel{ListElement {name: "Mitarbeiter1"} ListElement{name: "Mitarbeiter2"}} - delegate: Item + id: employeesList + //anchors.fill: parent + implicitHeight: parent.height + + model: employeeModel + + header: employeesHeader + + delegate: Row { + width: 200 + height: 15 + padding: 7 Text { - text: model.name + text: model.namens + color: "yellow" } } - // wrapMode: TextEdit.Wrap - // background: Rectangle - // { - // color: mitarbeiterhin.palette.base - // border.color: mitarbeiterhin.activeFocus? mitarbeiterhin.palette.highlight: mitarbeiterhin.palette.base - // } + } } RowLayout @@ -63,19 +86,43 @@ GridLayout Button { id: mitarbeiterhin - property var neuermitarbeiter: undefined text: qsTr("Mitarbeiter hinzufügen") onClicked: { var nm = Qt.createComponent("AddObjectEmployee.qml") if (nm.status === Component.Ready) { - neuermitarbeiter = nm.createObject (appWindow, {width: 600, height: 400}) - neuermitarbeiter.show() + employeeForm = nm.createObject (appWindow, {width: 600, height: 400}) + employeeForm.addNewEmployee.connect(onAddEmployee) + employeeForm.show() } + else console.log(nm.errorString()) } } } + + function onAddEmployee(new_employee) + { + var num_employees = 0 + + if (employees === null || employees === undefined) employees = {} + else num_employees = Object.keys(employees).length; + + employees[num_employees] = {} + employees[num_employees]["assignee"] = new_employee["assignee"]; + employees[num_employees]["duration"] = new_employee["duration"]; + employees[num_employees]["wage"] = new_employee["wage"]; + employees[num_employees]["cleandays"] = new_employee["cleandays"]; + employees[num_employees]["tasks"] = new_employee["tasks"]; + employees[num_employees]["output"] = new_employee["output"]; + + employeeModel.append({namens: new_employee["assignee"]}); + + console.log(employeeModel.get(num_employees).namens) + + console.log(new_employee["assignee"]) + console.log(JSON.stringify(new_employee)) + } } From 416b9cb5b1d30fc90fed4f289ade76f2c0a3c6fd46669cb349a61b1ec1e91ef4 Mon Sep 17 00:00:00 2001 From: Marco Gatzen Date: Wed, 15 Jan 2025 09:48:17 +0100 Subject: [PATCH 3/3] Contactperson aligned --- Gui/ObjectAddOnContactPerson.qml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Gui/ObjectAddOnContactPerson.qml b/Gui/ObjectAddOnContactPerson.qml index 7b39aaf..7e4824c 100644 --- a/Gui/ObjectAddOnContactPerson.qml +++ b/Gui/ObjectAddOnContactPerson.qml @@ -147,8 +147,8 @@ GridLayout text: qsTr("Name") width: 175 font.bold: true - horizontalAlignment: Text.AlignHCenter - color: "yellow" + horizontalAlignment: Text.AlignLeft + color: "black" } Text @@ -157,8 +157,8 @@ GridLayout text: qsTr("Telefon") width: 100 font.bold: true - horizontalAlignment: Text.AlignHCenter - color: "yellow" + horizontalAlignment: Text.AlignLeft + color: "black" } Text @@ -167,8 +167,8 @@ GridLayout text: qsTr("Position") width: 150 font.bold: true - horizontalAlignment: Text.AlignHCenter - color: "yellow" + horizontalAlignment: Text.AlignLeft + color: "black" } } } @@ -197,21 +197,24 @@ GridLayout Row { - spacing: 9 + //spacing: 9 Text { text: model.name width: 175 + horizontalAlignment: Text.AlignLeft } Text { text: model.phone width: 100 + horizontalAlignment: Text.AlignLeft } Text { text: model.posizion width: 150 + horizontalAlignment: Text.AlignLeft } } }