Chris@116: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@116: Chris@116: /* Chris@116: Sonic Visualiser Chris@116: An audio file viewer and annotation editor. Chris@116: Centre for Digital Music, Queen Mary, University of London. Chris@116: This file copyright 2006 Chris Cannam. Chris@116: Chris@116: This program is free software; you can redistribute it and/or Chris@116: modify it under the terms of the GNU General Public License as Chris@116: published by the Free Software Foundation; either version 2 of the Chris@116: License, or (at your option) any later version. See the file Chris@116: COPYING included with this distribution for more information. Chris@116: */ Chris@116: Chris@1581: #ifndef SV_UNIT_DATABASE_H Chris@1581: #define SV_UNIT_DATABASE_H Chris@116: Chris@116: #include Chris@116: #include Chris@116: #include Chris@116: #include Chris@116: Chris@116: // This grandly named class is just a list of the names of known scale Chris@116: // units for the various models, for use as the set of fixed values in Chris@116: // unit dropdown menus etc. Of course, the user should be allowed to Chris@116: // enter their own as well. Chris@116: Chris@116: class UnitDatabase : public QObject Chris@116: { Chris@116: Q_OBJECT Chris@116: Chris@116: public: Chris@116: static UnitDatabase *getInstance(); Chris@116: Chris@116: QStringList getKnownUnits() const; Chris@116: void registerUnit(QString unit); Chris@199: Chris@199: /** Chris@199: * Return the reference id for a given unit name. If registerNew is Chris@199: * true and the unit is not known, register it and return its new Chris@199: * id. If register is false and the unit is not known, return -1. Chris@199: */ Chris@199: int getUnitId(QString unit, bool registerNew = true); Chris@199: Chris@116: QString getUnitById(int id); Chris@116: Chris@116: signals: Chris@116: void unitDatabaseChanged(); Chris@116: Chris@116: protected: Chris@116: UnitDatabase(); Chris@116: Chris@116: typedef std::map UnitMap; Chris@116: UnitMap m_units; Chris@116: int m_nextId; Chris@116: Chris@116: static UnitDatabase m_instance; Chris@116: }; Chris@116: Chris@116: #endif Chris@116: