-rw-r--r-- | noncore/apps/keyz-cfg/cfgfile.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/keyz-cfg/config.in | 2 | ||||
-rw-r--r-- | noncore/apps/keyz-cfg/keyz-cfg.pro | 16 | ||||
-rw-r--r-- | noncore/apps/keyz-cfg/zkb.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/keyz-cfg/zkbcfg.cpp | 15 |
5 files changed, 29 insertions, 20 deletions
diff --git a/noncore/apps/keyz-cfg/cfgfile.cpp b/noncore/apps/keyz-cfg/cfgfile.cpp index b0dc968..81d1ee1 100644 --- a/noncore/apps/keyz-cfg/cfgfile.cpp +++ b/noncore/apps/keyz-cfg/cfgfile.cpp | |||
@@ -1,27 +1,33 @@ | |||
1 | #include <qmessagebox.h> | ||
2 | #include "cfgfile.h" | 1 | #include "cfgfile.h" |
3 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | /* QT */ | ||
8 | #include <qmessagebox.h> | ||
9 | |||
4 | // CfgEntry implementation | 10 | // CfgEntry implementation |
5 | CfgEntry::CfgEntry() { | 11 | CfgEntry::CfgEntry() { |
6 | } | 12 | } |
7 | 13 | ||
8 | CfgEntry::CfgEntry(const QString& f, const QString& l): | 14 | CfgEntry::CfgEntry(const QString& f, const QString& l): |
9 | file(f), label(l) { | 15 | file(f), label(l) { |
10 | } | 16 | } |
11 | 17 | ||
12 | const QString& CfgEntry::getFile() const { | 18 | const QString& CfgEntry::getFile() const { |
13 | return file; | 19 | return file; |
14 | } | 20 | } |
15 | 21 | ||
16 | void CfgEntry::setFile(const QString& f) { | 22 | void CfgEntry::setFile(const QString& f) { |
17 | file = f; | 23 | file = f; |
18 | } | 24 | } |
19 | 25 | ||
20 | const QString& CfgEntry::getLabel() const { | 26 | const QString& CfgEntry::getLabel() const { |
21 | return label; | 27 | return label; |
22 | } | 28 | } |
23 | 29 | ||
24 | void CfgEntry::setLabel(const QString& f) { | 30 | void CfgEntry::setLabel(const QString& f) { |
25 | label = f; | 31 | label = f; |
26 | } | 32 | } |
27 | 33 | ||
@@ -74,60 +80,60 @@ int CfgFile::getAutorepeatPeriod() const { | |||
74 | 80 | ||
75 | void CfgFile::setAutorepeatPeriod(int n) { | 81 | void CfgFile::setAutorepeatPeriod(int n) { |
76 | arperiod = n; | 82 | arperiod = n; |
77 | } | 83 | } |
78 | 84 | ||
79 | // CfgParser implementation | 85 | // CfgParser implementation |
80 | CfgParser::CfgParser() { | 86 | CfgParser::CfgParser() { |
81 | } | 87 | } |
82 | 88 | ||
83 | bool CfgParser::load(QString file, CfgFile& cfg) { | 89 | bool CfgParser::load(QString file, CfgFile& cfg) { |
84 | QFile f(file); | 90 | QFile f(file); |
85 | QXmlInputSource is(f); | 91 | QXmlInputSource is(f); |
86 | QXmlSimpleReader reader; | 92 | QXmlSimpleReader reader; |
87 | CfgHandler p(*this); | 93 | CfgHandler p(*this); |
88 | 94 | ||
89 | reader.setErrorHandler(this); | 95 | reader.setErrorHandler(this); |
90 | reader.setContentHandler(&p); | 96 | reader.setContentHandler(&p); |
91 | 97 | ||
92 | err = ""; | 98 | err = ""; |
93 | ardelay = -1; | 99 | ardelay = -1; |
94 | arperiod = -1; | 100 | arperiod = -1; |
95 | reader.parse(is); | 101 | reader.parse(is); |
96 | 102 | ||
97 | if (!err.isEmpty()) { | 103 | if (!err.isEmpty()) { |
98 | qDebug(err); | 104 | odebug << err << oendl; |
99 | return false; | 105 | return false; |
100 | } | 106 | } |
101 | 107 | ||
102 | QMap<QString, QString>::Iterator fit, lit; | 108 | QMap<QString, QString>::Iterator fit, lit; |
103 | for(uint i = 0; i < includeList.count(); i++) { | 109 | for(uint i = 0; i < includeList.count(); i++) { |
104 | QString file = *includeList.at(i); | 110 | QString file = *includeList.at(i); |
105 | fit = includes.find(file); | 111 | fit = includes.find(file); |
106 | QString prefix = fit.data(); | 112 | QString prefix = fit.data(); |
107 | QString label = ""; | 113 | QString label = ""; |
108 | 114 | ||
109 | qDebug("include: file=" + fit.key() + ", prefix=" + fit.data()); | 115 | odebug << "include: file=" + fit.key() + ", prefix=" + fit.data() << oendl; |
110 | lit = labels.find(prefix+":*"); | 116 | lit = labels.find(prefix+":*"); |
111 | if (lit != labels.end()) { | 117 | if (lit != labels.end()) { |
112 | label = lit.data(); | 118 | label = lit.data(); |
113 | } | 119 | } |
114 | 120 | ||
115 | cfg.replaceEntry(file, label); | 121 | cfg.replaceEntry(file, label); |
116 | } | 122 | } |
117 | 123 | ||
118 | if (ardelay != -1) { | 124 | if (ardelay != -1) { |
119 | cfg.setAutorepeatDelay(ardelay); | 125 | cfg.setAutorepeatDelay(ardelay); |
120 | } | 126 | } |
121 | 127 | ||
122 | if (arperiod != -1) { | 128 | if (arperiod != -1) { |
123 | cfg.setAutorepeatPeriod(arperiod); | 129 | cfg.setAutorepeatPeriod(arperiod); |
124 | } | 130 | } |
125 | 131 | ||
126 | return true; | 132 | return true; |
127 | } | 133 | } |
128 | 134 | ||
129 | bool CfgParser::save(QString file, CfgFile& cfg) { | 135 | bool CfgParser::save(QString file, CfgFile& cfg) { |
130 | FILE* f = fopen((const char*) file.local8Bit(), "w"); | 136 | FILE* f = fopen((const char*) file.local8Bit(), "w"); |
131 | 137 | ||
132 | fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" " | 138 | fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" " |
133 | "author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(), | 139 | "author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(), |
diff --git a/noncore/apps/keyz-cfg/config.in b/noncore/apps/keyz-cfg/config.in index 29a10f5..8e1be2d 100644 --- a/noncore/apps/keyz-cfg/config.in +++ b/noncore/apps/keyz-cfg/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config KEYZCFG | 1 | config KEYZCFG |
2 | boolean "keyz-cfg (configuration tool for keyz applet)" | 2 | boolean "keyz-cfg (configuration tool for keyz applet)" |
3 | default "n" | 3 | default "n" |
4 | depends ( LIBQPE || LIBQPE-X11 ) | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE |
diff --git a/noncore/apps/keyz-cfg/keyz-cfg.pro b/noncore/apps/keyz-cfg/keyz-cfg.pro index 44bbb5f..7ac604b 100644 --- a/noncore/apps/keyz-cfg/keyz-cfg.pro +++ b/noncore/apps/keyz-cfg/keyz-cfg.pro | |||
@@ -1,24 +1,24 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | DESTDIR = $(OPIEDIR)/bin | 2 | DESTDIR = $(OPIEDIR)/bin |
3 | CONFIG = qt warn_on | 3 | CONFIG = qt warn_on |
4 | HEADERS = zkb.h \ | 4 | HEADERS = zkb.h \ |
5 | zkbcfg.h \ | 5 | zkbcfg.h \ |
6 | zkbnames.h \ | 6 | zkbnames.h \ |
7 | zkbxml.h \ | 7 | zkbxml.h \ |
8 | cfgdlg.h \ | 8 | cfgdlg.h \ |
9 | cfgfile.h | 9 | cfgfile.h |
10 | 10 | ||
11 | SOURCES = main.cpp \ | 11 | SOURCES = main.cpp \ |
12 | cfgdlg.cpp \ | 12 | cfgdlg.cpp \ |
13 | cfgfile.cpp \ | 13 | cfgfile.cpp \ |
14 | zkb.cpp \ | 14 | zkb.cpp \ |
15 | zkbcfg.cpp \ | 15 | zkbcfg.cpp \ |
16 | zkbnames.cpp \ | 16 | zkbnames.cpp \ |
17 | zkbxml.cpp | 17 | zkbxml.cpp |
18 | 18 | ||
19 | INCLUDEPATH += $(OPIEDIR)/include | 19 | INCLUDEPATH += $(OPIEDIR)/include |
20 | DEPENDPATH += $(OPIEDIR)/include | 20 | DEPENDPATH += $(OPIEDIR)/include |
21 | LIBS += -lqpe | 21 | LIBS += -lqpe -lopiecore2 |
22 | TARGET = keyz-cfg | 22 | TARGET = keyz-cfg |
23 | 23 | ||
24 | include ( $(OPIEDIR)/include.pro ) | 24 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/keyz-cfg/zkb.cpp b/noncore/apps/keyz-cfg/zkb.cpp index f315d4b..8382615 100644 --- a/noncore/apps/keyz-cfg/zkb.cpp +++ b/noncore/apps/keyz-cfg/zkb.cpp | |||
@@ -343,49 +343,49 @@ QStringList Keymap::listLabels() { | |||
343 | 343 | ||
344 | return ret; | 344 | return ret; |
345 | } | 345 | } |
346 | 346 | ||
347 | State* Keymap::getStateByLabel(const QString& label) { | 347 | State* Keymap::getStateByLabel(const QString& label) { |
348 | QMap<QString, QString>::Iterator lit = labels.find(label); | 348 | QMap<QString, QString>::Iterator lit = labels.find(label); |
349 | State* state = 0; | 349 | State* state = 0; |
350 | 350 | ||
351 | if (lit == labels.end()) { | 351 | if (lit == labels.end()) { |
352 | return 0; | 352 | return 0; |
353 | } | 353 | } |
354 | 354 | ||
355 | QString name = lit.data(); | 355 | QString name = lit.data(); |
356 | 356 | ||
357 | int n = name.find(":*"); | 357 | int n = name.find(":*"); |
358 | if (n>=0 && n==(int)(name.length()-2)) { | 358 | if (n>=0 && n==(int)(name.length()-2)) { |
359 | name=name.left(name.length() - 1); | 359 | name=name.left(name.length() - 1); |
360 | 360 | ||
361 | n = currentStateName.findRev(":"); | 361 | n = currentStateName.findRev(":"); |
362 | if (n >= 0) { | 362 | if (n >= 0) { |
363 | name += currentStateName.mid(n+1); | 363 | name += currentStateName.mid(n+1); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | //qDebug("look for: %s\n", (const char*) name.utf8()); | 367 | //odebug << "look for: " << (const char*) name.utf8() << "\n" << oendl; |
368 | QMap<QString, State*>::Iterator sit = states.find(name); | 368 | QMap<QString, State*>::Iterator sit = states.find(name); |
369 | if (sit != states.end()) { | 369 | if (sit != states.end()) { |
370 | state = sit.data(); | 370 | state = sit.data(); |
371 | } | 371 | } |
372 | 372 | ||
373 | return state; | 373 | return state; |
374 | } | 374 | } |
375 | 375 | ||
376 | bool Keymap::addState(const QString& name, State* state) { | 376 | bool Keymap::addState(const QString& name, State* state) { |
377 | if (states.find(name) != states.end()) { | 377 | if (states.find(name) != states.end()) { |
378 | return false; | 378 | return false; |
379 | } | 379 | } |
380 | 380 | ||
381 | states.insert(name, state); | 381 | states.insert(name, state); |
382 | lsmapInSync = false; | 382 | lsmapInSync = false; |
383 | 383 | ||
384 | if (currentState == 0) { | 384 | if (currentState == 0) { |
385 | setCurrentState(state); | 385 | setCurrentState(state); |
386 | } | 386 | } |
387 | 387 | ||
388 | return true; | 388 | return true; |
389 | } | 389 | } |
390 | 390 | ||
391 | State* Keymap::getCurrentState() const { | 391 | State* Keymap::getCurrentState() const { |
@@ -395,49 +395,49 @@ State* Keymap::getCurrentState() const { | |||
395 | QString Keymap::getCurrentLabel() { | 395 | QString Keymap::getCurrentLabel() { |
396 | return currentLabel; | 396 | return currentLabel; |
397 | } | 397 | } |
398 | 398 | ||
399 | bool Keymap::setCurrentState(State* state) { | 399 | bool Keymap::setCurrentState(State* state) { |
400 | QMap<QString, State*>::Iterator it; | 400 | QMap<QString, State*>::Iterator it; |
401 | for(it = states.begin(); it != states.end(); ++it) { | 401 | for(it = states.begin(); it != states.end(); ++it) { |
402 | State* s = it.data(); | 402 | State* s = it.data(); |
403 | if (s == state) { | 403 | if (s == state) { |
404 | currentState = s; | 404 | currentState = s; |
405 | currentStateName = it.key(); | 405 | currentStateName = it.key(); |
406 | 406 | ||
407 | qDebug("state changed: %s\n", (const char*) | 407 | qDebug("state changed: %s\n", (const char*) |
408 | currentStateName.utf8()); | 408 | currentStateName.utf8()); |
409 | 409 | ||
410 | if (!lsmapInSync) { | 410 | if (!lsmapInSync) { |
411 | generateLabelStateMaps(); | 411 | generateLabelStateMaps(); |
412 | } | 412 | } |
413 | 413 | ||
414 | QMap<State*, QString>::Iterator tit; | 414 | QMap<State*, QString>::Iterator tit; |
415 | tit = stateLabelMap.find(state); | 415 | tit = stateLabelMap.find(state); |
416 | if (tit != stateLabelMap.end()) { | 416 | if (tit != stateLabelMap.end()) { |
417 | currentLabel = tit.data(); | 417 | currentLabel = tit.data(); |
418 | } else { | 418 | } else { |
419 | // qDebug("no label for: " + currentStateName + "\n"); | 419 | // odebug << "no label for: " + currentStateName + "\n" << oendl; |
420 | currentLabel = ""; | 420 | currentLabel = ""; |
421 | } | 421 | } |
422 | 422 | ||
423 | return true; | 423 | return true; |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | return false; | 427 | return false; |
428 | } | 428 | } |
429 | 429 | ||
430 | bool Keymap::removeState(const QString& name, bool force) { | 430 | bool Keymap::removeState(const QString& name, bool force) { |
431 | QMap<QString, State*>::Iterator it = states.find(name); | 431 | QMap<QString, State*>::Iterator it = states.find(name); |
432 | 432 | ||
433 | if (it == states.end()) { | 433 | if (it == states.end()) { |
434 | return false; | 434 | return false; |
435 | } | 435 | } |
436 | 436 | ||
437 | State* state = it.data(); | 437 | State* state = it.data(); |
438 | QList<Action> acts = findStateUsage(state); | 438 | QList<Action> acts = findStateUsage(state); |
439 | 439 | ||
440 | if (!acts.isEmpty()) { | 440 | if (!acts.isEmpty()) { |
441 | if (!force) { | 441 | if (!force) { |
442 | return false; | 442 | return false; |
443 | } else { | 443 | } else { |
diff --git a/noncore/apps/keyz-cfg/zkbcfg.cpp b/noncore/apps/keyz-cfg/zkbcfg.cpp index 0992b9a..f1d53ba 100644 --- a/noncore/apps/keyz-cfg/zkbcfg.cpp +++ b/noncore/apps/keyz-cfg/zkbcfg.cpp | |||
@@ -1,58 +1,61 @@ | |||
1 | #include <qfileinfo.h> | ||
2 | |||
3 | #include "zkbcfg.h" | 1 | #include "zkbcfg.h" |
4 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | /* QT */ | ||
8 | #include <qfileinfo.h> | ||
5 | 9 | ||
6 | // Implementation of XkbConfig class | 10 | // Implementation of XkbConfig class |
7 | ZkbConfig::ZkbConfig(const QString& dir):path(dir) { | 11 | ZkbConfig::ZkbConfig(const QString& dir):path(dir) { |
8 | } | 12 | } |
9 | 13 | ||
10 | ZkbConfig::~ZkbConfig() { | 14 | ZkbConfig::~ZkbConfig() { |
11 | } | 15 | } |
12 | 16 | ||
13 | bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) { | 17 | bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) { |
14 | bool ret; | 18 | bool ret; |
15 | QFile f(path+"/"+file); | 19 | QFile f(path+"/"+file); |
16 | QFileInfo fi(f); | 20 | QFileInfo fi(f); |
17 | 21 | ||
18 | qDebug("start loading file=%s\n", (const char*) file.utf8()); | 22 | odebug << "start loading file=" << (const char*) file.utf8() << "\n" << oendl; |
19 | if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) { | 23 | if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) { |
20 | return false; | 24 | return false; |
21 | } | 25 | } |
22 | 26 | ||
23 | includedFiles.insert(fi.absFilePath(), 1); | 27 | includedFiles.insert(fi.absFilePath(), 1); |
24 | QXmlInputSource is(f); | 28 | QXmlInputSource is(f); |
25 | QXmlSimpleReader reader; | 29 | QXmlSimpleReader reader; |
26 | ZkbHandler h(*this, keymap, prefix); | 30 | ZkbHandler h(*this, keymap, prefix); |
27 | 31 | ||
28 | reader.setContentHandler(&h); | 32 | reader.setContentHandler(&h); |
29 | reader.setErrorHandler(this); | 33 | reader.setErrorHandler(this); |
30 | ret = reader.parse(is); | 34 | ret = reader.parse(is); |
31 | includedFiles.remove(fi.absFilePath()); | 35 | includedFiles.remove(fi.absFilePath()); |
32 | 36 | ||
33 | qDebug("end loading file=%s : status=%s\n", (const char*) file.utf8(), | 37 | odebug << "end loading file=" << file.utf8() << ": status=" << err.utf8() << oendl; |
34 | (const char*) err.utf8()); | ||
35 | return ret; | 38 | return ret; |
36 | } | 39 | } |
37 | 40 | ||
38 | bool ZkbConfig::warning(const QXmlParseException& e) { | 41 | bool ZkbConfig::warning(const QXmlParseException& e) { |
39 | QString tmp; | 42 | QString tmp; |
40 | 43 | ||
41 | tmp.sprintf("%d: warning: %s\n", e.lineNumber(), | 44 | tmp.sprintf("%d: warning: %s\n", e.lineNumber(), |
42 | (const char*) e.message().utf8()); | 45 | (const char*) e.message().utf8()); |
43 | 46 | ||
44 | err += tmp; | 47 | err += tmp; |
45 | 48 | ||
46 | return true; | 49 | return true; |
47 | } | 50 | } |
48 | 51 | ||
49 | bool ZkbConfig::error(const QXmlParseException& e) { | 52 | bool ZkbConfig::error(const QXmlParseException& e) { |
50 | QString tmp; | 53 | QString tmp; |
51 | 54 | ||
52 | tmp.sprintf("%d: error: %s\n", e.lineNumber(), | 55 | tmp.sprintf("%d: error: %s\n", e.lineNumber(), |
53 | (const char*) e.message().utf8()); | 56 | (const char*) e.message().utf8()); |
54 | 57 | ||
55 | err += tmp; | 58 | err += tmp; |
56 | 59 | ||
57 | return true; | 60 | return true; |
58 | } | 61 | } |
@@ -101,49 +104,49 @@ bool ZkbHandler::startIncludeElement(const QString& file, | |||
101 | if (!ret) { | 104 | if (!ret) { |
102 | setError("Error including file: " + file); | 105 | setError("Error including file: " + file); |
103 | } | 106 | } |
104 | 107 | ||
105 | return ret; | 108 | return ret; |
106 | } | 109 | } |
107 | 110 | ||
108 | bool ZkbHandler::startLabelElement(const QString& label, | 111 | bool ZkbHandler::startLabelElement(const QString& label, |
109 | const QString& state) { | 112 | const QString& state) { |
110 | 113 | ||
111 | if (!keymap.addLabel(label, prefix + state)) { | 114 | if (!keymap.addLabel(label, prefix + state)) { |
112 | err = "label " + label + " already defined"; | 115 | err = "label " + label + " already defined"; |
113 | return false; | 116 | return false; |
114 | } | 117 | } |
115 | 118 | ||
116 | return true; | 119 | return true; |
117 | } | 120 | } |
118 | 121 | ||
119 | bool ZkbHandler::startStateElement(const QString& name, | 122 | bool ZkbHandler::startStateElement(const QString& name, |
120 | const QString& parentName, bool dflt) { | 123 | const QString& parentName, bool dflt) { |
121 | 124 | ||
122 | currentStateName = prefix + name; | 125 | currentStateName = prefix + name; |
123 | currentState = keymap.getStateByName(currentStateName); | 126 | currentState = keymap.getStateByName(currentStateName); |
124 | 127 | ||
125 | //qDebug("state name=%s\n", (const char*) currentStateName.utf8()); | 128 | //odebug << "state name=" << (const char*) currentStateName.utf8() << "\n" << oendl; |
126 | 129 | ||
127 | State* parent = 0; | 130 | State* parent = 0; |
128 | if (!parentName.isEmpty()) { | 131 | if (!parentName.isEmpty()) { |
129 | QString pn = prefix + parentName; | 132 | QString pn = prefix + parentName; |
130 | parent = keymap.getStateByName(pn); | 133 | parent = keymap.getStateByName(pn); |
131 | if (parent == 0) { | 134 | if (parent == 0) { |
132 | err = currentStateName + | 135 | err = currentStateName + |
133 | ": undefined parent state: " + pn; | 136 | ": undefined parent state: " + pn; |
134 | return false; | 137 | return false; |
135 | } | 138 | } |
136 | } | 139 | } |
137 | 140 | ||
138 | if (currentState == 0) { | 141 | if (currentState == 0) { |
139 | currentState = new State(parent); | 142 | currentState = new State(parent); |
140 | keymap.addState(currentStateName, currentState); | 143 | keymap.addState(currentStateName, currentState); |
141 | } else { | 144 | } else { |
142 | if (parent!=0) { | 145 | if (parent!=0) { |
143 | currentState->setParent(parent); | 146 | currentState->setParent(parent); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | 149 | ||
147 | if (dflt) { | 150 | if (dflt) { |
148 | keymap.setCurrentState(currentState); | 151 | keymap.setCurrentState(currentState); |
149 | } | 152 | } |