Warning, /pim/merkuro/src/contacts/qml/ContactView.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-3.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 as QQC2 0006 import QtQuick.Layouts 1.15 0007 import org.kde.kirigami 2.19 as Kirigami 0008 import org.kde.merkuro.contact 1.0 0009 import './private' 0010 0011 Kirigami.ScrollablePage { 0012 id: page 0013 objectName: "contactView" 0014 0015 property var attendeeAkonadiIds 0016 0017 title: i18n("Contacts") 0018 0019 actions: Kirigami.Action { 0020 icon.name: 'contact-new-symbolic' 0021 text: i18nc("@action:inmenu", "Create") 0022 Kirigami.Action { 0023 id: createNewContactAction 0024 text: i18nc("@action:inmenu", "New Contact") 0025 onTriggered: pageStack.pushDialogLayer(Qt.resolvedUrl("./private/contact_editor/ContactEditorPage.qml"), { 0026 mode: ContactEditor.CreateMode, 0027 }) 0028 } 0029 Kirigami.Action { 0030 id: createNewContactGroupAction 0031 text: i18nc("@action:inmenu", "New Contact Group") 0032 onTriggered: pageStack.pushDialogLayer(Qt.resolvedUrl("./private/contact_editor/ContactGroupEditorPage.qml"), { 0033 mode: ContactGroupEditor.CreateMode, 0034 }) 0035 } 0036 } 0037 0038 Connections { 0039 target: ContactApplication 0040 0041 function onCreateNewContact() { 0042 createNewContactAction.trigger(); 0043 } 0044 0045 function onCreateNewContactGroup() { 0046 createNewContactGroupAction.trigger(); 0047 } 0048 } 0049 0050 ListView { 0051 id: contactsList 0052 reuseItems: true 0053 section { 0054 property: "display" 0055 criteria: ViewSection.FirstCharacter 0056 delegate: Kirigami.ListSectionHeader { 0057 text: section.trim().length > 0 ? section : i18nc("Placeholder", "No Name") 0058 } 0059 } 0060 clip: true 0061 model: ContactManager.filteredContacts 0062 delegate: ContactListItem { 0063 id: contactListItem 0064 height: Kirigami.Settings.isMobile ? Kirigami.Units.gridUnit * 3 : Kirigami.Units.gridUnit * 2 0065 name: model && model.display && model.display.trim().length > 0 ? model.display : i18nc("Placeholder", "No Name") 0066 avatarIcon: model && model.decoration 0067 0068 onClicked: if (model.mimeType === 'application/x-vnd.kde.contactgroup') { 0069 contactsList.currentIndex = index; 0070 applicationWindow().pageStack.push(Qt.resolvedUrl('./private/ContactGroupPage.qml'), { 0071 itemId: model.itemId, 0072 }); 0073 } else { 0074 contactsList.currentIndex = index; 0075 applicationWindow().pageStack.push(Qt.resolvedUrl('./private/ContactPage.qml'), { 0076 itemId: model.itemId, 0077 }); 0078 } 0079 0080 onCreateContextMenu: createContactListContextMenu(model.item, model.display) 0081 0082 Component { 0083 id: contactListContextMenu 0084 QQC2.Menu { 0085 id: actionsPopup 0086 0087 property var item: null 0088 property var name: '' 0089 0090 QQC2.MenuItem { 0091 icon.name: "edit-entry" 0092 text: i18nc("@action:inmenu", "Edit contact…") 0093 onClicked: if (model.mimeType === 'application/x-vnd.kde.contactgroup') { 0094 const page = applicationWindow().pageStack.push(Qt.resolvedUrl('./private/ContactGroupPage.qml'), { 0095 itemId: model.itemId, 0096 }) 0097 page.openEditor(); 0098 } else { 0099 const page = applicationWindow().pageStack.push(Qt.resolvedUrl('./private/ContactPage.qml'), { 0100 itemId: model.itemId, 0101 }) 0102 page.openEditor(); 0103 } 0104 } 0105 QQC2.MenuItem { 0106 icon.name: "delete" 0107 text: i18nc("@action:inmenu", "Delete contact") 0108 action: DeleteContactAction { 0109 item: actionsPopup.item 0110 name: actionsPopup.name 0111 } 0112 } 0113 } 0114 } 0115 function createContactListContextMenu(item, name: string) { 0116 const menu = contactListContextMenu.createObject(page, { 0117 item: item, 0118 name: name, 0119 }) 0120 menu.popup() 0121 } 0122 } 0123 Kirigami.PlaceholderMessage { 0124 anchors.centerIn: parent 0125 text: i18n("No contacts") 0126 visible: contactsList.count === 0 0127 } 0128 } 0129 }