Diffstat (limited to 'noncore/tools/calc2/engine.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calc2/engine.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/tools/calc2/engine.cpp b/noncore/tools/calc2/engine.cpp index a9a47c4..e843e29 100644 --- a/noncore/tools/calc2/engine.cpp +++ b/noncore/tools/calc2/engine.cpp @@ -56,159 +56,159 @@ Data Engine::evalStack (Data num, bool inbrace = FALSE) void Engine::eval () { num = evalStack (num); if (state != sError) { displayData(num); state = sStart; } // if the user didnt close all their braces, its no big deal braces = 0; } void Engine::immediateInstruction (Instruction * i) { if (state != sError) { i->setRep(currentRep); num = i->eval (num); displayData(num); state = sStart; } } void Engine::pushInstruction (Instruction * i) { if (state != sError) { i->setRep(currentRep); i->acc = num; stack.push (i); state = sStart; } } void Engine::pushValue (char v) { if (state == sAppend) { bool ok = FALSE; switch (currentRep) { case rDouble: displayString.append(v); num.dbl=displayString.toDouble(&ok); break; case rFraction: break; default: displayString.append(v); num.i=displayString.toInt(&ok, calcBase()); }; if (!ok) { state = sError; - qDebug("pushValue() - num->string conversion"); + odebug << "pushValue() - num->string conversion" << oendl; } else { const QString constString = displayString; emit(display(constString)); }; } else if (state == sStart) { softReset(); displayString.truncate(0); state = sAppend; pushValue (v); } else if (state == sError) { qDebug ("in error state"); return; } } void Engine::del () { bool ok; switch (currentRep) { case rDouble: displayString.truncate(displayString.length()); num.dbl=displayString.toDouble(&ok); break; case rFraction: - qDebug("not available"); + odebug << "not available" << oendl; break; default: displayString.truncate(displayString.length()); num.i = displayString.toInt(&ok, calcBase()); }; if (!ok) { state = sError; - qDebug("del() - num->string conversion"); + odebug << "del() - num->string conversion" << oendl; } else { const QString constString = displayString; emit(display(constString)); }; } void Engine::displayData(Data d) { switch (currentRep) { case rDouble: displayString.setNum(d.dbl); break; case rFraction: - qDebug("fractional display not yet impl"); + odebug << "fractional display not yet impl" << oendl; break; default: displayString.setNum(d.i, calcBase()); break; }; const QString constString= displayString; emit(display(constString)); } // Returns the base when Rep is an integer type int Engine::calcBase () { switch (currentRep) { case rBin: return 2; case rOct: return 8; case rDec: return 10; case rHex: return 16; default: state = sError; - qDebug("Error - attempt to calc base for non-integer"); + odebug << "Error - attempt to calc base for non-integer" << oendl; return 10; }; } // Special instruction for internal use only class iOpenBrace:public Instruction { public: iOpenBrace (Engine *e):Instruction (100) {engine = e;}; ~iOpenBrace () {}; Data eval (Data num) { engine->decBraces(); return num; }; private: Engine *engine; }; void Engine::openBrace() { pushInstruction(new iOpenBrace(this)); } void Engine::closeBrace() { braces++;evalStack(num,TRUE); } // will need to show and hide display widgets void Engine::setRepresentation(Representation r) { currentRep = r; clearData(&num); clearData(&mem); state = sStart; } void Engine::clearData(Data *d) { d->i = d->fraction.numerator = d->fraction.denominator = 0; d->dbl = 0; } |