Warning, /plasma-mobile/spacebar/src/contents/ui/PhoneNumberDialog.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Layouts
0009 import QtQuick.Controls as Controls
0010 
0011 import org.kde.kirigami as Kirigami
0012 import org.kde.kirigamiaddons.delegates as Delegates
0013 
0014 import org.kde.spacebar
0015 
0016 Kirigami.Dialog {
0017     id: root
0018 
0019     property alias numbers: list.model
0020     property var selected: []
0021 
0022     signal numberSelected(string number)
0023 
0024     ListView {
0025         id: list
0026         implicitWidth: Kirigami.Units.gridUnit * 20
0027         implicitHeight: contentHeight
0028         currentIndex: -1
0029 
0030         delegate: Delegates.RoundedItemDelegate {
0031             id: delegateItem
0032             width: parent.width
0033             implicitHeight: Kirigami.Units.iconSizes.medium + Kirigami.Units.largeSpacing * 2
0034             verticalPadding: 0
0035             contentItem: RowLayout {
0036                 spacing: Kirigami.Units.largeSpacing
0037 
0038                 RowLayout {
0039                     Controls.CheckBox {
0040                         Layout.fillHeight: true
0041                         Layout.preferredWidth: height
0042                         checked: selected.findIndex(o => o.phoneNumber == subtitleItem.text) >= 0
0043                         checkable: true
0044                         onToggled: root.numberSelected(modelData.normalizedNumber)
0045                     }
0046                 }
0047 
0048                 ColumnLayout {
0049                     Layout.fillWidth: true
0050                     spacing: 0
0051 
0052                     Controls.Label {
0053                         id: labelItem
0054                         Layout.fillWidth: true
0055                         Layout.alignment: subtitleItem.visible ? Qt.AlignLeft | Qt.AlignBottom : Qt.AlignLeft | Qt.AlignVCenter
0056                         text: modelData.typeLabel
0057                         elide: Text.ElideRight
0058                         color: Kirigami.Theme.textColor
0059                     }
0060                     Controls.Label {
0061                         id: subtitleItem
0062                         visible: text
0063                         Layout.fillWidth: true
0064                         Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0065                         text: Utils.phoneNumberToInternationalString(Utils.phoneNumber(modelData.number))
0066                         elide: Text.ElideRight
0067                         color: Kirigami.Theme.textColor
0068                         opacity: 0.7
0069                         font: Kirigami.Theme.smallFont
0070                     }
0071                 }
0072 
0073             }
0074             onClicked: {
0075                 close()
0076                 root.numberSelected(modelData.normalizedNumber)
0077             }
0078         }
0079     }
0080 }