Warning, /plasma-mobile/plasma-dialer/plasma-dialer/src/qml/ContactsPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls as Controls
0009 import QtQuick.Layouts
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.people as KPeople
0012 
0013 import org.kde.telephony
0014 
0015 import "call"
0016 
0017 Kirigami.ScrollablePage {
0018     id: contactsPage
0019     title: i18n("Contacts")
0020     icon.name: "view-pim-contacts"
0021 
0022     // page animation
0023     property real yTranslate: 0
0024     
0025     actions: [
0026         Kirigami.Action {
0027             icon.name: "settings-configure"
0028             displayHint: Kirigami.DisplayHint.IconOnly
0029             visible: !applicationWindow().isWidescreen
0030             enabled: !applicationWindow().lockscreenMode
0031             text: i18n("Settings")
0032             onTriggered: applicationWindow().pageStack.push(applicationWindow().getPage("Settings"))
0033         }
0034     ]
0035 
0036     Component {
0037         id: callPopup
0038 
0039         PhoneNumberDialog {}
0040     }
0041     
0042     header: ColumnLayout {
0043         anchors.margins: Kirigami.Units.smallSpacing
0044         spacing: Kirigami.Units.smallSpacing
0045         
0046         InCallInlineMessage {}
0047         
0048         Kirigami.SearchField {
0049             id: searchField
0050             onTextChanged: contactsProxyModel.setFilterFixedString(text)
0051             Layout.fillWidth: true
0052             Layout.margins: Kirigami.Units.largeSpacing
0053         }
0054     }
0055 
0056     ListView {
0057         id: contactsList
0058         transform: Translate { y: yTranslate }
0059 
0060         section.property: "display"
0061         section.criteria: ViewSection.FirstCharacter
0062         section.delegate: Kirigami.ListSectionHeader {
0063             text: section
0064         }
0065         clip: true
0066         reuseItems: true
0067 
0068         model: KPeople.PersonsSortFilterProxyModel {
0069             id: contactsProxyModel
0070             sourceModel: KPeople.PersonsModel {
0071                 id: contactsModel
0072             }
0073             requiredProperties: "phoneNumber"
0074             filterRole: Qt.DisplayRole
0075             sortRole: Qt.DisplayRole
0076             filterCaseSensitivity: Qt.CaseInsensitive
0077             Component.onCompleted: sort(0)
0078         }
0079 
0080         boundsBehavior: Flickable.StopAtBounds
0081 
0082         delegate: Controls.ItemDelegate {
0083             icon: model && model.decoration
0084             text: model && model.display
0085             width: ListView.view.width
0086 
0087             onClicked: {
0088                 const phoneNumbers = ContactUtils.phoneNumbers(model.personUri)
0089                 if (phoneNumbers.length === 1) {
0090                     applicationWindow().call(phoneNumbers[0].normalizedNumber)
0091                 } else {
0092                     const pop = callPopup.createObject(parent, {numbers: phoneNumbers, title: i18n("Select number to call")})
0093                     pop.onNumberSelected.connect(number => applicationWindow().call(number))
0094                     pop.open()
0095                 }
0096             }
0097         }
0098 
0099         Kirigami.PlaceholderMessage {
0100             anchors.centerIn: parent
0101             text: i18n("No contacts have a phone number set")
0102             icon.name: "contact-new-symbolic"
0103             visible: contactsList.count === 0
0104         }
0105     }
0106 }