From 2b64a84d39eeed5681d0ee5068c7d11a01527750 Mon Sep 17 00:00:00 2001 From: alwin Date: Mon, 28 Feb 2005 09:40:30 +0000 Subject: other keymapping tool - not working this moment, I have to check it out - the reason is that the config file is somewhat easier to understand than from zkbapplet and has a nice config tool. Please don't put it into any repositories this moment. --- (limited to 'noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp') diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp new file mode 100644 index 0000000..00a43d1 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp @@ -0,0 +1,110 @@ +#include "ExtensionFactory.h" + +ExtensionFactory::ExtensionFactory() +{ + qDebug("ExtensionFactory::ExtensionFactory()"); + m_pLoadList = NULL; +} + +ExtensionFactory::~ExtensionFactory() +{ + qDebug("ExtensionFactory::~ExtensionFactory()"); +} + +ExtensionInterface* ExtensionFactory::createInstance(const QString& kind) +{ + ExtensionInterface* ext; + QString kindstr = kind.lower(); + + if(kindstr == "switch"){ + ext = new TaskSwitcher(kindstr); + } else if(kindstr == "select"){ + ext = new TaskSelector(kindstr); + } else if(kindstr.find("launch") == 0){ + ext = new KeyLauncher(kindstr); + } else if(kindstr.find("menu") == 0){ + ext = new MenuLauncher(kindstr); + } else { + return(NULL); + } + m_oExtList.append(ext); + return(ext); +} + +ExtensionInterface* ExtensionFactory::createInstance(const QString& kind, + int keycode, int keymask) +{ + ExtensionInterface* ext; + QString kindstr = kind.lower(); + + ext = loadInstance(kindstr, keycode, keymask); + if(ext != NULL){ + return(ext); + } + + if(kindstr == "switch"){ + ext = new TaskSwitcher(kindstr); + } else if(kindstr == "select"){ + ext = new TaskSelector(kindstr); + } else if(kindstr.find("launch") == 0){ + ext = new KeyLauncher(kindstr); + } else if(kindstr.find("menu") == 0){ + ext = new MenuLauncher(kindstr); + } else { + return(NULL); + } + ext->setKeycode(keycode); + ext->setKeymask(keymask); + + m_oExtList.append(ext); + return(ext); +} + +ExtensionInterface* ExtensionFactory::loadInstance(const QString& kindstr, + int keycode, int keymask) +{ + if(m_pLoadList == NULL){ + return(NULL); + } + + for(ExtensionList::Iterator it=m_pLoadList->begin(); + it!=m_pLoadList->end(); ++it){ + if((*it)->kind() == kindstr + && (*it)->getKeycode() == keycode + && (*it)->getKeymask() == keymask){ + m_oExtList.append(*it); + return(*it); + } + } + return(NULL); +} + +void ExtensionFactory::clear() +{ + for(ExtensionList::Iterator it=m_oExtList.begin(); + it!=m_oExtList.end(); ++it){ + delete *it; + } + m_oExtList.clear(); +} + +void ExtensionFactory::reset() +{ + m_pLoadList = new ExtensionList(m_oExtList); + m_oExtList.clear(); +} + +void ExtensionFactory::sweep() +{ + if(m_pLoadList == NULL){ + return; + } + for(ExtensionList::Iterator it=m_pLoadList->begin(); + it!=m_pLoadList->end(); ++it){ + if(m_oExtList.contains(*it) == false){ + delete *it; + } + } + delete m_pLoadList; + m_pLoadList = NULL; +} -- cgit v0.9.0.2