/[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 961 by capela, Sun Dec 3 18:26:13 2006 UTC revision 1486 by schoenebeck, Sat Nov 17 02:02:28 2007 UTC
# Line 1  Line 1 
1  // qsamplerDevice.h  // qsamplerDevice.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5       Copyright (C) 2007, 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 22  Line 23 
23  #ifndef __qsamplerDevice_h  #ifndef __qsamplerDevice_h
24  #define __qsamplerDevice_h  #define __qsamplerDevice_h
25    
26  #include <qlistview.h>  #include <QListWidget>
27  #include <qtable.h>  #include <QListWidgetItem>
28    #include <QTreeWidgetItem>
29    #include <QTableWidget>
30    #include <QTableWidgetItem>
31    #include <QAbstractTableModel>
32    #include <QMetaType>
33    #include <QItemDelegate>
34    #include <QFontMetrics>
35    #include <QModelIndex>
36    #include <QSize>
37    #include <QList>
38    #include <Q3PtrList>
39    
40  #include <lscp/client.h>  #include <lscp/client.h>
41  #include <lscp/device.h>  #include <lscp/device.h>
# Line 75  public: Line 87  public:
87  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;
88    
89  // Typedef'd device port/channels QptrList.  // Typedef'd device port/channels QptrList.
90  typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList;  typedef Q3PtrList<qsamplerDevicePort> qsamplerDevicePortList;
91    
92    
93  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 212  private: Line 224  private:
224  // qsamplerDeviceItem - QListView device item.  // qsamplerDeviceItem - QListView device item.
225  //  //
226    
227  class qsamplerDeviceItem : public QListViewItem  class qsamplerDeviceItem : public QTreeWidgetItem
228  {  {
229  public:  public:
230    
231          // Constructors.          // Constructors.
232          qsamplerDeviceItem(QListView *pListView,          qsamplerDeviceItem(QTreeWidget* pTreeWidget,
233                  qsamplerDevice::qsamplerDeviceType deviceType);                  qsamplerDevice::qsamplerDeviceType deviceType);
234          qsamplerDeviceItem(QListViewItem *pItem,          qsamplerDeviceItem(QTreeWidgetItem* pItem,
235                  qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);                  qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
236          // Default destructor.          // Default destructor.
237          ~qsamplerDeviceItem();          ~qsamplerDeviceItem();
# Line 227  public: Line 239  public:
239          // Instance accessors.          // Instance accessors.
240          qsamplerDevice& device();          qsamplerDevice& device();
241    
         // To virtually distinguish between list view items.  
         virtual int rtti() const;  
   
242  private:  private:
243    
244          // Instance variables.          // Instance variables.
245          qsamplerDevice m_device;          qsamplerDevice m_device;
246  };  };
247    
248    struct DeviceParameterRow {
249        QString             name;
250        qsamplerDeviceParam param;
251    };
252    
253    // so we can use it i.e. through QVariant
254    Q_DECLARE_METATYPE(DeviceParameterRow)
255    
256  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
257  // qsamplerDeviceParamTable - Device parameter view table.  // AbstractDeviceParamModel - data model base class for device parameters
258  //  //
259    class AbstractDeviceParamModel : public QAbstractTableModel {
260  class qsamplerDeviceParamTable : public QTable          Q_OBJECT
261  {      public:
262          Q_OBJECT          AbstractDeviceParamModel(QObject* parent = 0);
263    
264  public:          // overridden methods from subclass(es)
265            int rowCount(const QModelIndex& parent = QModelIndex()) const;
266          // Constructor.          int columnCount(const QModelIndex& parent = QModelIndex() ) const;
267          qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);          QVariant data(const QModelIndex &index, int role) const;
268          // Default destructor.          QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
269          ~qsamplerDeviceParamTable();          Qt::ItemFlags flags(const QModelIndex& index) const;
270    
271          // Common parameter table renderer.          virtual void clear();
272          void refresh(const qsamplerDeviceParamMap& params, bool bEditable);  
273            void refresh(const qsamplerDeviceParamMap* params, bool bEditable);
274    
275        protected:
276            const qsamplerDeviceParamMap* params;
277            bool bEditable;
278  };  };
279    
   
280  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
281  // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.  // DeviceParamModel - data model for device parameters (used for QTableView)
282  //  //
283    class DeviceParamModel : public AbstractDeviceParamModel {
284            Q_OBJECT
285        public:
286            DeviceParamModel(QObject* parent = 0);
287    
288            // overridden methods from subclass(es)
289            bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
290            void clear();
291    
292  class qsamplerDeviceParamTableSpinBox : public QTableItem      public slots:
293  {          void refresh(qsamplerDevice* pDevice, bool bEditable);
 public:  
294    
295          // Constructor.      private:
296          qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,          qsamplerDevice* device;
                 const QString& sText);  
   
         // Public accessors.  
         void setMinValue(int iMinValue);  
         void setMaxValue(int iMaxValue);  
         void setValue(int iValue);  
   
 protected:  
   
         // Virtual implemetations.  
         QWidget *createEditor() const;  
         void setContentFromEditor(QWidget *pWidget);  
   
 private:  
   
         // Initial value holders.  
         int m_iValue;  
         int m_iMinValue;  
         int m_iMaxValue;  
297  };  };
298    
   
299  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
300  // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.  // PortParamModel - data model for port parameters (used for QTableView)
301  //  //
302    class PortParamModel : public AbstractDeviceParamModel {
303            Q_OBJECT
304        public:
305            PortParamModel(QObject* parent = 0);
306    
307            // overridden methods from subclass(es)
308            bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
309            void clear();
310    
311  class qsamplerDeviceParamTableEditBox : public QTableItem      public slots:
312  {          void refresh(qsamplerDevicePort* pPort, bool bEditable);
 public:  
   
         // Constructor.  
         qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType,  
                 const QString& sText);  
   
 protected:  
313    
314          // Virtual implemetations.      private:
315          QWidget *createEditor() const;          qsamplerDevicePort* port;
         void setContentFromEditor(QWidget *pWidget);  
316  };  };
317    
318    //-------------------------------------------------------------------------
319    // DeviceParamDelegate - table cell renderer for device/port parameters
320    //
321    class DeviceParamDelegate : public QItemDelegate {
322            Q_OBJECT
323        public:
324            DeviceParamDelegate(QObject* parent = 0);
325            QWidget* createEditor(QWidget* parent,
326                                  const QStyleOptionViewItem& option,
327                                  const QModelIndex& index) const;
328            void setEditorData(QWidget* editor, const QModelIndex& index) const;
329            void setModelData(QWidget* editor, QAbstractItemModel* model,
330                              const QModelIndex& index) const;
331            void updateEditorGeometry(QWidget* editor,
332                                      const QStyleOptionViewItem& option,
333                                      const QModelIndex& index) const;
334    };
335    
336  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
337    
   
338  // end of qsamplerDevice.h  // end of qsamplerDevice.h

Legend:
Removed from v.961  
changed lines
  Added in v.1486

  ViewVC Help
Powered by ViewVC