File indexing completed on 2024-04-21 04:03:04

0001 //
0002 // C++ Implementation: cvartrigger
0003 //
0004 // Description: One variable trigger.
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 "cvartrigger.h"
0024 
0025 #include <kconfig.h>
0026 #include <kconfiggroup.h>
0027 
0028 cVarTrigger::cVarTrigger (int _sess) : sess(_sess)
0029 {
0030 }
0031 
0032 
0033 cVarTrigger::~cVarTrigger()
0034 {
0035 }
0036 
0037 cSaveableField *cVarTrigger::newInstance ()
0038 {
0039   return new cVarTrigger (sess);
0040 }
0041 
0042 void cVarTrigger::load (KConfig *config, const QString &group)
0043 {
0044   KConfigGroup g = config->group (group);
0045   setVarName (g.readEntry ("Variable name", ""));
0046 
0047   newtext.clear();
0048   int cmdcount = g.readEntry ("Command count", 0);
0049   for (int i = 1; i <= cmdcount; i++)
0050   {
0051     QString cmdline = g.readEntry ("Command line " +
0052           QString::number (i), "");
0053     newtext.push_back (cmdline);
0054   }
0055 }
0056 
0057 void cVarTrigger::setVarName (const QString &varname)
0058 {
0059   QString v = varname;
0060   //remove all leading $-characters, if any
0061   while ((!v.isEmpty()) && (v[0] == '$'))
0062     v = v.mid (1);
0063   //set the variable name, if it's non-empty
0064   if (!v.isEmpty())
0065     var = v;
0066 }
0067 
0068