From b318694acbb3dba27ea360256d9f4127c8a76703c10c8373b27aeac7106289e5 Mon Sep 17 00:00:00 2001 From: linuxero Date: Wed, 11 Dec 2024 21:30:16 +0100 Subject: [PATCH] Added CustomerView to better organise the code and fix Info textarea expansion --- Gui/AddCustomer.qml | 197 +---------------------------------------- Gui/CustomerView.qml | 206 +++++++++++++++++++++++++++++++++++++++++++ qml.qrc | 1 + 3 files changed, 211 insertions(+), 193 deletions(-) create mode 100644 Gui/CustomerView.qml diff --git a/Gui/AddCustomer.qml b/Gui/AddCustomer.qml index d4f1184..580a07b 100644 --- a/Gui/AddCustomer.qml +++ b/Gui/AddCustomer.qml @@ -33,201 +33,12 @@ ColumnLayout Layout.fillWidth: true Layout.fillHeight: true spacing: 45 - GridLayout + + CustomerView { - id: businessGrid - columns: 2 - Layout.fillWidth: true - Layout.fillHeight: true - rowSpacing: 9 - - Label - { - id: lblFirmenName - text: qsTr("Firmenname") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - - TextField - { - property string name: "business" - id: firmenName - Layout.fillWidth: true - Layout.alignment: Qt.AlignVCenter - onTextChanged: isEmptyField() - placeholderText: "Pflichtfeld" - placeholderTextColor: "red" - - - } - - Label - { - text: qsTr("Straße") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - - TextField - { - property string name: "street" - id: streetid - Layout.fillWidth: true - onTextChanged: isEmptyField() - placeholderText: "Pflichtfeld" - placeholderTextColor: "red" - } - Label - { - text: qsTr("PLZ") - Layout.alignment: Qt.AlignRight - } - - ComboBox - { - property string name: "postcode" - id: postcode - Layout.fillWidth: true - editable: true - onCurrentTextChanged: isEmptyField() - onEditTextChanged: isEmptyField() - onActivated: currentValue - model: address_model - textRole: "display" - popup.height: 300 - popup.y: postcode.y + 5 - (postcode.height * 2) - currentIndex: -1 - onCurrentIndexChanged: city.currentIndex = postcode.currentIndex - } - - Label - { - text: qsTr("Ort") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - ComboBox - { - property string name: "city" - id: city - Layout.fillWidth: true - editable: true - onEditTextChanged: isEmptyField() - onCurrentTextChanged: isEmptyField() - model: address_model - textRole: "city" - popup.height: 300 - popup.y: postcode.y + 5 - (postcode.height * 2) - currentIndex: -1 - // onCurrentIndexChanged: postcode.currentIndex = city.currentIndex - } - - Label - { - text: qsTr("Telefon") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - TextField - { - property string name: "telephone" - id: telephone - Layout.fillWidth: true - } - - Label - { - text: qsTr("Handy") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - TextField - { - property string name: "cellphone" - id: cellphone - Layout.fillWidth: true - } - - Label - { - text: qsTr("E-Mail") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "email" - id: email - Layout.fillWidth: true - } - - Label - { - text: qsTr("Homepage") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "homepage" - id: homepage - Layout.fillWidth: true - } - - Label - { - text: qsTr("Geschäftsführer") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "ceo" - id: ceo - Layout.fillWidth: true - } - - Label - { - text: qsTr("USt-IdNr") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "taxno" - id: taxno - Layout.fillWidth: true - } - Label - { - text: qsTr("Typ") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "typeid" - id: typeid - Layout.fillWidth: true - editable: false - model: business_type - textRole: "display" - } - Label - { - text: qsTr("Info") - Layout.alignment: Qt.AlignRight | Qt.AlignTop - } - - ScrollView - { - Layout.fillWidth: true - Layout.preferredHeight: 100 - - TextArea - { - property string name: "customerinfo" - id: customerInfo - background: Rectangle - { - color: customerInfo.palette.base - border.color: customerInfo.activeFocus? customerInfo.palette.highlight: customerInfo.palette.base - } - } - } + id: customerView } + AddContact { id: addContactLayout diff --git a/Gui/CustomerView.qml b/Gui/CustomerView.qml new file mode 100644 index 0000000..cb841f3 --- /dev/null +++ b/Gui/CustomerView.qml @@ -0,0 +1,206 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +GridLayout +{ + id: businessGrid + columns: 2 + Layout.fillWidth: true + Layout.fillHeight: true + rowSpacing: 9 + + Label + { + id: lblFirmenName + text: qsTr("Firmenname") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + + TextField + { + property string name: "business" + id: firmenName + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + onTextChanged: isEmptyField() + placeholderText: "Pflichtfeld" + placeholderTextColor: "red" + + + } + + Label + { + text: qsTr("Straße") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + + TextField + { + property string name: "street" + id: streetid + Layout.fillWidth: true + onTextChanged: isEmptyField() + placeholderText: "Pflichtfeld" + placeholderTextColor: "red" + } + Label + { + text: qsTr("PLZ") + Layout.alignment: Qt.AlignRight + } + + ComboBox + { + property string name: "postcode" + id: postcode + Layout.fillWidth: true + editable: true + onCurrentTextChanged: isEmptyField() + onEditTextChanged: isEmptyField() + onActivated: currentValue + model: address_model + textRole: "display" + popup.height: 300 + popup.y: postcode.y + 5 - (postcode.height * 2) + currentIndex: -1 + onCurrentIndexChanged: city.currentIndex = postcode.currentIndex + } + + Label + { + text: qsTr("Ort") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + ComboBox + { + property string name: "city" + id: city + Layout.fillWidth: true + editable: true + onEditTextChanged: isEmptyField() + onCurrentTextChanged: isEmptyField() + model: address_model + textRole: "city" + popup.height: 300 + popup.y: postcode.y + 5 - (postcode.height * 2) + currentIndex: -1 + // onCurrentIndexChanged: postcode.currentIndex = city.currentIndex + } + + Label + { + text: qsTr("Telefon") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + TextField + { + property string name: "telephone" + id: telephone + Layout.fillWidth: true + } + + Label + { + text: qsTr("Handy") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + TextField + { + property string name: "cellphone" + id: cellphone + Layout.fillWidth: true + } + + Label + { + text: qsTr("E-Mail") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "email" + id: email + Layout.fillWidth: true + } + + Label + { + text: qsTr("Homepage") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "homepage" + id: homepage + Layout.fillWidth: true + } + + Label + { + text: qsTr("Geschäftsführer") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "ceo" + id: ceo + Layout.fillWidth: true + } + + Label + { + text: qsTr("USt-IdNr") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "taxno" + id: taxno + Layout.fillWidth: true + } + Label + { + text: qsTr("Typ") + Layout.alignment: Qt.AlignRight + } + ComboBox + { + property string name: "typeid" + id: typeid + Layout.fillWidth: true + editable: false + model: business_type + textRole: "display" + } + Label + { + text: qsTr("Info") + Layout.alignment: Qt.AlignRight | Qt.AlignTop + } + + ScrollView + { + id: infoView + Layout.fillWidth: true + Layout.preferredHeight: 100 + ScrollBar.horizontal: ScrollBar + { + policy: ScrollBar.AlwaysOn + } + + TextArea + { + property string name: "customerinfo" + id: customerInfo + implicitWidth: parent.width + wrapMode: TextEdit.Wrap + background: Rectangle + { + color: customerInfo.palette.base + border.color: customerInfo.activeFocus? customerInfo.palette.highlight: customerInfo.palette.base + } + } + } +} diff --git a/qml.qrc b/qml.qrc index b3843d5..9448bdf 100644 --- a/qml.qrc +++ b/qml.qrc @@ -14,5 +14,6 @@ Gui/main.qml Gui/SearchBar.qml js/qmldict.js + Gui/CustomerView.qml