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

0001 // SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls
0006 import QtQuick.Layouts
0007 
0008 import org.kde.kirigami as Kirigami
0009 
0010 import org.kde.telephony
0011 
0012 import "call"
0013 import "history"
0014 
0015 Kirigami.ScrollablePage {
0016     id: historyPage
0017 
0018     title: i18n("Call History")
0019     icon.name: "clock"
0020     
0021     // page animation
0022     property real yTranslate: 0
0023     
0024     header: ColumnLayout {
0025         anchors.margins: Kirigami.Units.smallSpacing
0026         spacing: Kirigami.Units.smallSpacing
0027         InCallInlineMessage {}
0028     }
0029 
0030     actions: [
0031         Kirigami.Action {
0032             icon.name: "edit-clear-history"
0033             onTriggered: promptDialog.open()
0034             text: i18n("Clear history")
0035         },
0036         Kirigami.Action {
0037             icon.name: "settings-configure"
0038             displayHint: Kirigami.DisplayHint.IconOnly
0039             visible: !applicationWindow().isWidescreen
0040             enabled: !applicationWindow().lockscreenMode
0041             text: i18n("Settings")
0042             onTriggered: applicationWindow().pageStack.push(applicationWindow().getPage("Settings"))
0043         }
0044     ]
0045 
0046     function secondsToTimeString(seconds) {
0047         var h = Math.floor(seconds / 3600);
0048         var m = Math.floor((seconds - (h * 3600)) / 60);
0049         var s = seconds - h * 3600 - m * 60;
0050         if(m < 10) m = '0' + m;
0051         if(s < 10) s = '0' + s;
0052         if(h === 0) return '' + m + ':' + s;
0053         return '' + h + ':' + m + ':' + s;
0054     }
0055 
0056 
0057     ListView {
0058         id: view
0059         transform: Translate { y: yTranslate }
0060         model: CallHistoryModel
0061         section {
0062             property: "date"
0063             delegate: Kirigami.ListSectionHeader {
0064                 label: Qt.formatDate(section, Qt.locale().dateFormat(Locale.LongFormat));
0065             }
0066         }
0067         delegate: HistoryDelegate {
0068             width: ListView.view.width
0069         }
0070         
0071         Kirigami.PlaceholderMessage {
0072             anchors.centerIn: parent
0073             text: i18n("No recent calls")
0074             icon.name: "call-outgoing"
0075             visible: view.count == 0
0076         }
0077     }
0078 
0079     Kirigami.PromptDialog {
0080         id: promptDialog
0081         title: "Clear history?"
0082         subtitle: "Delete the call history log without option to restore it"
0083         standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
0084         onAccepted: CallHistoryModel.clear()
0085         onRejected: close()
0086         maximumHeight: applicationWindow().height
0087     }
0088 }