diff options
| author | 2015-03-24 21:53:40 +0100 | |
|---|---|---|
| committer | 2015-03-24 21:53:40 +0100 | |
| commit | 7ed106bc79c222586279d4351db1c5f005b0b1f3 (patch) | |
| tree | ff0efc466457d10431a85c3f23fc1a154dcdc26c /node | |
| parent | 24d48effb863e458c00dcb1bea1ad5aa82309599 (diff) | |
| download | OneRoll-7ed106bc79c222586279d4351db1c5f005b0b1f3.tar.gz OneRoll-7ed106bc79c222586279d4351db1c5f005b0b1f3.zip | |
-Add listaliasnode to list all alias.
Diffstat (limited to 'node')
| -rw-r--r-- | node/helpnode.cpp | 1 | ||||
| -rw-r--r-- | node/listaliasnode.cpp | 46 | ||||
| -rw-r--r-- | node/listaliasnode.h | 33 | ||||
| -rw-r--r-- | node/node.pri | 6 |
4 files changed, 83 insertions, 3 deletions
diff --git a/node/helpnode.cpp b/node/helpnode.cpp index bae4b21..82f44f8 100644 --- a/node/helpnode.cpp +++ b/node/helpnode.cpp @@ -9,7 +9,6 @@ void HelpNode::run(ExecutionNode* previous) m_previousNode = previous; StringResult* txtResult = dynamic_cast<StringResult*>(m_result); - qDebug() << m_result->hasResultOfType(Result::SCALAR) << m_result->hasResultOfType(Result::STRING); if(NULL != previous) { if(previous->getResult() == NULL) diff --git a/node/listaliasnode.cpp b/node/listaliasnode.cpp new file mode 100644 index 0000000..1d50c80 --- /dev/null +++ b/node/listaliasnode.cpp @@ -0,0 +1,46 @@ +#include "listaliasnode.h" + +ListAliasNode::ListAliasNode(QMap<QString,QString>* apAlias) + : m_mapAlias(apAlias) +{ + m_result = new StringResult(); +} +void ListAliasNode::run(ExecutionNode* previous ) +{ + m_previousNode = previous; + StringResult* txtResult = dynamic_cast<StringResult*>(m_result); + + if(NULL != previous) + { + if(previous->getResult() == NULL) + { + txtResult->setText(toString()); + + } + else + { + txtResult->setText(previous->getHelp()); + } + m_result->setPrevious(previous->getResult()); + } + + if(NULL!=m_nextNode) + { + m_nextNode->run(this); + } +} +QString ListAliasNode::toString()const +{ + QString result(QObject::tr("List of Alias:\n")); + foreach(QString key, m_mapAlias->keys()) + { + result+=QString("%1 : %2\n").arg(key).arg(m_mapAlias->value(key)); + } + + return result; +} + +qint64 ListAliasNode::getPriority() const +{ + return 0; +} diff --git a/node/listaliasnode.h b/node/listaliasnode.h new file mode 100644 index 0000000..d01d17a --- /dev/null +++ b/node/listaliasnode.h @@ -0,0 +1,33 @@ +#ifndef LISTALIASNODE_H +#define LISTALIASNODE_H + +#include "executionnode.h" +#include "result/stringresult.h" + + +class ListAliasNode : public ExecutionNode +{ +public: + ListAliasNode(QMap<QString,QString>* mapAlias); + /** + * @brief run + * @param previous + */ + virtual void run(ExecutionNode* previous = NULL); + + /** + * @brief toString + * @return + */ + virtual QString toString()const; + /** + * @brief getPriority + * @return + */ + virtual qint64 getPriority() const; + +private: + QMap<QString,QString>* m_mapAlias; +}; + +#endif // LISTALIASNODE_H diff --git a/node/node.pri b/node/node.pri index 7ed357c..7424c0b 100644 --- a/node/node.pri +++ b/node/node.pri @@ -12,7 +12,8 @@ HEADERS += \ node/parenthesesnode.h \ node/helpnode.h \ $$PWD/jumpbackwardnode.h \ - node/listsetrollnode.h + node/listsetrollnode.h \ + $$PWD/listaliasnode.h SOURCES += \ node/dicerollernode.cpp \ @@ -28,4 +29,5 @@ SOURCES += \ node/parenthesesnode.cpp \ node/helpnode.cpp \ $$PWD/jumpbackwardnode.cpp \ - node/listsetrollnode.cpp + node/listsetrollnode.cpp \ + $$PWD/listaliasnode.cpp |