/[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 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC revision 1558 by capela, Thu Dec 6 09:35:33 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 23  Line 24 
24  #define __qsamplerChannel_h  #define __qsamplerChannel_h
25    
26  #include <QTableWidgetItem>  #include <QTableWidgetItem>
 #include <QAbstractTableModel>  
 #include <QMetaType>  
27  #include <QItemDelegate>  #include <QItemDelegate>
 #include <QFontMetrics>  
 #include <QModelIndex>  
 #include <QSize>  
28    
29  #include <lscp/client.h>  #include <lscp/client.h>
30  #include <lscp/device.h>  #include <lscp/device.h>
31    
32  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
33    
34  class qsamplerDevice;  namespace QSampler {
35    
36    class Device;
37    
38  // Typedef'd QMap.  // Typedef'd QMap.
39  typedef QMap<int, int> qsamplerChannelRoutingMap;  typedef QMap<int, int> ChannelRoutingMap;
40    
41    
42  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
43  // qsamplerChannel - Sampler channel structure.  // QSampler::Channel - Sampler channel structure.
44  //  //
45    
46  class qsamplerChannel  class Channel
47  {  {
48  public:  public:
49    
50          // Constructor.          // Constructor.
51          qsamplerChannel(int iChannelID = -1);          Channel(int iChannelID = -1);
52          // Default destructor.          // Default destructor.
53          ~qsamplerChannel();          ~Channel();
54    
55          // Add/remove sampler channel methods.          // Add/remove sampler channel methods.
56          bool     addChannel();          bool     addChannel();
# Line 125  public: Line 122  public:
122          int      audioChannel(int iAudioOut) const;          int      audioChannel(int iAudioOut) const;
123          bool     setAudioChannel(int iAudioOut, int iAudioIn);          bool     setAudioChannel(int iAudioOut, int iAudioIn);
124          // The audio routing map itself.          // The audio routing map itself.
125          const qsamplerChannelRoutingMap& audioRouting() const;          const ChannelRoutingMap& audioRouting() const;
126    
127          // Istrument name remapper.          // Istrument name remapper.
128          void     updateInstrumentName();          void     updateInstrumentName();
# Line 189  private: Line 186  private:
186          bool    m_bSolo;          bool    m_bSolo;
187    
188          // The audio routing mapping.          // The audio routing mapping.
189          qsamplerChannelRoutingMap m_audioRouting;          ChannelRoutingMap m_audioRouting;
190  };  };
191    
192    
193  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
194  // qsamplerChannelRoutingTable - Channel routing table widget.  // QSampler::ChannelRoutingModel - data model for audio routing
195    //                                 (used for QTableView)
196  //  //
197    
198  #if 0  struct ChannelRoutingItem {
199  class qsamplerChannelRoutingTable : public QTable          QStringList options;
200            int         selection;
201    };
202    
203    class ChannelRoutingModel : public QAbstractTableModel
204  {  {
205          Q_OBJECT          Q_OBJECT
   
206  public:  public:
207    
208          // Constructor.          ChannelRoutingModel(QObject* pParent = NULL);
         qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0);  
         // Default destructor.  
         ~qsamplerChannelRoutingTable();  
   
         // Common parameter table renderer.  
         void refresh(qsamplerDevice *pDevice,  
                 const qsamplerChannelRoutingMap& routing);  
209    
210          // Commit any pending editing.          // overridden methods from subclass(es)
211          void flush();          int rowCount(const QModelIndex& parent = QModelIndex()) const;
212  };          int columnCount(const QModelIndex& parent = QModelIndex()) const;
213  #endif          Qt::ItemFlags flags(const QModelIndex& index) const;
214            bool setData(const QModelIndex& index, const QVariant& value,
215                    int role = Qt::EditRole);
216            QVariant data(const QModelIndex &index, int role) const;
217            QVariant headerData(int section, Qt::Orientation orientation,
218                    int role = Qt::DisplayRole) const;
219    
220            // own methods
221            ChannelRoutingMap routingMap() const { return m_routing; }
222    
223  struct ChannelRoutingItem {          void clear() { m_routing.clear(); }
     QStringList options;  
     int         selection;  
 };  
224    
225  // so we can use it i.e. through QVariant  public slots:
 Q_DECLARE_METATYPE(ChannelRoutingItem)  
226    
227  class ChannelRoutingModel : public QAbstractTableModel {          void refresh(Device *pDevice,
228          Q_OBJECT                  const ChannelRoutingMap& routing);
     public:  
         ChannelRoutingModel(QObject* parent = 0);  
   
         // overridden methods from subclass(es)  
         int rowCount(const QModelIndex &parent) const;  
         int columnCount(const QModelIndex &parent) const;  
         QVariant data(const QModelIndex &index, int role) const;  
         QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;  
   
     public slots:  
         void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing);  
   
     private:  
         qsamplerDevice* pDevice;  
         qsamplerChannelRoutingMap routing;  
 };  
229    
230  class ChannelRoutingDelegate : public QItemDelegate {  private:
         Q_OBJECT  
     public:  
         ChannelRoutingDelegate(QObject* parent = 0);  
   
         QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,  
                               const QModelIndex& index) const;  
   
         void setEditorData(QWidget* editor, const QModelIndex& index) const;  
         void setModelData(QWidget* editor, QAbstractItemModel* model,  
                           const QModelIndex& index) const;  
231    
232          void updateEditorGeometry(QWidget* editor,          Device *m_pDevice;
233              const QStyleOptionViewItem& option, const QModelIndex& index) const;          ChannelRoutingMap m_routing;
234  };  };
235    
236    
237  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
238  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.  // QSampler::ChannelRoutingDelegate - table cell renderer for audio routing
239  //  //
240    
241  /*  class ChannelRoutingDelegate : public QItemDelegate
 class qsamplerChannelRoutingComboBox : public QTableWidgetItem  
242  {  {
243            Q_OBJECT
244    
245  public:  public:
246    
247          // Constructor.          ChannelRoutingDelegate(QObject* pParent = NULL);
         qsamplerChannelRoutingComboBox(QTableWidget *pTable,  
                 const QStringList& list, const QPixmap& pixmap);  
248    
249          // Public accessors.          QWidget* createEditor(QWidget *pParent,
250          void setCurrentItem(int iCurrentItem);                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
251          int currentItem() const;          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
252            void setModelData(QWidget *pEditor, QAbstractItemModel* model,
253  protected:                  const QModelIndex& index) const;
254            void updateEditorGeometry(QWidget *pEditor,
255          // Virtual implemetations.                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
256          QWidget *createEditor() const;  };
         void setContentFromEditor(QWidget *pWidget);  
257    
258  private:  } // namespace QSampler
259    
260          // Initial value holders  // So we can use it i.e. through QVariant
261          QStringList m_list;  Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem)
         int m_iCurrentItem;  
 };  
 */  
262    
263  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
264    

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

  ViewVC Help
Powered by ViewVC