/* * AdvoTracker - Hotline tackingtool for Advocats * * Copyright (c) 2017 Ralf Zerres * * AdvoTracker is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * AdvoTracker is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with AdvoTracker; If not, see . */ import QtQuick 2.10 // Qt 5.10 import QtQuick.Controls 2.3 // Qt 5.10 import QtQuick.Layouts 1.3 // Qt 5.10 import QtQuick.Controls.Material 2.3 // Qt 5.10 // AdvoTracker Module import de.networkx.AdvoTracker 1.0 as Nwx import SortFilterProxyModel 0.2 Pane { id: paneSqlTestPage Layout.fillWidth: true //anchors: fill ListModel { id: modelPerson ListElement { firstName: "Dirk" lastName: "Hiedemann" favorite: false } ListElement { firstName: "Helmut" lastName: "Schlömer" favorite: true } ListElement { firstName: "Katarina" lastName: "Muth" favorite: false } ListElement { firstName: "Ralf" lastName: "Zerres" favorite: true } ListElement { firstName: "Jochen" lastName: "Plank" favorite: true } ListElement { firstName: "Peter" lastName: "Lafferenz" favorite: false } ListElement { firstName: "Frank" lastName: "Jakoby" favorite: false } } // modelPerson // simple filter SortFilterProxyModel { id: filterModelPerson sourceModel: modelPerson filters: RegExpFilter { roleName: "lastName" pattern: textSearch.text caseSensitivity: Qt.CaseInsensitive } sorters: StringSorter { roleName: "firstName" } } // multiple filter / sorters SortFilterProxyModel { id: filterModelPersonComplex sourceModel: modelPerson filters: [ ValueFilter { //enabled: onlyShowFavoritesCheckbox.checked roleName: "favorite" value: true }, AnyOf { RegExpFilter { roleName: "lastName" pattern: textSearch.text caseSensitivity: Qt.CaseInsensitive } RegExpFilter { roleName: "firstName" pattern: textSearch.text caseSensitivity: Qt.CaseInsensitive } } ] sorters: [ RoleSorter { roleName: "favorite"; sortOrder: Qt.DescendingOrder }, StringSorter { roleName: "firstName" }, StringSorter { roleName: "lastName" } ] } // filterModelPersonComplex RowLayout { id: rowHeader //anchors.fill: parent Layout.fillWidth: true //Material.elevation: 6 height: 14 spacing: 8 Nwx.Button { text: Nwx.MdiFont.Icon.pencil + " " + qsTr("Add an item") onPressed: { modelPerson.append({ "firstName": "Mustafa", "lastName": "Hammadi", "favorite": true }) } } Label { id: labelSearch anchors.right: textSearch.left anchors.rightMargin: rowLayout.spacing text: Nwx.MdiFont.Icon.magnify } TextField { id: textSearch anchors { top: parent.top; right: parent.right } anchors.rightMargin: rowLayout.spacing height: implicitHeight placeholderText: qsTr("Search ...") } } ListView { anchors { top: rowHeader.bottom; bottom: parent.bottom; left: parent.left; right: parent.right } anchors.topMargin: 25 model: filterModelPersonComplex //delegate: Text { text: model.firstName + " " + model.lastName} delegate: Text { text: model.firstName + " " + model.lastName; } } // ListView }