annotate widgets/SubdividingMenu.h @ 532:188049db73fa

* some improvements to log scale in colour 3d plot (still only in dense mode though)
author Chris Cannam
date Tue, 19 May 2009 13:03:36 +0000
parents cd81066ac7ad
children e4773943c9c1
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@222 39 Q_OBJECT
Chris@222 40
Chris@151 41 public:
Chris@152 42 SubdividingMenu(size_t lowerLimit = 0, size_t upperLimit = 0,
Chris@152 43 QWidget *parent = 0);
Chris@152 44 SubdividingMenu(const QString &title, size_t lowerLimit = 0,
Chris@152 45 size_t upperLimit = 0, QWidget *parent = 0);
Chris@151 46 virtual ~SubdividingMenu();
Chris@151 47
Chris@151 48 void setEntries(const std::set<QString> &entries);
Chris@152 49 void entriesAdded();
Chris@151 50
Chris@151 51 // Action names and strings passed to addAction and addMenu must
Chris@151 52 // appear in the set previously given to setEntries. If you want
Chris@151 53 // to use a different string, use the two-argument method and pass
Chris@151 54 // the entry string (used to determine which submenu the action
Chris@151 55 // ends up on) as the first argument.
Chris@151 56
Chris@151 57 virtual void addAction(QAction *);
Chris@151 58 virtual QAction *addAction(const QString &);
Chris@151 59 virtual void addAction(const QString &entry, QAction *);
Chris@151 60
Chris@151 61 virtual void addMenu(QMenu *);
Chris@151 62 virtual QMenu *addMenu(const QString &);
Chris@151 63 virtual void addMenu(const QString &entry, QMenu *);
Chris@151 64
Chris@151 65 protected:
Chris@151 66 std::map<QString, QMenu *> m_nameToChunkMenuMap;
Chris@152 67
Chris@152 68 size_t m_lowerLimit;
Chris@152 69 size_t m_upperLimit;
Chris@152 70
Chris@152 71 bool m_entriesSet;
Chris@152 72 std::map<QString, QObject *> m_pendingEntries;
Chris@151 73 };
Chris@151 74
Chris@151 75 #endif
Chris@151 76