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
1=== modified file 'Simple/CalcLabel.qml'
2--- Simple/CalcLabel.qml 2013-03-14 09:38:40 +0000
3+++ Simple/CalcLabel.qml 2013-03-19 18:11:22 +0000
4@@ -49,4 +49,11 @@
5 font.family: "Ubuntu"
6 }
7 }
8+
9+ MouseArea{
10+ anchors.fill: parent
11+ onClicked: {
12+ addFromMemory(root.numbers)
13+ }
14+ }
15 }
16
17=== modified file 'Simple/Memory.qml'
18--- Simple/Memory.qml 2013-03-09 14:23:13 +0000
19+++ Simple/Memory.qml 2013-03-19 18:11:22 +0000
20@@ -6,7 +6,6 @@
21 ListElement {
22 dbId: -1
23 isLastItem: true
24- answer: ''
25 operators: []
26 mainLabel: ''
27 }
28
29=== modified file 'Simple/Screen.qml'
30--- Simple/Screen.qml 2013-03-16 09:18:09 +0000
31+++ Simple/Screen.qml 2013-03-19 18:11:22 +0000
32@@ -2,6 +2,8 @@
33 import Ubuntu.Components 0.1
34 import Ubuntu.Components.ListItems 0.1
35
36+//TODO: reuse a number clicking on it
37+
38 Item{
39 id: root
40 height: _content.height + divider.height
41@@ -21,7 +23,6 @@
42 id: inputs
43 anchors.top: parent.top
44 anchors.topMargin: units.gu(2)
45- spacing: units.gu(0.5)
46 width: parent.width - units.gu(4)
47 anchors.centerIn: parent
48
49@@ -40,44 +41,27 @@
50 Repeater{
51 id: repeater
52 model: ops
53- CalcLabel {
54- id: formulaLabel
55- labelText: _text
56- numbers: _number
57- operation: _operation
58- numbersColor: (answer === '' && index === repeater.model.count-1) ? "#dd4814" : "#757373"
59- numbersHeight: (answer === '' && index === repeater.model.count-1) ? units.gu(7) : units.gu(4)
60-
61- onLabelTextChanged: {
62- root.labelTextUpdated(index, labelText)
63+ Column{
64+ width: parent.width
65+ spacing: units.gu(0.5)
66+ Rectangle{
67+ visible: (_operation == '=')
68+ height: units.gu(0.1)
69+ width: formulaLabel.operationsWidth
70+ anchors.right: parent.right
71+ color: '#757373'
72 }
73- }
74- }
75-
76- Rectangle{
77- visible: answerLabel.visible
78- height: units.gu(0.1)
79- width: answerLabel.operationsWidth
80- anchors.right: parent.right
81- color: '#757373'
82- }
83-
84- CalcLabel {
85- id: answerLabel
86- visible: (answer !== '')
87- numbers: answer
88- labelReadOnly: true
89- labelText: i18n.tr("Total")
90- numbersColor: "#dd4814"
91- numbersHeight: units.gu(7)
92-
93- MouseArea {
94- id: screenMA
95- enabled: !isLastItem
96- anchors.fill: parent
97- onClicked: {
98- if (answer.indexOf('error') === -1)
99- root.useAnswer(answer, formula_data)
100+ CalcLabel {
101+ id: formulaLabel
102+ labelText: _text
103+ numbers: _number
104+ operation: _operation
105+ numbersColor: (isLastItem && index === repeater.model.count-1) ? "#dd4814" : "#757373"
106+ numbersHeight: (isLastItem && index === repeater.model.count-1) ? units.gu(7) : units.gu(4)
107+
108+ onLabelTextChanged: {
109+ root.labelTextUpdated(index, labelText)
110+ }
111 }
112 }
113 }
114
115=== modified file 'Simple/SimplePage.qml'
116--- Simple/SimplePage.qml 2013-03-18 15:39:31 +0000
117+++ Simple/SimplePage.qml 2013-03-19 18:11:22 +0000
118@@ -6,7 +6,6 @@
119
120 property var context: new CALC.Context;
121 property var scanner: new CALC.Scanner(engineFormula.join(''), context);
122- property string answer: ''
123 property var screenFormula: [{_text:'', _operation: '', _number:''}]
124 property var engineFormula: ['']
125
126@@ -110,10 +109,11 @@
127 if(exception instanceof CALC.DivisionByZeroError){
128 result = "division by zero error";
129 } else if(exception instanceof SyntaxError){
130- result = "";
131+ return;
132 }
133 }
134- answer = result;
135+ screenFormula.push({_text:'', _operation: '=', _number:result.toString()});
136+ formulaView.currentOperatorsChanged();
137 }
138
139 function remove(index){
140@@ -123,17 +123,20 @@
141 }
142
143 function clear(){
144- answer = '';
145 screenFormula = [{_text:'', _operation: '', _number:''}];
146 engineFormula = [''];
147 scanner = new CALC.Scanner(engineFormula.join(''), context);
148 formulaView.currentOperatorsChanged();
149 }
150
151- function addFromMemory(answerToAdd, formulaData) {
152- if (answerToAdd !== '' && answerToAdd.indexOf('error') === -1 && answerToAdd.indexOf('∞') === -1) {
153- for (var i = 0; i < answerToAdd.length; i++)
154- formulaPush(answerToAdd[i], answerToAdd[i], answerToAdd[i] === '.' ? 'real' : 'number')
155+ function addFromMemory(numberToAdd) {
156+ try{
157+ var temp = new CALC.Scanner(numberToAdd, context);
158+ }catch(e){
159+ return;
160+ }
161+ if(temp.tokens.length === 1 && temp.tokens.last().type === CALC.T_NUMBER){
162+ formulaPush(numberToAdd, numberToAdd);
163 }
164 }
165
166@@ -147,16 +150,15 @@
167 clip: true
168
169 signal currentOperatorsChanged()
170- property string currentAnswer: answer
171
172 function addCurrentToMemory() {
173- if (answer !== '') {
174+ if (screenFormula[screenFormula.length-1]._operation === '=') {
175 var currentDate = new Date();
176 if (memory.get(0).mainLabel.length == 0)
177 memory.get(0).mainLabel = currentDate.toString();
178 memory.get(0).isLastItem = false
179 memory.setProperty(0, "timeStamp", currentDate.getTime());
180- memory.insert(0,{'dbId': -1, 'answer': '', 'operators': [{_text:'', _operation:'', _number:''}], 'isLastItem': true, 'mainLabel': ''});
181+ memory.insert(0,{'dbId': -1, 'operators': [{_text:'', _operation:'', _number:''}], 'isLastItem': true, 'mainLabel': ''});
182 positionViewAtBeginning();
183 }
184 }
185@@ -180,14 +182,10 @@
186 }
187
188 onCurrentOperatorsChanged: {
189- memory.get(0).operators = screenFormula
190+ memory.set(0, {"operators": screenFormula});
191 positionViewAtBeginning();
192 }
193
194- onCurrentAnswerChanged: {
195- memory.get(0).answer = currentAnswer
196- }
197-
198 model: Memory{
199 id: memory
200 Component.onCompleted: {
201@@ -208,6 +206,7 @@
202 onMainLabelUpdated: {
203 memory.get(index).mainLabel = newText;
204 }
205+
206 onLabelTextUpdated: {
207 if(index === 0){
208 screenFormula[idx]._text = newText;
209@@ -215,6 +214,7 @@
210 }
211 memory.get(index).operators.get(idx)._text = newText;
212 }
213+
214 onRemoveItem: {
215 storage.removeCalculation(memory.get(index));
216 memory.remove(index)
217@@ -246,7 +246,6 @@
218 var newElement = {'dbId': memory.get(i).dbId,
219 'isLastItem': false,
220 'mainLabel': memory.get(i).mainLabel,
221- 'answer': memory.get(i).answer,
222 'operators': newop};
223 calculations.push({"calc": newElement, "date": memory.get(i).timeStamp})
224 }
225
226=== modified file 'Storage.qml'
227--- Storage.qml 2013-03-11 22:33:27 +0000
228+++ Storage.qml 2013-03-19 18:11:22 +0000
229@@ -1,4 +1,3 @@
230-//TODO: modify saved calculations text
231 import QtQuick 2.0
232 import QtQuick.LocalStorage 2.0
233

Subscribers

People subscribed via source and target branches