File indexing completed on 2024-12-08 06:46:43
0001 // 0002 // C++ Implementation: vartrigplugin 0003 // 0004 // Description: vartrigplugin 0005 // 0006 /* 0007 Copyright 2009-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 "vartrigplugin.h" 0024 0025 #include "clistmanager.h" 0026 #include "cprofilemanager.h" 0027 0028 #include "cvartriggerlist.h" 0029 0030 #include <kpluginfactory.h> 0031 #include <kpluginloader.h> 0032 #include <KLocalizedString> 0033 0034 K_PLUGIN_CLASS_WITH_JSON(cVarTrigPlugin, "vartrigplugin.json") 0035 0036 cVarTrigPlugin::cVarTrigPlugin (QObject *, const QVariantList &) 0037 : cActionBase ("vartrigplugin", 0) 0038 { 0039 cListManager *lm = cListManager::self(); 0040 lm->registerType ("vartriggers", i18n ("Variable Triggers"), cVarTriggerList::newList); 0041 0042 addEventHandler ("var-changed", 50, PT_STRING); 0043 } 0044 0045 cVarTrigPlugin::~cVarTrigPlugin() 0046 { 0047 removeEventHandler ("var-changed"); 0048 0049 cListManager *lm = cListManager::self(); 0050 lm->unregisterType ("vartriggers"); 0051 } 0052 0053 void cVarTrigPlugin::eventStringHandler (QString event, int session, 0054 QString &par1, const QString &) 0055 { 0056 if (event != "var-changed") return; 0057 0058 cListManager *lm = cListManager::self(); 0059 cVarTriggerList *vtl = (cVarTriggerList *) lm->getList (session, "vartriggers"); 0060 if (vtl) vtl->variableChanged (par1); 0061 } 0062 0063 0064 #include "vartrigplugin.moc"