Diffstat (limited to 'noncore/apps/keyz-cfg/zkbcfg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/keyz-cfg/zkbcfg.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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 | } |