summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/zkbnames.cpp3
-rw-r--r--noncore/apps/keyz-cfg/zkbnames.h4
-rw-r--r--noncore/apps/keyz-cfg/zkbxml.cpp14
3 files changed, 0 insertions, 21 deletions
diff --git a/noncore/apps/keyz-cfg/zkbnames.cpp b/noncore/apps/keyz-cfg/zkbnames.cpp
index fec3a2e..c20a114 100644
--- a/noncore/apps/keyz-cfg/zkbnames.cpp
+++ b/noncore/apps/keyz-cfg/zkbnames.cpp
@@ -1,450 +1,447 @@
1#ifdef USE_ZKB_NAMES
2
3#include <qmap.h> 1#include <qmap.h>
4#include <qstring.h> 2#include <qstring.h>
5 3
6#include "zkbnames.h" 4#include "zkbnames.h"
7 5
8QString Null_String((const char*) 0); 6QString Null_String((const char*) 0);
9 7
10// Implementation of KeyNames 8// Implementation of KeyNames
11static struct { 9static struct {
12 int key; 10 int key;
13 char *name; 11 char *name;
14} Key_Names[] = { 12} Key_Names[] = {
15 { 32, "Space" }, 13 { 32, "Space" },
16 { 39, "Apostrophe" }, 14 { 39, "Apostrophe" },
17 { 44, "Comma" }, 15 { 44, "Comma" },
18 { 46, "Period" }, 16 { 46, "Period" },
19 { 47, "Slash" }, 17 { 47, "Slash" },
20 { 65, "A" }, 18 { 65, "A" },
21 { 66, "B" }, 19 { 66, "B" },
22 { 67, "C" }, 20 { 67, "C" },
23 { 68, "D" }, 21 { 68, "D" },
24 { 69, "E" }, 22 { 69, "E" },
25 { 70, "F" }, 23 { 70, "F" },
26 { 71, "G" }, 24 { 71, "G" },
27 { 72, "H" }, 25 { 72, "H" },
28 { 73, "I" }, 26 { 73, "I" },
29 { 74, "J" }, 27 { 74, "J" },
30 { 75, "K" }, 28 { 75, "K" },
31 { 76, "L" }, 29 { 76, "L" },
32 { 77, "M" }, 30 { 77, "M" },
33 { 78, "N" }, 31 { 78, "N" },
34 { 79, "O" }, 32 { 79, "O" },
35 { 80, "P" }, 33 { 80, "P" },
36 { 81, "Q" }, 34 { 81, "Q" },
37 { 82, "R" }, 35 { 82, "R" },
38 { 83, "S" }, 36 { 83, "S" },
39 { 84, "T" }, 37 { 84, "T" },
40 { 85, "U" }, 38 { 85, "U" },
41 { 86, "V" }, 39 { 86, "V" },
42 { 87, "W" }, 40 { 87, "W" },
43 { 88, "X" }, 41 { 88, "X" },
44 { 89, "Y" }, 42 { 89, "Y" },
45 { 90, "Z" }, 43 { 90, "Z" },
46 { 4096, "Cancel" }, 44 { 4096, "Cancel" },
47 { 4097, "Tab" }, 45 { 4097, "Tab" },
48 { 4099, "Backspace" }, 46 { 4099, "Backspace" },
49 { 4100, "Enter" }, 47 { 4100, "Enter" },
50 { 4114, "Left" }, 48 { 4114, "Left" },
51 { 4115, "Up" }, 49 { 4115, "Up" },
52 { 4116, "Right" }, 50 { 4116, "Right" },
53 { 4117, "Down" }, 51 { 4117, "Down" },
54 { 4128, "Left Shift" }, 52 { 4128, "Left Shift" },
55 { 4130, "Right Shift" }, 53 { 4130, "Right Shift" },
56 { 4152, "Calendar" }, 54 { 4152, "Calendar" },
57 { 4153, "Addressbook" }, 55 { 4153, "Addressbook" },
58 { 4154, "Menu" }, 56 { 4154, "Menu" },
59 { 4155, "Home" }, 57 { 4155, "Home" },
60 { 4156, "Mail" }, 58 { 4156, "Mail" },
61 { 4165, "Fn" }, 59 { 4165, "Fn" },
62 { 4173, "Middle" }, 60 { 4173, "Middle" },
63 { 4176, "OK" }, 61 { 4176, "OK" },
64 { 4177, "Off" }, 62 { 4177, "Off" },
65 { 4178, "Light" }, 63 { 4178, "Light" },
66 { 0, 0 } 64 { 0, 0 }
67}; 65};
68 66
69static QMap<QString, int> kn_map; 67static QMap<QString, int> kn_map;
70static QMap<int, QString> kn_rmap; 68static QMap<int, QString> kn_rmap;
71 69
72void init_kn_maps() { 70void init_kn_maps() {
73 int i = 0; 71 int i = 0;
74 while (Key_Names[i].name != 0) { 72 while (Key_Names[i].name != 0) {
75 int key = Key_Names[i].key; 73 int key = Key_Names[i].key;
76 QString name(Key_Names[i].name); 74 QString name(Key_Names[i].name);
77 75
78 kn_map.insert(name, key); 76 kn_map.insert(name, key);
79 kn_rmap.insert(key, name); 77 kn_rmap.insert(key, name);
80 i++; 78 i++;
81 } 79 }
82} 80}
83 81
84int KeyNames::find(const QString& key) { 82int KeyNames::find(const QString& key) {
85 if (kn_map.isEmpty()) { 83 if (kn_map.isEmpty()) {
86 init_kn_maps(); 84 init_kn_maps();
87 } 85 }
88 86
89 QMap<QString, int>::Iterator it = kn_map.find(key); 87 QMap<QString, int>::Iterator it = kn_map.find(key);
90 if (it == kn_map.end()) { 88 if (it == kn_map.end()) {
91 return -1; 89 return -1;
92 } else { 90 } else {
93 return it.data(); 91 return it.data();
94 } 92 }
95} 93}
96 94
97const QString& KeyNames::find(int k) { 95const QString& KeyNames::find(int k) {
98 if (kn_map.isEmpty()) { 96 if (kn_map.isEmpty()) {
99 init_kn_maps(); 97 init_kn_maps();
100 } 98 }
101 99
102 QMap<int, QString>::Iterator it = kn_rmap.find(k); 100 QMap<int, QString>::Iterator it = kn_rmap.find(k);
103 if (it == kn_rmap.end()) { 101 if (it == kn_rmap.end()) {
104 return Null_String; 102 return Null_String;
105 } else { 103 } else {
106 return it.data(); 104 return it.data();
107 } 105 }
108} 106}
109 107
110// Implementation of ModifierNames 108// Implementation of ModifierNames
111struct { 109struct {
112 int value; 110 int value;
113 char* name; 111 char* name;
114} Modifier_Names[] = { 112} Modifier_Names[] = {
115 { 8, "Shift" }, 113 { 8, "Shift" },
116 { 16, "Control" }, 114 { 16, "Control" },
117 { 32, "Alt" }, 115 { 32, "Alt" },
118 { 0x4000, "Keypad" }, 116 { 0x4000, "Keypad" },
119 { 0, 0 } 117 { 0, 0 }
120}; 118};
121 119
122static QMap<QString, int> mn_map; 120static QMap<QString, int> mn_map;
123static QMap<int, QString> mn_rmap; 121static QMap<int, QString> mn_rmap;
124 122
125void init_mn_maps() { 123void init_mn_maps() {
126 int i = 0; 124 int i = 0;
127 while (Modifier_Names[i].name != 0) { 125 while (Modifier_Names[i].name != 0) {
128 int value = Modifier_Names[i].value; 126 int value = Modifier_Names[i].value;
129 QString name(Modifier_Names[i].name); 127 QString name(Modifier_Names[i].name);
130 128
131 mn_map.insert(name, value); 129 mn_map.insert(name, value);
132 mn_rmap.insert(value, name); 130 mn_rmap.insert(value, name);
133 i++; 131 i++;
134 } 132 }
135} 133}
136 134
137int ModifierNames::find(const QString& key) { 135int ModifierNames::find(const QString& key) {
138 if (mn_map.isEmpty()) { 136 if (mn_map.isEmpty()) {
139 init_mn_maps(); 137 init_mn_maps();
140 } 138 }
141 139
142 QMap<QString, int>::Iterator it = mn_map.find(key); 140 QMap<QString, int>::Iterator it = mn_map.find(key);
143 if (it == mn_map.end()) { 141 if (it == mn_map.end()) {
144 return -1; 142 return -1;
145 } else { 143 } else {
146 return it.data(); 144 return it.data();
147 } 145 }
148} 146}
149 147
150const QString& ModifierNames::find(int k) { 148const QString& ModifierNames::find(int k) {
151 if (mn_map.isEmpty()) { 149 if (mn_map.isEmpty()) {
152 init_mn_maps(); 150 init_mn_maps();
153 } 151 }
154 152
155 QMap<int, QString>::Iterator it = mn_rmap.find(k); 153 QMap<int, QString>::Iterator it = mn_rmap.find(k);
156 if (it == mn_rmap.end()) { 154 if (it == mn_rmap.end()) {
157 return Null_String; 155 return Null_String;
158 } else { 156 } else {
159 return it.data(); 157 return it.data();
160 } 158 }
161} 159}
162 160
163// Implementation of KeycodeNames 161// Implementation of KeycodeNames
164 162
165struct { 163struct {
166 char* name; 164 char* name;
167 int keycode; 165 int keycode;
168} Keycode_Names[] = { 166} Keycode_Names[] = {
169 { "Escape", 0x1000 }, 167 { "Escape", 0x1000 },
170 { "Tab", 0x1001 }, 168 { "Tab", 0x1001 },
171 { "Backtab", 0x1002 }, 169 { "Backtab", 0x1002 },
172 { "Backspace", 0x1003 }, 170 { "Backspace", 0x1003 },
173 { "BackSpace", 0x1003 }, 171 { "BackSpace", 0x1003 },
174 { "Return", 0x1004 }, 172 { "Return", 0x1004 },
175 { "Enter", 0x1005 }, 173 { "Enter", 0x1005 },
176 { "Insert", 0x1006 }, 174 { "Insert", 0x1006 },
177 { "Delete", 0x1007 }, 175 { "Delete", 0x1007 },
178 { "Pause", 0x1008 }, 176 { "Pause", 0x1008 },
179 { "Print", 0x1009 }, 177 { "Print", 0x1009 },
180 { "SysReq", 0x100a }, 178 { "SysReq", 0x100a },
181 { "Home", 0x1010 }, 179 { "Home", 0x1010 },
182 { "End", 0x1011 }, 180 { "End", 0x1011 },
183 { "Left", 0x1012 }, 181 { "Left", 0x1012 },
184 { "Up", 0x1013 }, 182 { "Up", 0x1013 },
185 { "Right", 0x1014 }, 183 { "Right", 0x1014 },
186 { "Down", 0x1015 }, 184 { "Down", 0x1015 },
187 { "Prior", 0x1016 }, 185 { "Prior", 0x1016 },
188 { "PageUp", 0x1016 }, 186 { "PageUp", 0x1016 },
189 { "Next", 0x1017 }, 187 { "Next", 0x1017 },
190 { "PageDown", 0x1017 }, 188 { "PageDown", 0x1017 },
191 { "Shift", 0x1020 }, 189 { "Shift", 0x1020 },
192 { "Control", 0x1021 }, 190 { "Control", 0x1021 },
193 { "Meta", 0x1022 }, 191 { "Meta", 0x1022 },
194 { "Alt", 0x1023 }, 192 { "Alt", 0x1023 },
195 { "CapsLock", 0x1024 }, 193 { "CapsLock", 0x1024 },
196 { "NumLock", 0x1025 }, 194 { "NumLock", 0x1025 },
197 { "ScrollLock", 0x1026 }, 195 { "ScrollLock", 0x1026 },
198 { "F1", 0x1030 }, 196 { "F1", 0x1030 },
199 { "F2", 0x1031 }, 197 { "F2", 0x1031 },
200 { "F3", 0x1032 }, 198 { "F3", 0x1032 },
201 { "F4", 0x1033 }, 199 { "F4", 0x1033 },
202 { "F5", 0x1034 }, 200 { "F5", 0x1034 },
203 { "F6", 0x1035 }, 201 { "F6", 0x1035 },
204 { "F7", 0x1036 }, 202 { "F7", 0x1036 },
205 { "F8", 0x1037 }, 203 { "F8", 0x1037 },
206 { "F9", 0x1038 }, 204 { "F9", 0x1038 },
207 { "F10", 0x1039 }, 205 { "F10", 0x1039 },
208 { "F11", 0x103a }, 206 { "F11", 0x103a },
209 { "F12", 0x103b }, 207 { "F12", 0x103b },
210 { "F13", 0x103c }, 208 { "F13", 0x103c },
211 { "F14", 0x103d }, 209 { "F14", 0x103d },
212 { "F15", 0x103e }, 210 { "F15", 0x103e },
213 { "F16", 0x103f }, 211 { "F16", 0x103f },
214 { "F17", 0x1040 }, 212 { "F17", 0x1040 },
215 { "F18", 0x1041 }, 213 { "F18", 0x1041 },
216 { "F19", 0x1042 }, 214 { "F19", 0x1042 },
217 { "F20", 0x1043 }, 215 { "F20", 0x1043 },
218 { "F21", 0x1044 }, 216 { "F21", 0x1044 },
219 { "F22", 0x1045 }, 217 { "F22", 0x1045 },
220 { "F23", 0x1046 }, 218 { "F23", 0x1046 },
221 { "F24", 0x1047 }, 219 { "F24", 0x1047 },
222 { "F25", 0x1048 }, 220 { "F25", 0x1048 },
223 { "F26", 0x1049 }, 221 { "F26", 0x1049 },
224 { "F27", 0x104a }, 222 { "F27", 0x104a },
225 { "F28", 0x104b }, 223 { "F28", 0x104b },
226 { "F29", 0x104c }, 224 { "F29", 0x104c },
227 { "F30", 0x104d }, 225 { "F30", 0x104d },
228 { "F31", 0x104e }, 226 { "F31", 0x104e },
229 { "F32", 0x104f }, 227 { "F32", 0x104f },
230 { "F33", 0x1050 }, 228 { "F33", 0x1050 },
231 { "F34", 0x1051 }, 229 { "F34", 0x1051 },
232 { "F35", 0x1052 }, 230 { "F35", 0x1052 },
233 { "Super_L", 0x1053 }, 231 { "Super_L", 0x1053 },
234 { "Super_R", 0x1054 }, 232 { "Super_R", 0x1054 },
235 { "Menu", 0x1055 }, 233 { "Menu", 0x1055 },
236 { "Hyper_L", 0x1056 }, 234 { "Hyper_L", 0x1056 },
237 { "Hyper_R", 0x1057 }, 235 { "Hyper_R", 0x1057 },
238 { "Help", 0x1058 }, 236 { "Help", 0x1058 },
239 { "Space", 0x20 }, 237 { "Space", 0x20 },
240 { "Any", 0x20 }, 238 { "Any", 0x20 },
241 { "Exclam", 0x21 }, 239 { "Exclam", 0x21 },
242 { "QuoteDbl", 0x22 }, 240 { "QuoteDbl", 0x22 },
243 { "NumberSign", 0x23 }, 241 { "NumberSign", 0x23 },
244 { "Dollar", 0x24 }, 242 { "Dollar", 0x24 },
245 { "Percent", 0x25 }, 243 { "Percent", 0x25 },
246 { "Ampersand", 0x26 }, 244 { "Ampersand", 0x26 },
247 { "Apostrophe", 0x27 }, 245 { "Apostrophe", 0x27 },
248 { "ParenLeft", 0x28 }, 246 { "ParenLeft", 0x28 },
249 { "ParenRight", 0x29 }, 247 { "ParenRight", 0x29 },
250 { "Asterisk", 0x2a }, 248 { "Asterisk", 0x2a },
251 { "Plus", 0x2b }, 249 { "Plus", 0x2b },
252 { "Comma", 0x2c }, 250 { "Comma", 0x2c },
253 { "Minus", 0x2d }, 251 { "Minus", 0x2d },
254 { "Period", 0x2e }, 252 { "Period", 0x2e },
255 { "Slash", 0x2f }, 253 { "Slash", 0x2f },
256 { "0", 0x30 }, 254 { "0", 0x30 },
257 { "1", 0x31 }, 255 { "1", 0x31 },
258 { "2", 0x32 }, 256 { "2", 0x32 },
259 { "3", 0x33 }, 257 { "3", 0x33 },
260 { "4", 0x34 }, 258 { "4", 0x34 },
261 { "5", 0x35 }, 259 { "5", 0x35 },
262 { "6", 0x36 }, 260 { "6", 0x36 },
263 { "7", 0x37 }, 261 { "7", 0x37 },
264 { "8", 0x38 }, 262 { "8", 0x38 },
265 { "9", 0x39 }, 263 { "9", 0x39 },
266 { "Colon", 0x3a }, 264 { "Colon", 0x3a },
267 { "Semicolon", 0x3b }, 265 { "Semicolon", 0x3b },
268 { "Less", 0x3c }, 266 { "Less", 0x3c },
269 { "Equal", 0x3d }, 267 { "Equal", 0x3d },
270 { "Greater", 0x3e }, 268 { "Greater", 0x3e },
271 { "Question", 0x3f }, 269 { "Question", 0x3f },
272 { "At", 0x40 }, 270 { "At", 0x40 },
273 { "A", 0x41 }, 271 { "A", 0x41 },
274 { "B", 0x42 }, 272 { "B", 0x42 },
275 { "C", 0x43 }, 273 { "C", 0x43 },
276 { "D", 0x44 }, 274 { "D", 0x44 },
277 { "E", 0x45 }, 275 { "E", 0x45 },
278 { "F", 0x46 }, 276 { "F", 0x46 },
279 { "G", 0x47 }, 277 { "G", 0x47 },
280 { "H", 0x48 }, 278 { "H", 0x48 },
281 { "I", 0x49 }, 279 { "I", 0x49 },
282 { "J", 0x4a }, 280 { "J", 0x4a },
283 { "K", 0x4b }, 281 { "K", 0x4b },
284 { "L", 0x4c }, 282 { "L", 0x4c },
285 { "M", 0x4d }, 283 { "M", 0x4d },
286 { "N", 0x4e }, 284 { "N", 0x4e },
287 { "O", 0x4f }, 285 { "O", 0x4f },
288 { "P", 0x50 }, 286 { "P", 0x50 },
289 { "Q", 0x51 }, 287 { "Q", 0x51 },
290 { "R", 0x52 }, 288 { "R", 0x52 },
291 { "S", 0x53 }, 289 { "S", 0x53 },
292 { "T", 0x54 }, 290 { "T", 0x54 },
293 { "U", 0x55 }, 291 { "U", 0x55 },
294 { "V", 0x56 }, 292 { "V", 0x56 },
295 { "W", 0x57 }, 293 { "W", 0x57 },
296 { "X", 0x58 }, 294 { "X", 0x58 },
297 { "Y", 0x59 }, 295 { "Y", 0x59 },
298 { "Z", 0x5a }, 296 { "Z", 0x5a },
299 { "BracketLeft", 0x5b }, 297 { "BracketLeft", 0x5b },
300 { "Backslash", 0x5c }, 298 { "Backslash", 0x5c },
301 { "BracketRight", 0x5d }, 299 { "BracketRight", 0x5d },
302 { "AsciiCircum", 0x5e }, 300 { "AsciiCircum", 0x5e },
303 { "Underscore", 0x5f }, 301 { "Underscore", 0x5f },
304 { "QuoteLeft", 0x60 }, 302 { "QuoteLeft", 0x60 },
305 { "BraceLeft", 0x7b }, 303 { "BraceLeft", 0x7b },
306 { "Bar", 0x7c }, 304 { "Bar", 0x7c },
307 { "BraceRight", 0x7d }, 305 { "BraceRight", 0x7d },
308 { "AsciiTilde", 0x7e }, 306 { "AsciiTilde", 0x7e },
309 { "nobreakspace", 0x0a0 }, 307 { "nobreakspace", 0x0a0 },
310 { "exclamdown", 0x0a1 }, 308 { "exclamdown", 0x0a1 },
311 { "cent", 0x0a2 }, 309 { "cent", 0x0a2 },
312 { "sterling", 0x0a3 }, 310 { "sterling", 0x0a3 },
313 { "currency", 0x0a4 }, 311 { "currency", 0x0a4 },
314 { "yen", 0x0a5 }, 312 { "yen", 0x0a5 },
315 { "brokenbar", 0x0a6 }, 313 { "brokenbar", 0x0a6 },
316 { "section", 0x0a7 }, 314 { "section", 0x0a7 },
317 { "diaeresis", 0x0a8 }, 315 { "diaeresis", 0x0a8 },
318 { "copyright", 0x0a9 }, 316 { "copyright", 0x0a9 },
319 { "ordfeminine", 0x0aa }, 317 { "ordfeminine", 0x0aa },
320 { "guillemotleft", 0x0ab }, 318 { "guillemotleft", 0x0ab },
321 { "notsign", 0x0ac }, 319 { "notsign", 0x0ac },
322 { "hyphen", 0x0ad }, 320 { "hyphen", 0x0ad },
323 { "registered", 0x0ae }, 321 { "registered", 0x0ae },
324 { "macron", 0x0af }, 322 { "macron", 0x0af },
325 { "degree", 0x0b0 }, 323 { "degree", 0x0b0 },
326 { "plusminus", 0x0b1 }, 324 { "plusminus", 0x0b1 },
327 { "twosuperior", 0x0b2 }, 325 { "twosuperior", 0x0b2 },
328 { "threesuperior", 0x0b3 }, 326 { "threesuperior", 0x0b3 },
329 { "acute", 0x0b4 }, 327 { "acute", 0x0b4 },
330 { "mu", 0x0b5 }, 328 { "mu", 0x0b5 },
331 { "paragraph", 0x0b6 }, 329 { "paragraph", 0x0b6 },
332 { "periodcentered", 0x0b7 }, 330 { "periodcentered", 0x0b7 },
333 { "cedilla", 0x0b8 }, 331 { "cedilla", 0x0b8 },
334 { "onesuperior", 0x0b9 }, 332 { "onesuperior", 0x0b9 },
335 { "masculine", 0x0ba }, 333 { "masculine", 0x0ba },
336 { "guillemotright", 0x0bb }, 334 { "guillemotright", 0x0bb },
337 { "onequarter", 0x0bc }, 335 { "onequarter", 0x0bc },
338 { "onehalf", 0x0bd }, 336 { "onehalf", 0x0bd },
339 { "threequarters", 0x0be }, 337 { "threequarters", 0x0be },
340 { "questiondown", 0x0bf }, 338 { "questiondown", 0x0bf },
341 { "Agrave", 0x0c0 }, 339 { "Agrave", 0x0c0 },
342 { "Aacute", 0x0c1 }, 340 { "Aacute", 0x0c1 },
343 { "Acircumflex", 0x0c2 }, 341 { "Acircumflex", 0x0c2 },
344 { "Atilde", 0x0c3 }, 342 { "Atilde", 0x0c3 },
345 { "Adiaeresis", 0x0c4 }, 343 { "Adiaeresis", 0x0c4 },
346 { "Aring", 0x0c5 }, 344 { "Aring", 0x0c5 },
347 { "AE", 0x0c6 }, 345 { "AE", 0x0c6 },
348 { "Ccedilla", 0x0c7 }, 346 { "Ccedilla", 0x0c7 },
349 { "Egrave", 0x0c8 }, 347 { "Egrave", 0x0c8 },
350 { "Eacute", 0x0c9 }, 348 { "Eacute", 0x0c9 },
351 { "Ecircumflex", 0x0ca }, 349 { "Ecircumflex", 0x0ca },
352 { "Ediaeresis", 0x0cb }, 350 { "Ediaeresis", 0x0cb },
353 { "Igrave", 0x0cc }, 351 { "Igrave", 0x0cc },
354 { "Iacute", 0x0cd }, 352 { "Iacute", 0x0cd },
355 { "Icircumflex", 0x0ce }, 353 { "Icircumflex", 0x0ce },
356 { "Idiaeresis", 0x0cf }, 354 { "Idiaeresis", 0x0cf },
357 { "ETH", 0x0d0 }, 355 { "ETH", 0x0d0 },
358 { "Ntilde", 0x0d1 }, 356 { "Ntilde", 0x0d1 },
359 { "Ograve", 0x0d2 }, 357 { "Ograve", 0x0d2 },
360 { "Oacute", 0x0d3 }, 358 { "Oacute", 0x0d3 },
361 { "Ocircumflex", 0x0d4 }, 359 { "Ocircumflex", 0x0d4 },
362 { "Otilde", 0x0d5 }, 360 { "Otilde", 0x0d5 },
363 { "Odiaeresis", 0x0d6 }, 361 { "Odiaeresis", 0x0d6 },
364 { "multiply", 0x0d7 }, 362 { "multiply", 0x0d7 },
365 { "Ooblique", 0x0d8 }, 363 { "Ooblique", 0x0d8 },
366 { "Ugrave", 0x0d9 }, 364 { "Ugrave", 0x0d9 },
367 { "Uacute", 0x0da }, 365 { "Uacute", 0x0da },
368 { "Ucircumflex", 0x0db }, 366 { "Ucircumflex", 0x0db },
369 { "Udiaeresis", 0x0dc }, 367 { "Udiaeresis", 0x0dc },
370 { "Yacute", 0x0dd }, 368 { "Yacute", 0x0dd },
371 { "THORN", 0x0de }, 369 { "THORN", 0x0de },
372 { "ssharp", 0x0df }, 370 { "ssharp", 0x0df },
373 { "agrave", 0x0e0 }, 371 { "agrave", 0x0e0 },
374 { "aacute", 0x0e1 }, 372 { "aacute", 0x0e1 },
375 { "acircumflex", 0x0e2 }, 373 { "acircumflex", 0x0e2 },
376 { "atilde", 0x0e3 }, 374 { "atilde", 0x0e3 },
377 { "adiaeresis", 0x0e4 }, 375 { "adiaeresis", 0x0e4 },
378 { "aring", 0x0e5 }, 376 { "aring", 0x0e5 },
379 { "ae", 0x0e6 }, 377 { "ae", 0x0e6 },
380 { "ccedilla", 0x0e7 }, 378 { "ccedilla", 0x0e7 },
381 { "egrave", 0x0e8 }, 379 { "egrave", 0x0e8 },
382 { "eacute", 0x0e9 }, 380 { "eacute", 0x0e9 },
383 { "ecircumflex", 0x0ea }, 381 { "ecircumflex", 0x0ea },
384 { "ediaeresis", 0x0eb }, 382 { "ediaeresis", 0x0eb },
385 { "igrave", 0x0ec }, 383 { "igrave", 0x0ec },
386 { "iacute", 0x0ed }, 384 { "iacute", 0x0ed },
387 { "icircumflex", 0x0ee }, 385 { "icircumflex", 0x0ee },
388 { "idiaeresis", 0x0ef }, 386 { "idiaeresis", 0x0ef },
389 { "eth", 0x0f0 }, 387 { "eth", 0x0f0 },
390 { "ntilde", 0x0f1 }, 388 { "ntilde", 0x0f1 },
391 { "ograve", 0x0f2 }, 389 { "ograve", 0x0f2 },
392 { "oacute", 0x0f3 }, 390 { "oacute", 0x0f3 },
393 { "ocircumflex", 0x0f4 }, 391 { "ocircumflex", 0x0f4 },
394 { "otilde", 0x0f5 }, 392 { "otilde", 0x0f5 },
395 { "odiaeresis", 0x0f6 }, 393 { "odiaeresis", 0x0f6 },
396 { "division", 0x0f7 }, 394 { "division", 0x0f7 },
397 { "oslash", 0x0f8 }, 395 { "oslash", 0x0f8 },
398 { "ugrave", 0x0f9 }, 396 { "ugrave", 0x0f9 },
399 { "uacute", 0x0fa }, 397 { "uacute", 0x0fa },
400 { "ucircumflex", 0x0fb }, 398 { "ucircumflex", 0x0fb },
401 { "udiaeresis", 0x0fc }, 399 { "udiaeresis", 0x0fc },
402 { "yacute", 0x0fd }, 400 { "yacute", 0x0fd },
403 { "thorn", 0x0fe }, 401 { "thorn", 0x0fe },
404 { "ydiaeresis", 0x0ff }, 402 { "ydiaeresis", 0x0ff },
405 { "unknown", 0xffff }, 403 { "unknown", 0xffff },
406 { 0, 0} 404 { 0, 0}
407}; 405};
408 406
409static QMap<QString, int> kcn_map; 407static QMap<QString, int> kcn_map;
410static QMap<int, QString> kcn_rmap; 408static QMap<int, QString> kcn_rmap;
411 409
412void init_kcn_maps() { 410void init_kcn_maps() {
413 int i = 0; 411 int i = 0;
414 while (Keycode_Names[i].name != 0) { 412 while (Keycode_Names[i].name != 0) {
415 int keycode = Keycode_Names[i].keycode; 413 int keycode = Keycode_Names[i].keycode;
416 QString name(Keycode_Names[i].name); 414 QString name(Keycode_Names[i].name);
417 415
418 kcn_map.insert(name, keycode); 416 kcn_map.insert(name, keycode);
419 kcn_rmap.insert(keycode, name); 417 kcn_rmap.insert(keycode, name);
420 i++; 418 i++;
421 } 419 }
422} 420}
423 421
424int KeycodeNames::find(const QString& key) { 422int KeycodeNames::find(const QString& key) {
425 if (kcn_map.isEmpty()) { 423 if (kcn_map.isEmpty()) {
426 init_kcn_maps(); 424 init_kcn_maps();
427 } 425 }
428 426
429 QMap<QString, int>::Iterator it = kcn_map.find(key); 427 QMap<QString, int>::Iterator it = kcn_map.find(key);
430 if (it == kcn_map.end()) { 428 if (it == kcn_map.end()) {
431 return -1; 429 return -1;
432 } else { 430 } else {
433 return it.data(); 431 return it.data();
434 } 432 }
435} 433}
436 434
437const QString& KeycodeNames::find(int k) { 435const QString& KeycodeNames::find(int k) {
438 if (kcn_map.isEmpty()) { 436 if (kcn_map.isEmpty()) {
439 init_kcn_maps(); 437 init_kcn_maps();
440 } 438 }
441 439
442 QMap<int, QString>::Iterator it = kcn_rmap.find(k); 440 QMap<int, QString>::Iterator it = kcn_rmap.find(k);
443 if (it == kcn_rmap.end()) { 441 if (it == kcn_rmap.end()) {
444 return Null_String; 442 return Null_String;
445 } else { 443 } else {
446 return it.data(); 444 return it.data();
447 } 445 }
448} 446}
449 447
450#endif
diff --git a/noncore/apps/keyz-cfg/zkbnames.h b/noncore/apps/keyz-cfg/zkbnames.h
index 58462ff..0d1e7f5 100644
--- a/noncore/apps/keyz-cfg/zkbnames.h
+++ b/noncore/apps/keyz-cfg/zkbnames.h
@@ -1,27 +1,23 @@
1#ifndef ZKBNAMES_H 1#ifndef ZKBNAMES_H
2#define ZKBNAMES_H 2#define ZKBNAMES_H
3 3
4#ifdef USE_ZKB_NAMES
5
6#include <qstring.h> 4#include <qstring.h>
7 5
8class KeyNames { 6class KeyNames {
9public: 7public:
10 static int find(const QString& key); 8 static int find(const QString& key);
11 static const QString& find(int); 9 static const QString& find(int);
12}; 10};
13 11
14class KeycodeNames { 12class KeycodeNames {
15public: 13public:
16 static int find(const QString& key); 14 static int find(const QString& key);
17 static const QString& find(int); 15 static const QString& find(int);
18}; 16};
19 17
20class ModifierNames { 18class ModifierNames {
21public: 19public:
22 static int find(const QString& key); 20 static int find(const QString& key);
23 static const QString& find(int); 21 static const QString& find(int);
24}; 22};
25
26#endif
27#endif 23#endif
diff --git a/noncore/apps/keyz-cfg/zkbxml.cpp b/noncore/apps/keyz-cfg/zkbxml.cpp
index 76472cb..5b0084c 100644
--- a/noncore/apps/keyz-cfg/zkbxml.cpp
+++ b/noncore/apps/keyz-cfg/zkbxml.cpp
@@ -108,480 +108,466 @@ bool ZkbXmlHandler::startNextStateElement(const QString& state) {
108} 108}
109 109
110 110
111bool ZkbXmlHandler::endKeymapElement() { 111bool ZkbXmlHandler::endKeymapElement() {
112 return false; 112 return false;
113} 113}
114 114
115bool ZkbXmlHandler::endIncludeElement() { 115bool ZkbXmlHandler::endIncludeElement() {
116 return false; 116 return false;
117} 117}
118 118
119bool ZkbXmlHandler::endLabelElement() { 119bool ZkbXmlHandler::endLabelElement() {
120 return false; 120 return false;
121} 121}
122 122
123bool ZkbXmlHandler::endStateElement() { 123bool ZkbXmlHandler::endStateElement() {
124 return false; 124 return false;
125} 125}
126 126
127bool ZkbXmlHandler::endMapElement() { 127bool ZkbXmlHandler::endMapElement() {
128 return false; 128 return false;
129} 129}
130 130
131bool ZkbXmlHandler::endEventElement() { 131bool ZkbXmlHandler::endEventElement() {
132 return false; 132 return false;
133} 133}
134 134
135bool ZkbXmlHandler::endNextStateElement() { 135bool ZkbXmlHandler::endNextStateElement() {
136 return false; 136 return false;
137} 137}
138 138
139 139
140bool ZkbXmlHandler::start_keymap(const QXmlAttributes& attr) { 140bool ZkbXmlHandler::start_keymap(const QXmlAttributes& attr) {
141 int nattr = 0; 141 int nattr = 0;
142 int didx = attr.index("autorepeat-delay"); 142 int didx = attr.index("autorepeat-delay");
143 int pidx = attr.index("autorepeat-period"); 143 int pidx = attr.index("autorepeat-period");
144 int aidx = attr.index("author"); 144 int aidx = attr.index("author");
145 int ard = -1; 145 int ard = -1;
146 int arp = -1; 146 int arp = -1;
147 QString author; 147 QString author;
148 148
149 if (!elements.isEmpty()) { 149 if (!elements.isEmpty()) {
150 setError("keymap element should be top-level element"); 150 setError("keymap element should be top-level element");
151 return false; 151 return false;
152 } 152 }
153 153
154 if (didx >= 0) { 154 if (didx >= 0) {
155 QString s = attr.value(didx); 155 QString s = attr.value(didx);
156 bool ok; 156 bool ok;
157 157
158 ard = s.toInt(&ok); 158 ard = s.toInt(&ok);
159 if (!ok) { 159 if (!ok) {
160 setError("Invalid autorepeat-delay value: " + s); 160 setError("Invalid autorepeat-delay value: " + s);
161 return false; 161 return false;
162 } 162 }
163 163
164 nattr++; 164 nattr++;
165 } 165 }
166 166
167 if (pidx >= 0) { 167 if (pidx >= 0) {
168 QString s = attr.value(pidx); 168 QString s = attr.value(pidx);
169 bool ok; 169 bool ok;
170 170
171 arp = s.toInt(&ok); 171 arp = s.toInt(&ok);
172 if (!ok) { 172 if (!ok) {
173 setError("Invalid autorepeat-period value: " + s); 173 setError("Invalid autorepeat-period value: " + s);
174 return false; 174 return false;
175 } 175 }
176 176
177 nattr++; 177 nattr++;
178 } 178 }
179 179
180 if (aidx >= 0) { 180 if (aidx >= 0) {
181 author = attr.value(aidx); 181 author = attr.value(aidx);
182 nattr++; 182 nattr++;
183 } 183 }
184 184
185 if (attr.length() > nattr) { 185 if (attr.length() > nattr) {
186 setError("Unsupported attributes"); 186 setError("Unsupported attributes");
187 return false; 187 return false;
188 } 188 }
189 189
190 return startKeymapElement(ard, arp, author); 190 return startKeymapElement(ard, arp, author);
191} 191}
192 192
193bool ZkbXmlHandler::start_include(const QXmlAttributes& attr) { 193bool ZkbXmlHandler::start_include(const QXmlAttributes& attr) {
194 int nattr = 0; 194 int nattr = 0;
195 int fidx = attr.index("file"); 195 int fidx = attr.index("file");
196 int pidx = attr.index("prefix"); 196 int pidx = attr.index("prefix");
197 QString file; 197 QString file;
198 QString prefix((const char*) 0); 198 QString prefix((const char*) 0);
199 199
200 if (elements.first() != Keymap_Tag) { 200 if (elements.first() != Keymap_Tag) {
201 setError("include element should be used only " 201 setError("include element should be used only "
202 "within keymap element"); 202 "within keymap element");
203 return false; 203 return false;
204 } 204 }
205 205
206 if (fidx >= 0) { 206 if (fidx >= 0) {
207 file = attr.value(fidx); 207 file = attr.value(fidx);
208 nattr++; 208 nattr++;
209 } else { 209 } else {
210 setError("Missing file attribute"); 210 setError("Missing file attribute");
211 return false; 211 return false;
212 } 212 }
213 213
214 if (pidx >= 0) { 214 if (pidx >= 0) {
215 prefix = attr.value(pidx); 215 prefix = attr.value(pidx);
216 nattr++; 216 nattr++;
217 } 217 }
218 218
219 if (attr.length() > nattr) { 219 if (attr.length() > nattr) {
220 setError("Unsupported attributes"); 220 setError("Unsupported attributes");
221 return false; 221 return false;
222 } 222 }
223 223
224 return startIncludeElement(file, prefix); 224 return startIncludeElement(file, prefix);
225} 225}
226 226
227bool ZkbXmlHandler::start_label(const QXmlAttributes& attr) { 227bool ZkbXmlHandler::start_label(const QXmlAttributes& attr) {
228 int nattr = 0; 228 int nattr = 0;
229 int nidx = attr.index("name"); 229 int nidx = attr.index("name");
230 int sidx = attr.index("state"); 230 int sidx = attr.index("state");
231 QString name; 231 QString name;
232 QString state; 232 QString state;
233 233
234 if (elements.first() != Keymap_Tag) { 234 if (elements.first() != Keymap_Tag) {
235 setError("label element should be used only " 235 setError("label element should be used only "
236 "within keymap element"); 236 "within keymap element");
237 return false; 237 return false;
238 } 238 }
239 239
240 if (nidx >= 0) { 240 if (nidx >= 0) {
241 name = attr.value(nidx); 241 name = attr.value(nidx);
242 nattr++; 242 nattr++;
243 } else { 243 } else {
244 setError("Missing name attribute"); 244 setError("Missing name attribute");
245 return false; 245 return false;
246 } 246 }
247 247
248 if (sidx >= 0) { 248 if (sidx >= 0) {
249 state = attr.value(sidx); 249 state = attr.value(sidx);
250 nattr++; 250 nattr++;
251 } else { 251 } else {
252 setError("Missing name attribute"); 252 setError("Missing name attribute");
253 return false; 253 return false;
254 } 254 }
255 255
256 if (attr.length() > nattr) { 256 if (attr.length() > nattr) {
257 setError("Unsupported attributes"); 257 setError("Unsupported attributes");
258 return false; 258 return false;
259 } 259 }
260 260
261 return startLabelElement(name, state); 261 return startLabelElement(name, state);
262} 262}
263 263
264bool ZkbXmlHandler::start_state(const QXmlAttributes& attr) { 264bool ZkbXmlHandler::start_state(const QXmlAttributes& attr) {
265 int nattr = 0; 265 int nattr = 0;
266 int nidx = attr.index("name"); 266 int nidx = attr.index("name");
267 int pidx = attr.index("parent"); 267 int pidx = attr.index("parent");
268 int didx = attr.index("default"); 268 int didx = attr.index("default");
269 QString name; 269 QString name;
270 QString parent((const char*) 0); 270 QString parent((const char*) 0);
271 bool dflt = false; 271 bool dflt = false;
272 272
273 if (elements.first() != Keymap_Tag) { 273 if (elements.first() != Keymap_Tag) {
274 setError("state element should be used only " 274 setError("state element should be used only "
275 "within keymap element"); 275 "within keymap element");
276 return false; 276 return false;
277 } 277 }
278 278
279 if (nidx >= 0) { 279 if (nidx >= 0) {
280 name = attr.value(nidx); 280 name = attr.value(nidx);
281 nattr++; 281 nattr++;
282 } else { 282 } else {
283 setError("Missing name attribute"); 283 setError("Missing name attribute");
284 return false; 284 return false;
285 } 285 }
286 286
287 if (pidx >= 0) { 287 if (pidx >= 0) {
288 parent = attr.value(pidx); 288 parent = attr.value(pidx);
289 nattr++; 289 nattr++;
290 } 290 }
291 291
292 if (didx >= 0) { 292 if (didx >= 0) {
293 dflt = str2bool(attr.value(didx)); 293 dflt = str2bool(attr.value(didx));
294 if (!err.isEmpty()) { 294 if (!err.isEmpty()) {
295 return false; 295 return false;
296 } 296 }
297 297
298 nattr++; 298 nattr++;
299 } 299 }
300 300
301 if (attr.length() > nattr) { 301 if (attr.length() > nattr) {
302 setError("Unsupported attributes"); 302 setError("Unsupported attributes");
303 return false; 303 return false;
304 } 304 }
305 305
306 return startStateElement(name, parent, dflt); 306 return startStateElement(name, parent, dflt);
307} 307}
308 308
309bool ZkbXmlHandler::start_map(const QXmlAttributes& attr) { 309bool ZkbXmlHandler::start_map(const QXmlAttributes& attr) {
310 int nattr = 0; 310 int nattr = 0;
311 int kidx = attr.index("keycode"); 311 int kidx = attr.index("keycode");
312 int pidx = attr.index("pressed"); 312 int pidx = attr.index("pressed");
313 int key; 313 int key;
314 bool pressed; 314 bool pressed;
315 315
316 if (elements.first() != State_Tag) { 316 if (elements.first() != State_Tag) {
317 setError("map element should be used only " 317 setError("map element should be used only "
318 "within state element"); 318 "within state element");
319 return false; 319 return false;
320 } 320 }
321 321
322 if (kidx >= 0) { 322 if (kidx >= 0) {
323 key = str2key(attr.value(kidx)); 323 key = str2key(attr.value(kidx));
324 if (!err.isEmpty()) { 324 if (!err.isEmpty()) {
325 return false; 325 return false;
326 } 326 }
327 nattr++; 327 nattr++;
328 } else { 328 } else {
329 setError("Missing keycode attribute"); 329 setError("Missing keycode attribute");
330 return false; 330 return false;
331 } 331 }
332 332
333 if (pidx >= 0) { 333 if (pidx >= 0) {
334 pressed = str2bool(attr.value(pidx)); 334 pressed = str2bool(attr.value(pidx));
335 if (!err.isEmpty()) { 335 if (!err.isEmpty()) {
336 return false; 336 return false;
337 } 337 }
338 nattr++; 338 nattr++;
339 } else { 339 } else {
340 setError("Missing pressed attribute"); 340 setError("Missing pressed attribute");
341 return false; 341 return false;
342 } 342 }
343 343
344 if (attr.length() > nattr) { 344 if (attr.length() > nattr) {
345 setError("Unsupported attributes"); 345 setError("Unsupported attributes");
346 return false; 346 return false;
347 } 347 }
348 348
349 return startMapElement(key, pressed); 349 return startMapElement(key, pressed);
350} 350}
351 351
352bool ZkbXmlHandler::start_event(const QXmlAttributes& attr) { 352bool ZkbXmlHandler::start_event(const QXmlAttributes& attr) {
353 int nattr = 0; 353 int nattr = 0;
354 int kidx = attr.index("keycode"); 354 int kidx = attr.index("keycode");
355 int pidx = attr.index("pressed"); 355 int pidx = attr.index("pressed");
356 int uidx = attr.index("unicode"); 356 int uidx = attr.index("unicode");
357 int midx = attr.index("modifiers"); 357 int midx = attr.index("modifiers");
358 int aidx = attr.index("autorepeat"); 358 int aidx = attr.index("autorepeat");
359 359
360 int keycode; 360 int keycode;
361 int unicode; 361 int unicode;
362 int modifiers = 0; 362 int modifiers = 0;
363 bool pressed; 363 bool pressed;
364 bool autorepeat = false; 364 bool autorepeat = false;
365 365
366 if (elements.first() != Map_Tag) { 366 if (elements.first() != Map_Tag) {
367 setError("event element should be used only " 367 setError("event element should be used only "
368 "within map element"); 368 "within map element");
369 return false; 369 return false;
370 } 370 }
371 371
372 if (kidx >= 0) { 372 if (kidx >= 0) {
373 keycode = str2keycode(attr.value(kidx)); 373 keycode = str2keycode(attr.value(kidx));
374 if (!err.isEmpty()) { 374 if (!err.isEmpty()) {
375 return false; 375 return false;
376 } 376 }
377 nattr++; 377 nattr++;
378 } else { 378 } else {
379 setError("Missing keycode attribute"); 379 setError("Missing keycode attribute");
380 return false; 380 return false;
381 } 381 }
382 382
383 if (uidx >= 0) { 383 if (uidx >= 0) {
384 unicode = str2unicode(attr.value(uidx)); 384 unicode = str2unicode(attr.value(uidx));
385 if (!err.isEmpty()) { 385 if (!err.isEmpty()) {
386 return false; 386 return false;
387 } 387 }
388 nattr++; 388 nattr++;
389 } else { 389 } else {
390 setError("Missing unicode attribute"); 390 setError("Missing unicode attribute");
391 return false; 391 return false;
392 } 392 }
393 393
394 if (midx >= 0) { 394 if (midx >= 0) {
395 modifiers = str2modifier(attr.value(midx)); 395 modifiers = str2modifier(attr.value(midx));
396 if (!err.isEmpty()) { 396 if (!err.isEmpty()) {
397 return false; 397 return false;
398 } 398 }
399 nattr++; 399 nattr++;
400 } 400 }
401 401
402 if (pidx >= 0) { 402 if (pidx >= 0) {
403 pressed = str2bool(attr.value(pidx)); 403 pressed = str2bool(attr.value(pidx));
404 if (!err.isEmpty()) { 404 if (!err.isEmpty()) {
405 return false; 405 return false;
406 } 406 }
407 nattr++; 407 nattr++;
408 } else { 408 } else {
409 setError("Missing pressed attribute"); 409 setError("Missing pressed attribute");
410 return false; 410 return false;
411 } 411 }
412 412
413 if (aidx >= 0) { 413 if (aidx >= 0) {
414 autorepeat = str2bool(attr.value(aidx)); 414 autorepeat = str2bool(attr.value(aidx));
415 if (!err.isEmpty()) { 415 if (!err.isEmpty()) {
416 return false; 416 return false;
417 } 417 }
418 nattr++; 418 nattr++;
419 } 419 }
420 420
421 if (attr.length() > nattr) { 421 if (attr.length() > nattr) {
422 setError("Unsupported attributes"); 422 setError("Unsupported attributes");
423 return false; 423 return false;
424 } 424 }
425 425
426 return startEventElement(keycode, unicode, modifiers, pressed, 426 return startEventElement(keycode, unicode, modifiers, pressed,
427 autorepeat); 427 autorepeat);
428} 428}
429 429
430bool ZkbXmlHandler::start_next_state(const QXmlAttributes& attr) { 430bool ZkbXmlHandler::start_next_state(const QXmlAttributes& attr) {
431 int nattr = 0; 431 int nattr = 0;
432 int nidx = attr.index("name"); 432 int nidx = attr.index("name");
433 QString name; 433 QString name;
434 434
435 if (elements.first() != Map_Tag) { 435 if (elements.first() != Map_Tag) {
436 setError("next-state element should be used only " 436 setError("next-state element should be used only "
437 "within map element"); 437 "within map element");
438 return false; 438 return false;
439 } 439 }
440 440
441 if (nidx >= 0) { 441 if (nidx >= 0) {
442 name = attr.value(nidx); 442 name = attr.value(nidx);
443 nattr++; 443 nattr++;
444 } else { 444 } else {
445 setError("Missing name attribute"); 445 setError("Missing name attribute");
446 return false; 446 return false;
447 } 447 }
448 448
449 if (attr.length() > nattr) { 449 if (attr.length() > nattr) {
450 setError("Unsupported attributes"); 450 setError("Unsupported attributes");
451 return false; 451 return false;
452 } 452 }
453 453
454 return startNextStateElement(name); 454 return startNextStateElement(name);
455} 455}
456 456
457bool ZkbXmlHandler::end_keymap() { 457bool ZkbXmlHandler::end_keymap() {
458 return endKeymapElement(); 458 return endKeymapElement();
459} 459}
460 460
461bool ZkbXmlHandler::end_include() { 461bool ZkbXmlHandler::end_include() {
462 return endIncludeElement(); 462 return endIncludeElement();
463} 463}
464 464
465bool ZkbXmlHandler::end_label() { 465bool ZkbXmlHandler::end_label() {
466 return endLabelElement(); 466 return endLabelElement();
467} 467}
468 468
469bool ZkbXmlHandler::end_state() { 469bool ZkbXmlHandler::end_state() {
470 return endStateElement(); 470 return endStateElement();
471} 471}
472 472
473bool ZkbXmlHandler::end_map() { 473bool ZkbXmlHandler::end_map() {
474 return endMapElement(); 474 return endMapElement();
475} 475}
476 476
477bool ZkbXmlHandler::end_event() { 477bool ZkbXmlHandler::end_event() {
478 return endEventElement(); 478 return endEventElement();
479} 479}
480 480
481bool ZkbXmlHandler::end_next_state() { 481bool ZkbXmlHandler::end_next_state() {
482 return endNextStateElement(); 482 return endNextStateElement();
483} 483}
484 484
485void ZkbXmlHandler::setError(const QString& e) { 485void ZkbXmlHandler::setError(const QString& e) {
486 err = e; 486 err = e;
487} 487}
488 488
489int ZkbXmlHandler::str2key(const QString& s) { 489int ZkbXmlHandler::str2key(const QString& s) {
490 int ret; 490 int ret;
491 491
492#ifdef USE_ZKB_NAMES
493 ret = KeyNames::find(s); 492 ret = KeyNames::find(s);
494 if (ret == -1) { 493 if (ret == -1) {
495 setError("Invalid value: " + s); 494 setError("Invalid value: " + s);
496 } 495 }
497 496
498#else
499 ret = str2uint(s);
500#endif
501
502 return ret; 497 return ret;
503} 498}
504 499
505int ZkbXmlHandler::str2modifier(const QString& val) { 500int ZkbXmlHandler::str2modifier(const QString& val) {
506 int ret; 501 int ret;
507 502
508#ifdef USE_ZKB_NAMES
509 int n, i; 503 int n, i;
510 ret = 0; 504 ret = 0;
511 n = 0; 505 n = 0;
512 do { 506 do {
513 i = val.find('|', n); 507 i = val.find('|', n);
514 if (i < 0) { 508 if (i < 0) {
515 i = val.length(); 509 i = val.length();
516 } 510 }
517 511
518 QString s = val.mid(n, i - n); 512 QString s = val.mid(n, i - n);
519 int v = ModifierNames::find(s.stripWhiteSpace()); 513 int v = ModifierNames::find(s.stripWhiteSpace());
520 514
521 if (v == -1) { 515 if (v == -1) {
522 setError("Invalid value: " + val); 516 setError("Invalid value: " + val);
523 return -1; 517 return -1;
524 } 518 }
525 519
526 ret |= v; 520 ret |= v;
527 n = i + 1; 521 n = i + 1;
528 } while (n < val.length()); 522 } while (n < val.length());
529#else
530 ret = str2uint(val);
531#endif
532 523
533 return ret; 524 return ret;
534} 525}
535 526
536bool ZkbXmlHandler::str2bool(const QString& s) { 527bool ZkbXmlHandler::str2bool(const QString& s) {
537 if (s == "true") { 528 if (s == "true") {
538 return true; 529 return true;
539 } else { 530 } else {
540 return false; 531 return false;
541 } 532 }
542} 533}
543 534
544int ZkbXmlHandler::str2unicode(const QString& s) { 535int ZkbXmlHandler::str2unicode(const QString& s) {
545 return str2uint(s); 536 return str2uint(s);
546} 537}
547 538
548int ZkbXmlHandler::str2keycode(const QString& s) { 539int ZkbXmlHandler::str2keycode(const QString& s) {
549 int ret; 540 int ret;
550 541
551#ifdef USE_ZKB_NAMES
552 ret = KeycodeNames::find(s); 542 ret = KeycodeNames::find(s);
553 if (ret == -1) { 543 if (ret == -1) {
554 setError("Invalid value: " + s); 544 setError("Invalid value: " + s);
555 } 545 }
556 546
557#else
558 ret = str2uint(s);
559#endif
560
561 return ret; 547 return ret;
562} 548}
563 549
564int ZkbXmlHandler::str2uint(const QString& s) { 550int ZkbXmlHandler::str2uint(const QString& s) {
565 int ret; 551 int ret;
566 bool ok; 552 bool ok;
567 QString val = s; 553 QString val = s;
568 int r; 554 int r;
569 555
570 if (val.left(2) == "0x") { 556 if (val.left(2) == "0x") {
571 val = s.mid(2); 557 val = s.mid(2);
572 r = 16; 558 r = 16;
573 } else if (val.left(1) == "0") { 559 } else if (val.left(1) == "0") {
574 val = s.mid(1); 560 val = s.mid(1);
575 r = 8; 561 r = 8;
576 } else { 562 } else {
577 r = 10; 563 r = 10;
578 } 564 }
579 565
580 ret = val.toInt(&ok, r); 566 ret = val.toInt(&ok, r);
581 if (!ok) { 567 if (!ok) {
582 setError("Invalid value: " + s); 568 setError("Invalid value: " + s);
583 ret = -1; 569 ret = -1;
584 } 570 }
585 571
586 return ret; 572 return ret;
587} 573}