diff --git a/dialer/package/contents/ui/Dialer/Dialer.qml b/dialer/package/contents/ui/Dialer/Dialer.qml index 42214bd1..061ae94e 100644 --- a/dialer/package/contents/ui/Dialer/Dialer.qml +++ b/dialer/package/contents/ui/Dialer/Dialer.qml @@ -36,6 +36,7 @@ Item { status.text = status.text + number } + //TODO: move in root item function call() { if (!voiceCallmanager.activeVoiceCall) { console.log("Calling: " + status.text); diff --git a/dialer/package/contents/ui/Dialer/History.qml b/dialer/package/contents/ui/Dialer/History.qml index 4b7a9c1b..c117fa59 100644 --- a/dialer/package/contents/ui/Dialer/History.qml +++ b/dialer/package/contents/ui/Dialer/History.qml @@ -21,10 +21,80 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras +import QtQuick.LocalStorage 2.0 Item { + + //TODO: move in root item + property string providerId: voiceCallmanager.providers.id(0) + function call(number) { + if (!voiceCallmanager.activeVoiceCall) { + console.log("Calling: " + status.text); + voiceCallmanager.dial(providerId, number); + + } else { + console.log("Hanging up: " + status.text); + status.text = ''; + var call = voiceCallmanager.activeVoiceCall; + if (call) { + call.hangup(); + } + } + } + + Component.onCompleted: { + var db = LocalStorage.openDatabaseSync("PlasmaPhoneDialer", "1.0", "Call history of the Plasma Phone dialer", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + //callType: wether is incoming, outgoing, unanswered + tx.executeSql('CREATE TABLE IF NOT EXISTS History(number TEXT, time DATETIME, callType TEXT)'); + + // Add (another) greeting row + //tx.executeSql("INSERT INTO History VALUES(?, datetime('now') )", ['+39000']); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM History'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).number + ", " + rs.rows.item(i).time + "\n" + historyModel.append({number: rs.rows.item(i).number, time: rs.rows.item(i).time}) + } + } + ) + } + PlasmaComponents.Label { anchors.centerIn: parent text: i18n("No recent calls") + visible: false + } + PlasmaExtras.ScrollArea { + anchors.fill: parent + ListView { + id: view + model: ListModel { + id: historyModel + } + delegate: MouseArea { + width: view.width + height: childrenRect.height + onClicked: call(model.number); + + RowLayout { + width: view.width + PlasmaComponents.Label { + text: model.number + Layout.fillWidth: true + } + PlasmaComponents.Label { + text: Qt.formatDateTime(model.time, Qt.locale().dateTimeFormat(Locale.LongFormat)); + } + } + } + } } } \ No newline at end of file