Mercurial > hg > easaier-soundaccess
comparison widgets/SubdividingMenu.h @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
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 This file copyright 2006 QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _SUBDIVIDING_MENU_H_ | |
17 #define _SUBDIVIDING_MENU_H_ | |
18 | |
19 #include <QMenu> | |
20 | |
21 #include <QString> | |
22 #include <set> | |
23 #include <map> | |
24 | |
25 /** | |
26 * A menu that divides its entries into submenus, alphabetically. For | |
27 * menus that may contain a very large or small number of named items | |
28 * (e.g. plugins). | |
29 * | |
30 * The menu needs to be told, before any of the actions are added, | |
31 * what the set of entry strings will be, so it can determine a | |
32 * reasonable categorisation. Do this by calling the setEntries() | |
33 * method. If it isn't practical to do this in advance, then add the | |
34 * entries and call entriesAdded() afterwards instead. | |
35 */ | |
36 | |
37 class SubdividingMenu : public QMenu | |
38 { | |
39 Q_OBJECT | |
40 | |
41 public: | |
42 SubdividingMenu(size_t lowerLimit = 0, size_t upperLimit = 0, | |
43 QWidget *parent = 0); | |
44 SubdividingMenu(const QString &title, size_t lowerLimit = 0, | |
45 size_t upperLimit = 0, QWidget *parent = 0); | |
46 virtual ~SubdividingMenu(); | |
47 | |
48 void setEntries(const std::set<QString> &entries); | |
49 void entriesAdded(); | |
50 | |
51 // Action names and strings passed to addAction and addMenu must | |
52 // appear in the set previously given to setEntries. If you want | |
53 // to use a different string, use the two-argument method and pass | |
54 // the entry string (used to determine which submenu the action | |
55 // ends up on) as the first argument. | |
56 | |
57 virtual void addAction(QAction *); | |
58 virtual QAction *addAction(const QString &); | |
59 virtual void addAction(const QString &entry, QAction *); | |
60 | |
61 virtual void addMenu(QMenu *); | |
62 virtual QMenu *addMenu(const QString &); | |
63 virtual void addMenu(const QString &entry, QMenu *); | |
64 | |
65 protected: | |
66 std::map<QString, QMenu *> m_nameToChunkMenuMap; | |
67 | |
68 size_t m_lowerLimit; | |
69 size_t m_upperLimit; | |
70 | |
71 bool m_entriesSet; | |
72 std::map<QString, QObject *> m_pendingEntries; | |
73 }; | |
74 | |
75 #endif | |
76 |