Code review comment for lp:~rpadovani/ubuntu-calculator-app/1287340

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

One more comment:

Instead of replacing:
  result = result.replace(".", separator);
you could use toLocaleString without checking
  result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,"").toLocaleString(Qt.locale(), "f", 0);

Instead of replacing separators,
            function buttonClicked(buttonName) {
                if (buttonName === separator) {
                    buttonName = '.';
                }
                keyboardButtons[buttonName].clicked();
            }

            function buttonReleased(buttonName) {
                if (buttonName === separator) {
                    buttonName = '.';
                }
                keyboardButtons[buttonName].released();
            }

try to use contruction:
  Keys.onPressed: {
...
  Keys.onReleased: {
...

     else if (event.text === separator) {
        buttonClicked(".")

Instead of
                if (separator !== '.' && last.value.toString() === '.') {
                    last.value = separator;
                }
                screenFormula[screenFormula.length - 1]._number += last.value.toString();

use:
            screenFormula[screenFormula.length - 1]._number += last.value.toLocaleString(Qt.locale(), "f", 0);

Thanks !

review: Needs Fixing

« Back to merge proposal