summaryrefslogtreecommitdiffstats
path: root/tdelirc/tdelirc/modes.h
blob: d0de17aa083947e0ef782bf2083b39f7a481327d (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
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Gav Wood <gav@kde.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef MODES_H
#define MODES_H

#include <tqstring.h>
#include <tqmap.h>
#include <tqpair.h>
#include <tqvaluelist.h>

#include "mode.h"

/**
@author Gav Wood
*/

class TDEConfig;

typedef TQValueList<Mode> ModeList;

class Modes : protected TQMap<TQString, TQMap<TQString, Mode> >
{
	void purgeAllModes(TDEConfig &theConfig);
	TQMap<TQString, TQString> theDefaults;

public:
	void loadFromConfig(TDEConfig &theConfig);
	void saveToConfig(TDEConfig &theConfig);
	void generateNulls(const TQStringList &theRemotes);

	const Mode &getMode(const TQString &remote, const TQString &mode) const;
	ModeList getModes(const TQString &remote) const;
	const Mode getDefault(const TQString &remote) const;
	bool isDefault(const Mode &mode) const;

	/**
	 * Call when you've changed a previously getMode'd mode and you want the changes
	 *   to be recorded
	 **/
	void updateMode(const Mode &mode) { operator[](mode.remote())[mode.name()] = mode; }
	void setDefault(const Mode &mode) { theDefaults[mode.remote()] = mode.name(); }
	void erase(const Mode &mode);
	void add(const Mode &mode);

	// dont use this without renaming all the modes in the actions!!!
	void rename(Mode &mode, const TQString name);

	Modes();
	~Modes();
};

#endif