advotracker_qml: advotracker variant with Qt/Qml GUI
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
290
advotracker_qml/resources/pages/PageUserEdit.qml
Executable file
290
advotracker_qml/resources/pages/PageUserEdit.qml
Executable file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* 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.10x
|
||||
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
|
||||
import de.networkx.BackendUser 1.0
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
Page {
|
||||
id: pageUserEdit
|
||||
leftPadding: 26
|
||||
rightPadding: 26
|
||||
topPadding: 18
|
||||
bottomPadding: 18
|
||||
|
||||
BackendUser { id: backendUser }
|
||||
|
||||
property string userId
|
||||
|
||||
Action {
|
||||
id: actionUserEditMenu
|
||||
shortcut: "Ctrl+M"
|
||||
onTriggered: menuUserEdit.open()
|
||||
} // actionEditMenu
|
||||
|
||||
Action {
|
||||
id: actionUserDelete
|
||||
text: Nwx.MdiFont.Icon.deleteVariant + " " + qsTr("&Delete")
|
||||
shortcut: StandardKey.delete
|
||||
//shortcut: "Ctrl+D"
|
||||
//onTriggered: window.activeFocusItem.cut()
|
||||
} // actionDelete
|
||||
|
||||
Action {
|
||||
id: actionUserNew
|
||||
text: Nwx.MdiFont.Icon.accountSettingsVariant + " " + qsTr("&New")
|
||||
shortcut: StandardKey.new
|
||||
//onTriggered: stackViewMain.push(newUser)
|
||||
} // actionNew
|
||||
|
||||
header: ToolBar {
|
||||
Material.foreground: "white"
|
||||
Label {
|
||||
id: pageTitle
|
||||
text: qsTr("Edit user details")
|
||||
//font.pixelSize: 20
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
ToolButton {
|
||||
text: Nwx.MdiFont.Icon.check + " " + qsTr("Save")
|
||||
anchors.right: menuUserTop.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: {
|
||||
/*
|
||||
* update database for given index (userId)
|
||||
* update the data model for given record
|
||||
*/
|
||||
|
||||
console.log("Mouse-Press: left; update record for userId:", userId);
|
||||
//modelUser.updateDatabase(userId.text, userEmail.text, userInitials.text, userLastName.text, userFirstName.text);
|
||||
|
||||
console.log("updateUserDetails for userId", userId, model.lastName, model.firstName, model.email, model.userInitials);
|
||||
console.log(listView1.currentItem.userEmail.text)
|
||||
/* db.updateUserDetails(userId, userEmail.text, userInitials.text, userLastName.text, userFirstName.text, userIdChanged.text);
|
||||
* email, userInitials, lastName, firstName, userIdChanged
|
||||
*/
|
||||
}
|
||||
}
|
||||
ToolButton {
|
||||
id: menuUserTop
|
||||
text: Nwx.MdiFont.Icon.dotsVertical
|
||||
font.pixelSize: 28
|
||||
action: actionUserEditMenu
|
||||
anchors.right: parent.right
|
||||
|
||||
Menu {
|
||||
id: menuUserEdit
|
||||
title: qsTr("Menu")
|
||||
x: parent.width - width
|
||||
transformOrigin: Menu.TopRight
|
||||
|
||||
MenuItem {
|
||||
id: menuDelete
|
||||
//title: Nwx.MdiFont.Icon.delete + " " + qsTr("Delete")
|
||||
action: actionUserDelete
|
||||
}
|
||||
MenuItem {
|
||||
id: menuNew
|
||||
//title: Nwx.MdiFont.Icon.new + " " + qsTr("Delete")
|
||||
action: actionUserNew
|
||||
}
|
||||
} // menuUserEdit
|
||||
} // menuUserTop
|
||||
|
||||
} // header
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: filterModelUser
|
||||
sourceModel: modelUser
|
||||
filters: RegExpFilter {
|
||||
roleName: "userId"
|
||||
pattern: userId
|
||||
//caseSensitivity: Qt.CaseInsensitive
|
||||
}
|
||||
sorters: [ StringSorter { roleName: "userId" } ]
|
||||
} // filterModelUser
|
||||
|
||||
Component {
|
||||
id: delegateUsersEdit
|
||||
|
||||
Pane {
|
||||
id: paneUsersEdit
|
||||
anchors.fill: parent
|
||||
Layout.fillWidth: true
|
||||
//Layout.fillHeight: true
|
||||
leftPadding: 6
|
||||
rightPadding: 6
|
||||
topPadding: 6
|
||||
bottomPadding: 6
|
||||
|
||||
GroupBox {
|
||||
id: groupBoxUserEdit
|
||||
title: qsTr("User data")
|
||||
width: parent.width
|
||||
Layout.fillWidth: true
|
||||
|
||||
ColumnLayout {
|
||||
id: columnUserDetail
|
||||
width: parent.width
|
||||
anchors.topMargin: 12
|
||||
spacing: 2
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
//spacing: 12
|
||||
Label {
|
||||
Layout.preferredWidth: 120
|
||||
text: qsTr("User-Id")
|
||||
}
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
background: Rectangle {
|
||||
color: "lightgrey"
|
||||
radius: 5
|
||||
}
|
||||
Label {
|
||||
//anchors.horizontalCenter: parent.horizontalCenter
|
||||
Layout.preferredWidth: 120
|
||||
text: model.userId
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
//spacing: 12
|
||||
Label {
|
||||
Layout.preferredWidth: 120
|
||||
text: qsTr("Lastname")
|
||||
}
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
background: Rectangle {
|
||||
color: "lightgrey"
|
||||
radius: 5
|
||||
}
|
||||
Nwx.TextField {
|
||||
id: userLastName
|
||||
text: model.lastName
|
||||
onEditingFinished: backendUser.lastName = text
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
//spacing: 12
|
||||
Label {
|
||||
Layout.preferredWidth: 120
|
||||
text: qsTr("Firstname")
|
||||
}
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
background: Rectangle {
|
||||
color: "lightgrey"
|
||||
radius: 5
|
||||
}
|
||||
Nwx.TextField {
|
||||
id: userFirstName
|
||||
text: model.firstName
|
||||
onEditingFinished: backendUser.firstName = text
|
||||
Layout.fillWidth: true
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
//spacing: 12
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
Layout.preferredWidth: 120
|
||||
text: qsTr("Email")
|
||||
}
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
background: Rectangle {
|
||||
color: "lightgrey"
|
||||
radius: 5
|
||||
}
|
||||
Nwx.TextField {
|
||||
id: userEmail
|
||||
text: model.email
|
||||
onEditingFinished: backendUser.email = text
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
//spacing: 12
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
Layout.preferredWidth: 120
|
||||
text: qsTr("Intitials")
|
||||
}
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
background: Rectangle {
|
||||
color: "lightgrey"
|
||||
radius: 5
|
||||
}
|
||||
Nwx.TextField {
|
||||
id: userInitials
|
||||
text: model.initials
|
||||
onEditingFinished: backendUser.initials = text
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Add")
|
||||
// Update fields in the database
|
||||
onClicked: {
|
||||
console.log("updateUserDetails for userId", model.userId, "with:", userEmail.text, userInitials.text, userLastName.text, userFirstName.text);
|
||||
//console.log("db.updateUserDetails(model.userId.text, model.userEmail.text, model.userInitials.text, model.userLastName.text, userFirstName.text");
|
||||
//db.updateUserDetails(model.userId.text, model.userEmail.text, model.userInitials.text, model.userLastName.text, userFirstName.text);
|
||||
//modelQueryUser.updateModel(model.userId.text)
|
||||
//db.updateUserDetails(model.userId, model.userEmail.text, model.userInitials.text, model.userLastName.text, userFirstName.text);
|
||||
//db.updateUserDetails(9999, "daniel@ra-hiedemann.de", "ddt", "Düsentrieb", "Daniel");
|
||||
//listUsersEdit.model.updateDatabase(userId.text, userEmail.text, userInitials.text, userLastName.text, userFirstName.text);
|
||||
modelUser.updateDatabase(userId, userEmail.text, userInitials.text, userLastName.text, userFirstName.text);
|
||||
//modelUser.updateModel(model.userId);
|
||||
}
|
||||
}
|
||||
|
||||
} // columnDetail
|
||||
} // groupBoxUserEdit
|
||||
} // paneUsersEdit
|
||||
} // delegateUsersEdit
|
||||
|
||||
ListView {
|
||||
id: listUsersEdit
|
||||
anchors.fill: parent
|
||||
|
||||
model: filterModelUser
|
||||
//header: headerUsersEdit
|
||||
//footer: footerUsersEdit
|
||||
delegate: delegateUsersEdit
|
||||
} // listUsersEdit
|
||||
|
||||
} // pageUserEdit
|
||||
Reference in New Issue
Block a user