aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-10-28 10:56:16 +0100
committerRenaud G <renaud@rolisteam.org>2015-10-28 10:56:16 +0100
commitd271811b7cf700eb22c16e4af30fc6569ac225bb (patch)
tree93e36c0597e216deabe85ec06f00c5437b8cbdb5
parent9e9dd15316e80cae916c532d13ddc5ddc5e93697 (diff)
downloadOneRoll-d271811b7cf700eb22c16e4af30fc6569ac225bb.tar.gz
OneRoll-d271811b7cf700eb22c16e4af30fc6569ac225bb.zip
Optimization about screen
-rw-r--r--booleancondition.cpp14
-rw-r--r--diceparser.cpp56
-rw-r--r--range.cpp2
-rw-r--r--result/diceresult.cpp2
4 files changed, 37 insertions, 37 deletions
diff --git a/booleancondition.cpp b/booleancondition.cpp
index c09166e..40a3804 100644
--- a/booleancondition.cpp
+++ b/booleancondition.cpp
@@ -83,26 +83,26 @@ void BooleanCondition::setValue(qint64 v)
}
QString BooleanCondition::toString()
{
- QString str="";
+ QString str(QStringLiteral(""));
switch (m_operator)
{
case Equal:
- str.append("=");
+ str.append(QStringLiteral("="));
break;
case GreaterThan:
- str.append(">");
+ str.append(QStringLiteral(">"));
break;
case LesserThan:
- str.append("<");
+ str.append(QStringLiteral("<"));
break;
case GreaterOrEqual:
- str.append(">=");
+ str.append(QStringLiteral(">="));
break;
case LesserOrEqual:
- str.append("<=");
+ str.append(QStringLiteral("<="));
break;
}
- return QString("[%1%2]").arg(str).arg(m_value);
+ return QStringLiteral("[%1%2]").arg(str).arg(m_value);
}
quint64 BooleanCondition::getValidRangeSize(quint64 faces) const
{
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<QString,DiceOperator>();
- 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<QString,OptionOperator>();
- 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<QString,NodeAction>();
- 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<ExecutionNode::ERROR_CODE,QString> DiceParser::getErrorMap()
QString DiceParser::humanReadableError()
{
QMapIterator<ExecutionNode::ERROR_CODE,QString> 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);
diff --git a/range.cpp b/range.cpp
index 482bcff..30c0812 100644
--- a/range.cpp
+++ b/range.cpp
@@ -61,7 +61,7 @@ qint64 Range::hasValid(Die* m,bool recursive, bool unhighlight) const
}
QString Range::toString()
{
- return QString("[%1-%2]").arg(m_start).arg(m_end);
+ return QStringLiteral("[%1-%2]").arg(m_start).arg(m_end);
}
quint64 Range::getValidRangeSize(quint64 faces) const
{
diff --git a/result/diceresult.cpp b/result/diceresult.cpp
index ceb77b8..ffa5d02 100644
--- a/result/diceresult.cpp
+++ b/result/diceresult.cpp
@@ -90,7 +90,7 @@ QString DiceResult::toString(bool wl)
}
if(wl)
{
- return QString("%3 [label=\"DiceResult Value %1 dice %2\"]").arg(getScalarResult()).arg(scalarSum.join('_')).arg(m_id);
+ return QStringLiteral("%3 [label=\"DiceResult Value %1 dice %2\"]").arg(getScalarResult()).arg(scalarSum.join('_')).arg(m_id);
}
else
{