summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperconf/KeyNames.h
blob: edd7dc59eb2343342de43c1fc537417cf0d58b44 (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
#ifndef _KEY_NAMES_H_
#define _KEY_NAMES_H_

#include <qstring.h>
#include <qmap.h>
#include <qnamespace.h>

class KeyNames
{
public:
	static const QString& getName(int code){
		if(namemap.isEmpty()) setNameMap();
		if(namemap.contains(code)){
			return(namemap[code]);
		} else {
			return(QString::null);
		}
	}
	static void clearName(){
		namemap.clear();
	}
	static int getCode(const QString& s){
		if(codemap.isEmpty()) setCodeMap();
		if(codemap.contains(s)){
			return(codemap[s]);
		} else {
			return(0);
		}
	}
	static void setCode(const QString& s, int code){
		if(codemap.contains(s) == false){
			codemap.insert(s, code);
		}
	}
	static void clearCode(){
		codemap.clear();
	}
	static void reset(){
		clearCode();
	}
private:
	static QMap<QString, int> codemap;
	static QMap<int, QString> namemap;

	static void setCodeMap();
	static void setNameMap();
};

#endif /* _KEY_NAMES_H_ */