File indexing completed on 2024-05-12 05:39:27
0001 /************************************************************************* 0002 * Copyright (C) 2009 by Renaud Guezennec * 0003 * * 0004 * https://rolisteam.org/ * 0005 * * 0006 * rolisteam is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published * 0008 * by the Free Software Foundation; either version 2 of the License, * 0009 * or (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, write to the * 0018 * Free Software Foundation, Inc., * 0019 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0020 *************************************************************************/ 0021 #include "listaliasnode.h" 0022 0023 ListAliasNode::ListAliasNode(const QList<DiceAlias*>& apAlias) : m_aliasList(apAlias) 0024 { 0025 m_result= new StringResult(); 0026 } 0027 void ListAliasNode::run(ExecutionNode* previous) 0028 { 0029 m_previousNode= previous; 0030 StringResult* txtResult= dynamic_cast<StringResult*>(m_result); 0031 txtResult->setHighLight(false); 0032 0033 txtResult->addText(buildList()); 0034 txtResult->finished(); 0035 if(nullptr != previous) 0036 { 0037 // txtResult->setText(previous->getHelp()); 0038 m_result->setPrevious(previous->getResult()); 0039 } 0040 0041 if(nullptr != m_nextNode) 0042 { 0043 m_nextNode->run(this); 0044 } 0045 } 0046 QString ListAliasNode::buildList() const 0047 { 0048 QString result(QObject::tr("List of Alias:\n")); 0049 for(auto& key : m_aliasList) 0050 { 0051 result+= QString("%1 : %2 # %3\n").arg(key->pattern(), key->command(), key->comment()); 0052 } 0053 return result; 0054 } 0055 QString ListAliasNode::toString(bool wl) const 0056 { 0057 QStringList resultList; 0058 for(auto& key : m_aliasList) 0059 { 0060 resultList << "{" << key->pattern() << key->command() << "}"; 0061 } 0062 0063 if(wl) 0064 { 0065 return QString("%1 [label=\"ListAliasNode %2\"]").arg(m_id, resultList.join(",")); 0066 } 0067 else 0068 { 0069 return m_id; 0070 } 0071 } 0072 qint64 ListAliasNode::getPriority() const 0073 { 0074 return 0; 0075 } 0076 0077 ExecutionNode* ListAliasNode::getCopy() const 0078 { 0079 ListAliasNode* node= new ListAliasNode(m_aliasList); 0080 if(nullptr != m_nextNode) 0081 { 0082 node->setNextNode(m_nextNode->getCopy()); 0083 } 0084 return node; 0085 }