summaryrefslogtreecommitdiff
path: root/noncore/apps/keyz-cfg/cfgfile.cpp
Unidiff
Diffstat (limited to 'noncore/apps/keyz-cfg/cfgfile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/cfgfile.cpp12
1 files changed, 9 insertions, 3 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>
5using namespace Opie::Core;
6
7/* QT */
8#include <qmessagebox.h>
9
4// CfgEntry implementation 10// CfgEntry implementation
5CfgEntry::CfgEntry() { 11CfgEntry::CfgEntry() {
6} 12}
7 13
8CfgEntry::CfgEntry(const QString& f, const QString& l): 14CfgEntry::CfgEntry(const QString& f, const QString& l):
9 file(f), label(l) { 15 file(f), label(l) {
10} 16}
11 17
12const QString& CfgEntry::getFile() const { 18const QString& CfgEntry::getFile() const {
13 return file; 19 return file;
14} 20}
15 21
16void CfgEntry::setFile(const QString& f) { 22void CfgEntry::setFile(const QString& f) {
17 file = f; 23 file = f;
18} 24}
19 25
20const QString& CfgEntry::getLabel() const { 26const QString& CfgEntry::getLabel() const {
21 return label; 27 return label;
22} 28}
23 29
24void CfgEntry::setLabel(const QString& f) { 30void 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
75void CfgFile::setAutorepeatPeriod(int n) { 81void CfgFile::setAutorepeatPeriod(int n) {
76 arperiod = n; 82 arperiod = n;
77} 83}
78 84
79// CfgParser implementation 85// CfgParser implementation
80CfgParser::CfgParser() { 86CfgParser::CfgParser() {
81} 87}
82 88
83bool CfgParser::load(QString file, CfgFile& cfg) { 89bool 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
129bool CfgParser::save(QString file, CfgFile& cfg) { 135bool 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(),