/[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 2828 by capela, Wed Jul 22 21:28:27 2015 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-2015, 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  {  {
38          Q_OBJECT          Q_OBJECT
39    
40  public:  public:
41    
42          MidiInstrumentsModel(QObject* pParent = NULL);          // Constructor.
43            InstrumentListModel(QObject *pParent = NULL);
44    
45            // Destructor.
46            ~InstrumentListModel();
47    
48          // Overridden methods from subclass(es)          // Overridden methods from subclass(es)
49          int rowCount(const QModelIndex& parent) const;          int rowCount(const QModelIndex& parent) const;
# Line 51  public: Line 53  public:
53          QVariant headerData(int section, Qt::Orientation orientation,          QVariant headerData(int section, Qt::Orientation orientation,
54                  int role = Qt::DisplayRole) const;                  int role = Qt::DisplayRole) const;
55    
         // 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);  
   
56          // Map selector.          // Map selector.
57          void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
58          int midiMap() const;          int midiMap() const;
59    
60  signals:          // Own methods
61            const Instrument *addInstrument(int iMap, int iBank, int iProg);
62          // Instrument map/session change signal.          void removeInstrument(Instrument *pInstrument);
63          void instrumentsChanged();          void updateInstrument(Instrument *pInstrument);
64            void resortInstrument(Instrument *pInstrument);
 public slots:  
65    
66          // General reloader.          // General reloader.
67          void refresh();          void refresh();
68    
69            // Make the following method public
70            void beginReset();
71            void endReset();
72    
73            // Map clear.
74            void clear();
75    
76    protected:
77    
78            QModelIndex index(int row, int col, const QModelIndex& parent) const;
79            QModelIndex parent(const QModelIndex& child) const;
80    
81  private:  private:
82    
83          typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;          typedef QList<Instrument *> InstrumentList;
84            typedef QMap<int, InstrumentList> InstrumentMap;
85    
86            InstrumentMap m_instruments;
87    
88          // Current map selection.          // Current map selection.
89          int m_iMidiMap;          int m_iMidiMap;
   
         InstrumentsMap m_instruments;  
90  };  };
91    
92    
93  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
94  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings  // QSampler::InstrumentListView - list view for MIDI prog mappings
95  // (doesn't actually do anything ATM, but is already there for a future  //
 // cell editor widget implementation)  
96    
97  class MidiInstrumentsDelegate : public QItemDelegate  class InstrumentListView : public QTreeView
98  {  {
         Q_OBJECT  
   
99  public:  public:
         MidiInstrumentsDelegate(QObject *pParent = NULL);  
100    
101          QWidget* createEditor(QWidget *pParent,          // Constructor.
102                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListView(QWidget *pParent = NULL);
103    
104            // Destructor.
105            ~InstrumentListView();
106    
107            // Map selector.
108            void setMidiMap(int iMidiMap);
109            int midiMap() const;
110    
111            // Own methods
112            const Instrument *addInstrument(int iMap, int iBank, int iProg);
113            void removeInstrument(Instrument *pInstrument);
114            void updateInstrument(Instrument *pInstrument);
115            void resortInstrument(Instrument *pInstrument);
116    
117            // General reloader.
118            void refresh();
119    
120          void setEditorData(QWidget *pEditor,  private:
                 const QModelIndex& index) const;  
         void setModelData(QWidget *pEditor,  
                 QAbstractItemModel* model, const QModelIndex& index) const;  
121    
122          void updateEditorGeometry(QWidget* pEditor,          // Instance variables.
123                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListModel *m_pListModel;
124  };  };
125    
126    
127    } // namespace QSampler
128    
129  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
130    
131    

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

  ViewVC Help
Powered by ViewVC