svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _SUBDIVIDING_MENU_H_ 00017 #define _SUBDIVIDING_MENU_H_ 00018 00019 #include <QMenu> 00020 00021 #include <QString> 00022 #include <set> 00023 #include <map> 00024 00037 class SubdividingMenu : public QMenu 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 SubdividingMenu(int lowerLimit = 0, int upperLimit = 0, 00043 QWidget *parent = 0); 00044 SubdividingMenu(const QString &title, int lowerLimit = 0, 00045 int upperLimit = 0, QWidget *parent = 0); 00046 virtual ~SubdividingMenu(); 00047 00048 void setEntries(const std::set<QString> &entries); 00049 void entriesAdded(); 00050 00051 // Action names and strings passed to addAction and addMenu must 00052 // appear in the set previously given to setEntries. If you want 00053 // to use a different string, use the two-argument method and pass 00054 // the entry string (used to determine which submenu the action 00055 // ends up on) as the first argument. 00056 00057 virtual void addAction(QAction *); 00058 virtual QAction *addAction(const QString &); 00059 virtual void addAction(const QString &entry, QAction *); 00060 00061 virtual void addMenu(QMenu *); 00062 virtual QMenu *addMenu(const QString &); 00063 virtual void addMenu(const QString &entry, QMenu *); 00064 00065 protected: 00066 std::map<QString, QMenu *> m_nameToChunkMenuMap; 00067 00068 int m_lowerLimit; 00069 int m_upperLimit; 00070 00071 bool m_entriesSet; 00072 std::map<QString, QObject *> m_pendingEntries; 00073 }; 00074 00075 #endif 00076