advotracker_qml: advotracker variant with Qt/Qml GUI
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
301
advotracker_qml/resources/pages/PageUserList.qml
Executable file
301
advotracker_qml/resources/pages/PageUserList.qml
Executable file
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* AdvoTracker - Hotline tracking tool for Advocats
|
||||
*
|
||||
* Copyright (c) 2017-2018 Ralf Zerres <ralf.zerres@networkx.de
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 de.networkx.SqlUserModel 1.0 as Nwx
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
Page {
|
||||
id: pageUserList
|
||||
//padding: 12
|
||||
Material.theme: Material.System
|
||||
//Material.theme: Material.Light
|
||||
//rightPadding: 24
|
||||
|
||||
// include AdvoTracker Type 'SearchToolBar'
|
||||
header: SearchToolBar {
|
||||
id: searchToolBar
|
||||
// search field: searchToolBar.text
|
||||
Material.foreground: "white"
|
||||
//font.pixelsize: 11
|
||||
Layout.fillWidth: true
|
||||
focus:true
|
||||
onFocusChanged: console.log("searchToolBar: Focus changed " + focus)
|
||||
//KeyNav.tabbacktabUp: searchToolBar.KeyNav.tabDown
|
||||
//KeyNav.tabbacktabUp: rowUserList.KeyNav.tabDown
|
||||
/*
|
||||
Keys.onPressed: {
|
||||
if (event.key == Qt.Key_Ctrl + Qt.Key_S) {
|
||||
console.log("search");
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* complex filter with two roles
|
||||
SortFilterProxyModel {
|
||||
id: filterComplex
|
||||
sourceModel: modelQueyUser
|
||||
sorters: [
|
||||
RoleSorter { roleName: "lastName"; sortOrder: Qt.DescendingOrder },
|
||||
StringSorter { roleName: "lastName" }
|
||||
]
|
||||
filters: RegExpFilter {
|
||||
id: nameFilter
|
||||
roleName: "lastName"
|
||||
enable: textSearch.nameFilter
|
||||
//pattern: searchToolBar.text
|
||||
pattern: "^" + searchToolBar.text
|
||||
caseSensitivity: Qt.CaseInsensitive
|
||||
}
|
||||
proxyRoles: SwitchRole {
|
||||
name: "sectionRole"
|
||||
filters: RegExpFilter {
|
||||
roleName: "lastName"
|
||||
enable: search
|
||||
value: true
|
||||
SwitchRole.value: "*"
|
||||
}
|
||||
defaultRoleName: "lastName"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// simple filter: one role, given explicit search pattern
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: filterModelUser
|
||||
//sourceModel: modelQueryUser
|
||||
sourceModel: modelUser
|
||||
filters: [
|
||||
ValueFilter {
|
||||
//enabled: onlyShowFavoritesCheckbox.checked
|
||||
//roleName: "roleName"
|
||||
roleName: "userId"
|
||||
//value: "Administrator"
|
||||
//value: "1001"
|
||||
},
|
||||
AnyOf {
|
||||
RegExpFilter {
|
||||
roleName: "userId"
|
||||
pattern: searchToolBar.text
|
||||
caseSensitivity: Qt.CaseInsensitive
|
||||
}
|
||||
RegExpFilter {
|
||||
roleName: "lastName"
|
||||
pattern: searchToolBar.text
|
||||
caseSensitivity: Qt.CaseInsensitive
|
||||
}
|
||||
RegExpFilter {
|
||||
roleName: "firstName"
|
||||
pattern: searchToolBar.text
|
||||
caseSensitivity: Qt.CaseInsensitive
|
||||
}
|
||||
}
|
||||
]
|
||||
sorters: [
|
||||
//RoleSorter { roleName: "userId"; sortOrder: Qt.DescendingOrder },
|
||||
RoleSorter { roleName: "userId"; sortOrder: Qt.AscendingOrder },
|
||||
StringSorter { roleName: "firstName" },
|
||||
StringSorter { roleName: "lastName" }
|
||||
]
|
||||
}
|
||||
|
||||
Component {
|
||||
id: headerUserList
|
||||
|
||||
Frame {
|
||||
id: frameHeaderUserList
|
||||
Layout.fillWidth: true
|
||||
width: parent.width
|
||||
height: 28
|
||||
anchors.right: parent.fill
|
||||
|
||||
Material.background: Material.color(Material.Grey)
|
||||
|
||||
RowLayout {
|
||||
id: rowHeaderUserList
|
||||
spacing: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
//anchors.right: parent.right
|
||||
Layout.fillWidth: true
|
||||
Material.foreground: Material.accent
|
||||
|
||||
Label {
|
||||
id: labelIndexHeaderUserList
|
||||
text: qsTr("Id")
|
||||
//font.pixelsize: 18
|
||||
Layout.preferredWidth: 150
|
||||
anchors.left: parent.left
|
||||
}
|
||||
Label {
|
||||
id: labelNameHeaderUserList
|
||||
text: qsTr("Username")
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 300
|
||||
}
|
||||
/*Label {
|
||||
id: labelIconHeaderUserList
|
||||
text: qsTr("Icon")
|
||||
Layout.preferredWidth: 50
|
||||
//anchors.right: parent.right
|
||||
//anchors.right: rowHeaderUserList.right
|
||||
}
|
||||
*/
|
||||
} // rowHeaderUserList
|
||||
} // frameHeaderUserList
|
||||
} // headerUserList
|
||||
|
||||
Component {
|
||||
id: footerUserList
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
width: ListView.view.width
|
||||
height: 20
|
||||
//color: "#ffffff"
|
||||
//border.color: Qt.darker(color, 1.2)
|
||||
property alias text: label.text
|
||||
property color fontColor: '#1f1f1f'
|
||||
Text {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
//font.pixelSize: 14
|
||||
color: root.fontColor
|
||||
text: qsTr("List ends here")
|
||||
}
|
||||
}
|
||||
} // footerUserList
|
||||
|
||||
Component {
|
||||
id: highlightUserList
|
||||
|
||||
Item {
|
||||
width: listUserList.width
|
||||
height: listUserList.currentItem.height
|
||||
y: listUserList.currentItem.y
|
||||
|
||||
|
||||
Behavior on y {
|
||||
SequentialAnimation {
|
||||
PropertyAnimation {
|
||||
target: rectangleHeighlight
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 500
|
||||
}
|
||||
NumberAnimation { duration: 5 }
|
||||
PropertyAnimation {
|
||||
target: rectangleHeighlight
|
||||
property: "opacity"
|
||||
to: 1
|
||||
duration: 200
|
||||
}
|
||||
//SpringAnimation { spring: 2; damping: 0.1 }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: rectangleHeighlight
|
||||
width: listUserList.width
|
||||
height: listUserList.currentItem.height
|
||||
anchors.fill: parent
|
||||
anchors.margins: 5
|
||||
color: "lightsteelblue"
|
||||
radius: 5
|
||||
|
||||
} // Rectangle
|
||||
|
||||
} // Item
|
||||
} // highlightUserList
|
||||
|
||||
/*
|
||||
Component {
|
||||
id: delegateUserList
|
||||
} // delegateUserList
|
||||
*/
|
||||
|
||||
/*
|
||||
Component {
|
||||
// called via: stackViewMain.push(PageUserDetail)
|
||||
id: componentUserDetail
|
||||
|
||||
} // componentUserDetail
|
||||
*/
|
||||
|
||||
/*
|
||||
Component {
|
||||
// called via: stackViewMain.push(PageUserEdit)
|
||||
id: componentUserEdit
|
||||
} // componentUserEdit
|
||||
*/
|
||||
|
||||
ListView {
|
||||
id: listUserList
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: 12
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 4
|
||||
|
||||
model: filterModelUser
|
||||
delegate: PageUserDelegate {}
|
||||
//delegate: stackViewMain.push(PageUserDelegate)
|
||||
//delegate: delegateUserList
|
||||
header: headerUserList
|
||||
footer: footerUserList
|
||||
highlight: highlightUserList
|
||||
highlightFollowsCurrentItem: false
|
||||
|
||||
//focus: true
|
||||
|
||||
//contentWidth: headerUserList.width
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
//Component.onCompleted: positionViewAtEnd()
|
||||
//Component.onCompleted: positionViewAtIndex(ListView.Center)
|
||||
|
||||
ScrollBar.vertical: Nwx.ScrollBar {
|
||||
id: scrollBarUserList
|
||||
//leftPadding: 2
|
||||
//topPadding: 2
|
||||
parent: listUserList.parent
|
||||
anchors.top: listUserList.top
|
||||
anchors.left: listUserList.right
|
||||
anchors.bottom: listUserList.bottom
|
||||
}
|
||||
|
||||
/*
|
||||
ScrollIndicator.vertical: Nwx.ScrollIndicator {
|
||||
id: scrollIndicatorUserList
|
||||
leftPadding: 5
|
||||
topPadding: 5
|
||||
}
|
||||
*/
|
||||
|
||||
} // listUserList
|
||||
|
||||
} // pageUserList
|
||||
Reference in New Issue
Block a user