Warning, /pim/itinerary/src/app/DocumentsCard.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtCore 0008 import QtQuick 0009 import QtQuick.Layouts 0010 import QtQuick.Controls as QQC2 0011 import QtQuick.Dialogs 0012 import org.kde.kirigami as Kirigami 0013 import org.kde.kitinerary 0014 import org.kde.itinerary 0015 import org.kde.kirigamiaddons.formcard as FormCard 0016 0017 ColumnLayout { 0018 id: root 0019 0020 property alias documentIds: docsModel.documentIds 0021 property alias title: cardHeader.title 0022 0023 signal addDocument(string file) 0024 signal removeDocument(string docId) 0025 0026 spacing: 0 0027 0028 DocumentsModel { 0029 id: docsModel 0030 documentManager: DocumentManager 0031 } 0032 0033 FileDialog { 0034 id: addDialog 0035 title: i18n("Add Document") 0036 currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) 0037 nameFilters: [i18n("All Files (*.*)")] 0038 onAccepted: root.addDocument(selectedFile) 0039 } 0040 0041 Component { 0042 id: documentDelegate 0043 FormCard.AbstractFormDelegate { 0044 Layout.fillWidth: true 0045 onClicked: ApplicationController.openDocument(model.filePath); 0046 Accessible.onPressAction: clicked() 0047 Accessible.name: model.display 0048 contentItem: RowLayout { 0049 Kirigami.Icon { 0050 source: model.decoration 0051 width: height 0052 height: Kirigami.Units.iconSizes.small 0053 } 0054 0055 QQC2.Label { 0056 text: model.display 0057 Layout.fillWidth: true 0058 elide: Text.ElideMiddle 0059 Accessible.ignored: true 0060 } 0061 0062 Kirigami.ActionToolBar { 0063 actions: QQC2.Action { 0064 icon.name: "edit-delete" 0065 text: i18n("Delete Document") 0066 onTriggered: { 0067 deleteWarningDialog.docId = model.id; 0068 deleteWarningDialog.open() 0069 } 0070 } 0071 } 0072 } 0073 } 0074 } 0075 0076 Kirigami.PromptDialog { 0077 id: deleteWarningDialog 0078 property string docId 0079 0080 title: i18n("Delete Document") 0081 subtitle: i18n("Do you really want to delete this document?") 0082 0083 standardButtons: QQC2.Dialog.Cancel 0084 0085 customFooterActions: [ 0086 Kirigami.Action { 0087 text: i18n("Delete") 0088 icon.name: "edit-delete" 0089 onTriggered: { 0090 root.removeDocument(deleteWarningDialog.docId); 0091 deleteWarningDialog.close() 0092 } 0093 } 0094 ] 0095 } 0096 0097 FormCard.FormHeader { 0098 id: cardHeader 0099 title: i18n("Documents") 0100 } 0101 0102 FormCard.FormCard { 0103 Repeater { 0104 delegate: documentDelegate 0105 model: docsModel 0106 } 0107 0108 FormCard.FormTextDelegate { 0109 text: i18n("No documents attached to this reservation.") 0110 visible: docsModel.empty 0111 Accessible.ignored: !visible 0112 } 0113 0114 FormCard.FormDelegateSeparator {} 0115 0116 FormCard.FormButtonDelegate { 0117 text: i18n("Add Document...") 0118 onClicked: addDialog.open() 0119 } 0120 } 0121 }