Mercurial > hg > svgui
comparison widgets/SubdividingMenu.h @ 151:8f51db2434dc
* Pull alphabetical categorisation code out into a SubdividingMenu class
author | Chris Cannam |
---|---|
date | Mon, 25 Sep 2006 11:21:12 +0000 |
parents | |
children | 6a3f3c13173f |
comparison
equal
deleted
inserted
replaced
150:b1a3a9400284 | 151:8f51db2434dc |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef _SUBDIVIDING_MENU_H_ | |
16 #define _SUBDIVIDING_MENU_H_ | |
17 | |
18 #include <QMenu> | |
19 | |
20 #include <QString> | |
21 #include <set> | |
22 #include <map> | |
23 | |
24 /** | |
25 * A menu that divides its entries into submenus, alphabetically. For | |
26 * menus that may contain a very large or small number of named items | |
27 * (e.g. plugins). | |
28 * | |
29 * The menu needs to be told, before any of the actions are added, | |
30 * what the set of entry strings will be, so it can determine a | |
31 * reasonable categorisation. Do this by calling the setEntries() | |
32 * method. | |
33 */ | |
34 | |
35 class SubdividingMenu : public QMenu | |
36 { | |
37 public: | |
38 SubdividingMenu(QWidget *parent = 0); | |
39 SubdividingMenu(const QString &title, QWidget *parent = 0); | |
40 virtual ~SubdividingMenu(); | |
41 | |
42 void setEntries(const std::set<QString> &entries); | |
43 | |
44 // Action names and strings passed to addAction and addMenu must | |
45 // appear in the set previously given to setEntries. If you want | |
46 // to use a different string, use the two-argument method and pass | |
47 // the entry string (used to determine which submenu the action | |
48 // ends up on) as the first argument. | |
49 | |
50 virtual void addAction(QAction *); | |
51 virtual QAction *addAction(const QString &); | |
52 virtual void addAction(const QString &entry, QAction *); | |
53 | |
54 virtual void addMenu(QMenu *); | |
55 virtual QMenu *addMenu(const QString &); | |
56 virtual void addMenu(const QString &entry, QMenu *); | |
57 | |
58 protected: | |
59 std::map<QString, QMenu *> m_nameToChunkMenuMap; | |
60 }; | |
61 | |
62 #endif | |
63 |