/[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 1461 by schoenebeck, Sun Oct 28 23:30:36 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    
6     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
7     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 22 
22  #ifndef __qsamplerDevice_h  #ifndef __qsamplerDevice_h
23  #define __qsamplerDevice_h  #define __qsamplerDevice_h
24    
25  #include <qlistview.h>  #include <QListWidget>
26  #include <qtable.h>  #include <QListWidgetItem>
27    #include <QTreeWidgetItem>
28    #include <QTableWidget>
29    #include <QTableWidgetItem>
30    #include <QAbstractTableModel>
31    #include <QMetaType>
32    #include <QItemDelegate>
33    #include <QFontMetrics>
34    #include <QModelIndex>
35    #include <QSize>
36    #include <QList>
37    #include <Q3PtrList>
38    
39  #include <lscp/client.h>  #include <lscp/client.h>
40  #include <lscp/device.h>  #include <lscp/device.h>
# Line 75  public: Line 86  public:
86  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;  typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;
87    
88  // Typedef'd device port/channels QptrList.  // Typedef'd device port/channels QptrList.
89  typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList;  typedef Q3PtrList<qsamplerDevicePort> qsamplerDevicePortList;
90    
91    
92  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 212  private: Line 223  private:
223  // qsamplerDeviceItem - QListView device item.  // qsamplerDeviceItem - QListView device item.
224  //  //
225    
226  class qsamplerDeviceItem : public QListViewItem  class qsamplerDeviceItem : public QTreeWidgetItem
227  {  {
228  public:  public:
229    
230          // Constructors.          // Constructors.
231          qsamplerDeviceItem(QListView *pListView,          qsamplerDeviceItem(QTreeWidget* pTreeWidget,
232                  qsamplerDevice::qsamplerDeviceType deviceType);                  qsamplerDevice::qsamplerDeviceType deviceType);
233          qsamplerDeviceItem(QListViewItem *pItem,          qsamplerDeviceItem(QTreeWidgetItem* pItem,
234                  qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);                  qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
235          // Default destructor.          // Default destructor.
236          ~qsamplerDeviceItem();          ~qsamplerDeviceItem();
# Line 227  public: Line 238  public:
238          // Instance accessors.          // Instance accessors.
239          qsamplerDevice& device();          qsamplerDevice& device();
240    
         // To virtually distinguish between list view items.  
         virtual int rtti() const;  
   
241  private:  private:
242    
243          // Instance variables.          // Instance variables.
# Line 241  private: Line 249  private:
249  // qsamplerDeviceParamTable - Device parameter view table.  // qsamplerDeviceParamTable - Device parameter view table.
250  //  //
251    
252    #if 0
253  class qsamplerDeviceParamTable : public QTable  class qsamplerDeviceParamTable : public QTable
254  {  {
255          Q_OBJECT          Q_OBJECT
# Line 255  public: Line 264  public:
264          // Common parameter table renderer.          // Common parameter table renderer.
265          void refresh(const qsamplerDeviceParamMap& params, bool bEditable);          void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
266  };  };
267    #endif
268    
269    struct DeviceParameterRow {
270        QString             name;
271        qsamplerDeviceParam param;
272    };
273    
274    // so we can use it i.e. through QVariant
275    Q_DECLARE_METATYPE(DeviceParameterRow)
276    
277    class DeviceParamModel : public QAbstractTableModel {
278            Q_OBJECT
279        public:
280            DeviceParamModel(QObject* parent = 0);
281    
282            // overridden methods from subclass(es)
283            int rowCount(const QModelIndex &parent) const;
284            int columnCount(const QModelIndex &parent) const;
285            QVariant data(const QModelIndex &index, int role) const;
286            QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
287    
288            void clear();
289    
290        public slots:
291            void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
292    
293        private:
294            qsamplerDeviceParamMap params;
295            bool bEditable;
296    };
297    
298    class DeviceParamDelegate : public QItemDelegate {
299            Q_OBJECT
300        public:
301            DeviceParamDelegate(QObject* parent = 0);
302    
303            QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
304                                  const QModelIndex& index) const;
305    
306            void setEditorData(QWidget* editor, const QModelIndex& index) const;
307            void setModelData(QWidget* editor, QAbstractItemModel* model,
308                              const QModelIndex& index) const;
309    
310            void updateEditorGeometry(QWidget* editor,
311                const QStyleOptionViewItem& option, const QModelIndex& index) const;
312    };
313    
314    
315  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
316  // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.  // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.
317  //  //
318    
319  class qsamplerDeviceParamTableSpinBox : public QTableItem  #if 0
320    class qsamplerDeviceParamTableSpinBox : public QTableWidgetItem
321  {  {
322  public:  public:
323    
324          // Constructor.          // Constructor.
325          qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,          qsamplerDeviceParamTableSpinBox (QTableWidget *pTable, Qt::ItemFlags flags,
326                  const QString& sText);                  const QString& sText);
327    
328          // Public accessors.          // Public accessors.
# Line 293  private: Line 349  private:
349  // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.  // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.
350  //  //
351    
352  class qsamplerDeviceParamTableEditBox : public QTableItem  class qsamplerDeviceParamTableEditBox : public QTableWidgetItem
353  {  {
354  public:  public:
355    
356          // Constructor.          // Constructor.
357          qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType,          qsamplerDeviceParamTableEditBox (QTableWidget *pTable, Qt::ItemFlags flags,
358                  const QString& sText);                  const QString& sText);
359    
360  protected:  protected:
# Line 307  protected: Line 363  protected:
363          QWidget *createEditor() const;          QWidget *createEditor() const;
364          void setContentFromEditor(QWidget *pWidget);          void setContentFromEditor(QWidget *pWidget);
365  };  };
366    #endif
367    
368  #endif  // __qsamplerDevice_h  #endif  // __qsamplerDevice_h
369    

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

  ViewVC Help
Powered by ViewVC