summaryrefslogtreecommitdiff
path: root/noncore/apps/keyz-cfg/zkbcfg.h
blob: dc1ac07a78494c0ef89c9d3bbbd5969d7c4f4527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef ZKBCFG_H
#define ZKBCFG_H

#include <qxml.h>
#include "zkb.h"
#include "zkbxml.h"

class ZkbConfig : public QXmlErrorHandler {
public:
	ZkbConfig(const QString& dir);
	virtual ~ZkbConfig();

	bool load(const QString& file, Keymap& keymap, const QString& prefix);

	virtual bool warning(const QXmlParseException& e);
	virtual bool error(const QXmlParseException& e);
	virtual bool fatalError(const QXmlParseException& e);
	virtual QString errorString();

protected:
	QString path;
	QMap<QString, int> includedFiles;
	QString err;
};

class ZkbHandler : public ZkbXmlHandler {
public:
	ZkbHandler(ZkbConfig& zkc, Keymap& keymap, const QString& prefix);
	virtual ~ZkbHandler();

protected:
	ZkbConfig& zkc;
	Keymap& keymap;
	QString prefix;

	// stuff for keymap tag
	int ardelay;
	int arperiod;

	// stuff for state tag
	QString currentStateName;
	State* currentState;

	// stuff for map tag
	Action* currentAction;

	virtual bool startKeymapElement(int ardelay, int arperiod, 
		const QString& author);
	virtual bool startIncludeElement(const QString& file, 
		const QString& prfix);
	virtual bool startLabelElement(const QString& label, 
		const QString& state);
	virtual bool startStateElement(const QString& name, 
		const QString& parent, bool dflt);
	virtual bool startMapElement(int key, bool pressed);
	virtual bool startEventElement(int keycode, int unicode, int modifiers,
		bool pressed, bool autorepeat);
	virtual bool startNextStateElement(const QString& state);

	virtual bool endKeymapElement();
	virtual bool endIncludeElement();
	virtual bool endLabelElement();
	virtual bool endStateElement();
	virtual bool endMapElement();
	virtual bool endEventElement();
	virtual bool endNextStateElement();
};

#endif