# HG changeset patch # User insilmaril # Date 1161704198 0 # Node ID 67cfa6e6b863b54e326d365d5e5a1b54f8b12a5d # Parent 053b8645e3e911a21e819c1c183e09679cbf5904 1.8.58 - More undoCommands, spanish translation of doc diff -r 053b8645e3e9 -r 67cfa6e6b863 api.cpp --- a/api.cpp Wed Oct 18 10:45:00 2006 +0000 +++ b/api.cpp Tue Oct 24 15:36:38 2006 +0000 @@ -11,13 +11,13 @@ { com=""; paramList.clear(); - errorString=""; - noErr=true; + resetError(); } -void API::parseCommand (const QString &s) +void API::parseInput (const QString &s) { initCommand(); + input=s; QRegExp re; int pos; @@ -75,32 +75,76 @@ return paramList; } -QString API::errorDesc() +int API::paramCount() { - return errorString; + return paramList.count(); } -bool API::error() + +QString API::errorMessage() { - // invert noErr - return (noErr) ?false:true; + QString l; + switch (errLevel) + { + case NoError: l="No Error"; + case Warning: l="Warning"; + case Aborted: l="Aborted"; + } + return QString ("Error Level: %1\n Command: %2\nDescription: %3") + .arg(l).arg(com).arg(errDescription); } -void API::setError(const QString &e) +QString API::errorDescription() { - noErr=false; - errorString=e; + return errDescription; +} + +ErrorLevel API::errorLevel() +{ + return errLevel; +} + +void API::setError(ErrorLevel level, const QString &description) +{ + errDescription=description; + errLevel=level; +} + +void API::resetError () +{ + errMessage=""; + errDescription=""; + errLevel=NoError; +} + + +bool API::checkParamCount (QList plist) +{ + QStringList expList; + QString expected; + for (int i=0; i paramList.count()) { - errorString =QString("Parameter index %1 is outside of parameter list").arg(index); - noErr=false; + errLevel=Aborted; + errDescription=QString("Parameter index %1 is outside of parameter list").arg(index); + return false; } else { paramList[index].toInt (&ok, 10); if (!ok) { - errorString=QString("Parameter %1 is not an integer").arg(index); - noErr=false; - } else - noErr=true; + errLevel=Aborted; + errDescription=QString("Parameter %1 is not an integer").arg(index); + return false; + } } - return noErr; + return true; } int API::parInt (bool &ok,const uint &index) @@ -145,3 +190,26 @@ ok=true; return r; } + +bool API::parBool (bool &ok,const int &index) +{ + // return the bool at index, this could be also stored in + // a variable later + QString r; + ok=true; + /* + QRegExp re("\"(.*)\""); + int pos=re.search (paramList[index]); + if (pos>=0) + r=re.cap (1); + else + r=""; + */ + if (paramList[index]=="true") + return true; + else if (paramList[index]=="false") + return false; + ok=false; + return ok; +} + diff -r 053b8645e3e9 -r 67cfa6e6b863 api.h --- a/api.h Wed Oct 18 10:45:00 2006 +0000 +++ b/api.h Tue Oct 24 15:36:38 2006 +0000 @@ -1,28 +1,37 @@ #ifndef API_H #define API_H -#include +#include + +enum ErrorLevel {NoError,Warning,Aborted}; class API { public: API(); void initCommand(); - void parseCommand (const QString&); + void parseInput (const QString &input); QString command(); QStringList parameters(); - QString errorDesc(); - bool error(); - void setError (const QString &); - bool checkParamCount (const int &); - bool checkParamIsInt (const int &); - int parInt (bool &,const uint&); - QString parString(bool &,const int &); + int paramCount(); + QString errorMessage(); + QString errorDescription(); + ErrorLevel errorLevel(); + void setError (ErrorLevel level,const QString &description); + void resetError(); + bool checkParamCount (QList plist); + bool checkParamCount (const int &index); + bool checkParamIsInt (const int &index); + int parInt (bool &,const uint &index); + QString parString(bool &ok,const int &index); + bool parBool (bool &ok, const int &index); private: + QString input; QString com; QStringList paramList; - QString errorString; - bool noErr; + QString errMessage; + QString errDescription; + ErrorLevel errLevel; }; #endif diff -r 053b8645e3e9 -r 67cfa6e6b863 branchobj.cpp --- a/branchobj.cpp Wed Oct 18 10:45:00 2006 +0000 +++ b/branchobj.cpp Tue Oct 24 15:36:38 2006 +0000 @@ -1242,7 +1242,6 @@ int th = bboxTotal.height(); // TODO testing /* -*/ cout << "BO::alignRelTo "<