/[svn]/qsampler/trunk/src/qsamplerDevice.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerDevice.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1510 by capela, Thu Nov 22 14:17:24 2007 UTC revision 1558 by capela, Thu Dec 6 09:35:33 2007 UTC
# Line 40  Line 40 
40    
41  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
42    
43    namespace QSampler {
44    
45    class DevicePort;
46    
47  // Special QListViewItem::rtti() unique return value.  // Special QListViewItem::rtti() unique return value.
48  #define QSAMPLER_DEVICE_ITEM    1001  #define QSAMPLER_DEVICE_ITEM    1001
49    
 // Early forward declarations.  
 class qsamplerMainForm;  
 class qsamplerDevicePort;  
   
50    
51  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
52  // qsamplerDeviceParam - MIDI/Audio Device parameter structure.  // QSampler::DeviceParam - MIDI/Audio Device parameter structure.
53  //  //
54  class qsamplerDeviceParam  
55    class DeviceParam
56  {  {
57  public:  public:
58    
59          // Constructor.          // Constructor.
60          qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL,          DeviceParam(lscp_param_info_t *pParamInfo = NULL,
61                  const char *pszValue = NULL);                  const char *pszValue = NULL);
62          // Default destructor.          // Default destructor.
63          ~qsamplerDeviceParam();          ~DeviceParam();
64    
65          // Initializer.          // Initializer.
66          void setParam(lscp_param_info_t *pParamInfo,          void setParam(lscp_param_info_t *pParamInfo,
# Line 82  public: Line 82  public:
82  };  };
83    
84  // Typedef'd parameter QMap.  // Typedef'd parameter QMap.
85  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;  typedef QMap<QString, DeviceParam> DeviceParamMap;
86    
87  // Typedef'd device port/channels QptrList.  // Typedef'd device port/channels QList.
88  typedef QList<qsamplerDevicePort *> qsamplerDevicePortList;  typedef QList<DevicePort *> DevicePortList;
89    
90    
91  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
92  // qsamplerDevice - MIDI/Audio Device structure.  // QSampler::Device - MIDI/Audio Device structure.
93  //  //
94    
95  class qsamplerDevice  class Device
96  {  {
97  public:  public:
98    
# Line 100  public: Line 100  public:
100          enum DeviceType { None, Midi, Audio };          enum DeviceType { None, Midi, Audio };
101    
102          // Constructor.          // Constructor.
103          qsamplerDevice(DeviceType deviceType, int iDeviceID = -1);          Device(DeviceType deviceType, int iDeviceID = -1);
104          // Copy constructor.          // Copy constructor.
105          qsamplerDevice(const qsamplerDevice& device);          Device(const Device& device);
106    
107          // Default destructor.          // Default destructor.
108          ~qsamplerDevice();          ~Device();
109    
110          // Initializer.          // Initializer.
111          void setDevice(DeviceType deviceType, int iDeviceID = -1);          void setDevice(DeviceType deviceType, int iDeviceID = -1);
# Line 125  public: Line 126  public:
126          bool setParam (const QString& sParam, const QString& sValue);          bool setParam (const QString& sParam, const QString& sValue);
127    
128          // Device parameters accessor.          // Device parameters accessor.
129          const qsamplerDeviceParamMap& params() const;          const DeviceParamMap& params() const;
130    
131          // Device port/channel list accessor.          // Device port/channel list accessor.
132          qsamplerDevicePortList& ports();          DevicePortList& ports();
133    
134          // Device parameter dependency list refreshner.          // Device parameter dependency list refreshner.
135          int refreshParams();          int refreshParams();
# Line 169  private: Line 170  private:
170          QString    m_sDeviceName;          QString    m_sDeviceName;
171    
172          // Device parameter list.          // Device parameter list.
173          qsamplerDeviceParamMap m_params;          DeviceParamMap m_params;
174    
175          // Device port/channel list.          // Device port/channel list.
176          qsamplerDevicePortList m_ports;          DevicePortList m_ports;
177  };  };
178    
179    
180  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
181  // qsamplerDevicePort - MIDI/Audio Device port/channel structure.  // QSampler::DevicePort - MIDI/Audio Device port/channel structure.
182  //  //
183    
184  class qsamplerDevicePort  class DevicePort
185  {  {
186  public:  public:
187    
188          // Constructor.          // Constructor.
189          qsamplerDevicePort(qsamplerDevice& device, int iPortID);          DevicePort(Device& device, int iPortID);
190          // Default destructor.          // Default destructor.
191          ~qsamplerDevicePort();          ~DevicePort();
192    
193          // Initializer.          // Initializer.
194          void setDevicePort(int iPortID);          void setDevicePort(int iPortID);
# Line 197  public: Line 198  public:
198          const QString& portName() const;          const QString& portName() const;
199    
200          // Device port parameters accessor.          // Device port parameters accessor.
201          const qsamplerDeviceParamMap& params() const;          const DeviceParamMap& params() const;
202    
203          // Set the proper device port/channel parameter value.          // Set the proper device port/channel parameter value.
204          bool setParam (const QString& sParam, const QString& sValue);          bool setParam (const QString& sParam, const QString& sValue);
# Line 205  public: Line 206  public:
206  private:  private:
207    
208          // Device reference.          // Device reference.
209          qsamplerDevice& m_device;          Device& m_device;
210    
211          // Instance variables.          // Instance variables.
212          int     m_iPortID;          int     m_iPortID;
213          QString m_sPortName;          QString m_sPortName;
214    
215          // Device port parameter list.          // Device port parameter list.
216          qsamplerDeviceParamMap m_params;          DeviceParamMap m_params;
217  };  };
218    
219    
220  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
221  // qsamplerDeviceItem - QListView device item.  // QSampler::DeviceItem - QTreeWidget device item.
222  //  //
223    
224  class qsamplerDeviceItem : public QTreeWidgetItem  class DeviceItem : public QTreeWidgetItem
225  {  {
226  public:  public:
227    
228          // Constructors.          // Constructors.
229          qsamplerDeviceItem(QTreeWidget *pTreeWidget,          DeviceItem(QTreeWidget *pTreeWidget,
230                  qsamplerDevice::DeviceType deviceType);                  Device::DeviceType deviceType);
231          qsamplerDeviceItem(QTreeWidgetItem *pItem,          DeviceItem(QTreeWidgetItem *pItem,
232                  qsamplerDevice::DeviceType deviceType, int iDeviceID);                  Device::DeviceType deviceType, int iDeviceID);
233    
234          // Default destructor.          // Default destructor.
235          ~qsamplerDeviceItem();          ~DeviceItem();
236    
237          // Instance accessors.          // Instance accessors.
238          qsamplerDevice& device();          Device& device();
239    
240  private:  private:
241    
242          // Instance variables.          // Instance variables.
243          qsamplerDevice m_device;          Device m_device;
244  };  };
245    
246    
247  struct DeviceParameterRow {  struct DeviceParameterRow {
248          QString             name;          QString     name;
249          qsamplerDeviceParam param;          DeviceParam param;
250          bool                alive; // whether these params refer to an existing device or for a device that is yet to be created          bool        alive; // whether these params refer to an existing device
251                               // or for a device that is yet to be created
252  };  };
253    
 // so we can use it i.e. through QVariant  
 Q_DECLARE_METATYPE(DeviceParameterRow)  
   
254    
255  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
256  // AbstractDeviceParamModel - data model base class for device parameters  // QSampler::AbstractDeviceParamModel - data model base class for device parameters
257  //  //
258    
259  class AbstractDeviceParamModel : public QAbstractTableModel  class AbstractDeviceParamModel : public QAbstractTableModel
260  {  {
261          Q_OBJECT          Q_OBJECT
# Line 271  public: Line 273  public:
273    
274          virtual void clear();          virtual void clear();
275    
276          void refresh(const qsamplerDeviceParamMap* params, bool bEditable);          void refresh(const DeviceParamMap* params, bool bEditable);
277    
278  protected:  protected:
279    
280          const qsamplerDeviceParamMap *m_pParams;          const DeviceParamMap *m_pParams;
281          bool m_bEditable;          bool m_bEditable;
282  };  };
283    
284    
285  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
286  // DeviceParamModel - data model for device parameters (used for QTableView)  // QSampler::DeviceParamModel - data model for device parameters
287  //  //                              (used for QTableView)
288    
289  class DeviceParamModel : public AbstractDeviceParamModel  class DeviceParamModel : public AbstractDeviceParamModel
290  {  {
# Line 301  public: Line 303  public:
303    
304  public slots:  public slots:
305    
306          void refresh(qsamplerDevice* pDevice, bool bEditable);          void refresh(Device* pDevice, bool bEditable);
307    
308  private:  private:
309    
310          qsamplerDevice *m_pDevice;          Device *m_pDevice;
311  };  };
312    
313    
314  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
315  // PortParamModel - data model for port parameters (used for QTableView)  // QSampler::PortParamModel - data model for port parameters
316  //  //                            (used for QTableView)
317    
318  class PortParamModel : public AbstractDeviceParamModel  class PortParamModel : public AbstractDeviceParamModel
319  {  {
# Line 330  public: Line 332  public:
332    
333  public slots:  public slots:
334    
335          void refresh(qsamplerDevicePort* pPort, bool bEditable);          void refresh(DevicePort* pPort, bool bEditable);
336    
337  private:  private:
338    
339          qsamplerDevicePort* m_pPort;          DevicePort* m_pPort;
340  };  };
341    
342    
343  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
344  // DeviceParamDelegate - table cell renderer for device/port parameters  // QSampler::DeviceParamDelegate - table cell renderer for device/port parameters
345  //  //
346    
347  class DeviceParamDelegate : public QItemDelegate  class DeviceParamDelegate : public QItemDelegate
348  {  {
349          Q_OBJECT          Q_OBJECT
# Line 358  public: Line 361  public:
361                  const QStyleOptionViewItem& option, const QModelIndex& index) const;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
362  };  };
363    
364    } // namespace QSampler
365    
366    // so we can use it i.e. through QVariant
367    Q_DECLARE_METATYPE(QSampler::DeviceParameterRow)
368    
369  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
370    
371    
372  // end of qsamplerDevice.h  // end of qsamplerDevice.h

Legend:
Removed from v.1510  
changed lines
  Added in v.1558

  ViewVC Help
Powered by ViewVC