Files
advotracker/advotracker_qml/resources/pages/PageUserDelegate.qml
2020-06-19 17:44:02 +02:00

140 lines
5.0 KiB
QML
Executable File

/*
* AdvoTracker - Hotline tracking tool for Advocats
*
* Copyright (c) 2017 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 SortFilterProxyModel 0.2
ItemDelegate {
id: itemUserList
Layout.fillWidth: true
width: parent.width
anchors.right: parent.fill
focus: true
contentItem: RowLayout {
id: rowUserList
spacing: 8
anchors.horizontalCenter: parent.horizontalCenter
//focus: true
Label {
id: userId
text: model.userId
Layout.preferredWidth: 150
}
Label {
id: userName
text: model.firstName + " " + model.lastName
Layout.fillWidth: true
}
/*
Nwx.IconButton {
id: valueUserList
text: model.userIcon
Layout.preferredWidth: 50
}
*/
} // rowUserList (contentItem)
// adapt the current item
states: State {
name: "Current"
when: itemUserList.ListView.isCurrentItem
PropertyChanges { target: userId ; color: Material.color(Material.primary, Material.ShadeA700) }
PropertyChanges { target: userName ; color: Material.color(Material.accent, Material.ShadeA700) }
}
transitions: Transition {
NumberAnimation { properties: "color"; duration: 200 }
SpringAnimation { spring: 2; damping: 0.1 }
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed: {
console.log("Mouse-Press: left; index:", index, "; lastName:", filterModelUser.get(index).lastName)
/*PropertyChanges { target: nameUserList ; color: Material.color(Material.primary) }
PropertyChanges {
target: labelUserList
color: Material.color(Material.Red, Material.ShadeA700)
}
*/
itemUserList.ListView.view.currentIndex = index
}
onDoubleClicked: {
console.log("Mouse-Press: double; index:", index, "; lastName:", filterModelUser.get(index).lastName)
console.log("Mouse-Press: double; index:", index, "; userId:", filterModelUser.get(index).userId)
//stackViewMain.push(componentDetail, { userId: filterModelUser.get(index).userId } )
stackViewMain.push("qrc:/pages/PageUserDetail.qml", { userId: filterModelUser.get(index).userId } )
}
} // MouseArea
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: {
console.log("Mouse-Press: right; index:", index, "; userId:", filterModelUser.get(index).userId)
itemUserList.ListView.view.currentIndex = index
}
} // MouseArea
Keys.onPressed: {
console.log("list-item: " + event.key + " : " + event.text)
}
Shortcut {
context: Qt.ApplicationShortcut
sequence: [ StandardKey.Find ]
//onActivated: view.currentIndex++
onActivated: {
searchToolBar.forceActiveFocus()
console.log("Key-Press->Find: Shortcut activated.")
}
}
Keys.onUpPressed: {
console.log("Key-Press: Up; index:", index, "; UserId:", filterModelUser.get(index).userId)
//scrollBarUserList.decrease()
}
Keys.onDownPressed: scrollBarUserList.increase()
Keys.onReturnPressed: {
itemUserList.ListView.view.currentIndex = index
//stackViewMain.push(componentDetail, { userId: "filterModelUser.get(index).userId" } )
stackViewMain.push("qrc:/page/PageUserDetail.qml", { userId: filterModelUser.get(index).userId } )
}
Keys.onTabPressed: {
// Windows: Ctrl-Tab, Alt+Right, Ctrl-F6
// Gnome: Ctrl-Tab
console.log("Key-Press: Tab; index:", index, "; iconName:", filterModelUser.get(index).userId)
itemUserList.ListView.view.currentIndex = index + 1
}
Keys.onBacktabPressed: {
// Windows: Ctrl-Shift-Tab, Alt+Left, Ctrl-Shift-F6
// Gnome: Ctrl-Shift-Tab, Alt+Left
console.log("Key-Press: Backtab (Shift+tab); index:", index, "; iconName:", filterModelUser.get(index).userId)
itemUserList.ListView.view.currentIndex = index -1
}
} // itemUserList