SubdividingMenu.h
Go to the documentation of this file.
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 SV_SUBDIVIDING_MENU_H
17 #define SV_SUBDIVIDING_MENU_H
18 
19 #include <QMenu>
20 
21 #include <QString>
22 #include <set>
23 #include <map>
24 
37 class SubdividingMenu : public QMenu
38 {
39  Q_OBJECT
40 
41 public:
42  SubdividingMenu(int lowerLimit = 0, int upperLimit = 0,
43  QWidget *parent = 0);
44  SubdividingMenu(const QString &title, int lowerLimit = 0,
45  int 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 
70 
72  std::map<QString, QObject *> m_pendingEntries;
73 };
74 
75 #endif
76 
virtual void addMenu(QMenu *)
std::map< QString, QObject * > m_pendingEntries
virtual ~SubdividingMenu()
virtual void addAction(QAction *)
void setEntries(const std::set< QString > &entries)
A menu that divides its entries into submenus, alphabetically.
SubdividingMenu(int lowerLimit=0, int upperLimit=0, QWidget *parent=0)
std::map< QString, QMenu * > m_nameToChunkMenuMap