Implement Quick Filters

This commit is contained in:
Yuri Becker
2025-03-21 13:25:03 +01:00
parent 83f64f9af8
commit 721232a975
16 changed files with 196 additions and 238 deletions

View File

@@ -16,7 +16,7 @@ GridLayout
Label Label
{ {
text: qsTr("Straße") text: qsTr("Straße*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -27,13 +27,11 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("Nr.") text: qsTr("Nr.*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -44,8 +42,6 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
// New grid row // New grid row
@@ -197,7 +193,7 @@ GridLayout
Label Label
{ {
text: qsTr("Reinigungsmittel wo?") text: qsTr("Reinigungsmittel wo?*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -206,8 +202,6 @@ GridLayout
property string name: "cleaningproducts" property string name: "cleaningproducts"
id: cleaningproducts id: cleaningproducts
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
onTextChanged: checkFields() onTextChanged: checkFields()
} }
Item Item

View File

@@ -37,7 +37,7 @@ GridLayout
} }
Label Label
{ {
text: qsTr("Vorname") text: qsTr("Vorname*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
@@ -45,14 +45,12 @@ GridLayout
property string name: "firstname" property string name: "firstname"
id: firstname id: firstname
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
onTextChanged: checkFields() onTextChanged: checkFields()
Layout.columnSpan: 3 Layout.columnSpan: 3
} }
Label Label
{ {
text: qsTr("Nachname") text: qsTr("Nachname*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
@@ -60,8 +58,6 @@ GridLayout
property string name: "lastname" property string name: "lastname"
id: lastname id: lastname
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
onTextChanged: checkFields() onTextChanged: checkFields()
Layout.columnSpan: 3 Layout.columnSpan: 3
} }
@@ -164,7 +160,7 @@ GridLayout
} }
Label Label
{ {
text: qsTr("Geburtsdatum") text: qsTr("Geburtsdatum*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
visible: radio.children[1].checked visible: radio.children[1].checked
} }
@@ -173,8 +169,6 @@ GridLayout
property string name: "birthday" property string name: "birthday"
id: birthday id: birthday
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
onTextChanged: checkFields() onTextChanged: checkFields()
Layout.columnSpan: 3 Layout.columnSpan: 3
visible: radio.children[1].checked visible: radio.children[1].checked
@@ -195,7 +189,7 @@ GridLayout
Label Label
{ {
text: qsTr("Geburtsort") text: qsTr("Geburtsort*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
visible: radio.children[1].checked visible: radio.children[1].checked
} }
@@ -204,8 +198,6 @@ GridLayout
property string name: "placeofbirth" property string name: "placeofbirth"
id: placeofbirth id: placeofbirth
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
onTextChanged: checkFields() onTextChanged: checkFields()
Layout.columnSpan: 3 Layout.columnSpan: 3
visible: radio.children[1].checked visible: radio.children[1].checked

View File

@@ -16,7 +16,7 @@ GridLayout
Label Label
{ {
id: lblFirmenName id: lblFirmenName
text: qsTr("Firmenname") text: qsTr("Firmenname*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -28,34 +28,26 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
Layout.columnSpan: 3 Layout.columnSpan: 3
} }
Label Label
{ {
text: qsTr("Straße") text: qsTr("Straße*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
TextField TextField
{ {
property string name: "street" property string name: "street"
id: streetid id: streetid
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("Nr.") text: qsTr("Nr.*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -65,8 +57,6 @@ GridLayout
id: housenoid id: housenoid
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
validator: RegularExpressionValidator validator: RegularExpressionValidator
{ {
regularExpression: /([0-9a-zA-Z\-]{1,6})/ regularExpression: /([0-9a-zA-Z\-]{1,6})/

View File

@@ -3,78 +3,69 @@ import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.qmlmodels import Qt.labs.qmlmodels
Item { ColumnLayout {
function viewCriterion(criterion) { function viewCriterion(criterion) {
business_model.viewCriterion(criterion.text); business_model.viewCriterion(criterion.text);
} }
anchors.fill: parent
Component.onCompleted: customersStack.pop() Component.onCompleted: customersStack.pop()
SearchBar { RowLayout {
id: searchBar Layout.fillWidth: true
Layout.horizontalStretchFactor: 1
spacing: Dimensions.l
anchors.margins: 9 SearchBar {
} }
QuickFilter {
onSelectedChanged: (name) => {
business_model.viewCriterion(name)
}
model: ListModel {
ListElement {
name: "Alle"
text: qsTr("Alle")
selected: true
}
ListElement {
name: "showProvider"
text: qsTr("Interessent")
selected: false
}
ListElement {
name: "showClientele"
text: qsTr("Kunde")
selected: false
}
ListElement {
name: "showProvider"
text: qsTr("Lieferant")
selected: false
}
ListElement {
name: "showFinished"
text: qsTr("Erledigt")
selected: false
}
}
}
Button { Button {
id: addCustomer id: addCustomer
anchors.right: parent.right Layout.alignment: Qt.AlignRight
icon.source: "qrc:/images/PlusCircle.svg" icon.source: "qrc:/images/PlusCircle.svg"
text: qsTr("Kunde hinzufügen") text: qsTr("Kunde Hinzufügen")
onClicked: appLoader.source = "AddCustomer.qml" onClicked: appLoader.source = "AddCustomer.qml"
} }
}
ColumnLayout { ColumnLayout {
id: tableColumn
clip: true clip: true
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
top: searchBar.bottom
}
RowLayout {
id: sortView
RadioButton {
id: showAll
checked: true
text: qsTr("Alle")
onClicked: viewCriterion(showAll)
}
RadioButton {
id: showInterested
text: qsTr("Interessent")
onClicked: viewCriterion(showInterested)
}
RadioButton {
id: showClientele
text: qsTr("Kunden")
onClicked: viewCriterion(showClientele)
}
RadioButton {
id: showProvider
text: qsTr("Lieferant")
onClicked: viewCriterion(showProvider)
}
RadioButton {
id: showFinished
text: qsTr("Erledigt")
onClicked: viewCriterion(showFinished)
}
}
HorizontalHeaderView { HorizontalHeaderView {
id: horizontalHeader id: horizontalHeader
@@ -107,7 +98,6 @@ Item {
property real newWidth: 0 property real newWidth: 0
Layout.fillHeight: true Layout.fillHeight: true
//height: tableColumn.height - (sortView.height + horizontalHeader.height)
Layout.fillWidth: true Layout.fillWidth: true
alternatingRows: true alternatingRows: true
columnSpacing: 1 columnSpacing: 1

View File

@@ -35,71 +35,45 @@ GridLayout
} }
Label Label
{ {
text: qsTr("Vorname") text: qsTr("Vorname*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
{ {
id: firstname id: firstname
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
// onTextChanged: checkContactFields() // onTextChanged: checkContactFields()
} }
Label Label
{ {
text: qsTr("Nachname") text: qsTr("Nachname*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
{ {
id: lastname id: lastname
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("Telefonnummer") text: mobile.text ? qsTr("Telefonnummer") : qsTr("Telefonnummer*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
{ {
id: phonenumber id: phonenumber
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: mobile.text ? "" : "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("Mobil") text: phonenumber.text ? qsTr("Mobil") : qsTr("Mobil*")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
TextField TextField
{ {
id: mobile id: mobile
Layout.fillWidth: true Layout.fillWidth: true
placeholderText: phonenumber.text ? "" : "Pflichtfeld"
placeholderTextColor: "red"
} }
// Label
// {
// text: qsTr("Position")
// Layout.alignment: Qt.AlignRight
// }
// TextField
// {
// id: posizion
// Layout.fillWidth: true
// placeholderText: "Pflichtfeld"
// placeholderTextColor: "red"
// }
RowLayout RowLayout
{ {

View File

@@ -27,7 +27,7 @@ GridLayout
Label Label
{ {
text: qsTr("Straße") text: qsTr("Straße*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -38,12 +38,10 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("Nr.") text: qsTr("Nr.*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -54,13 +52,11 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {
text: qsTr("PLZ") text: qsTr("PLZ*")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
} }
@@ -70,8 +66,6 @@ GridLayout
id: postcode id: postcode
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: checkFields() onTextChanged: checkFields()
placeholderText: "Pflichtfeld"
placeholderTextColor: "red"
} }
Label Label
{ {

View File

@@ -2,79 +2,12 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
TextField {
RowLayout
{
id: searchBar
TextField
{
id: searchField
placeholderText: qsTr("Suche")
leftPadding: 3
rightPadding: 3
Layout.preferredWidth: 300 Layout.preferredWidth: 300
placeholderText: qsTr("Suche")
Button Button {
{
icon.source: "qrc:/images/MagnifyingGlass.svg" icon.source: "qrc:/images/MagnifyingGlass.svg"
x: parent.x + parent.width - width isFieldButton: true
height: parent.height
flat: true
}
Button
{
id: filterBtn
icon.source: "qrc:/images/Funnel.svg"
x: parent.x + parent.width
height: searchField.height
flat: true
onClicked: filterPopup.open()
}
}
Popup
{
id: filterPopup
x: filterBtn.x + filterBtn.width
y: filterBtn.y
width: 100
height: 150
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
contentItem: Item
{
ColumnLayout
{
anchors.fill: parent
//id: filterContent
Repeater
{
model: availableFilters
CheckBox
{
text: model.modelData
onClicked:
{
setFilter(text, checkState)
}
}
}
}
}
}
function setFilter(filter,activated)
{
console.log(filter)
console.log(activated)
} }
} }

View File

@@ -53,14 +53,11 @@ ApplicationWindow
anchors anchors
{ {
left: parent.left fill: parent
right: parent.right topMargin: Dimensions.l
top: topBar.bottom bottomMargin: Dimensions.l
bottom: parent.bottom rightMargin: Dimensions.l
topMargin: 0 leftMargin: Dimensions.l
bottomMargin: 5
rightMargin: 9
leftMargin: 9
} }
property alias window: appWindow property alias window: appWindow

View File

@@ -6,37 +6,55 @@ import QtQuick.Templates as T
T.Button { T.Button {
id: control id: control
/**
* Set true when the button is supposed to be displayed in e.g. a TextField.
* You want to do this when this button is directly related to the TextField
* and the primary and only action for the TextField.
* Usually, you'd only want to display an icon in this button.
* If true, automatically sets height, width and position.
*
* ```qml
* TextField {
* placeholderText: "Search..."
* Button {
* icon.source: "qrc:/images/MagnifyingGlass.svg"
* isFieldButton: true
* }
* }
* ```
*/
property bool isFieldButton: false
height: isFieldButton ? parent.height : null
icon.color: Colors.primaryContrast icon.color: Colors.primaryContrast
icon.height: 21 icon.height: 21
icon.width: 21 icon.width: 21
implicitHeight: Math.max( implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
implicitBackgroundHeight + topInset + bottomInset, implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
implicitContentHeight + topPadding + bottomPadding /**
) * Icon is slightly larger than Text, so we need to reduce the padding a
implicitWidth: Math.max( * tiny bit to make sure all Buttons are still the same height.
implicitBackgroundWidth + leftInset + rightInset, */
implicitContentWidth + leftPadding + rightPadding padding: Dimensions.m - (icon.source.toString() === "" ? 0 : 1)
) x: isFieldButton ? parent.x + parent.width - width : null
padding: Dimensions.s - (icon.source.toString() === "" ? 0 : 1)
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
border.color: Colors.interactive
border.width: isFieldButton ? 1 : 0
bottomLeftRadius: topLeftRadius
color: Colors.primary color: Colors.primary
radius: Dimensions.radius radius: Dimensions.radius
topLeftRadius: isFieldButton ? 0 : radius
} }
contentItem: I.IconLabel { contentItem: I.IconLabel {
spacing: Dimensions.s
mirrored: control.mirrored
display: control.display
icon: control.icon
text: control.text
font: control.font
color: Colors.primaryContrast color: Colors.primaryContrast
} display: control.display
font: control.font
onIconChanged: () => { icon: control.icon
// console.log("ICON '" + JSON.stringify(icon.source) + "' " + (icon.source.toString() === "") + " "); mirrored: control.mirrored
spacing: Dimensions.s
text: control.text
} }
MouseArea { MouseArea {

View File

@@ -15,6 +15,7 @@ QtObject {
readonly property color mantle: theme === dark ? "#1e1f22" : "#e7e9ef" readonly property color mantle: theme === dark ? "#1e1f22" : "#e7e9ef"
readonly property color interactive: theme === dark ? "#878b97" : "#d9d9da" readonly property color interactive: theme === dark ? "#878b97" : "#d9d9da"
readonly property color error: theme === dark ? "#ff2264" : "#ff004b" readonly property color error: theme === dark ? "#ff2264" : "#ff004b"
readonly property color transparent: "transparent"
readonly property double highlightOpacity: .3 readonly property double highlightOpacity: .3
} }

60
TeroStyle/QuickFilter.qml Normal file
View File

@@ -0,0 +1,60 @@
import QtQuick
import QtCore
import QtQuick.Layouts
RowLayout {
id: root
required property ListModel model
signal selectedChanged(string name)
spacing: Dimensions.m
Repeater {
model: root.model
Item {
id: item
required property int index
required property var modelData
property real padding: Dimensions.m
height: text.height + padding * 2
width: text.width + padding * 2
Rectangle {
anchors.fill: parent
border.color: modelData.selected ? Colors.transparent : Colors.foreground
border.width: 2
color: modelData.selected ? Colors.primary : Colors.transparent
radius: parent.height
}
Text {
id: text
color: Colors.foreground
font: Typography.body
text: modelData.text
x: parent.padding
y: parent.padding
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onPressed: {
if (item.modelData.selected)
return;
const model = root.model;
for (let i = 0; i < model.count; i++) {
model.setProperty(i, "selected", false);
}
model.setProperty(item.index, "selected", true);
selectedChanged(item.modelData.name)
}
}
}
}
}

View File

@@ -17,4 +17,22 @@ T.TextField {
placeholderTextColor: Colors.interactive placeholderTextColor: Colors.interactive
font: Typography.body font: Typography.body
padding: Dimensions.m padding: Dimensions.m
/**
* Placeholder
*/
Text {
x: control.leftPadding
y: control.topPadding
width: control.width - (control.leftPadding + control.rightPadding)
height: control.height - (control.topPadding + control.bottomPadding)
font: control.font
text: control.placeholderText
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
renderType: control.renderType
}
} }

View File

@@ -6,4 +6,5 @@ Button Button.qml
ComboBox ComboBox.qml ComboBox ComboBox.qml
Field Field.qml Field Field.qml
Label Label.qml Label Label.qml
QuickFilter QuickFilter.qml
TextField TextField.qml TextField TextField.qml

View File

@@ -11,7 +11,6 @@ class BusinessDAO(QObject):
__all_cols = None __all_cols = None
def __init__(self): def __init__(self):
#print(f"*** File: {__file__}, init()")
super().__init__() super().__init__()
self.__con = DbManager().getConnection() self.__con = DbManager().getConnection()
if self.__con: if self.__con:

View File

@@ -56,6 +56,7 @@
<file>TeroStyle/Field.qml</file> <file>TeroStyle/Field.qml</file>
<file>TeroStyle/Label.qml</file> <file>TeroStyle/Label.qml</file>
<file>TeroStyle/qmldir</file> <file>TeroStyle/qmldir</file>
<file>TeroStyle/QuickFilter.qml</file>
<file>TeroStyle/TextField.qml</file> <file>TeroStyle/TextField.qml</file>
<file>TeroStyle/Typography.qml</file> <file>TeroStyle/Typography.qml</file>
</qresource> </qresource>

View File

@@ -7,7 +7,3 @@ mariadb
soundfile soundfile
sounddevice sounddevice
reportlab reportlab