/[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 1489 by schoenebeck, Mon Nov 19 03:29:57 2007 UTC revision 2387 by capela, Sat Dec 29 00:21:11 2012 UTC
# Line 1  Line 1 
1  // qsamplerChannel.h  // qsamplerChannel.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     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
# Line 24  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 126  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 159  public: Line 155  public:
155          static QString loadingInstrument();          static QString loadingInstrument();
156    
157          // Check whether a given file is an instrument file.          // Check whether a given file is an instrument file.
158          static bool isInstrumentFile (const QString& sInstrumentFile);          static bool isDlsInstrumentFile (const QString& sInstrumentFile);
159    
160          // Retrieve the available instrument name(s) of an instrument file (.gig).          // Retrieve the available instrument name(s) of an instrument file (.gig).
161          static QString getInstrumentName (const QString& sInstrumentFile,          static QString getInstrumentName (const QString& sInstrumentFile,
# Line 190  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  // ChannelRoutingModel - data model for audio routing (used for QTableView)  // QSampler::ChannelRoutingModel - data model for audio routing
195    //                                 (used for QTableView)
196  //  //
197    
198  struct ChannelRoutingItem {  struct ChannelRoutingItem {
199      QStringList options;          QStringList options;
200      int         selection;          int         selection;
201  };  };
202    
203  // so we can use it i.e. through QVariant  class ChannelRoutingModel : public QAbstractTableModel
204  Q_DECLARE_METATYPE(ChannelRoutingItem)  {
205            Q_OBJECT
206    public:
207    
208            ChannelRoutingModel(QObject* pParent = NULL);
209    
210            // overridden methods from subclass(es)
211            int rowCount(const QModelIndex& parent = QModelIndex()) const;
212            int columnCount(const QModelIndex& parent = QModelIndex()) const;
213            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            void clear() { m_routing.clear(); }
224    
225    public slots:
226    
227            void refresh(Device *pDevice,
228                    const ChannelRoutingMap& routing);
229    
230    private:
231    
232  class ChannelRoutingModel : public QAbstractTableModel {          Device *m_pDevice;
233          Q_OBJECT          ChannelRoutingMap m_routing;
     public:  
         ChannelRoutingModel(QObject* parent = 0);  
   
         // overridden methods from subclass(es)  
         int rowCount(const QModelIndex &parent = QModelIndex()) const;  
         int columnCount(const QModelIndex &parent = QModelIndex()) const;  
         Qt::ItemFlags flags(const QModelIndex& index) const;  
         bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);  
         QVariant data(const QModelIndex &index, int role) const;  
         QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;  
   
         // own methods  
         qsamplerChannelRoutingMap routingMap() const {  
             return routing;  
         }  
   
         void clear() { routing.clear(); }  
   
     public slots:  
         void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing);  
   
     private:  
         qsamplerDevice* pDevice;  
         qsamplerChannelRoutingMap routing;  
234  };  };
235    
236    
237  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
238  // ChannelRoutingDelegate - table cell renderer for audio routing  // QSampler::ChannelRoutingDelegate - table cell renderer for audio routing
239  //  //
240    
241  class ChannelRoutingDelegate : public QItemDelegate {  class ChannelRoutingDelegate : public QItemDelegate
242          Q_OBJECT  {
243      public:          Q_OBJECT
244          ChannelRoutingDelegate(QObject* parent = 0);  
245          QWidget* createEditor(QWidget* parent,  public:
246                                const QStyleOptionViewItem& option,  
247                                const QModelIndex& index) const;          ChannelRoutingDelegate(QObject* pParent = NULL);
248          void setEditorData(QWidget* editor, const QModelIndex& index) const;  
249          void setModelData(QWidget* editor, QAbstractItemModel* model,          QWidget* createEditor(QWidget *pParent,
250                            const QModelIndex& index) const;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
251          void updateEditorGeometry(QWidget* editor,          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
252                                    const QStyleOptionViewItem& option,          void setModelData(QWidget *pEditor, QAbstractItemModel* model,
253                                    const QModelIndex& index) const;                  const QModelIndex& index) const;
254            void updateEditorGeometry(QWidget *pEditor,
255                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
256  };  };
257    
258    } // namespace QSampler
259    
260    // So we can use it i.e. through QVariant
261    Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem)
262    
263  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
264    
265    
266  // end of qsamplerChannel.h  // end of qsamplerChannel.h

Legend:
Removed from v.1489  
changed lines
  Added in v.2387

  ViewVC Help
Powered by ViewVC