From f172468ba6bad4227ef2bf4713963792093b3a499b4d77f1acac9c11a3adf4a2 Mon Sep 17 00:00:00 2001 From: Yuri Becker Date: Thu, 3 Apr 2025 10:56:42 +0200 Subject: [PATCH] Extract Employee View into own dir --- Gui/{ => Employees}/AddApplicant.qml | 8 +- Gui/{ => Employees}/EmployeeDetails.qml | 0 Gui/Employees/EmployeesTable.qml | 134 +++++++++++++ .../EmployeesView.qml} | 0 Gui/Employees/qmldir | 1 + Gui/EmployeesTable.qml | 187 ------------------ Gui/Navigation.qml | 2 +- Gui/qmldir | 2 +- {Gui => TeroStyle}/SearchBar.qml | 0 TeroStyle/qmldir | 1 + lib/DB/EmployeeModel.py | 13 +- qml.qrc | 13 +- 12 files changed, 153 insertions(+), 208 deletions(-) rename Gui/{ => Employees}/AddApplicant.qml (95%) rename Gui/{ => Employees}/EmployeeDetails.qml (100%) create mode 100644 Gui/Employees/EmployeesTable.qml rename Gui/{EmployeeTable.qml => Employees/EmployeesView.qml} (100%) create mode 100644 Gui/Employees/qmldir delete mode 100644 Gui/EmployeesTable.qml rename {Gui => TeroStyle}/SearchBar.qml (100%) diff --git a/Gui/AddApplicant.qml b/Gui/Employees/AddApplicant.qml similarity index 95% rename from Gui/AddApplicant.qml rename to Gui/Employees/AddApplicant.qml index b14861c..6210d0b 100644 --- a/Gui/AddApplicant.qml +++ b/Gui/Employees/AddApplicant.qml @@ -1,7 +1,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts -import "../js/qmldict.js" as JsLib +import "../../js/qmldict.js" as JsLib ColumnLayout @@ -114,7 +114,7 @@ ColumnLayout Button { text: qsTr("Abbrechen") - onClicked: appLoader.source = "EmployeeTable.qml" + onClicked: appLoader.source = "Employees/EmployeesView.qml" } Button { @@ -150,15 +150,13 @@ ColumnLayout employee_model.addedNewEmployee.connect(onAddNewEmployee) } -// } -// } // ScrollView function onAddNewEmployee(added) { if (added) console.log('addedsuccesfully') else console.log('failedtoadd') - appLoader.source = 'EmployeeTable.qml' + appLoader.source = 'Employees/EmployeesView.qml' } function checkFields() diff --git a/Gui/EmployeeDetails.qml b/Gui/Employees/EmployeeDetails.qml similarity index 100% rename from Gui/EmployeeDetails.qml rename to Gui/Employees/EmployeeDetails.qml diff --git a/Gui/Employees/EmployeesTable.qml b/Gui/Employees/EmployeesTable.qml new file mode 100644 index 0000000..3e44acc --- /dev/null +++ b/Gui/Employees/EmployeesTable.qml @@ -0,0 +1,134 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import Qt.labs.qmlmodels + +ColumnLayout { + anchors.fill: parent + spacing: Dimensions.l + + RowLayout { + Layout.fillWidth: true + spacing: Dimensions.l + + SearchBar { + } + QuickFilter { + model: ListModel { + ListElement { + name: "Alle" + selected: true + text: qsTr("Alle") + } + ListElement { + name: "Bewerber" + selected: false + text: qsTr("Bewerber") + } + ListElement { + name: "Mitarbeiter" + selected: false + text: qsTr("Kunde") + } + ListElement { + name: "Erledigt" + selected: false + text: qsTr("Erledigt") + } + } + + onSelectedChanged: name => { + employee_model.viewCriterion(name); + } + } + Button { + Layout.alignment: Qt.AlignRight + flat: true + icon.source: "qrc:/images/PlusCircle.svg" + text: qsTr("Mitarbeiter Hinzufügen") + + onClicked: appLoader.source = "Employees/AddApplicant.qml" + } + } + HorizontalHeaderView { + Layout.fillWidth: true + implicitHeight: 40 + movableColumns: true //@disable-check M16 + syncView: appliEmpTable + + delegate: Rectangle { + Layout.fillWidth: true + border.color: palette.base + color: palette.alternateBase + implicitHeight: 40 + implicitWidth: 1 + + Text { + color: palette.text + elide: Text.ElideRight + height: parent.height + horizontalAlignment: Text.AlignHCenter + text: model.display + verticalAlignment: Text.AlignVCenter + width: parent.width + } + } + } + TableView { + id: appliEmpTable + + Layout.fillHeight: true + Layout.fillWidth: true + alternatingRows: true + columnSpacing: 1 + model: employee_model + resizableColumns: true + rowSpacing: 2 + selectionBehavior: TableView.SelectRows + z: 1 + + ScrollBar.vertical: ScrollBar { + policy: appliEmpTable.contentHeight > appliEmpTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff + } + delegate: Rectangle { + required property bool current + required property bool selected + + color: selected ? palette.highlight : (appliEmpTable.alternatingRows && row % 2 !== 0 ? palette.base : palette.alternateBase) + implicitHeight: 25 + implicitWidth: appliEmpTable.width / appliEmpTable.columns + + Text { + color: palette.text + elide: Text.ElideRight + height: parent.height + leftPadding: 9 + text: (model.display === null || model.display === undefined) ? "" : model.display + verticalAlignment: Text.AlignVCenter + width: parent.width + } + MouseArea { + property bool hovered: false + + anchors.fill: parent + hoverEnabled: true + + onDoubleClicked: { + employeesStack.push("EmployeeDetails.qml", { + selectedEmployee: row + }); + } + onEntered: { + appliEmpTable.selectionModel.select(appliEmpTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows); + } + } + } + selectionModel: ItemSelectionModel { + model: appliEmpTable.model + } + } + Item { + Layout.fillWidth: true + } +} + diff --git a/Gui/EmployeeTable.qml b/Gui/Employees/EmployeesView.qml similarity index 100% rename from Gui/EmployeeTable.qml rename to Gui/Employees/EmployeesView.qml diff --git a/Gui/Employees/qmldir b/Gui/Employees/qmldir new file mode 100644 index 0000000..430ac62 --- /dev/null +++ b/Gui/Employees/qmldir @@ -0,0 +1 @@ +module Employees \ No newline at end of file diff --git a/Gui/EmployeesTable.qml b/Gui/EmployeesTable.qml deleted file mode 100644 index 5dae07a..0000000 --- a/Gui/EmployeesTable.qml +++ /dev/null @@ -1,187 +0,0 @@ -import QtQuick -import QtQuick.Layouts -import QtQuick.Controls -import Qt.labs.qmlmodels - -ColumnLayout -{ - - function viewEmployees(criterion) - { - employee_model.viewCriterion(criterion) - // employee_model.viewCriterion(criterion, showProcessed.checked, showFired.checked, showEveryone.checked) - } - - anchors.fill: parent - spacing: Dimensions.l - - Component.onCompleted: employeesStack.pop() - // property var availableFilters: ["Name", "Adresse", "PLZ", "Ort", "Status"] - RowLayout - { - Layout.fillWidth: true - spacing: Dimensions.l - SearchBar - { - id:searchBar - } - QuickFilter - { - onSelectedChanged: (name) => - { - business_model.viewCriterion(name) - } - - model: ListModel - { - ListElement - { - - name: "Alle" - text: qsTr("Alle") - selected: true - } - ListElement - { - name: "Bewerber" - text: qsTr("Bewerber") - selected: false - } - ListElement - { - name: "Mitarbeiter" - text: qsTr("Kunde") - selected: false - } - - ListElement - { - name: "Erledigt" - text: qsTr("Erledigt") - selected: false - } - } - } - Button - { - id: addEmployeeBtn - text: qsTr("Mitarbeiter Hinzufügen") - icon.source: "qrc:/images/PlusCircle.svg" - Layout.alignment: Qt.AlignRight - flat: true - onClicked: appLoader.source = "AddApplicant.qml" - } - } - - - HorizontalHeaderView - { - id: employeeTableHeader - Layout.fillWidth: true - syncView: appliEmpTable - implicitHeight: 40 - movableColumns: true //@disable-check M16 - delegate: Rectangle - { - color: addEmployeeBtn.palette.alternateBase - border.color: palette.base - implicitHeight: 40 - Layout.fillWidth: true - implicitWidth: 1 - Text - { - text: model.display - elide: Text.ElideRight - width: parent.width - height: parent.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: palette.text - } - } - } - - TableView - { - id: appliEmpTable - //Layout.fillHeight: true - //height: tableParent.height - (viewCriterion.height + employeeTableHeader.height) - Layout.fillWidth: true - Layout.fillHeight: true - columnSpacing: 1 - rowSpacing: 2 - alternatingRows: true - resizableColumns: true - model: employee_model - selectionBehavior: TableView.SelectRows - z: 1 - ScrollBar.vertical: ScrollBar - { - policy: appliEmpTable.contentHeight > appliEmpTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff - } - - selectionModel: ItemSelectionModel - { - id: selModel - model: appliEmpTable.model - } - - - delegate:Rectangle - { - required property bool selected - required property bool current - implicitWidth: appliEmpTable.width / appliEmpTable.columns - implicitHeight: 25 - color: selected - ? addEmployeeBtn.palette.highlight //palette.highlight - : (appliEmpTable.alternatingRows && row % 2 !== 0 - ? addEmployeeBtn.palette.base // palette.base - : addEmployeeBtn.palette.alternateBase) //palette.alternateBase) - - Text - { - text: (model.display === null || model.display === undefined)? "": model.display - elide: Text.ElideRight - width: parent.width - height: parent.height - verticalAlignment: Text.AlignVCenter - leftPadding: 9 //@d isable-check M16 - color: palette.text - - } - - MouseArea - { - id: mouseArea - property bool hovered:false - - anchors.fill: parent - hoverEnabled: true - - onDoubleClicked: - { - employeesStack.push("EmployeeDetails.qml", {selectedEmployee: row}); - } - - onEntered: - { - appliEmpTable.selectionModel.select(appliEmpTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows) - } - - } - } - } - - Item - { - Layout.fillWidth: true - } - } - - // function viewEmployees(criterion) - // { - // employee_model.viewCriterion(criterion, showProcessed.checked, showFired.checked, showEveryone.checked) - // } - // Component.onCompleted: employeesStack.pop() - diff --git a/Gui/Navigation.qml b/Gui/Navigation.qml index b0a4058..351019c 100644 --- a/Gui/Navigation.qml +++ b/Gui/Navigation.qml @@ -54,7 +54,7 @@ ColumnLayout { text: qsTr("Mitarbeiter") onClicked: { - appLoader.source = "EmployeeTable.qml"; + appLoader.source = "Employees/EmployeesView.qml"; } } BarButton { diff --git a/Gui/qmldir b/Gui/qmldir index a5ac533..2302c4f 100644 --- a/Gui/qmldir +++ b/Gui/qmldir @@ -1,2 +1,2 @@ module gui -TopBar 1.0 Navigation.qml +Navigation 1.0 Navigation.qml diff --git a/Gui/SearchBar.qml b/TeroStyle/SearchBar.qml similarity index 100% rename from Gui/SearchBar.qml rename to TeroStyle/SearchBar.qml diff --git a/TeroStyle/qmldir b/TeroStyle/qmldir index 2b7975c..0273944 100644 --- a/TeroStyle/qmldir +++ b/TeroStyle/qmldir @@ -9,6 +9,7 @@ TextField TextField.qml BarButton BarButton.qml Label Label.qml QuickFilter QuickFilter.qml +SearchBar SearchBar.qml diff --git a/lib/DB/EmployeeModel.py b/lib/DB/EmployeeModel.py index 0d12d8c..1ea26b7 100644 --- a/lib/DB/EmployeeModel.py +++ b/lib/DB/EmployeeModel.py @@ -49,14 +49,11 @@ class EmployeeModel(QAbstractTableModel): 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.__everyone = criterion == 'Alle' + self.__col_skip = 2 + self.__getData(criterion, criterion == 'Erledigt', False, criterion == 'Alle') def data(self, index, role= Qt.DisplayRole): if role == Qt.DisplayRole: diff --git a/qml.qrc b/qml.qrc index 8c0bae2..dfb6c82 100644 --- a/qml.qrc +++ b/qml.qrc @@ -9,9 +9,7 @@ Gui/AddCustomer.qml Gui/CustomerTable.qml Gui/Dashboard.qml - Gui/EmployeeTable.qml Gui/main.qml - Gui/SearchBar.qml js/qmldict.js Gui/CustomerView.qml Gui/NoDbConnection.qml @@ -23,7 +21,6 @@ Gui/ObjectAddOnContactPerson.qml Gui/ObjectAddOnEmployee.qml Gui/AddObjectEmployee.qml - Gui/AddApplicant.qml Gui/ApplicantPersonalData.qml Gui/ApplicantBankData.qml Gui/ApplicantNationalInsurance.qml @@ -31,8 +28,6 @@ Gui/CustomersTable.qml Gui/CustomerDetails.qml Gui/ObjectsTable.qml - Gui/EmployeesTable.qml - Gui/EmployeeDetails.qml Gui/ObjectDetails.qml Gui/AddNewObject.qml Gui/PrinterDialog.qml @@ -49,6 +44,12 @@ Gui/UtilityDialogs.qml Gui/OffersTable.qml Gui/OfferTable.qml + Gui/Employees/AddApplicant.qml + Gui/Employees/EmployeeDetails.qml + Gui/Employees/EmployeesTable.qml + Gui/Employees/EmployeesView.qml + Gui/Employees/qmldir + TeroStyle/BarButton.qml TeroStyle/Button.qml TeroStyle/Colors.qml TeroStyle/ComboBox.qml @@ -57,9 +58,9 @@ TeroStyle/Label.qml TeroStyle/qmldir TeroStyle/QuickFilter.qml + TeroStyle/SearchBar.qml TeroStyle/TextField.qml TeroStyle/Typography.qml - TeroStyle/BarButton.qml Gui/AddOffer.qml Gui/AddNewOffer.qml