Merge lp:~f-riccardo87/ubuntu-calculator-app/results-appearence into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Riccardo Ferrazzo
Status: Merged
Approved by: Dalius
Approved revision: 36
Merged at revision: 34
Proposed branch: lp:~f-riccardo87/ubuntu-calculator-app/results-appearence
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 232 lines (+45/-57)
5 files modified
Simple/CalcLabel.qml (+7/-0)
Simple/Memory.qml (+0/-1)
Simple/Screen.qml (+22/-38)
Simple/SimplePage.qml (+16/-17)
Storage.qml (+0/-1)
To merge this branch: bzr merge lp:~f-riccardo87/ubuntu-calculator-app/results-appearence
Reviewer Review Type Date Requested Status
Dalius (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+154159@code.launchpad.net

Commit message

Orange text only for user inputs, every label editable, addFromMemory function restored

Description of the change

Changes:
- Orange text used only for user inputs
- Total label editable
- addFromMemory() function now works again

To post a comment you must log in.
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
Dalius (dalius-sandbox) wrote :

Good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Simple/CalcLabel.qml'
--- Simple/CalcLabel.qml 2013-03-14 09:38:40 +0000
+++ Simple/CalcLabel.qml 2013-03-19 18:11:22 +0000
@@ -49,4 +49,11 @@
49 font.family: "Ubuntu"49 font.family: "Ubuntu"
50 }50 }
51 }51 }
52
53 MouseArea{
54 anchors.fill: parent
55 onClicked: {
56 addFromMemory(root.numbers)
57 }
58 }
52}59}
5360
=== modified file 'Simple/Memory.qml'
--- Simple/Memory.qml 2013-03-09 14:23:13 +0000
+++ Simple/Memory.qml 2013-03-19 18:11:22 +0000
@@ -6,7 +6,6 @@
6 ListElement {6 ListElement {
7 dbId: -17 dbId: -1
8 isLastItem: true8 isLastItem: true
9 answer: ''
10 operators: []9 operators: []
11 mainLabel: ''10 mainLabel: ''
12 }11 }
1312
=== modified file 'Simple/Screen.qml'
--- Simple/Screen.qml 2013-03-16 09:18:09 +0000
+++ Simple/Screen.qml 2013-03-19 18:11:22 +0000
@@ -2,6 +2,8 @@
2import Ubuntu.Components 0.12import Ubuntu.Components 0.1
3import Ubuntu.Components.ListItems 0.13import Ubuntu.Components.ListItems 0.1
44
5//TODO: reuse a number clicking on it
6
5Item{7Item{
6 id: root8 id: root
7 height: _content.height + divider.height9 height: _content.height + divider.height
@@ -21,7 +23,6 @@
21 id: inputs23 id: inputs
22 anchors.top: parent.top24 anchors.top: parent.top
23 anchors.topMargin: units.gu(2)25 anchors.topMargin: units.gu(2)
24 spacing: units.gu(0.5)
25 width: parent.width - units.gu(4)26 width: parent.width - units.gu(4)
26 anchors.centerIn: parent27 anchors.centerIn: parent
2728
@@ -40,44 +41,27 @@
40 Repeater{41 Repeater{
41 id: repeater42 id: repeater
42 model: ops43 model: ops
43 CalcLabel {44 Column{
44 id: formulaLabel45 width: parent.width
45 labelText: _text46 spacing: units.gu(0.5)
46 numbers: _number47 Rectangle{
47 operation: _operation48 visible: (_operation == '=')
48 numbersColor: (answer === '' && index === repeater.model.count-1) ? "#dd4814" : "#757373"49 height: units.gu(0.1)
49 numbersHeight: (answer === '' && index === repeater.model.count-1) ? units.gu(7) : units.gu(4)50 width: formulaLabel.operationsWidth
5051 anchors.right: parent.right
51 onLabelTextChanged: {52 color: '#757373'
52 root.labelTextUpdated(index, labelText)
53 }53 }
54 }54 CalcLabel {
55 }55 id: formulaLabel
5656 labelText: _text
57 Rectangle{57 numbers: _number
58 visible: answerLabel.visible58 operation: _operation
59 height: units.gu(0.1)59 numbersColor: (isLastItem && index === repeater.model.count-1) ? "#dd4814" : "#757373"
60 width: answerLabel.operationsWidth60 numbersHeight: (isLastItem && index === repeater.model.count-1) ? units.gu(7) : units.gu(4)
61 anchors.right: parent.right61
62 color: '#757373'62 onLabelTextChanged: {
63 }63 root.labelTextUpdated(index, labelText)
6464 }
65 CalcLabel {
66 id: answerLabel
67 visible: (answer !== '')
68 numbers: answer
69 labelReadOnly: true
70 labelText: i18n.tr("Total")
71 numbersColor: "#dd4814"
72 numbersHeight: units.gu(7)
73
74 MouseArea {
75 id: screenMA
76 enabled: !isLastItem
77 anchors.fill: parent
78 onClicked: {
79 if (answer.indexOf('error') === -1)
80 root.useAnswer(answer, formula_data)
81 }65 }
82 }66 }
83 }67 }
8468
=== modified file 'Simple/SimplePage.qml'
--- Simple/SimplePage.qml 2013-03-18 15:39:31 +0000
+++ Simple/SimplePage.qml 2013-03-19 18:11:22 +0000
@@ -6,7 +6,6 @@
66
7 property var context: new CALC.Context;7 property var context: new CALC.Context;
8 property var scanner: new CALC.Scanner(engineFormula.join(''), context);8 property var scanner: new CALC.Scanner(engineFormula.join(''), context);
9 property string answer: ''
10 property var screenFormula: [{_text:'', _operation: '', _number:''}]9 property var screenFormula: [{_text:'', _operation: '', _number:''}]
11 property var engineFormula: ['']10 property var engineFormula: ['']
1211
@@ -110,10 +109,11 @@
110 if(exception instanceof CALC.DivisionByZeroError){109 if(exception instanceof CALC.DivisionByZeroError){
111 result = "division by zero error";110 result = "division by zero error";
112 } else if(exception instanceof SyntaxError){111 } else if(exception instanceof SyntaxError){
113 result = "";112 return;
114 }113 }
115 }114 }
116 answer = result;115 screenFormula.push({_text:'', _operation: '=', _number:result.toString()});
116 formulaView.currentOperatorsChanged();
117 }117 }
118118
119 function remove(index){119 function remove(index){
@@ -123,17 +123,20 @@
123 }123 }
124124
125 function clear(){125 function clear(){
126 answer = '';
127 screenFormula = [{_text:'', _operation: '', _number:''}];126 screenFormula = [{_text:'', _operation: '', _number:''}];
128 engineFormula = [''];127 engineFormula = [''];
129 scanner = new CALC.Scanner(engineFormula.join(''), context);128 scanner = new CALC.Scanner(engineFormula.join(''), context);
130 formulaView.currentOperatorsChanged();129 formulaView.currentOperatorsChanged();
131 }130 }
132131
133 function addFromMemory(answerToAdd, formulaData) {132 function addFromMemory(numberToAdd) {
134 if (answerToAdd !== '' && answerToAdd.indexOf('error') === -1 && answerToAdd.indexOf('∞') === -1) {133 try{
135 for (var i = 0; i < answerToAdd.length; i++)134 var temp = new CALC.Scanner(numberToAdd, context);
136 formulaPush(answerToAdd[i], answerToAdd[i], answerToAdd[i] === '.' ? 'real' : 'number')135 }catch(e){
136 return;
137 }
138 if(temp.tokens.length === 1 && temp.tokens.last().type === CALC.T_NUMBER){
139 formulaPush(numberToAdd, numberToAdd);
137 }140 }
138 }141 }
139142
@@ -147,16 +150,15 @@
147 clip: true150 clip: true
148151
149 signal currentOperatorsChanged()152 signal currentOperatorsChanged()
150 property string currentAnswer: answer
151153
152 function addCurrentToMemory() {154 function addCurrentToMemory() {
153 if (answer !== '') {155 if (screenFormula[screenFormula.length-1]._operation === '=') {
154 var currentDate = new Date();156 var currentDate = new Date();
155 if (memory.get(0).mainLabel.length == 0)157 if (memory.get(0).mainLabel.length == 0)
156 memory.get(0).mainLabel = currentDate.toString();158 memory.get(0).mainLabel = currentDate.toString();
157 memory.get(0).isLastItem = false159 memory.get(0).isLastItem = false
158 memory.setProperty(0, "timeStamp", currentDate.getTime());160 memory.setProperty(0, "timeStamp", currentDate.getTime());
159 memory.insert(0,{'dbId': -1, 'answer': '', 'operators': [{_text:'', _operation:'', _number:''}], 'isLastItem': true, 'mainLabel': ''});161 memory.insert(0,{'dbId': -1, 'operators': [{_text:'', _operation:'', _number:''}], 'isLastItem': true, 'mainLabel': ''});
160 positionViewAtBeginning();162 positionViewAtBeginning();
161 }163 }
162 }164 }
@@ -180,14 +182,10 @@
180 }182 }
181183
182 onCurrentOperatorsChanged: {184 onCurrentOperatorsChanged: {
183 memory.get(0).operators = screenFormula185 memory.set(0, {"operators": screenFormula});
184 positionViewAtBeginning();186 positionViewAtBeginning();
185 }187 }
186188
187 onCurrentAnswerChanged: {
188 memory.get(0).answer = currentAnswer
189 }
190
191 model: Memory{189 model: Memory{
192 id: memory190 id: memory
193 Component.onCompleted: {191 Component.onCompleted: {
@@ -208,6 +206,7 @@
208 onMainLabelUpdated: {206 onMainLabelUpdated: {
209 memory.get(index).mainLabel = newText;207 memory.get(index).mainLabel = newText;
210 }208 }
209
211 onLabelTextUpdated: {210 onLabelTextUpdated: {
212 if(index === 0){211 if(index === 0){
213 screenFormula[idx]._text = newText;212 screenFormula[idx]._text = newText;
@@ -215,6 +214,7 @@
215 }214 }
216 memory.get(index).operators.get(idx)._text = newText;215 memory.get(index).operators.get(idx)._text = newText;
217 }216 }
217
218 onRemoveItem: {218 onRemoveItem: {
219 storage.removeCalculation(memory.get(index));219 storage.removeCalculation(memory.get(index));
220 memory.remove(index)220 memory.remove(index)
@@ -246,7 +246,6 @@
246 var newElement = {'dbId': memory.get(i).dbId,246 var newElement = {'dbId': memory.get(i).dbId,
247 'isLastItem': false,247 'isLastItem': false,
248 'mainLabel': memory.get(i).mainLabel,248 'mainLabel': memory.get(i).mainLabel,
249 'answer': memory.get(i).answer,
250 'operators': newop};249 'operators': newop};
251 calculations.push({"calc": newElement, "date": memory.get(i).timeStamp})250 calculations.push({"calc": newElement, "date": memory.get(i).timeStamp})
252 }251 }
253252
=== modified file 'Storage.qml'
--- Storage.qml 2013-03-11 22:33:27 +0000
+++ Storage.qml 2013-03-19 18:11:22 +0000
@@ -1,4 +1,3 @@
1//TODO: modify saved calculations text
2import QtQuick 2.01import QtQuick 2.0
3import QtQuick.LocalStorage 2.02import QtQuick.LocalStorage 2.0
43

Subscribers

People subscribed via source and target branches