/[svn]/qsampler/trunk/src/qsamplerChannel.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannel.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 980 by capela, Sun Dec 17 22:29:29 2006 UTC revision 1510 by capela, Thu Nov 22 14:17:24 2007 UTC
# Line 1  Line 1 
1  // qsamplerChannel.h  // qsamplerChannel.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 __qsamplerChannel_h  #ifndef __qsamplerChannel_h
24  #define __qsamplerChannel_h  #define __qsamplerChannel_h
25    
26  #include <qtable.h>  #include <QTableWidgetItem>
27    #include <QItemDelegate>
28    
29  #include <lscp/client.h>  #include <lscp/client.h>
30  #include <lscp/device.h>  #include <lscp/device.h>
# Line 133  public: Line 135  public:
135          // Reset channel method.          // Reset channel method.
136          bool     channelReset();          bool     channelReset();
137    
138            // Spawn instrument editor method.
139            bool     editChannel();
140    
141          // Message logging methods (brainlessly mapped to main form's).          // Message logging methods (brainlessly mapped to main form's).
142          void     appendMessages       (const QString & s) const;          void     appendMessages       (const QString & s) const;
143          void     appendMessagesColor  (const QString & s, const QString & c) const;          void     appendMessagesColor  (const QString & s, const QString & c) const;
# Line 185  private: Line 190  private:
190    
191    
192  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
193  // qsamplerChannelRoutingTable - Channel routing table widget.  // ChannelRoutingModel - data model for audio routing (used for QTableView)
194  //  //
195    
196  class qsamplerChannelRoutingTable : public QTable  struct ChannelRoutingItem {
197            QStringList options;
198            int         selection;
199    };
200    
201    // so we can use it i.e. through QVariant
202    Q_DECLARE_METATYPE(ChannelRoutingItem)
203    
204    class ChannelRoutingModel : public QAbstractTableModel
205  {  {
206          Q_OBJECT          Q_OBJECT
   
207  public:  public:
208    
209          // Constructor.          ChannelRoutingModel(QObject* pParent = NULL);
210          qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0);  
211          // Default destructor.          // overridden methods from subclass(es)
212          ~qsamplerChannelRoutingTable();          int rowCount(const QModelIndex& parent = QModelIndex()) const;
213            int columnCount(const QModelIndex& parent = QModelIndex()) const;
214            Qt::ItemFlags flags(const QModelIndex& index) const;
215            bool setData(const QModelIndex& index, const QVariant& value,
216                    int role = Qt::EditRole);
217            QVariant data(const QModelIndex &index, int role) const;
218            QVariant headerData(int section, Qt::Orientation orientation,
219                    int role = Qt::DisplayRole) const;
220    
221            // own methods
222            qsamplerChannelRoutingMap routingMap() const { return m_routing; }
223    
224            void clear() { m_routing.clear(); }
225    
226    public slots:
227    
         // Common parameter table renderer.  
228          void refresh(qsamplerDevice *pDevice,          void refresh(qsamplerDevice *pDevice,
229                  const qsamplerChannelRoutingMap& routing);                  const qsamplerChannelRoutingMap& routing);
230    
231          // Commit any pending editing.  private:
232          void flush();  
233            qsamplerDevice *m_pDevice;
234            qsamplerChannelRoutingMap m_routing;
235  };  };
236    
237    
238  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
239  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.  // ChannelRoutingDelegate - table cell renderer for audio routing
240  //  //
241    
242  class qsamplerChannelRoutingComboBox : public QTableItem  class ChannelRoutingDelegate : public QItemDelegate
243  {  {
244  public:          Q_OBJECT
   
         // Constructor.  
         qsamplerChannelRoutingComboBox(QTable *pTable,  
                 const QStringList& list, const QPixmap& pixmap);  
245    
246          // Public accessors.  public:
         void setCurrentItem(int iCurrentItem);  
         int currentItem() const;  
   
 protected:  
   
         // Virtual implemetations.  
         QWidget *createEditor() const;  
         void setContentFromEditor(QWidget *pWidget);  
247    
248  private:          ChannelRoutingDelegate(QObject* pParent = NULL);
249    
250          // Initial value holders          QWidget* createEditor(QWidget *pParent,
251          QStringList m_list;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
252          int m_iCurrentItem;          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
253            void setModelData(QWidget *pEditor, QAbstractItemModel* model,
254                    const QModelIndex& index) const;
255            void updateEditorGeometry(QWidget *pEditor,
256                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
257  };  };
258    
   
259  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
260    
   
261  // end of qsamplerChannel.h  // end of qsamplerChannel.h

Legend:
Removed from v.980  
changed lines
  Added in v.1510

  ViewVC Help
Powered by ViewVC