annotate widgets/SubdividingMenu.h @ 210:748985c7e2c1

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