Merge lp:~gang65/ubuntu-calculator-app/reboot_copy_selected_calculation into lp:ubuntu-calculator-app

Proposed by Bartosz Kosiorek
Status: Merged
Approved by: Giulio Collura
Approved revision: 65
Merged at revision: 66
Proposed branch: lp:~gang65/ubuntu-calculator-app/reboot_copy_selected_calculation
Merge into: lp:ubuntu-calculator-app
Diff against target: 101 lines (+40/-7)
1 file modified
app/ubuntu-calculator-app.qml (+40/-7)
To merge this branch: bzr merge lp:~gang65/ubuntu-calculator-app/reboot_copy_selected_calculation
Reviewer Review Type Date Requested Status
Giulio Collura Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Pending
Review via email: mp+246505@code.launchpad.net

Commit message

Add feature to copy selected calculation from the history

Description of the change

Add feature to copy selected calculation from the history

To post a comment you must log in.
Revision history for this message
Giulio Collura (gcollura) wrote :

We need to set action names for our actions, otherwise we end up with a empty label in overflow action menu, see http://i.imgur.com/oqc9gSQ.png

Thanks!

Giulio

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Thanks Giulio.

I was wondering why we need these additional text caption, while we are using icons :-P

63. By Bartosz Kosiorek

Add captions to action buttons

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Giulio Collura (gcollura) wrote :

Do we really need to copy the date in the clipboard?
I copied a couple of calculation as test and the date just stand in the way without a real meaning, see:
[Wed Jan 14 23:20:19 2015 GMT+0100] 2+6=8
[Wed Jan 14 23:20:19 2015 GMT+0100] -10^2/5=-20
The actual calculation is short, while the date and time takes a lot of space. I'd like also to discuss about this with rpadovani :)

Also, we may want to support the "copy to clipboard" for a single entry, be swiping the list item to the left, similarly to delete, which is shown with a swipe to right gesture.

I also left a comment inline.

review: Needs Information
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

I agree with Giulio, I think we don't need the date in the clipboard or, if we want it, we definitely need to change the format

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Ok. I will remove date.

64. By Bartosz Kosiorek

Remove date from copied data

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

As you already noticed, copied data is in engine format, without formatting.
In my opinion is simpler to modify ASCII data, rather than UTF-8 chars.

For example:

1/0=Infinity

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

As I remember, according to design swipe to left was reserved for adding calculation to favourites.

Favourites is not implemented yet. In my opinion copy has higher priority.

Revision history for this message
Giulio Collura (gcollura) wrote :

We can have two rightSideActions in ListItemWithActions, one action for copy another for favouring, because it can be tedious to start the selection mode, just to copy a single calculation. Anyway if this a design pattern and since I'm not a designer, I can't judge :)

I almost forgot, we have to filter out the entries in the model which have been hidden and have a dbId < 0, otherwise a empty calculation will be copied, if these get selected when selecting all the entries (I know this may be a bug in MultipleSelectionVisualModel, but it's better to workaround it here in this case). Just put a 'if (items.get(j).model.dbId !== -1)' before adding the calculations to mimeData.text.

Thank you!

Giulio

review: Needs Fixing
65. By Bartosz Kosiorek

Do not copy calculation with dbId === -1

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Nice catch Giulio.

Please also review other Merge Reqest.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Giulio Collura (gcollura) wrote :

Ok thank you for the patience and the merge proposal :)
Approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ubuntu-calculator-app.qml'
2--- app/ubuntu-calculator-app.qml 2015-01-14 14:47:03 +0000
3+++ app/ubuntu-calculator-app.qml 2015-01-15 18:57:16 +0000
4@@ -62,6 +62,9 @@
5
6 property var decimalPoint: Qt.locale().decimalPoint
7
8+ // By default we delete selected calculation from history
9+ property bool deleteSelectedCalculation: true;
10+
11 state: visualModel.isInSelectionMode ? "selection" : "default"
12 states: [
13 State {
14@@ -227,16 +230,25 @@
15 }
16 actions: [
17 Action {
18+ id: copySelectedAction
19+ objectName: "copySelectedAction"
20+ iconName: "edit-copy"
21+ text: i18n.tr("Copy")
22+ onTriggered: copySelectedCalculations()
23+ },
24+ Action {
25 id: selectAllAction
26 objectName: "selectAllAction"
27 iconName: "select"
28+ text: i18n.tr("Select All")
29 onTriggered: visualModel.selectAll()
30 },
31 Action {
32 id: multiDeleteAction
33 objectName: "multiDeleteAction"
34 iconName: "delete"
35- onTriggered: visualModel.endSelection()
36+ text: i18n.tr("Delete")
37+ onTriggered: deleteSelectedCalculations()
38 }
39 ]
40 }
41@@ -254,7 +266,7 @@
42 width: parent ? parent.width : 0
43
44 property var model: itemModel
45- visible: model.dbId != -1
46+ visible: model.dbId !== -1
47
48 selectionMode: visualModel.isInSelectionMode
49 selected: visualModel.isSelected(visualDelegate)
50@@ -327,13 +339,34 @@
51 }
52 }
53
54+ function deleteSelectedCalculations() {
55+ deleteSelectedCalculation = true;
56+ visualModel.endSelection();
57+ }
58+
59+ function copySelectedCalculations() {
60+ deleteSelectedCalculation = false;
61+ visualModel.endSelection();
62+ }
63+
64 MultipleSelectionVisualModel {
65 id: visualModel
66 model: calculationHistory.getContents()
67
68 onSelectionDone: {
69- for (var i = 0; i < items.count; i++) {
70- calculationHistory.deleteCalc(items.get(i).model.dbId, items.get(i).model.index);
71+ if(deleteSelectedCalculation === true) {
72+ for(var i = 0; i < items.count; i++) {
73+ calculationHistory.deleteCalc(items.get(i).model.dbId, items.get(i).model.index);
74+ }
75+ } else {
76+ var mimeData = Clipboard.newData();
77+ mimeData.text = "";
78+ for(var j = 0; j < items.count; j++) {
79+ if (items.get(j).model.dbId !== -1) {
80+ mimeData.text = mimeData.text + items.get(j).model.formula + "=" + items.get(j).model.result + "\n";
81+ }
82+ }
83+ Clipboard.push(mimeData);
84 }
85 }
86
87@@ -341,11 +374,11 @@
88 Loader {
89 property var itemModel: model
90 width: parent.width
91- height: model.dbId != -1 ? item.height : 0;
92+ height: model.dbId !== -1 ? item.height : 0;
93 sourceComponent: screenDelegateComponent
94- opacity: ((y+height) >= scrollableView.contentY) && (y <= (scrollableView.contentY + scrollableView.height)) ? 1 : 0
95+ opacity: ((y + height) >= scrollableView.contentY) && (y <= (scrollableView.contentY + scrollableView.height)) ? 1 : 0
96 onOpacityChanged: {
97- if (this.hasOwnProperty('item') && this.item != null) {
98+ if (this.hasOwnProperty('item') && this.item !== null) {
99 if (opacity > 0) {
100 sourceComponent = screenDelegateComponent;
101 } else {

Subscribers

People subscribed via source and target branches