From 67fd3b480f543f2f18bd632ea85d829ba2102a20 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 2 Apr 2015 23:44:42 +0200 Subject: Add list for warnings Remove data where reading list. --- diceparser.h | 1 + parsingtoolbox.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/diceparser.h b/diceparser.h index 683be88..bec3975 100644 --- a/diceparser.h +++ b/diceparser.h @@ -257,6 +257,7 @@ private: QStringList* m_commandList; QMap m_errorMap; + QMap m_warningMap; ExecutionNode* m_start; diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index e03690e..63b5739 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -181,6 +181,7 @@ bool ParsingToolBox::readList(QString& str,QStringList& list) { QString liststr = str.left(pos); list = liststr.split(","); + str=str.remove(0,liststr.size()+1); return true; } } -- cgit v1.2.3-70-g09d2 From 26e813ad2e4fa13f4b2873df99cb8e3be380c875 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 27 Aug 2015 01:29:13 +0200 Subject: add method to get all string results --- diceparser.cpp | 23 +++++++++++++++++++++++ diceparser.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/diceparser.cpp b/diceparser.cpp index 3831400..8c910a2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -393,6 +393,29 @@ QString DiceParser::getStringResult() } return str; } +QStringList DiceParser::getAllStringResult(bool& hasAlias) +{ + ExecutionNode* next = getLeafNode(); + Result* result=next->getResult(); + QStringList stringListResult; + + while(NULL!=result) + { + if(result->hasResultOfType(Result::STRING)) + { + StringResult* stringResult = dynamic_cast(result); + if(NULL!=stringResult) + { + stringListResult << stringResult->getText(); + hasAlias = stringResult->hasHighLight(); + } + } + result = result->getPrevious(); + } + + return stringListResult; +} + void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) { ExecutionNode* next = getLeafNode(); diff --git a/diceparser.h b/diceparser.h index 3eb55f1..6cc6d47 100644 --- a/diceparser.h +++ b/diceparser.h @@ -191,6 +191,11 @@ public: * @param l the path. */ void setPathToHelp(QString l); + /** + * @brief getAllStringResult + * @return + */ + QStringList getAllStringResult(bool& hasAlias); private: /** -- cgit v1.2.3-70-g09d2 From 2d3a37b290b9fbd9be7a7fc4e722b30bb160ffd5 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 27 Aug 2015 01:29:45 +0200 Subject: disable the highlight --- node/helpnode.cpp | 1 + node/listaliasnode.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/node/helpnode.cpp b/node/helpnode.cpp index 6108e4d..62dc86e 100644 --- a/node/helpnode.cpp +++ b/node/helpnode.cpp @@ -9,6 +9,7 @@ void HelpNode::run(ExecutionNode* previous) { m_previousNode = previous; StringResult* txtResult = dynamic_cast(m_result); + txtResult->setHighLight(false); if(NULL != previous) { diff --git a/node/listaliasnode.cpp b/node/listaliasnode.cpp index ddb8ac9..1809eac 100644 --- a/node/listaliasnode.cpp +++ b/node/listaliasnode.cpp @@ -29,6 +29,7 @@ void ListAliasNode::run(ExecutionNode* previous ) { m_previousNode = previous; StringResult* txtResult = dynamic_cast(m_result); + txtResult->setHighLight(false); if(NULL != previous) { -- cgit v1.2.3-70-g09d2 From 0e4d08bf25a81ac68635f526f17ae5e82152cb10 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 27 Aug 2015 01:30:14 +0200 Subject: add highlight management --- result/stringresult.cpp | 10 ++++++++++ result/stringresult.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/result/stringresult.cpp b/result/stringresult.cpp index 4dbd577..474ae23 100644 --- a/result/stringresult.cpp +++ b/result/stringresult.cpp @@ -2,6 +2,7 @@ StringResult::StringResult() { + m_highlight = true; m_resultTypes = Result::STRING; } void StringResult::setText(QString text) @@ -35,3 +36,12 @@ QString StringResult::toString() { return QString("StringResult_value_%1").arg(getText().replace(" ","_")); } +void StringResult::setHighLight(bool b) +{ + m_highlight = b; +} + +bool StringResult::hasHighLight() const +{ + return m_highlight; +} diff --git a/result/stringresult.h b/result/stringresult.h index 5a6b26c..6819aaa 100644 --- a/result/stringresult.h +++ b/result/stringresult.h @@ -37,8 +37,12 @@ public: * @return */ virtual QString toString(); + + virtual void setHighLight(bool ); + virtual bool hasHighLight() const; private: QString m_value; + bool m_highlight; }; #endif // STRINGRESULT_H -- cgit v1.2.3-70-g09d2 From da1db7bc2436f94ab288d8da8d98a8209d3d2caa Mon Sep 17 00:00:00 2001 From: Renaud G Date: Fri, 28 Aug 2015 08:35:33 +0200 Subject: fix cppcheck issue --- booleancondition.cpp | 1 + diceparser.cpp | 17 +++++++++-------- node/keepdiceexecnode.cpp | 4 +--- node/parenthesesnode.cpp | 1 + node/scalaroperatornode.cpp | 2 +- node/sortresult.cpp | 7 +------ parsingtoolbox.cpp | 5 +++-- result/result.cpp | 2 +- 8 files changed, 18 insertions(+), 21 deletions(-) diff --git a/booleancondition.cpp b/booleancondition.cpp index 533ec02..c5fd7c7 100644 --- a/booleancondition.cpp +++ b/booleancondition.cpp @@ -23,6 +23,7 @@ BooleanCondition::BooleanCondition() + : m_operator(Equal) { } qint64 BooleanCondition::hasValid(Die* b,bool recursive,bool unhighlight) const diff --git a/diceparser.cpp b/diceparser.cpp index 8c910a2..bfe8247 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -42,7 +42,7 @@ #define DEFAULT_FACES_NUMBER 10 DiceParser::DiceParser() - : m_start(NULL) + : m_start(NULL),m_current(NULL) { m_parsingToolbox = new ParsingToolBox(); @@ -166,7 +166,8 @@ bool DiceParser::parseLine(QString str) keepParsing =!str.isEmpty(); if(keepParsing) { - keepParsing = readOperator(str,m_current); + // keepParsing = + readOperator(str,m_current); m_current = getLatestNode(m_current); } @@ -428,7 +429,6 @@ void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) DiceResult* diceResult = dynamic_cast(result); if(NULL!=diceResult) { - bool hasResult = false; quint64 face=0; ListDiceResult listpair; foreach(Die* die, diceResult->getResultList()) @@ -436,7 +436,6 @@ void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) if(!die->hasBeenDisplayed()) { QList valuesResult; - hasResult=true; valuesResult.append(die->getValue()); die->displayed(); face = die->getFaces(); @@ -545,10 +544,10 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node) if(readDiceOperator(str,currentOperator)) { - int num; - int end; if(currentOperator==D) { + int num; + int end; if(m_parsingToolbox->readNumber(str,num)) { if(num<1) @@ -837,7 +836,8 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice)/ if(NULL!=validator) { /// @todo display warning here. - bool b = m_parsingToolbox->isValidValidator(previous,validator); + //bool b = + m_parsingToolbox->isValidValidator(previous,validator); CountExecuteNode* countNode = new CountExecuteNode(); countNode->setValidator(validator); @@ -859,7 +859,8 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice)/ if(NULL!=validator) { /// @todo display warning here. - bool b = m_parsingToolbox->isValidValidator(previous,validator); + //bool b = + m_parsingToolbox->isValidValidator(previous,validator); RerollDiceNode* rerollNode = new RerollDiceNode(); if(m_OptionOp->value(tmp)==RerollAndAdd) { diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp index a225ac4..a230107 100644 --- a/node/keepdiceexecnode.cpp +++ b/node/keepdiceexecnode.cpp @@ -42,10 +42,8 @@ m_previousNode = previous; if(NULL!=previousDiceResult) { QList diceList=previousDiceResult->getResultList(); - QList diceList2=m_diceResult->getResultList(); + QList diceList2 = diceList.mid(0,m_numberOfDice); - - diceList2 = diceList.mid(0,m_numberOfDice); foreach(Die* tmp,diceList.mid(m_numberOfDice,-1)) { tmp->setHighlighted(false); diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp index 2876147..f81fc1c 100644 --- a/node/parenthesesnode.cpp +++ b/node/parenthesesnode.cpp @@ -22,6 +22,7 @@ #include "parenthesesnode.h" ParenthesesNode::ParenthesesNode() + : m_internalNode(NULL) { } diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp index c5f91f9..d532df0 100644 --- a/node/scalaroperatornode.cpp +++ b/node/scalaroperatornode.cpp @@ -26,7 +26,7 @@ ScalarOperatorNode::ScalarOperatorNode() - : m_internalNode(NULL),m_scalarResult(new ScalarResult()) + : m_internalNode(NULL),m_scalarResult(new ScalarResult()),m_operator(PLUS) { m_scalarOperationList.insert('+',PLUS); m_scalarOperationList.insert('-',MINUS); diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 44a25f0..421beb3 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -54,14 +54,11 @@ void SortResultNode::run(ExecutionNode* node) bool found = false; int start = 0; int end = diceList2.size(); - int distance = 0; Die* tmp2 = NULL; while(!found) { - distance = end-start; + int distance = end-start; j = (start+end)/2; - - if(distance == 0) { j=end; @@ -78,9 +75,7 @@ void SortResultNode::run(ExecutionNode* node) { start=j+1; } - } - } diceList2.insert(j,tmp1); } diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index f6b1f12..2d26d79 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -75,7 +75,6 @@ Validator* ParsingToolBox::readValidator(QString& str) { Validator* returnVal=NULL; bool expectSquareBrasket=false; - bool isOk = true; if((str.startsWith("["))) { str=str.remove(0,1); @@ -83,11 +82,13 @@ Validator* ParsingToolBox::readValidator(QString& str) } BooleanCondition::LogicOperator myLogicOp = BooleanCondition::Equal; - bool hasReadLogicOperator = readLogicOperator(str,myLogicOp); + //bool hasReadLogicOperator = + readLogicOperator(str,myLogicOp); int value=0; if(readNumber(str,value)) { + bool isOk = true; if(str.startsWith("-")) { str=str.remove(0,1); diff --git a/result/result.cpp b/result/result.cpp index 257045c..161cfea 100644 --- a/result/result.cpp +++ b/result/result.cpp @@ -22,7 +22,7 @@ #include "result.h" Result::Result() - : m_previous(NULL) + : m_previous(NULL),m_resultTypes(STRING) { } -- cgit v1.2.3-70-g09d2 From 4e36ee1d9ce7016f9fc2a56ff5d039a534c6d5f0 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 29 Aug 2015 00:18:57 +0200 Subject: fix compilation. --- diceparser.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/diceparser.cpp b/diceparser.cpp index bfe8247..dcb5030 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -181,11 +181,7 @@ bool DiceParser::parseLine(QString str) { m_errorMap.insert(ExecutionNode::NOTHING_UNDERSTOOD,QObject::tr("Nothing was understood")); } - else - { - return false; - } - + return false; } bool DiceParser::readExpression(QString& str,ExecutionNode* & node) -- cgit v1.2.3-70-g09d2 From 6eea02bc24ca34952506a2ec39975d075f1c980b Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 30 Aug 2015 09:22:21 +0200 Subject: fix warning in qmake .pri file. --- diceparser.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diceparser.pri b/diceparser.pri index cacca31..22ef326 100644 --- a/diceparser.pri +++ b/diceparser.pri @@ -25,7 +25,7 @@ HEADERS += \ $$PWD/die.h \ $$PWD/result/result.h \ $$PWD/result/scalarresult.h \ - $$PWD/result/parsingtoolbox.h \ + $$PWD/parsingtoolbox.h \ $$PWD/result/stringresult.h \ $$PWD/dicealias.h -- cgit v1.2.3-70-g09d2 From 6cfbebcde11e9256e88f9b9be0d340c2fda2a40f Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 1 Sep 2015 16:33:17 +0200 Subject: add gpl header --- node/startingnode.cpp | 21 +++++++++++++++++++-- node/startingnode.h | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/node/startingnode.cpp b/node/startingnode.cpp index b15101b..7e13f5d 100644 --- a/node/startingnode.cpp +++ b/node/startingnode.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "startingnode.h" #include @@ -24,7 +43,5 @@ qint64 StartingNode::getPriority() const { priority = m_nextNode->getPriority(); } - - return priority; } diff --git a/node/startingnode.h b/node/startingnode.h index ebe28c0..1edebc9 100644 --- a/node/startingnode.h +++ b/node/startingnode.h @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #ifndef STARTINGNODE_H #define STARTINGNODE_H @@ -31,3 +50,4 @@ public: }; #endif // STARTINGNODE_H + -- cgit v1.2.3-70-g09d2 From 28867d0554db6cc68d295e41927e31f7e27fe135 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 1 Sep 2015 16:33:41 +0200 Subject: add gpl header --- node/helpnode.cpp | 19 +++++++++++++++++++ node/helpnode.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/node/helpnode.cpp b/node/helpnode.cpp index 62dc86e..dd5f087 100644 --- a/node/helpnode.cpp +++ b/node/helpnode.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "helpnode.h" HelpNode::HelpNode() diff --git a/node/helpnode.h b/node/helpnode.h index 88a0842..be21b67 100644 --- a/node/helpnode.h +++ b/node/helpnode.h @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #ifndef HELPNODE_H #define HELPNODE_H #include "executionnode.h" -- cgit v1.2.3-70-g09d2 From 7ce5a4af6fb836432eb6ce7637ea09d6a5b4e0bd Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 1 Sep 2015 16:34:56 +0200 Subject: add getAllDiceResult function and hasSeparator --- diceparser.cpp | 45 +++++++++++++++++++++++++++++++++++++++------ diceparser.h | 9 +++++++++ 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/diceparser.cpp b/diceparser.cpp index dcb5030..802b5f2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -44,6 +44,7 @@ DiceParser::DiceParser() : m_start(NULL),m_current(NULL) { + m_currentTreeHasSeparator =false; m_parsingToolbox = new ParsingToolBox(); m_mapDiceOp = new QMap(); @@ -145,6 +146,7 @@ void DiceParser::insertAlias(DiceAlias* dice, int i) bool DiceParser::parseLine(QString str) { + m_currentTreeHasSeparator = false; m_errorMap.clear(); if(NULL!=m_start) { @@ -412,7 +414,36 @@ QStringList DiceParser::getAllStringResult(bool& hasAlias) return stringListResult; } +QStringList DiceParser::getAllDiceResult(bool& hasAlias) +{ + ExecutionNode* next = getLeafNode(); + Result* result=next->getResult(); + QList dieListResult; + QStringList stringListResult; + while(NULL!=result) + { + if(result->hasResultOfType(Result::DICE_LIST)) + { + DiceResult* stringResult = dynamic_cast(result); + if(NULL!=stringResult) + { + dieListResult << stringResult->getResultList(); + hasAlias = true; + } + } + result = result->getPrevious(); + } + foreach(Die* die, dieListResult) + { + foreach (qint64 value, die->getListValue()) + { + stringListResult << QString::number(value); + } + } + + return stringListResult; +} void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) { ExecutionNode* next = getLeafNode(); @@ -701,21 +732,19 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } else if(readInstructionOperator(str[0])) { - str=str.remove(0,1); - delete node; + str=str.remove(0,1); + delete node; ExecutionNode* nodeExec = NULL; if(readExpression(str,nodeExec)) { - - // nodeExec = getLatestNode(nodeExec); - if(NULL==nodeExec) { return false; } previous->setNextNode(nodeExec); - + m_currentTreeHasSeparator = true; return true; + } } else @@ -728,6 +757,10 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } return false; } +bool DiceParser::hasSeparator()const +{ + return m_currentTreeHasSeparator; +} DiceRollerNode* DiceParser::addRollDiceNode(qint64 faces,ExecutionNode* previous) { DiceRollerNode* mydiceRoller= new DiceRollerNode(faces); diff --git a/diceparser.h b/diceparser.h index 6cc6d47..3fc2cb7 100644 --- a/diceparser.h +++ b/diceparser.h @@ -196,6 +196,14 @@ public: * @return */ QStringList getAllStringResult(bool& hasAlias); + /** + * @brief getAllDiceResult + * @param hasAlias + * @return + */ + QStringList getAllDiceResult(bool& hasAlias); + + bool hasSeparator()const; private: /** @@ -301,6 +309,7 @@ private: QString m_command; ParsingToolBox* m_parsingToolbox; QString m_helpPath; + bool m_currentTreeHasSeparator; }; #endif // DICEPARSER_H -- cgit v1.2.3-70-g09d2 From c6449aebc9b16042672a2dffb5d1b3794584005b Mon Sep 17 00:00:00 2001 From: Renaud G Date: Mon, 7 Sep 2015 08:35:13 +0200 Subject: Change path to parsingtoolbox.h --- diceparser.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diceparser.pri b/diceparser.pri index cacca31..22ef326 100644 --- a/diceparser.pri +++ b/diceparser.pri @@ -25,7 +25,7 @@ HEADERS += \ $$PWD/die.h \ $$PWD/result/result.h \ $$PWD/result/scalarresult.h \ - $$PWD/result/parsingtoolbox.h \ + $$PWD/parsingtoolbox.h \ $$PWD/result/stringresult.h \ $$PWD/dicealias.h -- cgit v1.2.3-70-g09d2 From 114cd6a7990c44f0610dbf2080f101d0edbbaa57 Mon Sep 17 00:00:00 2001 From: "Renaud G." Date: Wed, 23 Sep 2015 12:22:47 +0200 Subject: Update HelpMe.md spelling --- HelpMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelpMe.md b/HelpMe.md index 73265e6..b2a6bd4 100644 --- a/HelpMe.md +++ b/HelpMe.md @@ -163,7 +163,7 @@ Substract 4 to 6 and then roll two dice. Divide by 2 the result of 1 die. -## Roll two (or more) kind of dice at once. +## Roll two (or more) kinds of dice at once. To make it, you have to separate all dice commands by `;` -- cgit v1.2.3-70-g09d2