author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (side-by-side diff) | |
tree | c8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp | |
parent | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff) | |
download | opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2 |
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.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
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; +} |