Merge lp:~rpadovani/ubuntu-calculator-app/1214395 into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
- 1214395
- Merge into old_trunk
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Gustavo Pichorim Boiko | ||||||||||||
Approved revision: | 158 | ||||||||||||
Merged at revision: | 151 | ||||||||||||
Proposed branch: | lp:~rpadovani/ubuntu-calculator-app/1214395 | ||||||||||||
Merge into: | lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk | ||||||||||||
Diff against target: |
584 lines (+79/-200) 9 files modified
Simple/CalcKeyboard.qml (+0/-1) Simple/CalcLabel.qml (+14/-35) Simple/KeyboardButton.qml (+0/-1) Simple/Screen.qml (+27/-30) Simple/SimplePage.qml (+8/-17) Storage.qml (+5/-2) bignumber.js (+9/-8) dateutils.js (+0/-99) engine.js (+16/-7) |
||||||||||||
To merge this branch: | bzr merge lp:~rpadovani/ubuntu-calculator-app/1214395 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Nekhelesh Ramananthan (community) | Needs Information | ||
Mihir Soni | Needs Fixing | ||
Review via email: mp+184440@code.launchpad.net |
Commit message
New design guideline
Description of the change
Implementation of new design guideline:
- One pencil icon acting as toggle to change between edit and normal view for labels
- Restrict the number of characters for labelling to 12 characters, header to 20 characters.
- Restrict the number of digits of calculation to 11 digits.
- Time of calc is now inline with title label
- Removed Timer and DateUtils that are no longer required with new design
- Removed font.family, no longer necessary
Fixed #1219718
Fixed #1214395
Fixed #1222144
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
- 150. By Riccardo Padovani
-
Update label
- 151. By Riccardo Padovani
-
New time format
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:151
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Mihir Soni (mihirsoni) wrote : | # |
Thank you for your fix, it needs some changes as follow :
1.When we try to edit header it overlaps edit icon & cursor.
2.We have to keep only date on right side ( No few seconds ago)
3.Dates should be visible when user start calculation (Need some inputs from boiko,dpm or popey)
- 152. By Riccardo Padovani
-
Fixed two issues with new design, removed Timer and DateUtils
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:152
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
Hi Mihir, thanks for your review.
I fixed 1 and 2, but I'm not sure to have understand about three, we need a clock updated every minute to show current hour? I think is not a good idea...
Mihir Soni (mihirsoni) wrote : | # |
Ricacardo , This is what we had discussion in our last design meeting still we need inputs.
Also, we have to make our result to 11 Digits inclusive of exponential.
We have to confirm this things first and then we can move further.
Thank you.
Mihir Soni (mihirsoni) wrote : | # |
Sorry , Third might be my misunderstanding. We can skip that..Can we make our result to 11 digits ? so that
- 153. By Riccardo Padovani
-
Activated the exp result
Riccardo Padovani (rpadovani) wrote : | # |
I have updated bignumber.js to have exp result when the lenght of result is > 11, but I have a doubt on how to limit the lenght of exp result to 11 digits, so I have ask to the developer.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:153
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 154. By Riccardo Padovani
-
Set max lenght for exponential form
Riccardo Padovani (rpadovani) wrote : | # |
Thanks to the fast answer of the dev I have implemented it.
Now I think is all ok.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:154
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Mihir Soni (mihirsoni) wrote : | # |
Hi Riccardo , this is awesome work and it's working superb on my machine.
Could you do one small change :-
1.Operands labels are length of 11 only , can we make underline accordingly , it looks too messy you can find in attached screenshot.
Mihir Soni (mihirsoni) wrote : | # |
Riccardo , I did some more testing and found a bug :-
Steps to reproduce :-
Start new calculation with 89*89 press (=)
Output should be 7921 , but current output is 7921.000000
Nekhelesh Ramananthan (nik90) wrote : | # |
I have 2 questions, the first being why do you explicitly state the font family? Isnt the Ubuntu font the default? (This is more a question since I do know it either)
font.family: "Ubuntu"
Also why do you Text {} instead of Label {} to display the date or anything? I think since Label is part of the SDK, it will automatically follow the SDK design styles. Correct me if I am wrong.
Nekhelesh Ramananthan (nik90) wrote : | # |
I meant above that I *did not* know it either.
Riccardo Padovani (rpadovani) wrote : | # |
Thanks for your observation Nik, I removed all font.family, I think they were there since there wasn't a theme.
Also, I changed Text in Label, but have a different theme from SDK.
Mihir, I have fixed the bug
- 155. By Riccardo Padovani
-
Bugfixes
- 156. By Riccardo Padovani
-
Minor bugfixes
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:156
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 157. By Riccardo Padovani
-
Update to MAX_LENGHT
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:157
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
48 + width: row.width-
Can you just add some spacing between the operators?
Gustavo Pichorim Boiko (boiko) wrote : | # |
92 + width: parent.width - units.gu(1)/2
isn't it the same as: parent.width - units.gu(0.5)?
Gustavo Pichorim Boiko (boiko) wrote : | # |
114 + width: parent.width / 20 * 11
That's a misterious value, would it be possible to have at least an explanation on what this value means?
- 158. By Riccardo Padovani
-
Updated some widths
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:158
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good to me now!
Preview Diff
1 | === modified file 'Simple/CalcKeyboard.qml' |
2 | --- Simple/CalcKeyboard.qml 2013-06-11 19:33:52 +0000 |
3 | +++ Simple/CalcKeyboard.qml 2013-09-11 10:39:56 +0000 |
4 | @@ -30,7 +30,6 @@ |
5 | visible: formulaView.__wasAtYBegining && formulaView.__displaceDist > units.gu(2) |
6 | font.pixelSize: units.gu(2) |
7 | text: formulaView.__toBeRefresh ? i18n.tr("Release to start new calculation") : i18n.tr("Pull to start new calculation") |
8 | - font.family: "Ubuntu" |
9 | anchors.horizontalCenter: parent.horizontalCenter |
10 | color: '#757373' |
11 | } |
12 | |
13 | === modified file 'Simple/CalcLabel.qml' |
14 | --- Simple/CalcLabel.qml 2013-09-04 15:20:51 +0000 |
15 | +++ Simple/CalcLabel.qml 2013-09-11 10:39:56 +0000 |
16 | @@ -43,31 +43,10 @@ |
17 | id: row |
18 | height: numbersHeight |
19 | width: parent.width |
20 | - Item { |
21 | - id: editIcon |
22 | - height: parent.height |
23 | - width: units.gu(3) |
24 | - |
25 | - Image { |
26 | - anchors.verticalCenter: parent.verticalCenter |
27 | - source: Qt.resolvedUrl("images/edit.png") |
28 | - visible: root.numbers || root.operation |
29 | - } |
30 | - |
31 | - MouseArea { |
32 | - anchors.fill: parent |
33 | - onClicked: { |
34 | - if (root.numbers || root.operation) { |
35 | - numberName.focus = true; |
36 | - numberName.forceActiveFocus(); |
37 | - calcKeyboardVisible = false; |
38 | - } |
39 | - } |
40 | - } |
41 | - } |
42 | - |
43 | - Item { |
44 | - width: row.width-editIcon.width-operatorLabel.width-formulaLabel.width |
45 | + anchors.left: parent.left |
46 | + |
47 | + Item { |
48 | + width: row.width - operatorLabel.width - formulaLabel.width |
49 | height: parent.height |
50 | |
51 | TextField { |
52 | @@ -79,11 +58,11 @@ |
53 | background: Item {} |
54 | } |
55 | |
56 | - visible: root.numbers || root.operation |
57 | - |
58 | onActiveFocusChanged: { |
59 | - if (numberName.activeFocus) |
60 | + if (numberName.activeFocus) { |
61 | + labelVisible = true |
62 | calcKeyboardVisible = false |
63 | + } |
64 | } |
65 | |
66 | readOnly: labelReadOnly |
67 | @@ -91,12 +70,14 @@ |
68 | color: "#FEFEFE" |
69 | onTextChanged: { labelText = numberName.text } |
70 | hasClearButton: false |
71 | + maximumLength: 12 |
72 | |
73 | InverseMouseArea { |
74 | onClicked: { |
75 | root.forceActiveFocus(); |
76 | numberName.focus = false; |
77 | mouse.accepted = false; |
78 | + labelVisible = false; |
79 | calcKeyboardVisible = true; |
80 | } |
81 | anchors.fill: parent; |
82 | @@ -106,23 +87,22 @@ |
83 | } |
84 | |
85 | Image { |
86 | - visible: numberName.focus && (root.numbers || root.operation) |
87 | + visible: labelVisible |
88 | anchors.bottom: parent.bottom |
89 | source: Qt.resolvedUrl("images/dot.png") |
90 | fillMode: Image.Tile |
91 | - width: parent.width-units.gu(1) |
92 | - height: units.gu(1)/2 |
93 | + width: parent.width - units.gu(0.5) |
94 | + height: units.gu(0.5) |
95 | } |
96 | } |
97 | |
98 | Label { |
99 | id: operatorLabel |
100 | - width: units.dp(2) |
101 | + width: units.gu(2) |
102 | anchors.verticalCenter: parent.verticalCenter |
103 | font.pixelSize: FontUtils.sizeToPixels("medium") |
104 | color: "#FEFEFE" |
105 | text: root.operation |
106 | - font.family: "Ubuntu" |
107 | } |
108 | Label { |
109 | id: formulaLabel |
110 | @@ -132,7 +112,7 @@ |
111 | property bool isLast: root.isLast |
112 | |
113 | objectName: "formulaLabel" |
114 | - width: parent.width / 2 |
115 | + width: parent.width / 1.5 |
116 | color: numbersColor |
117 | anchors.bottom: parent.bottom |
118 | font.pixelSize: numbersHeight |
119 | @@ -140,7 +120,6 @@ |
120 | horizontalAlignment: Text.AlignRight |
121 | // If is a new calculation or if last calculation as been deleted print 0, else the number |
122 | text: ((isLast && !newCalculation) || (root.numbers === "" && formulaView.headerItem.state !== "newPush")) ? "0" : root.numbers |
123 | - font.family: "Ubuntu" |
124 | } |
125 | } |
126 | } |
127 | |
128 | === modified file 'Simple/KeyboardButton.qml' |
129 | --- Simple/KeyboardButton.qml 2013-06-11 19:33:52 +0000 |
130 | +++ Simple/KeyboardButton.qml 2013-09-11 10:39:56 +0000 |
131 | @@ -46,7 +46,6 @@ |
132 | anchors.centerIn: parent |
133 | color: "#7474AC" |
134 | font.pixelSize: (calcGridUnit*3) |
135 | - font.family: "Ubuntu" |
136 | font.bold: true |
137 | } |
138 | |
139 | |
140 | === modified file 'Simple/Screen.qml' |
141 | --- Simple/Screen.qml 2013-09-10 17:00:58 +0000 |
142 | +++ Simple/Screen.qml 2013-09-11 10:39:56 +0000 |
143 | @@ -30,10 +30,10 @@ |
144 | |
145 | property var ops |
146 | property bool newCalculation: false |
147 | + property bool labelVisible: false |
148 | signal useAnswer(string answerToUse, string formulaData) |
149 | signal labelTextUpdated(int idx, string newText) |
150 | signal mainLabelUpdated(int idx, string newText) |
151 | - signal dateUpdate(int idx) |
152 | signal removeItem() |
153 | |
154 | Item { |
155 | @@ -62,7 +62,6 @@ |
156 | color: "#9094AA" |
157 | text: _content.x > root.width / 3 ? "Release To Delete" : "Pull To Delete" |
158 | font.italic: true |
159 | - font.family: "Ubuntu" |
160 | } |
161 | } |
162 | } |
163 | @@ -94,7 +93,6 @@ |
164 | color: "#9094AA" |
165 | text: _content.x < -root.width / 3 ? "Release To Delete" : "Pull To Delete" |
166 | font.italic: true |
167 | - font.family: "Ubuntu" |
168 | } |
169 | } |
170 | } |
171 | @@ -114,7 +112,6 @@ |
172 | Text { |
173 | width: parent.width |
174 | horizontalAlignment: Text.AlignHCenter |
175 | - font.family: "Ubuntu" |
176 | color: "#FFFFFF" |
177 | |
178 | text: i18n.tr("Delete this calculation?") |
179 | @@ -145,28 +142,11 @@ |
180 | id: inputs |
181 | anchors.top: parent.top |
182 | anchors.topMargin: units.gu(2) |
183 | - width: parent.width - units.gu(4) |
184 | + width: parent.width - units.gu(3) |
185 | anchors.centerIn: parent |
186 | |
187 | - // Every five minutes update date label |
188 | - Timer { |
189 | - interval: 300000 |
190 | - repeat: true |
191 | - running: true |
192 | - onTriggered: root.dateUpdate(index) |
193 | - } |
194 | - |
195 | - Text { |
196 | - id: dateLabel |
197 | - width: parent.width |
198 | - color: "#9094AA" |
199 | - text: dateText |
200 | - font.italic: true |
201 | - font.family: "Ubuntu" |
202 | - } |
203 | - |
204 | - //Edit Button icon in parent line |
205 | - Row{ |
206 | + //Edit Button icon and time in parent line |
207 | + Item { |
208 | id: row |
209 | height: units.gu(4) |
210 | width: parent.width |
211 | @@ -185,12 +165,13 @@ |
212 | onClicked: { |
213 | title.focus = true; |
214 | title.forceActiveFocus(); |
215 | + labelVisible = true |
216 | calcKeyboardVisible = false; |
217 | } |
218 | } |
219 | } |
220 | Item { |
221 | - width: parent.width |
222 | + width: parent.width / 2 |
223 | height: parent.height |
224 | |
225 | TextField { |
226 | @@ -198,6 +179,7 @@ |
227 | objectName: "title" |
228 | width: parent.width |
229 | anchors.verticalCenter: parent.verticalCenter |
230 | + x: units.gu(3) |
231 | // removes ubuntu shape |
232 | style: TextFieldStyle { |
233 | background: Item {} |
234 | @@ -208,15 +190,20 @@ |
235 | hasClearButton: false |
236 | font.pixelSize: FontUtils.sizeToPixels("medium") |
237 | |
238 | + maximumLength: 20; |
239 | + |
240 | onActiveFocusChanged: { |
241 | - if (title.activeFocus) |
242 | - calcKeyboardVisible = false |
243 | + if (title.activeFocus) { |
244 | + labelVisible = true; |
245 | + calcKeyboardVisible = false; |
246 | + } |
247 | } |
248 | |
249 | InverseMouseArea { |
250 | onClicked: { |
251 | title.focus = false; |
252 | mouse.accepted = false; |
253 | + labelVisible = false; |
254 | calcKeyboardVisible = true; |
255 | } |
256 | anchors.fill: parent; |
257 | @@ -226,14 +213,24 @@ |
258 | } |
259 | |
260 | Image { |
261 | - visible: title.focus |
262 | + visible: labelVisible |
263 | anchors.bottom: parent.bottom |
264 | + x: units.gu(3) |
265 | source: Qt.resolvedUrl("images/dot.png") |
266 | fillMode: Image.Tile |
267 | - width: parent.width-units.gu(1) |
268 | - height: units.gu(1)/2 |
269 | + width: parent.width - units.gu(1.5) |
270 | + height: units.gu(0.5) |
271 | } |
272 | } |
273 | + |
274 | + Label { |
275 | + id: dateLabel |
276 | + height: parent.height |
277 | + anchors.right: parent.right |
278 | + color: "#9094AA" |
279 | + text: dateText |
280 | + font.capitalization: Font.AllUppercase |
281 | + } |
282 | } |
283 | |
284 | Repeater{ |
285 | |
286 | === modified file 'Simple/SimplePage.qml' |
287 | --- Simple/SimplePage.qml 2013-09-10 17:00:58 +0000 |
288 | +++ Simple/SimplePage.qml 2013-09-11 10:39:56 +0000 |
289 | @@ -20,7 +20,6 @@ |
290 | import Ubuntu.Components 0.1 |
291 | import "../engine.js" as CALC |
292 | import "../formula.js" as F |
293 | -import "../dateutils.js" as DateUtils |
294 | |
295 | Page { |
296 | |
297 | @@ -139,7 +138,7 @@ |
298 | if (memory.get(0).mainLabel.length === 0) |
299 | memory.get(0).mainLabel = ''; |
300 | memory.get(0).isLastItem = false |
301 | - memory.get(0).dateText = i18n.tr("A few seconds ago...") |
302 | + memory.get(0).dateText = Qt.formatDateTime(currentDate, i18n.tr("dd MMM yy, hh:mm")) |
303 | memory.get(0).timeStamp = currentDate.getTime() |
304 | memory.setProperty(0, "timeStamp", currentDate.getTime()); |
305 | memory.insert(0,{'dbId': -1, 'dateText': "", 'operators': [{_text:'', _operation:'', _number:''}], 'isLastItem': true, 'mainLabel': ''}); |
306 | @@ -149,11 +148,13 @@ |
307 | } |
308 | } |
309 | |
310 | - function showError() { |
311 | - animateError.start() |
312 | - } |
313 | - |
314 | - PropertyAnimation {id: animateError; target: formulaView; properties: "color"; from: "#FFA0A0"; to: "#FFFFFF"; duration: 100} |
315 | + |
316 | +// Only for Scientific Calculator |
317 | +// function showError() { |
318 | +// animateError.start() |
319 | +// } |
320 | + |
321 | +// PropertyAnimation {id: animateError; target: formulaView; properties: "color"; from: "#FFA0A0"; to: "#FFFFFF"; duration: 100} |
322 | |
323 | remove: Transition{ |
324 | NumberAnimation {property: "opacity"; to: 0; duration: 200 } |
325 | @@ -196,16 +197,6 @@ |
326 | memory.get(index).mainLabel = newText; |
327 | } |
328 | |
329 | - // Update date label |
330 | - onDateUpdate: { |
331 | - // If is in database |
332 | - if (memory.get(index).dbId !== -1) |
333 | - memory.get(index).dateText = DateUtils.formatRelativeTime(i18n, storage.fromIdToDate(memory.get(index).dbId)); |
334 | - // If is in memory but not in database |
335 | - else if (memory.get(index).timeStamp) |
336 | - memory.get(index).dateText = DateUtils.formatRelativeTime(i18n, memory.get(index).timeStamp); |
337 | - } |
338 | - |
339 | onLabelTextUpdated: { |
340 | if(index === 0){ |
341 | screenFormula[idx]._text = newText; |
342 | |
343 | === modified file 'Storage.qml' |
344 | --- Storage.qml 2013-08-29 13:15:11 +0000 |
345 | +++ Storage.qml 2013-09-11 10:39:56 +0000 |
346 | @@ -18,7 +18,6 @@ |
347 | |
348 | import QtQuick 2.0 |
349 | import QtQuick.LocalStorage 2.0 |
350 | -import "./dateutils.js" as DateUtils |
351 | |
352 | Item { |
353 | property var db: null |
354 | @@ -83,7 +82,7 @@ |
355 | for(var i=res.rows.length - 1; i >= 0; i--){ |
356 | var obj = JSON.parse(res.rows.item(i).calc); |
357 | obj.dbId = res.rows.item(i).id; |
358 | - obj.dateText = DateUtils.formatRelativeTime(i18n, res.rows.item(i).insertDate); |
359 | + obj.dateText = Qt.formatDateTime(parseDate(res.rows.item(i).insertDate), i18n.tr("dd MMM yy, hh:mm")) |
360 | |
361 | if (!('mainLabel' in obj)) |
362 | obj.mainLabel = '' |
363 | @@ -94,6 +93,10 @@ |
364 | ); |
365 | } |
366 | |
367 | + function parseDate(dateAsStr) { |
368 | + return new Date(dateAsStr); |
369 | + } |
370 | + |
371 | function saveCalculations(calculations){ |
372 | openDB(); |
373 | var res; |
374 | |
375 | === modified file 'bignumber.js' |
376 | --- bignumber.js 2013-07-16 17:28:19 +0000 |
377 | +++ bignumber.js 2013-09-11 10:39:56 +0000 |
378 | @@ -55,8 +55,9 @@ |
379 | TO_EXP_NEG = -7, // 0 to -MAX |
380 | |
381 | // The exponent value at and above which toString returns exponential notation. |
382 | - // Number type: 21 |
383 | - TO_EXP_POS = 21, // 0 to MAX |
384 | + // Number type: 11 |
385 | + // Default: 21 |
386 | + TO_EXP_POS = 11, // 0 to MAX |
387 | |
388 | // RANGE : [MIN_EXP, MAX_EXP] |
389 | |
390 | @@ -158,9 +159,9 @@ |
391 | if ( j = new RegExp( '^' + i + '(?:\\.' + i + ')?$', 'i' ).test(n) ) { |
392 | |
393 | if ( isNum ) { |
394 | - if ( n.replace('.', '').length > 15 ) { |
395 | + if ( n.replace('.', '').length > 11 ) { |
396 | |
397 | - // 'new BigNumber() number type has more than 15 significant digits: {n}' |
398 | + // 'new BigNumber() number type has more than 11 significant digits: {n}' |
399 | ifExceptionsThrow( n, 0 ) |
400 | } |
401 | |
402 | @@ -230,10 +231,10 @@ |
403 | i = n.length |
404 | } |
405 | |
406 | - // Disallow numbers over 15 digits if number type. |
407 | - if ( b = n.length, isNum && b > 15 ) { |
408 | + // Disallow numbers over 11 digits if number type. |
409 | + if ( b = n.length, isNum && b > 11 ) { |
410 | |
411 | - // 'new BigNumber() number type has more than 15 significant digits: {n}' |
412 | + // 'new BigNumber() number type has more than 11 significant digits: {n}' |
413 | ifExceptionsThrow( n, 0 ) |
414 | } |
415 | |
416 | @@ -411,7 +412,7 @@ |
417 | ( isRange ? ' non-zero' : 'n' ) + ' integer'; |
418 | |
419 | error = ( [ |
420 | - method + ' number type has more than 15 significant digits', |
421 | + method + ' number type has more than 11 significant digits', |
422 | method + ' not a base ' + j + ' number', |
423 | method + ' base' + error, |
424 | method + ' not a number' ][i] || |
425 | |
426 | === removed file 'dateutils.js' |
427 | --- dateutils.js 2013-07-30 17:06:03 +0000 |
428 | +++ dateutils.js 1970-01-01 00:00:00 +0000 |
429 | @@ -1,99 +0,0 @@ |
430 | -/* |
431 | - * Copyright 2013 Canonical Ltd. |
432 | - * |
433 | - * This file is part of ubuntu-rssreader-app. |
434 | - * |
435 | - * ubuntu-calculator-app is free software; you can redistribute it and/or modify |
436 | - * it under the terms of the GNU General Public License as published by |
437 | - * the Free Software Foundation; version 3. |
438 | - * |
439 | - * ubuntu-calculator-app is distributed in the hope that it will be useful, |
440 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
441 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
442 | - * GNU General Public License for more details. |
443 | - * |
444 | - * You should have received a copy of the GNU General Public License |
445 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
446 | - */ |
447 | - |
448 | -.pragma library |
449 | - |
450 | -var SECONDS_LIMIT = 60 * 1000; // used as reference |
451 | -var MINUTES_LIMIT = 60 * SECONDS_LIMIT; // print minutes up to 1h |
452 | -var HOURS_LIMIT = 12 * MINUTES_LIMIT; // print hours up to 12h |
453 | -var DAY_LIMIT = 24 * MINUTES_LIMIT; // print '<val> days ago' up to 30 days back |
454 | -var DAYS_LIMIT = 30 * DAY_LIMIT; // print '<val> days ago' up to 30 days back |
455 | - |
456 | -function parseDate(dateAsStr) { |
457 | - return new Date(dateAsStr); |
458 | -} |
459 | - |
460 | -function formatRelativeTime(i18n, dateAsStr) { |
461 | - // fallback if none of the other formatters matched |
462 | - function defaultFallbackFormat(then) { |
463 | - return Qt.formatDateTime(then, i18n.tr("MMMM d")) |
464 | - } |
465 | - |
466 | - // Simple matches all diffs < limit, formats using the format function. |
467 | - function SimpleFormatter(limit, format) { |
468 | - this.matches = function (now, then, diff) { return diff < limit } |
469 | - this.format = format |
470 | - } |
471 | - |
472 | - // Matches yesterday date |
473 | - function YesterdayFormatter() { |
474 | - this.matches = function (now, then, diff) { |
475 | - return diff < DAY_LIMIT && now.getDate() !== then.getDate(); |
476 | - } |
477 | - this.format = function (now, then, diff) { |
478 | - return i18n.tr("Yesterday at %1").arg( |
479 | - Qt.formatDateTime(then, i18n.tr("h:mm AP"))) |
480 | - } |
481 | - } |
482 | - |
483 | - // Matches up to 7 days ago (formats date as a weekday + time) |
484 | - function WeekFormatter() { |
485 | - this.matches = function (now, then, diff) { |
486 | - return diff < 7 * DAY_LIMIT |
487 | - } |
488 | - this.format = function (now, then, diff) { |
489 | - return Qt.formatDateTime(then, i18n.tr("ddd, h:mm AP")); |
490 | - } |
491 | - } |
492 | - |
493 | - // An array of formatting object processed from 0 up to a matching object. |
494 | - // If none of the object matches a default fallback formatter will be used. |
495 | - var FORMATTERS = [ |
496 | - new SimpleFormatter(SECONDS_LIMIT, function (now, then, diff) { return i18n.tr("A few seconds ago...") }), |
497 | - new SimpleFormatter(MINUTES_LIMIT, function (now, then, diff) { |
498 | - var val = Math.floor(diff / SECONDS_LIMIT) |
499 | - return i18n.tr("%1 minute ago", "%1 minutes ago", val).arg(val) |
500 | - }), |
501 | - new SimpleFormatter(HOURS_LIMIT, function (now, then, diff) { |
502 | - var val = Math.floor(diff / MINUTES_LIMIT) |
503 | - return i18n.tr("%1 hour ago", "%1 hours ago", val).arg(val) |
504 | - }), |
505 | - new YesterdayFormatter(), |
506 | - new WeekFormatter(), |
507 | - new SimpleFormatter(DAYS_LIMIT, function (now, then, diff) { |
508 | - var val = Math.floor(diff / DAY_LIMIT) |
509 | - return i18n.tr("%1 day ago", "%1 days ago", val).arg(val) |
510 | - }) |
511 | - ] |
512 | - |
513 | - function formatDiff(now, then, diff) { |
514 | - for (var i=0; i<FORMATTERS.length; ++i) { |
515 | - var formatter = FORMATTERS[i] |
516 | - if (formatter.matches(now, then, diff)) { |
517 | - return formatter.format(now, then, diff) |
518 | - } |
519 | - } |
520 | - return defaultFallbackFormat(then) |
521 | - } |
522 | - |
523 | - var now = new Date(); |
524 | - var then = parseDate(dateAsStr); |
525 | - var diff = now - then; |
526 | - var formattedDiff = formatDiff(now, then, diff); |
527 | - return formattedDiff; |
528 | -} |
529 | |
530 | === modified file 'engine.js' |
531 | --- engine.js 2013-07-16 17:28:19 +0000 |
532 | +++ engine.js 2013-09-11 10:39:56 +0000 |
533 | @@ -23,7 +23,9 @@ |
534 | |
535 | // ---------------------------------------- |
536 | // constants (const keyword is not working) |
537 | -var MAX_DECIMAL = 13; // Number of maximum decimal positions |
538 | +var MAX_DECIMAL = 5; // Number of maximum decimal positions |
539 | +var PRECISION = 8 // Max lenght of result in exponential mode |
540 | +var MAX_LENGHT = 100000000000 // Highest number before exponential mode |
541 | |
542 | var RAD = 0, DEG = 1, GRAD = 2; //Trigonometric functions |
543 | |
544 | @@ -544,27 +546,34 @@ |
545 | |
546 | op: function op(type, lhs, rhs) { |
547 | if (lhs !== null) { |
548 | + var result; |
549 | switch (type) { |
550 | case T_PLUS: |
551 | - return lhs.value.plus(rhs.value); |
552 | + result = lhs.value.plus(rhs.value); |
553 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
554 | |
555 | case T_MINUS: |
556 | - return lhs.value.minus(rhs.value); |
557 | + result = lhs.value.minus(rhs.value); |
558 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
559 | |
560 | case T_TIMES: |
561 | - return lhs.value.times(rhs.value); |
562 | + result = lhs.value.times(rhs.value); |
563 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
564 | |
565 | case T_DIV: |
566 | - return lhs.value.div(rhs.value); |
567 | + result = lhs.value.div(rhs.value); |
568 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
569 | |
570 | case T_MOD: |
571 | if (rhs.value === 0.) |
572 | throw new DivisionByZeroError('modulo division by zero'); |
573 | |
574 | - return lhs.value.mod(rhs.value); |
575 | + result = lhs.value.mod(rhs.value); |
576 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
577 | |
578 | case T_POW: |
579 | - return lhs.value.pow(rhs.value); |
580 | + result = lhs.value.pow(rhs.value); |
581 | + return result > MAX_LENGHT ? result.toPrecision(PRECISION) : result; |
582 | } |
583 | |
584 | // throw? |
PASSED: Continuous integration, rev:149 91.189. 93.70:8080/ job/ubuntu- calculator- app-ci/ 77/ 91.189. 93.70:8080/ job/generic- mediumtests/ 299 91.189. 93.70:8080/ job/ubuntu- calculator- app-precise- amd64-ci/ 76 91.189. 93.70:8080/ job/ubuntu- calculator- app-quantal- amd64-ci/ 76 91.189. 93.70:8080/ job/ubuntu- calculator- app-raring- amd64-ci/ 76 91.189. 93.70:8080/ job/ubuntu- calculator- app-saucy- amd64-ci/ 76
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- calculator- app-ci/ 77/rebuild
http://