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

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

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

revision 1509 by capela, Thu Nov 22 11:10:44 2007 UTC revision 2066 by capela, Sat Mar 13 19:15:24 2010 UTC
# Line 1  Line 1 
1  // qsamplerInstrumentList.h  // qsamplerInstrumentList.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2003-2010, 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 23  Line 23 
23  #ifndef __qsamplerInstrumentList_h  #ifndef __qsamplerInstrumentList_h
24  #define __qsamplerInstrumentList_h  #define __qsamplerInstrumentList_h
25    
26  #include <QListWidget>  #include <QTreeView>
 #include <QItemDelegate>  
27    
28  #include <lscp/client.h>  namespace QSampler {
   
 #include "qsamplerInstrument.h"  
29    
30    class Instrument;
31    
32  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
33  // MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView)  // QSampler:InstrumentListModel - data model for MIDI prog mappings
34  //  //
35    
36  class MidiInstrumentsModel : public QAbstractTableModel  class InstrumentListModel : public QAbstractItemModel
37  {  {
         Q_OBJECT  
   
38  public:  public:
39    
40          MidiInstrumentsModel(QObject* pParent = NULL);          // Constructor.
41            InstrumentListModel(QObject *pParent = NULL);
42    
43            // Destructor.
44            ~InstrumentListModel();
45    
46          // Overridden methods from subclass(es)          // Overridden methods from subclass(es)
47          int rowCount(const QModelIndex& parent) const;          int rowCount(const QModelIndex& parent) const;
# Line 51  public: Line 51  public:
51          QVariant headerData(int section, Qt::Orientation orientation,          QVariant headerData(int section, Qt::Orientation orientation,
52                  int role = Qt::DisplayRole) const;                  int role = Qt::DisplayRole) const;
53    
         // Make the following method public  
         QAbstractTableModel::reset;  
   
         // Own methods  
         qsamplerInstrument* addInstrument(int iMap = 0,  
                 int iBank = -1, int iProg = -1);  
         void removeInstrument(const qsamplerInstrument& instrument);  
   
         void resort(const qsamplerInstrument instrument);  
   
54          // Map selector.          // Map selector.
55          void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
56          int midiMap() const;          int midiMap() const;
57    
58  signals:          // Own methods
59            const Instrument *addInstrument(int iMap, int iBank, int iProg);
60          // Instrument map/session change signal.          void removeInstrument(const Instrument *pInstrument);
61          void instrumentsChanged();          void updateInstrument(const Instrument *pInstrument);
   
 public slots:  
62    
63          // General reloader.          // General reloader.
64          void refresh();          void refresh();
65    
66            // Make the following method public
67            void beginReset();
68            void endReset();
69    
70            // Map clear.
71            void clear();
72    
73    protected:
74    
75            QModelIndex index(int row, int col, const QModelIndex& parent) const;
76            QModelIndex parent(const QModelIndex& child) const;
77    
78  private:  private:
79    
80          typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;          typedef QList<Instrument *> InstrumentList;
81            typedef QMap<int, InstrumentList> InstrumentMap;
82    
83            InstrumentMap m_instruments;
84    
85          // Current map selection.          // Current map selection.
86          int m_iMidiMap;          int m_iMidiMap;
   
         InstrumentsMap m_instruments;  
87  };  };
88    
89    
90  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
91  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings  // QSampler::InstrumentListView - list view for MIDI prog mappings
92  // (doesn't actually do anything ATM, but is already there for a future  //
 // cell editor widget implementation)  
93    
94  class MidiInstrumentsDelegate : public QItemDelegate  class InstrumentListView : public QTreeView
95  {  {
         Q_OBJECT  
   
96  public:  public:
         MidiInstrumentsDelegate(QObject *pParent = NULL);  
97    
98          QWidget* createEditor(QWidget *pParent,          // Constructor.
99                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListView(QWidget *pParent = NULL);
100    
101            // Destructor.
102            ~InstrumentListView();
103    
104            // Map selector.
105            void setMidiMap(int iMidiMap);
106            int midiMap() const;
107    
108            // Own methods
109            const Instrument *addInstrument(int iMap, int iBank, int iProg);
110            void removeInstrument(const Instrument *pInstrument);
111            void updateInstrument(const Instrument *pInstrument);
112    
113            // General reloader.
114            void refresh();
115    
116          void setEditorData(QWidget *pEditor,  private:
                 const QModelIndex& index) const;  
         void setModelData(QWidget *pEditor,  
                 QAbstractItemModel* model, const QModelIndex& index) const;  
117    
118          void updateEditorGeometry(QWidget* pEditor,          // Instance variables.
119                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListModel *m_pListModel;
120  };  };
121    
122    
123    } // namespace QSampler
124    
125  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
126    
127    

Legend:
Removed from v.1509  
changed lines
  Added in v.2066

  ViewVC Help
Powered by ViewVC