Warning, /pim/kube/views/people/qml/People.qml is written in an unsupported language. File is not indexed.

0001  /*
0002   Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com>
0003   Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
0004 
0005   This program is free software; you can redistribute it and/or modify
0006   it under the terms of the GNU General Public License as published by
0007   the Free Software Foundation; either version 2 of the License, or
0008   (at your option) any later version.
0009 
0010   This program is distributed in the hope that it will be useful,
0011   but WITHOUT ANY WARRANTY; without even the implied warranty of
0012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013   GNU General Public License for more details.
0014 
0015   You should have received a copy of the GNU General Public License along
0016   with this program; if not, write to the Free Software Foundation, Inc.,
0017   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019 
0020 import QtQuick 2.7
0021 import QtQuick.Controls 2
0022 import QtQuick.Layouts 1.1
0023 
0024 import org.kube.framework 1.0 as Kube
0025 
0026 
0027 FocusScope {
0028     id: root
0029 
0030     property var currentContact
0031 
0032     Item {
0033         id: peopleRoot
0034 
0035         anchors.fill: parent
0036 
0037         Item {
0038             id: toolbar
0039             anchors {
0040                 top: parent.top
0041                 horizontalCenter: parent.horizontalCenter
0042             }
0043 
0044             height: searchBar.height + Kube.Units.smallSpacing
0045             width: parent.width
0046 
0047             Kube.PositiveButton {
0048                 anchors {
0049                   verticalCenter: parent.verticalCenter
0050                   left: parent.left
0051                   leftMargin: Kube.Units.smallSpacing
0052                 }
0053                 text: qsTr("New Contact")
0054                 visible: stack.depth == 1
0055 
0056                 onClicked: {
0057                     stack.push(personComposer, {contact: null})
0058                 }
0059             }
0060 
0061             Kube.IconButton {
0062                 anchors {
0063                     top: parent.top
0064                     left: parent.left
0065                     leftMargin: Kube.Units.smallSpacing
0066                 }
0067                 visible: stack.depth > 1
0068                 iconName: Kube.Icons.goBack
0069                 onClicked: {
0070                     if(stack.depth == 1)
0071                         root.currentContact = ""
0072                     stack.pop()
0073                 }
0074             }
0075             Kube.TextField {
0076                 id: searchBar
0077                 focus: true
0078                 anchors.horizontalCenter: parent.horizontalCenter
0079                 width: parent.width * 0.5
0080                 placeholderText: qsTr("Search...")
0081             }
0082         }
0083 
0084         StackView {
0085             id: stack
0086 
0087             anchors {
0088                 top: toolbar.bottom
0089                 left: parent.left
0090                 right: parent.right
0091                 bottom: parent.bottom
0092             }
0093 
0094             initialItem: peoplePage
0095 
0096             clip: true
0097         }
0098     }
0099 
0100     Component {
0101         id: peoplePage
0102 
0103         Rectangle {
0104             id: peoplePageRoot
0105             color: Kube.Colors.viewBackgroundColor
0106 
0107             Kube.GridView {
0108                 id: gridView
0109                 anchors {
0110                     fill: parent
0111                     margins: Kube.Units.largeSpacing
0112                 }
0113 
0114                 activeFocusOnTab: true
0115 
0116                 model: Kube.PeopleModel {
0117                     filter: searchBar.text
0118                 }
0119 
0120                 cellWidth: Kube.Units.gridUnit * 10
0121                 cellHeight: Kube.Units.gridUnit * 3
0122 
0123                 onActiveFocusChanged: {
0124                     if (currentIndex < 0) {
0125                         currentIndex = 0
0126                     }
0127                 }
0128 
0129                 function selectObject(domainObject) {
0130                     root.currentContact = domainObject
0131                     stack.push(personPage)
0132                 }
0133 
0134                 delegate: Item {
0135                     id: delegateRoot
0136 
0137                     height: gridView.cellHeight - Kube.Units.smallSpacing * 2
0138                     width: gridView.cellWidth - Kube.Units.smallSpacing * 2
0139 
0140                     Keys.onReturnPressed: {
0141                         GridView.view.currentIndex = index
0142                         GridView.view.selectObject(model.domainObject)
0143                     }
0144 
0145                     Rectangle {
0146                         anchors.fill: parent
0147 
0148                         border.width: 1
0149                         border.color: Kube.Colors.buttonColor
0150 
0151                         Rectangle {
0152                             id: avatarPlaceholder
0153                             color: Kube.Colors.buttonColor
0154                             anchors {
0155                                 top: parent.top
0156                                 left: parent.left
0157                                 bottom: parent.bottom
0158                             }
0159                             clip: true
0160 
0161                             width: height
0162                             Kube.KubeImage {
0163                                 anchors.fill: parent
0164                                 visible: model.imageData != ""
0165                                 imageData: model.imageData
0166                             }
0167                             Kube.Icon {
0168                                 anchors.fill: parent
0169                                 visible: model.imageData == ""
0170                                 iconName: Kube.Icons.user
0171                             }
0172                         }
0173 
0174                         Column {
0175                             width: parent.width
0176                             anchors {
0177                                 left: avatarPlaceholder.right
0178                                 margins: Kube.Units.smallSpacing
0179                                 verticalCenter: parent.verticalCenter
0180                             }
0181 
0182                             Kube.Label {
0183                                 width: delegateRoot.width - avatarPlaceholder.width - Kube.Units.smallSpacing * 2
0184 
0185                                 text: model.firstName
0186                                 elide: Text.ElideRight
0187                             }
0188 
0189                             Kube.Label {
0190                                 width: delegateRoot.width - avatarPlaceholder.width - Kube.Units.smallSpacing * 2
0191 
0192                                 text: model.lastName
0193                                 elide: Text.ElideRight
0194                             }
0195                         }
0196                     }
0197                     Kube.AbstractButton {
0198 
0199                         anchors.fill: parent
0200 
0201                         color: "#00000000"
0202 
0203                         onClicked: {
0204                             parent.GridView.view.currentIndex = index
0205                             parent.GridView.view.selectObject(model.domainObject)
0206                         }
0207                     }
0208                 }
0209             }
0210         }
0211     }
0212 
0213     Component {
0214         id: personPage
0215 
0216         Rectangle {
0217             id: personPageRoot
0218 
0219             Kube.ContactController {
0220                 id: contactController
0221                 contact: root.currentContact
0222             }
0223 
0224             color: Kube.Colors.viewBackgroundColor
0225 
0226             PersonPage {
0227             }
0228 
0229             Kube.Button {
0230                 anchors {
0231                     bottom: parent.bottom
0232                     left: parent.left
0233                     margins: Kube.Units.largeSpacing
0234                 }
0235                 text: qsTr("Remove")
0236 
0237                 onClicked: {
0238                     contactController.remove()
0239                     stack.pop()
0240                 }
0241             }
0242 
0243             Kube.Button {
0244                 anchors {
0245                     bottom: parent.bottom
0246                     right: parent.right
0247                     margins: Kube.Units.largeSpacing
0248                 }
0249                 text: qsTr("Edit")
0250 
0251                 onClicked: {
0252                     stack.push(personComposer, {contact: root.currentContact})
0253                 }
0254             }
0255         }
0256     }
0257 
0258     Component {
0259         id: personComposer
0260 
0261         Rectangle {
0262             id: personComposerRoot
0263 
0264             property var contact: null
0265 
0266             color: Kube.Colors.viewBackgroundColor
0267 
0268             PersonComposer {
0269                 contactController: Kube.ContactController {
0270                     id: contactController
0271                     contact: personComposerRoot.contact
0272                 }
0273             }
0274 
0275             Kube.PositiveButton {
0276                 anchors {
0277                     bottom: parent.bottom
0278                     right: parent.right
0279                     margins: Kube.Units.largeSpacing
0280                 }
0281 
0282                 text: "Save"
0283 
0284                 onClicked: {
0285                     contactController.saveAction.execute()
0286                     stack.pop()
0287                 }
0288             }
0289         }
0290     }
0291 }
0292 
0293 //                     Column {
0294 //
0295 //                         width: parent.width
0296 //
0297 //                         spacing: Kube.Units.smallSpacing
0298 //
0299 //                         Text {
0300 //
0301 //                             text: root.firstname +  " is part of these groups:"
0302 //                         }
0303 //
0304 //                         GroupGrid {
0305 //                             id: groups
0306 //
0307 //                             width: root.width - Kube.Units.largeSpacing
0308 //
0309 //                             model: GroupModel1 {}
0310 //                         }
0311 //                     }
0312 
0313 //                     Column {
0314 //
0315 //                         width: parent.width
0316 //
0317 //                         spacing: Kube.Units.smallSpacing
0318 //
0319 //                         Text {
0320 //                             id: commonPeopleLabel
0321 //
0322 //                             text: root.firstname +  " is associated with:"
0323 //                         }
0324 //
0325 //                         PeopleGrid {
0326 //                             id: commonPeople
0327 //
0328 //                             width: root.width - Kube.Units.largeSpacing
0329 //
0330 //                             model: PeopleModel2 {}
0331 //                         }
0332 //                     }
0333