Warning, /plasma-mobile/calindori/src/contents/ui/EventsCardView.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 2.7 0008 import QtQuick.Controls 2.0 as Controls2 0009 import QtQuick.Layouts 1.3 0010 import org.kde.kirigami 2.12 as Kirigami 0011 import org.kde.calindori 0.1 as Calindori 0012 0013 Kirigami.ScrollablePage { 0014 id: root 0015 0016 property date eventStartDt 0017 property var calendar 0018 0019 title: i18n("Events") 0020 0021 leftPadding: 0 0022 rightPadding: 0 0023 visible: Kirigami.Settings.isMobile || (!Kirigami.Settings.isMobile && !pageStack.lastVisibleItem.hasOwnProperty("isEditorPage")) 0024 0025 actions.main: Kirigami.Action { 0026 id: mainAction 0027 0028 icon.name: "resource-calendar-insert" 0029 text: i18n("Create Event") 0030 onTriggered: pageStack.push(eventEditor, {startDt: (eventStartDt && !isNaN(eventStartDt)) ? new Date(root.eventStartDt.getTime() - root.eventStartDt.getMinutes()*60000 + 3600000) : Calindori.CalendarController.localSystemDateTime()}) 0031 } 0032 0033 Kirigami.PlaceholderMessage { 0034 anchors.centerIn: parent 0035 icon.name: "tag-events" 0036 width: parent.width - (Kirigami.Units.largeSpacing * 4) 0037 visible: cardsListview.count == 0 0038 text: !isNaN(eventStartDt) ? i18n("No events scheduled for %1", eventStartDt.toLocaleDateString(_appLocale, Locale.ShortFormat)) : i18n("No events scheduled") 0039 helpfulAction: mainAction 0040 } 0041 0042 Kirigami.CardsListView { 0043 id: cardsListview 0044 0045 model: eventsModel 0046 enabled: count > 0 && (root.state !== "deleting") 0047 clip: true 0048 0049 delegate: EventCard { 0050 id: cardDelegate 0051 0052 dataModel: model 0053 0054 actions: [ 0055 Kirigami.Action { 0056 text: i18n("Delete") 0057 icon.name: "delete" 0058 0059 onTriggered: { 0060 deleteMsg.eventUid = model.uid; 0061 deleteMsg.eventSummary = model.summary; 0062 root.state = "deleting"; 0063 } 0064 }, 0065 0066 Kirigami.Action { 0067 text: i18n("Edit") 0068 icon.name: "editor" 0069 0070 onTriggered: pageStack.push(eventEditor, { startDt: model.dtstart, uid: model.uid, incidenceData: model }) 0071 } 0072 ] 0073 } 0074 } 0075 0076 footer: Kirigami.InlineMessage { 0077 id: deleteMsg 0078 0079 property string eventUid 0080 property string eventSummary 0081 0082 text: i18n("Event %1 will be deleted", eventSummary) 0083 visible: false 0084 0085 actions: [ 0086 Kirigami.Action { 0087 text: i18n("Delete") 0088 0089 onTriggered: { 0090 Calindori.CalendarController.removeEvent(root.calendar, {"uid": deleteMsg.eventUid}); 0091 root.state = ""; 0092 } 0093 }, 0094 0095 Kirigami.Action { 0096 text: i18n("Cancel") 0097 0098 onTriggered: root.state = "" 0099 } 0100 ] 0101 } 0102 0103 0104 Calindori.IncidenceModel { 0105 id: eventsModel 0106 0107 appLocale: _appLocale 0108 filterDt: root.eventStartDt 0109 filterMode: 5 0110 } 0111 0112 Component { 0113 id: eventEditor 0114 0115 EventEditorPage { 0116 calendar: Calindori.CalendarController.activeCalendar 0117 0118 onEditcompleted: pageStack.pop() 0119 } 0120 } 0121 0122 states: [ 0123 State { 0124 name: "" 0125 PropertyChanges { target: deleteMsg; visible: false } 0126 }, 0127 State { 0128 name: "deleting" 0129 PropertyChanges { target: deleteMsg; visible: true } 0130 } 0131 ] 0132 }