/[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 1508 by schoenebeck, Thu Nov 22 02:48:41 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;
249        bool                alive; // whether these params refer to an existing device or for a device that is yet to be created
250  };  };
251    
252  // so we can use it i.e. through QVariant  // so we can use it i.e. through QVariant
253  Q_DECLARE_METATYPE(DeviceParameterRow)  Q_DECLARE_METATYPE(DeviceParameterRow)
254    
255  class DeviceParamModel : public QAbstractTableModel {  //-------------------------------------------------------------------------
256    // AbstractDeviceParamModel - data model base class for device parameters
257    //
258    class AbstractDeviceParamModel : public QAbstractTableModel {
259          Q_OBJECT          Q_OBJECT
260      public:      public:
261          DeviceParamModel(QObject* parent = 0);          AbstractDeviceParamModel(QObject* parent = 0);
262    
263          // overridden methods from subclass(es)          // overridden methods from subclass(es)
264          int rowCount(const QModelIndex &parent) const;          int rowCount(const QModelIndex& parent = QModelIndex()) const;
265          int columnCount(const QModelIndex &parent) const;          int columnCount(const QModelIndex& parent = QModelIndex() ) 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;          QVariant data(const QModelIndex &index, int role) const;
288            bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
289            void clear();
290    
291          void setEditorData(QWidget* editor, const QModelIndex& index) const;      public slots:
292          void setModelData(QWidget* editor, QAbstractItemModel* model,          void refresh(qsamplerDevice* pDevice, bool bEditable);
                           const QModelIndex& index) const;  
293    
294          void updateEditorGeometry(QWidget* editor,      private:
295              const QStyleOptionViewItem& option, const QModelIndex& index) const;          qsamplerDevice* device;
296  };  };
297    
   
298  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
299  // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.  // PortParamModel - data model for port parameters (used for QTableView)
300  //  //
301    class PortParamModel : public AbstractDeviceParamModel {
302            Q_OBJECT
303        public:
304            PortParamModel(QObject* parent = 0);
305    
306  #if 0          // overridden methods from subclass(es)
307  class qsamplerDeviceParamTableSpinBox : public QTableWidgetItem          QVariant data(const QModelIndex &index, int role) const;
308  {          bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
309  public:          void clear();
   
         // 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);  
310    
311  private:      public slots:
312            void refresh(qsamplerDevicePort* pPort, bool bEditable);
313    
314          // Initial value holders.      private:
315          int m_iValue;          qsamplerDevicePort* port;
         int m_iMinValue;  
         int m_iMaxValue;  
316  };  };
317    
   
318  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
319  // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.  // DeviceParamDelegate - table cell renderer for device/port parameters
320  //  //
321    class DeviceParamDelegate : public QItemDelegate {
322  class qsamplerDeviceParamTableEditBox : public QTableWidgetItem          Q_OBJECT
323  {      public:
324  public:          DeviceParamDelegate(QObject* parent = 0);
325            QWidget* createEditor(QWidget* parent,
326          // Constructor.                                const QStyleOptionViewItem& option,
327          qsamplerDeviceParamTableEditBox (QTableWidget *pTable, Qt::ItemFlags flags,                                const QModelIndex& index) const;
328                  const QString& sText);          void setEditorData(QWidget* editor, const QModelIndex& index) const;
329            void setModelData(QWidget* editor, QAbstractItemModel* model,
330  protected:                            const QModelIndex& index) const;
331            void updateEditorGeometry(QWidget* editor,
332          // Virtual implemetations.                                    const QStyleOptionViewItem& option,
333          QWidget *createEditor() const;                                    const QModelIndex& index) const;
         void setContentFromEditor(QWidget *pWidget);  
334  };  };
 #endif  
335    
336  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
337    
   
338  // end of qsamplerDevice.h  // end of qsamplerDevice.h

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

  ViewVC Help
Powered by ViewVC