summaryrefslogtreecommitdiff
path: root/noncore/applets/zkbapplet/keyzcfg/cfgfile.h
Unidiff
Diffstat (limited to 'noncore/applets/zkbapplet/keyzcfg/cfgfile.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/cfgfile.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/noncore/applets/zkbapplet/keyzcfg/cfgfile.h b/noncore/applets/zkbapplet/keyzcfg/cfgfile.h
new file mode 100644
index 0000000..9759900
--- a/dev/null
+++ b/noncore/applets/zkbapplet/keyzcfg/cfgfile.h
@@ -0,0 +1,106 @@
1#ifndef CFGFILE_H
2#define CFGFILE_H
3
4#include <qlist.h>
5#include "zkbxml.h"
6
7class CfgEntry {
8public:
9 CfgEntry();
10 CfgEntry(const QString& file, const QString& label);
11
12 const QString& getFile() const;
13 void setFile(const QString& f);
14 const QString& getLabel() const;
15 void setLabel(const QString& l);
16
17protected:
18 QString file;
19 QString label;
20};
21
22class CfgFile {
23public:
24 CfgFile();
25 ~CfgFile();
26
27 QList<CfgEntry>& getEntries();
28 bool replaceEntry(const QString& file, const QString& label,
29 int index = -1);
30 bool deleteEntry(const QString& file);
31
32 int getAutorepeatDelay() const;
33 void setAutorepeatDelay(int);
34 int getAutorepeatPeriod() const;
35 void setAutorepeatPeriod(int);
36
37protected:
38 QList<CfgEntry> entries;
39 int ardelay;
40 int arperiod;
41};
42
43class CfgParser : public QXmlErrorHandler {
44public:
45 CfgParser();
46 virtual ~CfgParser();
47
48 bool load(QString file, CfgFile& cfg);
49 bool save(QString file, CfgFile& cfg);
50
51 void addLabel(const QString& name, const QString& state);
52 void addFile(const QString& file, const QString& prefix);
53
54 int getAutorepeatDelay() const;
55 void setAutorepeatDelay(int);
56 int getAutorepeatPeriod() const;
57 void setAutorepeatPeriod(int);
58
59 virtual bool warning(const QXmlParseException& e);
60 virtual bool error(const QXmlParseException& e);
61 virtual bool fatalError(const QXmlParseException& e);
62 virtual QString errorString();
63
64 QString getError();
65
66protected:
67 QString err;
68 QMap<QString, QString> labels;
69 QMap<QString, QString> includes;
70 QList<QString> labelList;
71 QList<QString> includeList;
72 int ardelay;
73 int arperiod;
74};
75
76class CfgHandler : public ZkbXmlHandler {
77public:
78 CfgHandler(CfgParser &);
79 virtual ~CfgHandler();
80
81protected:
82 CfgParser& cfg;
83
84 virtual bool startKeymapElement(int ardelay, int arperiod,
85 const QString& author);
86 virtual bool startIncludeElement(const QString& file,
87 const QString& prfix);
88 virtual bool startLabelElement(const QString& label,
89 const QString& state);
90 virtual bool startStateElement(const QString& name,
91 const QString& parent, bool dflt);
92 virtual bool startMapElement(int key, bool pressed);
93 virtual bool startEventElement(int keycode, int unicode, int modifiers,
94 bool pressed, bool autorepeat);
95 virtual bool startNextStateElement(const QString& state);
96
97 virtual bool endKeymapElement();
98 virtual bool endIncludeElement();
99 virtual bool endLabelElement();
100 virtual bool endStateElement();
101 virtual bool endMapElement();
102 virtual bool endEventElement();
103 virtual bool endNextStateElement();
104};
105
106#endif