/[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 1509 by capela, Thu Nov 22 11:10:44 2007 UTC revision 2059 by capela, Wed Feb 17 19:50:04 2010 UTC
# Line 1  Line 1 
1  // qsamplerDevice.h  // qsamplerDevice.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 34  Line 34 
34  #include <QModelIndex>  #include <QModelIndex>
35  #include <QSize>  #include <QSize>
36  #include <QList>  #include <QList>
37    #include <set>
38    
39  #include <lscp/client.h>  #include <lscp/client.h>
40  #include <lscp/device.h>  #include <lscp/device.h>
41    
42  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
43    
44    namespace QSampler {
45    
46    class DevicePort;
47    
48  // Special QListViewItem::rtti() unique return value.  // Special QListViewItem::rtti() unique return value.
49  #define QSAMPLER_DEVICE_ITEM    1001  #define QSAMPLER_DEVICE_ITEM    1001
50    
 // Early forward declarations.  
 class qsamplerMainForm;  
 class qsamplerDevicePort;  
   
51    
52  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
53  // qsamplerDeviceParam - MIDI/Audio Device parameter structure.  // QSampler::DeviceParam - MIDI/Audio Device parameter structure.
54  //  //
55  class qsamplerDeviceParam  
56    class DeviceParam
57  {  {
58  public:  public:
59    
60          // Constructor.          // Constructor.
61          qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL,          DeviceParam(lscp_param_info_t *pParamInfo = NULL,
62                  const char *pszValue = NULL);                  const char *pszValue = NULL);
63          // Default destructor.          // Default destructor.
64          ~qsamplerDeviceParam();          ~DeviceParam();
65    
66          // Initializer.          // Initializer.
67          void setParam(lscp_param_info_t *pParamInfo,          void setParam(lscp_param_info_t *pParamInfo,
# Line 82  public: Line 83  public:
83  };  };
84    
85  // Typedef'd parameter QMap.  // Typedef'd parameter QMap.
86  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;  typedef QMap<QString, DeviceParam> DeviceParamMap;
87    
88  // Typedef'd device port/channels QptrList.  // Typedef'd device port/channels QList.
89  typedef QList<qsamplerDevicePort *> qsamplerDevicePortList;  typedef QList<DevicePort *> DevicePortList;
90    
91    
92  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
93  // qsamplerDevice - MIDI/Audio Device structure.  // QSampler::Device - MIDI/Audio Device structure.
94  //  //
95    
96  class qsamplerDevice  class Device
97  {  {
98  public:  public:
99    
# Line 100  public: Line 101  public:
101          enum DeviceType { None, Midi, Audio };          enum DeviceType { None, Midi, Audio };
102    
103          // Constructor.          // Constructor.
104          qsamplerDevice(DeviceType deviceType, int iDeviceID = -1);          Device(DeviceType deviceType, int iDeviceID = -1);
105          // Copy constructor.          // Copy constructor.
106          qsamplerDevice(const qsamplerDevice& device);          Device(const Device& device);
107    
108          // Default destructor.          // Default destructor.
109          ~qsamplerDevice();          ~Device();
110    
111          // Initializer.          // Initializer.
112          void setDevice(DeviceType deviceType, int iDeviceID = -1);          void setDevice(DeviceType deviceType, int iDeviceID = -1);
# Line 125  public: Line 127  public:
127          bool setParam (const QString& sParam, const QString& sValue);          bool setParam (const QString& sParam, const QString& sValue);
128    
129          // Device parameters accessor.          // Device parameters accessor.
130          const qsamplerDeviceParamMap& params() const;          const DeviceParamMap& params() const;
131    
132          // Device port/channel list accessor.          // Device port/channel list accessor.
133          qsamplerDevicePortList& ports();          DevicePortList& ports();
134    
135          // Device parameter dependency list refreshner.          // Device parameter dependency list refreshner.
136          int refreshParams();          int refreshParams();
# Line 151  public: Line 153  public:
153          // Device ids enumerator.          // Device ids enumerator.
154          static int *getDevices(lscp_client_t *pClient,          static int *getDevices(lscp_client_t *pClient,
155                  DeviceType deviceType);                  DeviceType deviceType);
156            static std::set<int> getDeviceIDs(lscp_client_t *pClient,
157                    DeviceType deviceType);
158    
159          // Driver names enumerator.          // Driver names enumerator.
160          static QStringList getDrivers(lscp_client_t *pClient,          static QStringList getDrivers(lscp_client_t *pClient,
# Line 169  private: Line 173  private:
173          QString    m_sDeviceName;          QString    m_sDeviceName;
174    
175          // Device parameter list.          // Device parameter list.
176          qsamplerDeviceParamMap m_params;          DeviceParamMap m_params;
177    
178          // Device port/channel list.          // Device port/channel list.
179          qsamplerDevicePortList m_ports;          DevicePortList m_ports;
180  };  };
181    
182    
183  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
184  // qsamplerDevicePort - MIDI/Audio Device port/channel structure.  // QSampler::DevicePort - MIDI/Audio Device port/channel structure.
185  //  //
186    
187  class qsamplerDevicePort  class DevicePort
188  {  {
189  public:  public:
190    
191          // Constructor.          // Constructor.
192          qsamplerDevicePort(qsamplerDevice& device, int iPortID);          DevicePort(Device& device, int iPortID);
193          // Default destructor.          // Default destructor.
194          ~qsamplerDevicePort();          ~DevicePort();
195    
196          // Initializer.          // Initializer.
197          void setDevicePort(int iPortID);          void setDevicePort(int iPortID);
# Line 197  public: Line 201  public:
201          const QString& portName() const;          const QString& portName() const;
202    
203          // Device port parameters accessor.          // Device port parameters accessor.
204          const qsamplerDeviceParamMap& params() const;          const DeviceParamMap& params() const;
205    
206          // Set the proper device port/channel parameter value.          // Set the proper device port/channel parameter value.
207          bool setParam (const QString& sParam, const QString& sValue);          bool setParam (const QString& sParam, const QString& sValue);
# Line 205  public: Line 209  public:
209  private:  private:
210    
211          // Device reference.          // Device reference.
212          qsamplerDevice& m_device;          Device& m_device;
213    
214          // Instance variables.          // Instance variables.
215          int     m_iPortID;          int     m_iPortID;
216          QString m_sPortName;          QString m_sPortName;
217    
218          // Device port parameter list.          // Device port parameter list.
219          qsamplerDeviceParamMap m_params;          DeviceParamMap m_params;
220  };  };
221    
222    
223  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
224  // qsamplerDeviceItem - QListView device item.  // QSampler::DeviceItem - QTreeWidget device item.
225  //  //
226    
227  class qsamplerDeviceItem : public QTreeWidgetItem  class DeviceItem : public QTreeWidgetItem
228  {  {
229  public:  public:
230    
231          // Constructors.          // Constructors.
232          qsamplerDeviceItem(QTreeWidget *pTreeWidget,          DeviceItem(QTreeWidget *pTreeWidget,
233                  qsamplerDevice::DeviceType deviceType);                  Device::DeviceType deviceType);
234          qsamplerDeviceItem(QTreeWidgetItem *pItem,          DeviceItem(QTreeWidgetItem *pItem,
235                  qsamplerDevice::DeviceType deviceType, int iDeviceID);                  Device::DeviceType deviceType, int iDeviceID);
236    
237          // Default destructor.          // Default destructor.
238          ~qsamplerDeviceItem();          ~DeviceItem();
239    
240          // Instance accessors.          // Instance accessors.
241          qsamplerDevice& device();          Device& device();
242    
243  private:  private:
244    
245          // Instance variables.          // Instance variables.
246          qsamplerDevice m_device;          Device m_device;
247  };  };
248    
249    
250  struct DeviceParameterRow {  struct DeviceParameterRow {
251          QString             name;          QString     name;
252          qsamplerDeviceParam param;          DeviceParam param;
253          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
254                               // or for a device that is yet to be created
255  };  };
256    
 // so we can use it i.e. through QVariant  
 Q_DECLARE_METATYPE(DeviceParameterRow)  
   
257    
258  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
259  // AbstractDeviceParamModel - data model base class for device parameters  // QSampler::AbstractDeviceParamModel - data model base class for device parameters
260  //  //
261    
262  class AbstractDeviceParamModel : public QAbstractTableModel  class AbstractDeviceParamModel : public QAbstractTableModel
263  {  {
264          Q_OBJECT          Q_OBJECT
# Line 271  public: Line 276  public:
276    
277          virtual void clear();          virtual void clear();
278    
279          void refresh(const qsamplerDeviceParamMap* params, bool bEditable);          void refresh(const DeviceParamMap* params, bool bEditable);
280    
281  protected:  protected:
282    
283          const qsamplerDeviceParamMap *m_params;          const DeviceParamMap *m_pParams;
284          bool m_bEditable;          bool m_bEditable;
285  };  };
286    
287    
288  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
289  // DeviceParamModel - data model for device parameters (used for QTableView)  // QSampler::DeviceParamModel - data model for device parameters
290  //  //                              (used for QTableView)
291    
292  class DeviceParamModel : public AbstractDeviceParamModel  class DeviceParamModel : public AbstractDeviceParamModel
293  {  {
# Line 301  public: Line 306  public:
306    
307  public slots:  public slots:
308    
309          void refresh(qsamplerDevice* pDevice, bool bEditable);          void refresh(Device* pDevice, bool bEditable);
310    
311  private:  private:
312    
313          qsamplerDevice *m_device;          Device *m_pDevice;
314  };  };
315    
316    
317  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
318  // PortParamModel - data model for port parameters (used for QTableView)  // QSampler::PortParamModel - data model for port parameters
319  //  //                            (used for QTableView)
320    
321  class PortParamModel : public AbstractDeviceParamModel  class PortParamModel : public AbstractDeviceParamModel
322  {  {
# Line 330  public: Line 335  public:
335    
336  public slots:  public slots:
337    
338          void refresh(qsamplerDevicePort* pPort, bool bEditable);          void refresh(DevicePort* pPort, bool bEditable);
339    
340  private:  private:
341    
342          qsamplerDevicePort* m_port;          DevicePort* m_pPort;
343  };  };
344    
345    
346  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
347  // DeviceParamDelegate - table cell renderer for device/port parameters  // QSampler::DeviceParamDelegate - table cell renderer for device/port parameters
348  //  //
349    
350  class DeviceParamDelegate : public QItemDelegate  class DeviceParamDelegate : public QItemDelegate
351  {  {
352          Q_OBJECT          Q_OBJECT
# Line 352  public: Line 358  public:
358          QWidget* createEditor(QWidget *pParent,          QWidget* createEditor(QWidget *pParent,
359                  const QStyleOptionViewItem& option, const QModelIndex& index) const;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
360          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
361          void setModelData(QWidget *pEditor, QAbstractItemModel* model,          void setModelData(QWidget *pEditor, QAbstractItemModel *pModel,
362                  const QModelIndex& index) const;                  const QModelIndex& index) const;
363          void updateEditorGeometry(QWidget* pEditor,          void updateEditorGeometry(QWidget* pEditor,
364                  const QStyleOptionViewItem& option, const QModelIndex& index) const;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
365  };  };
366    
367    } // namespace QSampler
368    
369    // so we can use it i.e. through QVariant
370    Q_DECLARE_METATYPE(QSampler::DeviceParameterRow)
371    
372  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
373    
374    
375  // end of qsamplerDevice.h  // end of qsamplerDevice.h

Legend:
Removed from v.1509  
changed lines
  Added in v.2059

  ViewVC Help
Powered by ViewVC