From d271811b7cf700eb22c16e4af30fc6569ac225bb Mon Sep 17 00:00:00 2001 From: Renaud G Date: Wed, 28 Oct 2015 10:56:16 +0100 Subject: Optimization about screen --- diceparser.cpp | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index 144a7d6..53dc305 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -48,17 +48,17 @@ DiceParser::DiceParser() m_parsingToolbox = new ParsingToolBox(); m_mapDiceOp = new QMap(); - m_mapDiceOp->insert("D",D); - m_mapDiceOp->insert("L",L); + m_mapDiceOp->insert(QStringLiteral("D"),D); + m_mapDiceOp->insert(QStringLiteral("L"),L); m_OptionOp = new QMap(); - m_OptionOp->insert(QObject::tr("k"),Keep); - m_OptionOp->insert(QObject::tr("K"),KeepAndExplose); - m_OptionOp->insert(QObject::tr("s"),Sort); - m_OptionOp->insert(QObject::tr("c"),Count); - m_OptionOp->insert(QObject::tr("r"),Reroll); - m_OptionOp->insert(QObject::tr("e"),Explosing); - m_OptionOp->insert(QObject::tr("a"),RerollAndAdd); + m_OptionOp->insert(QStringLiteral("k"),Keep); + m_OptionOp->insert(QStringLiteral("K"),KeepAndExplose); + m_OptionOp->insert(QStringLiteral("s"),Sort); + m_OptionOp->insert(QStringLiteral("c"),Count); + m_OptionOp->insert(QStringLiteral("r"),Reroll); + m_OptionOp->insert(QStringLiteral("e"),Explosing); + m_OptionOp->insert(QStringLiteral("a"),RerollAndAdd); //m_OptionOp->insert(QObject::tr("@"),JumpBackward); @@ -69,11 +69,11 @@ DiceParser::DiceParser() m_aliasList->append(new DiceAlias("(.*)wod(.*)","\\1d10e[=10]c[>=\\2]-@c[=1]",false));*/ m_nodeActionMap = new QMap(); - m_nodeActionMap->insert("@",JumpBackward); + m_nodeActionMap->insert(QStringLiteral("@"),JumpBackward); m_commandList = new QStringList(); - m_commandList->append("help"); - m_commandList->append("la"); + m_commandList->append(QStringLiteral("help")); + m_commandList->append(QStringLiteral("la")); } DiceParser::~DiceParser() @@ -290,8 +290,8 @@ QString DiceParser::displayResult() QTextStream stream(&str); Result* result=next->getResult(); - QString totalValue("you got %1 ;"); - QString dieValue("D%1 : {%2} "); + QString totalValue("you got %1 ;"); + QString dieValue("D%1 : {%2} "); bool scalarDone=false; while(NULL!=result) @@ -315,22 +315,22 @@ QString DiceParser::displayResult() { if(!die->hasBeenDisplayed()) { - resulStr+=QString("%1").arg(die->getValue()); + resulStr+=QStringLiteral("%1").arg(die->getValue()); die->displayed(); face = die->getFaces(); if(die->hasChildrenValue()) { - resulStr+=" ["; + resulStr+=QStringLiteral(" ["); foreach(qint64 i, die->getListValue()) { - resulStr+=QString("%1 ").arg(i); + resulStr+=QStringLiteral("%1 ").arg(i); } resulStr.remove(resulStr.size()-1,1); - resulStr+="]"; + resulStr+=QStringLiteral("]"); } - resulStr+=", "; + resulStr+=QStringLiteral(", "); } } resulStr.remove(resulStr.size()-2,2); @@ -355,7 +355,7 @@ QString DiceParser::displayResult() out << endl; - return QString("%1, you rolled:%3").arg(str.simplified()).arg(m_command) ; + return QStringLiteral("%1, you rolled:%3").arg(str.simplified()).arg(m_command) ; // qDebug() << "result count:" << resulCount; } @@ -653,14 +653,14 @@ bool DiceParser::readCommand(QString& str,ExecutionNode* & node) { if(m_commandList->contains(str)) { - if(str=="help") + if(str== QLatin1String("help")) { HelpNode* help = new HelpNode(); help->setHelpPath(m_helpPath); node = help; } - else if(str=="la") + else if(str== QLatin1String("la")) { node = new ListAliasNode(m_aliasList); } @@ -912,7 +912,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice)/ } else { - m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("Validator is missing after the %1 operator. Please, change it").arg(m_OptionOp->value(tmp)==Reroll?"r":"a")); + m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("Validator is missing after the %1 operator. Please, change it").arg(m_OptionOp->value(tmp)==Reroll?QStringLiteral("r"):QStringLiteral("a"))); } } @@ -953,12 +953,12 @@ QMap DiceParser::getErrorMap() QString DiceParser::humanReadableError() { QMapIterator i(m_errorMap); - QString str=""; + QString str(""); while (i.hasNext()) { i.next(); str.append(i.value()); - str.append("\n"); + str.append(QStringLiteral("\n")); } ///list @@ -967,7 +967,7 @@ QString DiceParser::humanReadableError() { j.next(); str.append(j.value()); - str.append("\n"); + str.append(QStringLiteral("\n")); } return str; } @@ -988,9 +988,9 @@ bool DiceParser::readOperand(QString& str,ExecutionNode* & node) } void DiceParser::writeDownDotTree(QString filepath) { - QString str("digraph ExecutionTree {\n"); + QString str(QStringLiteral("digraph ExecutionTree {\n")); m_start->generateDotTree(str); - str.append("}\n"); + str.append(QStringLiteral("}\n")); QFile file(filepath); -- cgit v1.2.3-70-g09d2