mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 22:53:09 +00:00
capability to remove items
better history delegate
This commit is contained in:
parent
c58e932db2
commit
fb4765d50a
3 changed files with 147 additions and 39 deletions
|
|
@ -17,14 +17,13 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.4
|
||||
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
|
||||
|
||||
Rectangle {
|
||||
color: syspal.base
|
||||
Item {
|
||||
|
||||
function secondsToTimeString(seconds) {
|
||||
seconds = Math.floor(seconds/1000)
|
||||
|
|
@ -50,46 +49,17 @@ Rectangle {
|
|||
section {
|
||||
property: "date"
|
||||
labelPositioning: ViewSection.CurrentLabelAtStart
|
||||
delegate: Rectangle {
|
||||
width: view.width
|
||||
height: childrenRect.height
|
||||
color: syspal.base
|
||||
delegate: PlasmaComponents.ListItem {
|
||||
//width: view.width
|
||||
//height: childrenRect.height
|
||||
//color: syspal.base
|
||||
sectionDelegate: true
|
||||
PlasmaComponents.Label {
|
||||
text: Qt.formatDate(section, Qt.locale().dateFormat(Locale.LongFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate: MouseArea {
|
||||
width: view.width
|
||||
height: childrenRect.height
|
||||
onClicked: call(model.number);
|
||||
|
||||
RowLayout {
|
||||
width: view.width
|
||||
PlasmaComponents.Label {
|
||||
text: {
|
||||
switch (model.callType) {
|
||||
case 0:
|
||||
return "miss";
|
||||
case 1:
|
||||
return "incoming";
|
||||
case 2:
|
||||
return "outgoing";
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: model.number
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: i18n("Duration: %1", secondsToTimeString(model.duration));
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: Qt.formatTime(model.date+" "+model.time, Qt.locale().timeFormat(Locale.LongFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate: HistoryDelegate {}
|
||||
}
|
||||
}
|
||||
}
|
||||
122
dialer/package/contents/ui/Dialer/HistoryDelegate.qml
Normal file
122
dialer/package/contents/ui/Dialer/HistoryDelegate.qml
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright 2015 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.4
|
||||
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
|
||||
|
||||
Item {
|
||||
id: delegateParent
|
||||
width: view.width
|
||||
height: childrenRect.height
|
||||
|
||||
Behavior on height {
|
||||
SpringAnimation { spring: 5; damping: 0.3 }
|
||||
}
|
||||
SequentialAnimation {
|
||||
id: removeAnim
|
||||
XAnimator {
|
||||
target: delegate
|
||||
from: delegate.x
|
||||
to: delegate.x > 0 ? width : -width
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: delegateParent
|
||||
properties: "height"
|
||||
to: 0
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
ScriptAction {
|
||||
script: removeCallFromHistory(index);
|
||||
}
|
||||
}
|
||||
|
||||
XAnimator {
|
||||
id: resetAnim
|
||||
target: delegate
|
||||
from: delegate.x
|
||||
to: 0
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
|
||||
PlasmaComponents.ListItem {
|
||||
id: delegate
|
||||
|
||||
MouseArea {
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
onClicked: call(model.number);
|
||||
drag.axis: Drag.XAxis
|
||||
drag.target: delegate
|
||||
onReleased: {
|
||||
if (drag.active) {
|
||||
if (delegate.x > delegate.width / 3 || delegate.x < width / -3) {
|
||||
removeAnim.running = true;
|
||||
} else {
|
||||
resetAnim.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
//FIXME: ad hoc icons
|
||||
PlasmaCore.IconItem {
|
||||
width: units.iconSizes.medium
|
||||
height: width
|
||||
source: {
|
||||
switch (model.callType) {
|
||||
case 0:
|
||||
return "list-remove";
|
||||
case 1:
|
||||
return "go-down";
|
||||
case 2:
|
||||
return "go-up";
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
PlasmaComponents.Label {
|
||||
text: "Name (todo)"
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: i18n("Number: %1", model.number)
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
PlasmaComponents.Label {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: Qt.formatTime(model.date+" "+model.time, Qt.locale().timeFormat(Locale.ShortFormat));
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: i18n("Duration: %1", secondsToTimeString(model.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,6 +115,23 @@ ApplicationWindow {
|
|||
)
|
||||
}
|
||||
|
||||
function removeCallFromHistory(id) {
|
||||
var item = historyModel.get(id);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
var db = LocalStorage.openDatabaseSync("PlasmaPhoneDialer", "1.0", "Call history of the Plasma Phone dialer", 1000000);
|
||||
|
||||
db.transaction(
|
||||
function(tx) {
|
||||
tx.executeSql("DELETE from History WHERE id=?", [id]);
|
||||
}
|
||||
)
|
||||
|
||||
historyModel.remove(id);
|
||||
}
|
||||
//END FUNCTIONS
|
||||
|
||||
//BEGIN DATABASE
|
||||
|
|
@ -223,7 +240,6 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
SystemPalette {id: syspal}
|
||||
//END MODELS
|
||||
|
||||
//BEGIN UI
|
||||
|
|
|
|||
Loading…
Reference in a new issue