summaryrefslogtreecommitdiffstats
path: root/arts/builder/menumaker.h
blob: f2481a2fee200c80ca186828cfc2047f8c51cfc9 (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
70
#ifndef __MENUMAKER_H__
#define __MENUMAKER_H__

#include <kaction.h>
#include <tqobject.h>
#include <string>
#include <list>

class MenuMaker;

class MenuEntry : public QObject
{
	Q_OBJECT

protected:
	MenuMaker *menumaker;
	KAction *action;
	TQCString text;

public:
	MenuEntry(MenuMaker *menumaker, KActionMenu *parent, const char *text);

public slots:
	void activated();
};

class MenuCategory
{
protected:
	KActionMenu *_menu;
	TQString _name;
	std::list<std::string> prefixList;
	bool _catchall;

public:
	MenuCategory(const TQString& name, const char *prefix, KActionMenu *menu);

	void addPrefix(const char *prefix);
	TQString name();
	KActionMenu *menu();

	bool catchall();
	bool matches(const char *item);
};

class MenuMaker :public QObject
{
	Q_OBJECT

	std::list<MenuCategory *> categories;
public:
	enum { CAT_MAGIC_ID = 10000 };

	MenuMaker(KActionMenu *root);

	void addCategory(const TQString& name, const char *prefix);
	MenuCategory *lookupCategoryByName(const TQString& name);
	void addItem(const char *name, int i);
	TQString basename(const TQString& name);
	TQString catname(const TQString& name);

	void clear();

	const char *findID(int id);

	void menuActivated(const char *text);
signals:
	void activated(const char *text);
};
#endif