annotate base/PropertyContainer.h @ 109:61a2ac1241b3

* Make a single base Thread class for RT and non-RT threads * Pull ResizeableBitmap out from the MatrixFile's ColumnBitmap * Reorder SpectrogramLayer::paint somewhat so as to improve cache hit ratio in the FFT file cache
author Chris Cannam
date Mon, 08 May 2006 16:44:47 +0000
parents 5b8392e80ed6
children a08718723b20
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _PROPERTY_CONTAINER_H_
Chris@0 17 #define _PROPERTY_CONTAINER_H_
Chris@0 18
Chris@46 19 #include "Command.h"
Chris@46 20
Chris@0 21 #include <QString>
Chris@0 22 #include <QObject>
Chris@0 23 #include <vector>
Chris@0 24
Chris@28 25 class PlayParameters;
Chris@0 26
Chris@29 27 class PropertyContainer : public QObject
Chris@0 28 {
Chris@29 29 Q_OBJECT
Chris@29 30
Chris@0 31 public:
Chris@27 32 virtual ~PropertyContainer() { }
Chris@27 33
Chris@0 34 typedef QString PropertyName;
Chris@0 35 typedef std::vector<PropertyName> PropertyList;
Chris@0 36
Chris@0 37 enum PropertyType {
Chris@0 38 ToggleProperty, // on or off
Chris@0 39 RangeProperty, // range of integers
Chris@0 40 ValueProperty, // range of integers given string labels
Chris@0 41 ColourProperty, // colours, get/set as qRgb
Chris@0 42 InvalidProperty, // property not found!
Chris@0 43 };
Chris@0 44
Chris@0 45 /**
Chris@0 46 * Get a list of the names of all the supported properties on this
Chris@94 47 * container. These should be fixed (i.e. not internationalized).
Chris@0 48 */
Chris@0 49 virtual PropertyList getProperties() const;
Chris@0 50
Chris@0 51 /**
Chris@94 52 * Return the human-readable (and i18n'ised) name of a property.
Chris@94 53 */
Chris@94 54 virtual QString getPropertyLabel(const PropertyName &) const = 0;
Chris@94 55
Chris@94 56 /**
Chris@0 57 * Return the type of the given property, or InvalidProperty if
Chris@0 58 * the property is not supported on this container.
Chris@0 59 */
Chris@0 60 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@0 61
Chris@0 62 /**
Chris@0 63 * If this property has something in common with other properties
Chris@0 64 * on this container, return a name that can be used to group them
Chris@0 65 * (in order to save screen space, for example). e.g. "Window
Chris@0 66 * Type" and "Window Size" might both have a group name of "Window".
Chris@0 67 * If this property is not groupable, return the empty string.
Chris@0 68 */
Chris@0 69 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@0 70
Chris@0 71 /**
Chris@0 72 * Return the minimum and maximum values for the given property
Chris@0 73 * and its current value in this container. Min and/or max may be
Chris@0 74 * passed as NULL if their values are not required.
Chris@0 75 */
Chris@0 76 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@0 77 int *min, int *max) const;
Chris@0 78
Chris@0 79 /**
Chris@0 80 * If the given property is a ValueProperty, return the display
Chris@0 81 * label to be used for the given value for that property.
Chris@0 82 */
Chris@0 83 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@0 84 int value) const;
Chris@0 85
Chris@29 86 virtual QString getPropertyContainerName() const = 0;
Chris@29 87 virtual QString getPropertyContainerIconName() const = 0;
Chris@29 88
Chris@29 89 virtual PlayParameters *getPlayParameters() { return 0; }
Chris@29 90
Chris@29 91 signals:
Chris@29 92 void propertyChanged(PropertyName);
Chris@29 93
Chris@29 94 public slots:
Chris@0 95 /**
Chris@0 96 * Set a property. This is used for all property types. For
Chris@0 97 * boolean properties, zero is false and non-zero true; for
Chris@0 98 * colours, the integer value should be treated as a qRgb.
Chris@0 99 */
Chris@0 100 virtual void setProperty(const PropertyName &, int value);
Chris@46 101
Chris@46 102 /**
Chris@46 103 * Set a property using a command, supporting undo and redo.
Chris@46 104 */
Chris@46 105 virtual void setPropertyWithCommand(const PropertyName &, int value);
Chris@46 106
Chris@46 107 protected:
Chris@46 108
Chris@46 109 class SetPropertyCommand : public Command
Chris@46 110 {
Chris@46 111 public:
Chris@46 112 SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int);
Chris@46 113 virtual ~SetPropertyCommand() { }
Chris@46 114
Chris@46 115 virtual void execute();
Chris@46 116 virtual void unexecute();
Chris@46 117 virtual QString getName() const;
Chris@46 118
Chris@46 119 protected:
Chris@46 120 PropertyContainer *m_pc;
Chris@46 121 PropertyName m_pn;
Chris@46 122 int m_value;
Chris@46 123 int m_oldValue;
Chris@46 124 };
Chris@0 125 };
Chris@0 126
Chris@0 127 #endif