annotate widgets/SubdividingMenu.h @ 154:30d624900564

* Introduce WritableWaveFileModel, and use it as an output model for audio real-time plugin transforms. Updates aren't working correctly yet.
author Chris Cannam
date Tue, 03 Oct 2006 14:17:37 +0000
parents 6a3f3c13173f
children 42118892f428
rev   line source
Chris@151 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@151 2
Chris@151 3 /*
Chris@151 4 Sonic Visualiser
Chris@151 5 An audio file viewer and annotation editor.
Chris@151 6 Centre for Digital Music, Queen Mary, University of London.
Chris@151 7
Chris@151 8 This program is free software; you can redistribute it and/or
Chris@151 9 modify it under the terms of the GNU General Public License as
Chris@151 10 published by the Free Software Foundation; either version 2 of the
Chris@151 11 License, or (at your option) any later version. See the file
Chris@151 12 COPYING included with this distribution for more information.
Chris@151 13 */
Chris@151 14
Chris@151 15 #ifndef _SUBDIVIDING_MENU_H_
Chris@151 16 #define _SUBDIVIDING_MENU_H_
Chris@151 17
Chris@151 18 #include <QMenu>
Chris@151 19
Chris@151 20 #include <QString>
Chris@151 21 #include <set>
Chris@151 22 #include <map>
Chris@151 23
Chris@151 24 /**
Chris@151 25 * A menu that divides its entries into submenus, alphabetically. For
Chris@151 26 * menus that may contain a very large or small number of named items
Chris@151 27 * (e.g. plugins).
Chris@151 28 *
Chris@151 29 * The menu needs to be told, before any of the actions are added,
Chris@151 30 * what the set of entry strings will be, so it can determine a
Chris@151 31 * reasonable categorisation. Do this by calling the setEntries()
Chris@152 32 * method. If it isn't practical to do this in advance, then add the
Chris@152 33 * entries and call entriesAdded() afterwards instead.
Chris@151 34 */
Chris@151 35
Chris@151 36 class SubdividingMenu : public QMenu
Chris@151 37 {
Chris@151 38 public:
Chris@152 39 SubdividingMenu(size_t lowerLimit = 0, size_t upperLimit = 0,
Chris@152 40 QWidget *parent = 0);
Chris@152 41 SubdividingMenu(const QString &title, size_t lowerLimit = 0,
Chris@152 42 size_t upperLimit = 0, QWidget *parent = 0);
Chris@151 43 virtual ~SubdividingMenu();
Chris@151 44
Chris@151 45 void setEntries(const std::set<QString> &entries);
Chris@152 46 void entriesAdded();
Chris@151 47
Chris@151 48 // Action names and strings passed to addAction and addMenu must
Chris@151 49 // appear in the set previously given to setEntries. If you want
Chris@151 50 // to use a different string, use the two-argument method and pass
Chris@151 51 // the entry string (used to determine which submenu the action
Chris@151 52 // ends up on) as the first argument.
Chris@151 53
Chris@151 54 virtual void addAction(QAction *);
Chris@151 55 virtual QAction *addAction(const QString &);
Chris@151 56 virtual void addAction(const QString &entry, QAction *);
Chris@151 57
Chris@151 58 virtual void addMenu(QMenu *);
Chris@151 59 virtual QMenu *addMenu(const QString &);
Chris@151 60 virtual void addMenu(const QString &entry, QMenu *);
Chris@151 61
Chris@151 62 protected:
Chris@151 63 std::map<QString, QMenu *> m_nameToChunkMenuMap;
Chris@152 64
Chris@152 65 size_t m_lowerLimit;
Chris@152 66 size_t m_upperLimit;
Chris@152 67
Chris@152 68 bool m_entriesSet;
Chris@152 69 std::map<QString, QObject *> m_pendingEntries;
Chris@151 70 };
Chris@151 71
Chris@151 72 #endif
Chris@151 73