author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (unidiff) | |
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 @@ | |||
1 | #include "ExtensionFactory.h" | ||
2 | |||
3 | ExtensionFactory::ExtensionFactory() | ||
4 | { | ||
5 | qDebug("ExtensionFactory::ExtensionFactory()"); | ||
6 | m_pLoadList = NULL; | ||
7 | } | ||
8 | |||
9 | ExtensionFactory::~ExtensionFactory() | ||
10 | { | ||
11 | qDebug("ExtensionFactory::~ExtensionFactory()"); | ||
12 | } | ||
13 | |||
14 | ExtensionInterface* ExtensionFactory::createInstance(const QString& kind) | ||
15 | { | ||
16 | ExtensionInterface* ext; | ||
17 | QString kindstr = kind.lower(); | ||
18 | |||
19 | if(kindstr == "switch"){ | ||
20 | ext = new TaskSwitcher(kindstr); | ||
21 | } else if(kindstr == "select"){ | ||
22 | ext = new TaskSelector(kindstr); | ||
23 | } else if(kindstr.find("launch") == 0){ | ||
24 | ext = new KeyLauncher(kindstr); | ||
25 | } else if(kindstr.find("menu") == 0){ | ||
26 | ext = new MenuLauncher(kindstr); | ||
27 | } else { | ||
28 | return(NULL); | ||
29 | } | ||
30 | m_oExtList.append(ext); | ||
31 | return(ext); | ||
32 | } | ||
33 | |||
34 | ExtensionInterface* ExtensionFactory::createInstance(const QString& kind, | ||
35 | int keycode, int keymask) | ||
36 | { | ||
37 | ExtensionInterface* ext; | ||
38 | QString kindstr = kind.lower(); | ||
39 | |||
40 | ext = loadInstance(kindstr, keycode, keymask); | ||
41 | if(ext != NULL){ | ||
42 | return(ext); | ||
43 | } | ||
44 | |||
45 | if(kindstr == "switch"){ | ||
46 | ext = new TaskSwitcher(kindstr); | ||
47 | } else if(kindstr == "select"){ | ||
48 | ext = new TaskSelector(kindstr); | ||
49 | } else if(kindstr.find("launch") == 0){ | ||
50 | ext = new KeyLauncher(kindstr); | ||
51 | } else if(kindstr.find("menu") == 0){ | ||
52 | ext = new MenuLauncher(kindstr); | ||
53 | } else { | ||
54 | return(NULL); | ||
55 | } | ||
56 | ext->setKeycode(keycode); | ||
57 | ext->setKeymask(keymask); | ||
58 | |||
59 | m_oExtList.append(ext); | ||
60 | return(ext); | ||
61 | } | ||
62 | |||
63 | ExtensionInterface* ExtensionFactory::loadInstance(const QString& kindstr, | ||
64 | int keycode, int keymask) | ||
65 | { | ||
66 | if(m_pLoadList == NULL){ | ||
67 | return(NULL); | ||
68 | } | ||
69 | |||
70 | for(ExtensionList::Iterator it=m_pLoadList->begin(); | ||
71 | it!=m_pLoadList->end(); ++it){ | ||
72 | if((*it)->kind() == kindstr | ||
73 | && (*it)->getKeycode() == keycode | ||
74 | && (*it)->getKeymask() == keymask){ | ||
75 | m_oExtList.append(*it); | ||
76 | return(*it); | ||
77 | } | ||
78 | } | ||
79 | return(NULL); | ||
80 | } | ||
81 | |||
82 | void ExtensionFactory::clear() | ||
83 | { | ||
84 | for(ExtensionList::Iterator it=m_oExtList.begin(); | ||
85 | it!=m_oExtList.end(); ++it){ | ||
86 | delete *it; | ||
87 | } | ||
88 | m_oExtList.clear(); | ||
89 | } | ||
90 | |||
91 | void ExtensionFactory::reset() | ||
92 | { | ||
93 | m_pLoadList = new ExtensionList(m_oExtList); | ||
94 | m_oExtList.clear(); | ||
95 | } | ||
96 | |||
97 | void ExtensionFactory::sweep() | ||
98 | { | ||
99 | if(m_pLoadList == NULL){ | ||
100 | return; | ||
101 | } | ||
102 | for(ExtensionList::Iterator it=m_pLoadList->begin(); | ||
103 | it!=m_pLoadList->end(); ++it){ | ||
104 | if(m_oExtList.contains(*it) == false){ | ||
105 | delete *it; | ||
106 | } | ||
107 | } | ||
108 | delete m_pLoadList; | ||
109 | m_pLoadList = NULL; | ||
110 | } | ||