/[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 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, 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 28  Line 29 
29  #include <QTableWidget>  #include <QTableWidget>
30  #include <QTableWidgetItem>  #include <QTableWidgetItem>
31  #include <QAbstractTableModel>  #include <QAbstractTableModel>
 #include <QMetaType>  
32  #include <QItemDelegate>  #include <QItemDelegate>
33  #include <QFontMetrics>  #include <QFontMetrics>
34  #include <QModelIndex>  #include <QModelIndex>
35  #include <QSize>  #include <QSize>
36  #include <QList>  #include <QList>
 #include <Q3PtrList>  
37    
38  #include <lscp/client.h>  #include <lscp/client.h>
39  #include <lscp/device.h>  #include <lscp/device.h>
# Line 86  public: Line 85  public:
85  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;
86    
87  // Typedef'd device port/channels QptrList.  // Typedef'd device port/channels QptrList.
88  typedef Q3PtrList<qsamplerDevicePort> qsamplerDevicePortList;  typedef QList<qsamplerDevicePort *> qsamplerDevicePortList;
89    
90    
91  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 244  private: Line 243  private:
243          qsamplerDevice m_device;          qsamplerDevice m_device;
244  };  };
245    
   
 //-------------------------------------------------------------------------  
 // qsamplerDeviceParamTable - Device parameter view table.  
 //  
   
 #if 0  
 class qsamplerDeviceParamTable : public QTable  
 {  
         Q_OBJECT  
   
 public:  
   
         // Constructor.  
         qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);  
         // Default destructor.  
         ~qsamplerDeviceParamTable();  
   
         // Common parameter table renderer.  
         void refresh(const qsamplerDeviceParamMap& params, bool bEditable);  
 };  
 #endif  
   
246  struct DeviceParameterRow {  struct DeviceParameterRow {
247      QString             name;      QString             name;
248      qsamplerDeviceParam param;      qsamplerDeviceParam param;
# Line 274  struct DeviceParameterRow { Line 251  struct DeviceParameterRow {
251  // so we can use it i.e. through QVariant  // so we can use it i.e. through QVariant
252  Q_DECLARE_METATYPE(DeviceParameterRow)  Q_DECLARE_METATYPE(DeviceParameterRow)
253    
254  class DeviceParamModel : public QAbstractTableModel {  //-------------------------------------------------------------------------
255    // AbstractDeviceParamModel - data model base class for device parameters
256    //
257    class AbstractDeviceParamModel : public QAbstractTableModel {
258          Q_OBJECT          Q_OBJECT
259      public:      public:
260          DeviceParamModel(QObject* parent = 0);          AbstractDeviceParamModel(QObject* parent = 0);
261    
262          // overridden methods from subclass(es)          // overridden methods from subclass(es)
263          int rowCount(const QModelIndex &parent) const;          int rowCount(const QModelIndex& parent = QModelIndex()) const;
264          int columnCount(const QModelIndex &parent) const;          int columnCount(const QModelIndex& parent = QModelIndex() ) const;
265          QVariant data(const QModelIndex &index, int role) const;          QVariant data(const QModelIndex &index, int role) const;
266          QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;          QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
267            Qt::ItemFlags flags(const QModelIndex& index) const;
268    
269          void clear();          virtual void clear();
270    
271      public slots:          void refresh(const qsamplerDeviceParamMap* params, bool bEditable);
         void refresh(const qsamplerDeviceParamMap& params, bool bEditable);  
272    
273      private:      protected:
274          qsamplerDeviceParamMap params;          const qsamplerDeviceParamMap* params;
275          bool bEditable;          bool bEditable;
276  };  };
277    
278  class DeviceParamDelegate : public QItemDelegate {  //-------------------------------------------------------------------------
279    // DeviceParamModel - data model for device parameters (used for QTableView)
280    //
281    class DeviceParamModel : public AbstractDeviceParamModel {
282          Q_OBJECT          Q_OBJECT
283      public:      public:
284          DeviceParamDelegate(QObject* parent = 0);          DeviceParamModel(QObject* parent = 0);
285    
286          QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,          // overridden methods from subclass(es)
287                                const QModelIndex& index) const;          bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
288            void clear();
289    
290          void setEditorData(QWidget* editor, const QModelIndex& index) const;      public slots:
291          void setModelData(QWidget* editor, QAbstractItemModel* model,          void refresh(qsamplerDevice* pDevice, bool bEditable);
                           const QModelIndex& index) const;  
292    
293          void updateEditorGeometry(QWidget* editor,      private:
294              const QStyleOptionViewItem& option, const QModelIndex& index) const;          qsamplerDevice* device;
295  };  };
296    
   
297  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
298  // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.  // PortParamModel - data model for port parameters (used for QTableView)
299  //  //
300    class PortParamModel : public AbstractDeviceParamModel {
301            Q_OBJECT
302        public:
303            PortParamModel(QObject* parent = 0);
304    
305  #if 0          // overridden methods from subclass(es)
306  class qsamplerDeviceParamTableSpinBox : public QTableWidgetItem          bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
307  {          void clear();
 public:  
   
         // Constructor.  
         qsamplerDeviceParamTableSpinBox (QTableWidget *pTable, Qt::ItemFlags flags,  
                 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);  
308    
309  private:      public slots:
310            void refresh(qsamplerDevicePort* pPort, bool bEditable);
311    
312          // Initial value holders.      private:
313          int m_iValue;          qsamplerDevicePort* port;
         int m_iMinValue;  
         int m_iMaxValue;  
314  };  };
315    
   
316  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
317  // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.  // DeviceParamDelegate - table cell renderer for device/port parameters
318  //  //
319    class DeviceParamDelegate : public QItemDelegate {
320  class qsamplerDeviceParamTableEditBox : public QTableWidgetItem          Q_OBJECT
321  {      public:
322  public:          DeviceParamDelegate(QObject* parent = 0);
323            QWidget* createEditor(QWidget* parent,
324          // Constructor.                                const QStyleOptionViewItem& option,
325          qsamplerDeviceParamTableEditBox (QTableWidget *pTable, Qt::ItemFlags flags,                                const QModelIndex& index) const;
326                  const QString& sText);          void setEditorData(QWidget* editor, const QModelIndex& index) const;
327            void setModelData(QWidget* editor, QAbstractItemModel* model,
328  protected:                            const QModelIndex& index) const;
329            void updateEditorGeometry(QWidget* editor,
330          // Virtual implemetations.                                    const QStyleOptionViewItem& option,
331          QWidget *createEditor() const;                                    const QModelIndex& index) const;
         void setContentFromEditor(QWidget *pWidget);  
332  };  };
 #endif  
333    
334  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
335    
   
336  // end of qsamplerDevice.h  // end of qsamplerDevice.h

Legend:
Removed from v.1461  
changed lines
  Added in v.1499

  ViewVC Help
Powered by ViewVC