File indexing completed on 2024-04-28 04:03:01

0001 //
0002 // C++ Implementation: cvartriggerlist
0003 //
0004 // Description:
0005 //
0006 /*
0007 Copyright 2004-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #include "cvartriggerlist.h"
0024 
0025 #include "cactionmanager.h"
0026 #include "ccmdqueue.h"
0027 #include "ccmdqueues.h"
0028 #include "cvartrigger.h"
0029 #include "cvartriggereditor.h"
0030 
0031 struct cVarTriggerList::Private {
0032   QString varName;
0033 };
0034 
0035 cVarTriggerList::cVarTriggerList ()
0036   : cList ("vartriggers")
0037 {
0038   d = new Private;
0039 
0040   addStringProperty ("variable", "Variable to react on");
0041   addIntProperty ("command-count", "Command count", 0);
0042   // then we have a "command-"+i string for each
0043 }
0044 
0045 cVarTriggerList::~cVarTriggerList()
0046 {
0047   delete d;
0048 }
0049 
0050 cListObject *cVarTriggerList::newObject ()
0051 {
0052   return new cVarTrigger (this);
0053 }
0054 
0055 cListEditor *cVarTriggerList::editor (QWidget *parent)
0056 {
0057   return new cVarTriggerEditor (parent);
0058 }
0059 
0060 void cVarTriggerList::variableChanged (const QString &varname)
0061 {
0062   d->varName = varname;
0063 
0064   traverse (VARTRIGGER_MATCH);
0065 }
0066 
0067 void cVarTriggerList::processCommands (const QStringList &commands)
0068 {
0069   //okay, send the commands!
0070   cCmdQueues *queues = (cCmdQueues *) cActionManager::self()->object ("cmdqueues", session());
0071   if (!queues) return;
0072   cCmdQueue *queue = new cCmdQueue (session());
0073   QStringList::const_iterator it;
0074   for (it = commands.begin(); it != commands.end(); ++it)
0075     queue->addCommand (*it);
0076   queues->addQueue (queue);
0077 }
0078 
0079 QString cVarTriggerList::variableName () const
0080 {
0081   return d->varName;
0082 }
0083 
0084