ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04668
[Merge] lp:~nik90/ubuntu-clock-app/remove-listitemwithactions-upstream-component into lp:ubuntu-clock-app
Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/remove-listitemwithactions-upstream-component into lp:ubuntu-clock-app.
Commit message:
- Removed ListItemWithActions upstream component by migrating the last place UserWorldCityDelegate.qml it was used in to 15.04 ListItem.
- Also fixed the user world city list count never decreasing to 0.
Requested reviews:
Ubuntu Clock Developers (ubuntu-clock-dev)
For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/remove-listitemwithactions-upstream-component/+merge/269562
- Removed ListItemWithActions upstream component by migrating the last place UserWorldCityDelegate.qml it was used in to 15.04 ListItem.
- Also fixed the user world city list count never decreasing to 0.
--
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/remove-listitemwithactions-upstream-component into lp:ubuntu-clock-app.
=== modified file 'app/upstreamcomponents/CMakeLists.txt'
--- app/upstreamcomponents/CMakeLists.txt 2015-08-11 15:05:34 +0000
+++ app/upstreamcomponents/CMakeLists.txt 2015-08-29 01:52:46 +0000
@@ -2,8 +2,6 @@
FakeHeader.qml
FastScroll.js
FastScroll.qml
- ListItemWithActions.qml
- ListItemWithActionsCheckBox.qml
PageWithBottomEdge.qml
)
=== removed file 'app/upstreamcomponents/ListItemWithActions.qml'
--- app/upstreamcomponents/ListItemWithActions.qml 2015-05-27 16:03:23 +0000
+++ app/upstreamcomponents/ListItemWithActions.qml 1970-01-01 00:00:00 +0000
@@ -1,453 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Canonical, Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-import QtQuick 2.4
-import Ubuntu.Components 1.2
-
-Item {
- id: root
-
- property Action leftSideAction: null
- property list<Action> rightSideActions
- property double defaultHeight: units.gu(8)
- property bool locked: false
- property Action activeAction: null
- property var activeItem: null
- property bool triggerActionOnMouseRelease: false
- property color color: Theme.palette.normal.background
- property color selectedColor: "#E6E6E6"
- property bool selected: false
- property bool selectionMode: false
- property alias internalAnchors: mainContents.anchors
- default property alias contents: mainContents.children
-
- readonly property double actionWidth: units.gu(4)
- readonly property double leftActionWidth: units.gu(10)
- readonly property double actionThreshold: actionWidth * 0.4
- readonly property double threshold: 0.4
- readonly property string swipeState: main.x == 0 ? "Normal" : main.x > 0 ? "LeftToRight" : "RightToLeft"
- readonly property alias swipping: mainItemMoving.running
- readonly property bool _showActions: mouseArea.pressed || swipeState != "Normal" || swipping
-
- /* internal */
- property var _visibleRightSideActions: filterVisibleActions(rightSideActions)
-
- signal itemClicked(var mouse)
- signal itemPressAndHold(var mouse)
-
- function returnToBoundsRTL(direction)
- {
- var actionFullWidth = actionWidth + units.gu(2)
-
- // go back to normal state if swipping reverse
- if (direction === "LTR") {
- updatePosition(0)
- return
- } else if (!triggerActionOnMouseRelease) {
- updatePosition(-rightActionsView.width + units.gu(2))
- return
- }
-
- var xOffset = Math.abs(main.x)
- var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length)
- var newX = 0
- if (index === _visibleRightSideActions.length) {
- newX = -(rightActionsView.width - units.gu(2))
- } else if (index >= 1) {
- newX = -(actionFullWidth * index)
- }
- updatePosition(newX)
- }
-
- function returnToBoundsLTR(direction)
- {
- var finalX = leftActionWidth
- if ((direction === "RTL") || (main.x <= (finalX * root.threshold)))
- finalX = 0
- updatePosition(finalX)
- }
-
- function returnToBounds(direction)
- {
- if (main.x < 0) {
- returnToBoundsRTL(direction)
- } else if (main.x > 0) {
- returnToBoundsLTR(direction)
- } else {
- updatePosition(0)
- }
- }
-
- function contains(item, point, marginX)
- {
- var itemStartX = item.x - marginX
- var itemEndX = item.x + item.width + marginX
- return (point.x >= itemStartX) && (point.x <= itemEndX) &&
- (point.y >= item.y) && (point.y <= (item.y + item.height));
- }
-
- function getActionAt(point)
- {
- if (contains(leftActionView, point, 0)) {
- return leftSideAction
- } else if (contains(rightActionsView, point, 0)) {
- var newPoint = root.mapToItem(rightActionsView, point.x, point.y)
- for (var i = 0; i < rightActionsRepeater.count; i++) {
- var child = rightActionsRepeater.itemAt(i)
- if (contains(child, newPoint, units.gu(1))) {
- return i
- }
- }
- }
- return -1
- }
-
- function updateActiveAction()
- {
- if (triggerActionOnMouseRelease &&
- (main.x <= -(root.actionWidth + units.gu(2))) &&
- (main.x > -(rightActionsView.width - units.gu(2)))) {
- var actionFullWidth = actionWidth + units.gu(2)
- var xOffset = Math.abs(main.x)
- var index = Math.min(Math.floor(xOffset / actionFullWidth), _visibleRightSideActions.length)
- index = index - 1
- if (index > -1) {
- root.activeItem = rightActionsRepeater.itemAt(index)
- root.activeAction = root._visibleRightSideActions[index]
- }
- } else {
- root.activeAction = null
- }
- }
-
- function resetSwipe()
- {
- updatePosition(0)
- }
-
- function filterVisibleActions(actions)
- {
- var visibleActions = []
- for(var i = 0; i < actions.length; i++) {
- var action = actions[i]
- if (action.visible) {
- visibleActions.push(action)
- }
- }
- return visibleActions
- }
-
- function updatePosition(pos)
- {
- if (!root.triggerActionOnMouseRelease && (pos !== 0)) {
- mouseArea.state = pos > 0 ? "RightToLeft" : "LeftToRight"
- } else {
- mouseArea.state = ""
- }
- main.x = pos
- }
-
- states: [
- State {
- name: "select"
- when: selectionMode || selected
- PropertyChanges {
- target: selectionIcon
- source: Qt.resolvedUrl("ListItemWithActionsCheckBox.qml")
- anchors.leftMargin: units.gu(2)
- }
- PropertyChanges {
- target: root
- locked: true
- }
- PropertyChanges {
- target: main
- x: 0
- }
- }
- ]
-
- height: defaultHeight
- clip: height !== defaultHeight
-
- Rectangle {
- id: leftActionView
-
- anchors {
- top: parent.top
- bottom: parent.bottom
- right: main.left
- }
- width: root.leftActionWidth + actionThreshold
- visible: leftSideAction
- color: UbuntuColors.red
-
- Icon {
- anchors {
- centerIn: parent
- horizontalCenterOffset: actionThreshold / 2
- }
- name: leftSideAction && _showActions ? leftSideAction.iconName : ""
- color: Theme.palette.selected.field
- height: units.gu(3)
- width: units.gu(3)
- }
- }
-
- Rectangle {
- id: rightActionsView
-
- anchors {
- top: main.top
- left: main.right
- bottom: main.bottom
- }
- visible: _visibleRightSideActions.length > 0
- width: rightActionsRepeater.count > 0 ? rightActionsRepeater.count * (root.actionWidth + units.gu(2)) + root.actionThreshold + units.gu(2) : 0
- color: "white"
- Row {
- anchors{
- top: parent.top
- left: parent.left
- leftMargin: units.gu(2)
- right: parent.right
- rightMargin: units.gu(2)
- bottom: parent.bottom
- }
- spacing: units.gu(2)
- Repeater {
- id: rightActionsRepeater
-
- model: _showActions ? _visibleRightSideActions : []
- Item {
- property alias image: img
-
- height: rightActionsView.height
- width: root.actionWidth
-
- Icon {
- id: img
-
- anchors.centerIn: parent
- width: units.gu(3)
- height: units.gu(3)
- name: modelData.iconName
- color: root.activeAction === modelData ? UbuntuColors.lightAubergine : UbuntuColors.lightGrey
- }
- }
- }
- }
- }
-
-
- Rectangle {
- id: main
- objectName: "mainItem"
-
- anchors {
- top: parent.top
- bottom: parent.bottom
- }
-
- width: parent.width
- color: root.selected ? root.selectedColor : root.color
-
- Loader {
- id: selectionIcon
-
- anchors {
- left: main.left
- verticalCenter: main.verticalCenter
- }
- width: (status === Loader.Ready) ? item.implicitWidth : 0
- visible: (status === Loader.Ready) && (item.width === item.implicitWidth)
- Behavior on width {
- NumberAnimation {
- duration: UbuntuAnimation.SnapDuration
- }
- }
- }
-
-
- Item {
- id: mainContents
-
- anchors {
- left: selectionIcon.right
- leftMargin: units.gu(2)
- top: parent.top
- topMargin: units.gu(1)
- right: parent.right
- rightMargin: units.gu(2)
- bottom: parent.bottom
- bottomMargin: units.gu(1)
- }
- }
-
- Behavior on x {
- UbuntuNumberAnimation {
- id: mainItemMoving
-
- easing.type: Easing.OutElastic
- duration: UbuntuAnimation.SlowDuration
- }
- }
- Behavior on color {
- ColorAnimation {}
- }
- }
-
- SequentialAnimation {
- id: triggerAction
-
- property var currentItem: root.activeItem ? root.activeItem.image : null
-
- running: false
- ParallelAnimation {
- UbuntuNumberAnimation {
- target: triggerAction.currentItem
- property: "opacity"
- from: 1.0
- to: 0.0
- duration: UbuntuAnimation.SlowDuration
- easing {type: Easing.InOutBack; }
- }
- UbuntuNumberAnimation {
- target: triggerAction.currentItem
- properties: "width, height"
- from: units.gu(3)
- to: root.actionWidth
- duration: UbuntuAnimation.SlowDuration
- easing {type: Easing.InOutBack; }
- }
- }
- PropertyAction {
- target: triggerAction.currentItem
- properties: "width, height"
- value: units.gu(3)
- }
- PropertyAction {
- target: triggerAction.currentItem
- properties: "opacity"
- value: 1.0
- }
- ScriptAction {
- script: {
- root.activeAction.triggered(root)
- mouseArea.state = ""
- }
- }
- PauseAnimation {
- duration: 500
- }
- UbuntuNumberAnimation {
- target: main
- property: "x"
- to: 0
-
- }
- }
-
- MouseArea {
- id: mouseArea
-
- property bool locked: root.locked || ((root.leftSideAction === null) && (root._visibleRightSideActions.count === 0))
- property bool manual: false
- property string direction: "None"
- property real lastX: -1
-
- anchors.fill: parent
- drag {
- target: locked ? null : main
- axis: Drag.XAxis
- minimumX: rightActionsView.visible ? -(rightActionsView.width) : 0
- maximumX: leftActionView.visible ? leftActionView.width : 0
- threshold: root.actionThreshold
- }
-
- states: [
- State {
- name: "LeftToRight"
- PropertyChanges {
- target: mouseArea
- drag.maximumX: 0
- }
- },
- State {
- name: "RightToLeft"
- PropertyChanges {
- target: mouseArea
- drag.minimumX: 0
- }
- }
- ]
-
- onMouseXChanged: {
- var offset = (lastX - mouseX)
- if (Math.abs(offset) <= root.actionThreshold) {
- return
- }
- lastX = mouseX
- direction = offset > 0 ? "RTL" : "LTR";
- }
-
- onPressed: {
- lastX = mouse.x
- }
-
- onReleased: {
- if (root.triggerActionOnMouseRelease && root.activeAction) {
- triggerAction.start()
- } else {
- root.returnToBounds(direction)
- root.activeAction = null
- }
- lastX = -1
- direction = "None"
- }
- onClicked: {
- if (main.x === 0) {
- root.itemClicked(mouse)
- } else if (main.x > 0) {
- var action = getActionAt(Qt.point(mouse.x, mouse.y))
- if (action && action !== -1) {
- action.triggered(root)
- }
- } else {
- var actionIndex = getActionAt(Qt.point(mouse.x, mouse.y))
- if (actionIndex !== -1) {
- root.activeItem = rightActionsRepeater.itemAt(actionIndex)
- root.activeAction = root._visibleRightSideActions[actionIndex]
- triggerAction.start()
- return
- }
- }
- root.resetSwipe()
- }
-
- onPositionChanged: {
- if (mouseArea.pressed) {
- updateActiveAction()
- }
- }
- onPressAndHold: {
- if (main.x === 0) {
- root.itemPressAndHold(mouse)
- }
- }
- z: -1
- }
-}
=== removed file 'app/upstreamcomponents/ListItemWithActionsCheckBox.qml'
--- app/upstreamcomponents/ListItemWithActionsCheckBox.qml 2015-05-27 16:03:23 +0000
+++ app/upstreamcomponents/ListItemWithActionsCheckBox.qml 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Canonical, Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-import QtQuick 2.4
-import Ubuntu.Components 1.2
-
-CheckBox {
- checked: root.selected
- width: implicitWidth
- // disable item mouse area to avoid conflicts with parent mouse area
- __mouseArea.enabled: false
-}
=== modified file 'app/upstreamcomponents/README.components'
--- app/upstreamcomponents/README.components 2014-08-08 14:19:45 +0000
+++ app/upstreamcomponents/README.components 2015-08-29 01:52:46 +0000
@@ -15,19 +15,3 @@
FastScroll.qml
https://bazaar.launchpad.net/~phablet-team/address-book-app/trunk/view/head:/src/imports/Ubuntu/Contacts/FastScroll.qml
-
-ListItemWithActions.qml
-
-https://bazaar.launchpad.net/~phablet-team/address-book-app/trunk/view/head:/src/imports/Ubuntu/Contacts/ListItemWithActions.qml
-
-ListItemWithActionsCheckBox.qml
-
-https://bazaar.launchpad.net/~phablet-team/address-book-app/trunk/view/head:/src/imports/Ubuntu/Contacts/ListItemWithActionsCheckBox.qml
-
-MultipleSelectionListView.qml
-
-https://bazaar.launchpad.net/~phablet-team/address-book-app/trunk/view/head:/src/imports/Ubuntu/Contacts/MultipleSelectionListView.qml
-
-MultipleSelectionVisualModel.qml
-
-https://bazaar.launchpad.net/~phablet-team/address-book-app/trunk/view/head:/src/imports/Ubuntu/Contacts/MultipleSelectionVisualModel.qml
=== modified file 'app/worldclock/UserWorldCityDelegate.qml'
--- app/worldclock/UserWorldCityDelegate.qml 2015-08-14 05:34:49 +0000
+++ app/worldclock/UserWorldCityDelegate.qml 2015-08-29 01:52:46 +0000
@@ -19,10 +19,9 @@
import QtQuick 2.4
import Ubuntu.Components 1.2
import "../components"
-import "../upstreamcomponents"
-ListItemWithActions {
- id: root
+ListItem {
+ id: userWorldCityDelegate
function getTimeDiff(time) {
var hours, minutes;
@@ -33,13 +32,15 @@
}
height: units.gu(9)
- width: parent ? parent.width : 0
- color: "Transparent"
+ divider.visible: false
Item {
id: delegate
- anchors.fill: parent
+ anchors {
+ fill: parent
+ margins: units.gu(2)
+ }
Column {
id: cityColumn
=== modified file 'app/worldclock/UserWorldCityList.qml'
--- app/worldclock/UserWorldCityList.qml 2015-08-26 23:30:10 +0000
+++ app/worldclock/UserWorldCityList.qml 2015-08-29 01:52:46 +0000
@@ -56,89 +56,32 @@
results: worldCityQuery.results
}
- property var _currentSwipedItem: null
-
- function _updateSwipeState(item)
- {
- if (item.swipping) {
- return
- }
-
- if (item.swipeState !== "Normal") {
- if (worldCityColumn._currentSwipedItem !== item) {
- if (worldCityColumn._currentSwipedItem) {
- worldCityColumn._currentSwipedItem.resetSwipe()
- }
- worldCityColumn._currentSwipedItem = item
- }
- } else if (item.swipeState !== "Normal"
- && worldCityColumn._currentSwipedItem === item) {
- worldCityColumn._currentSwipedItem = null
- }
- }
-
model: u1dbModel
delegate: UserWorldCityDelegate {
id: userWorldCityDelegate
objectName: "userWorldCityItem" + index
- property var removalAnimation
-
- function remove() {
- removalAnimation.start()
- }
-
- onSwippingChanged: {
- worldCityColumn._updateSwipeState(userWorldCityDelegate)
- }
-
- onSwipeStateChanged: {
- worldCityColumn._updateSwipeState(userWorldCityDelegate)
- }
-
- leftSideAction: Action {
- iconName: "delete"
- text: i18n.tr("Delete")
- onTriggered: {
- userWorldCityDelegate.remove()
- }
- }
-
- ListView.onRemove: ScriptAction {
- script: {
- if (worldCityColumn._currentSwipedItem
- === userWorldCityDelegate) {
- worldCityColumn._currentSwipedItem = null
+ leadingActions: ListItemActions {
+ actions: [
+ Action {
+ iconName: "delete"
+ text: i18n.tr("Delete")
+ onTriggered: {
+ /*
+ This if loop check is required due to a bug where the listitem
+ is not deleted when the listview count is 1. This should fix
+ http://pad.lv/1368393
+ */
+ if (worldCityColumn.count === 1) {
+ clockDB.deleteDoc(worldCityQuery.documents[index])
+ u1dbModel.clear()
+ } else {
+ clockDB.deleteDoc(worldCityQuery.documents[index])
+ }
+ }
}
- }
- }
-
- removalAnimation: SequentialAnimation {
- alwaysRunToEnd: true
-
- PropertyAction {
- target: userWorldCityDelegate
- property: "ListView.delayRemove"
- value: true
- }
-
- UbuntuNumberAnimation {
- target: userWorldCityDelegate
- property: "height"
- to: 0
- }
-
- PropertyAction {
- target: userWorldCityDelegate
- property: "ListView.delayRemove"
- value: false
- }
-
- ScriptAction {
- script: clockDB.deleteDoc(worldCityQuery.documents[index])
- }
+ ]
}
}
-
}
=== modified file 'backend/modules/WorldClock/generictimezonemodel.cpp'
--- backend/modules/WorldClock/generictimezonemodel.cpp 2015-08-25 16:11:38 +0000
+++ backend/modules/WorldClock/generictimezonemodel.cpp 2015-08-29 01:52:46 +0000
@@ -95,3 +95,12 @@
// Let QML know model is reusable again
endResetModel();
}
+
+void GenericTimeZoneModel::clear()
+{
+ beginResetModel();
+
+ m_citiesData.clear();
+
+ endResetModel();
+}
=== modified file 'backend/modules/WorldClock/generictimezonemodel.h'
--- backend/modules/WorldClock/generictimezonemodel.h 2015-08-25 16:11:38 +0000
+++ backend/modules/WorldClock/generictimezonemodel.h 2015-08-29 01:52:46 +0000
@@ -43,6 +43,9 @@
// Function to set the model
void setResults(const QList<QVariant> &results);
+public slots:
+ void clear();
+
signals:
// Signal to notify the change of the model to QML
void resultsChanged();
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-29 01:49:30 +0000
+++ debian/changelog 2015-08-29 01:52:46 +0000
@@ -1,6 +1,9 @@
ubuntu-clock-app (3.6) UNRELEASED; urgency=medium
+ [Nekhelesh Ramananthan]
* Bumped version to 3.6
+ * Removed ListItemWithActions upstream component and also fixed the user
+ world city list count never decreasing to 0. (LP: #1368393)
-- Nekhelesh Ramananthan <krnekhelesh@xxxxxxxxx> Sat, 29 Aug 2015 01:47:00 +0200
Follow ups