Files
pyqcrm/Gui/Employees/EmployeesTable.qml
2025-04-03 13:06:37 +02:00

135 lines
3.9 KiB
QML

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: contentStack.push("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: {
contentStack.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
}
}