/[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 2387 by capela, Sat Dec 29 00:21:11 2012 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-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 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(Instrument *pInstrument);
61          void instrumentsChanged();          void updateInstrument(Instrument *pInstrument);
62            void resortInstrument(Instrument *pInstrument);
 public slots:  
63    
64          // General reloader.          // General reloader.
65          void refresh();          void refresh();
66    
67            // Make the following method public
68            void beginReset();
69            void endReset();
70    
71            // Map clear.
72            void clear();
73    
74    protected:
75    
76            QModelIndex index(int row, int col, const QModelIndex& parent) const;
77            QModelIndex parent(const QModelIndex& child) const;
78    
79  private:  private:
80    
81          typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;          typedef QList<Instrument *> InstrumentList;
82            typedef QMap<int, InstrumentList> InstrumentMap;
83    
84            InstrumentMap m_instruments;
85    
86          // Current map selection.          // Current map selection.
87          int m_iMidiMap;          int m_iMidiMap;
   
         InstrumentsMap m_instruments;  
88  };  };
89    
90    
91  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
92  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings  // QSampler::InstrumentListView - list view for MIDI prog mappings
93  // (doesn't actually do anything ATM, but is already there for a future  //
 // cell editor widget implementation)  
94    
95  class MidiInstrumentsDelegate : public QItemDelegate  class InstrumentListView : public QTreeView
96  {  {
         Q_OBJECT  
   
97  public:  public:
         MidiInstrumentsDelegate(QObject *pParent = NULL);  
98    
99          QWidget* createEditor(QWidget *pParent,          // Constructor.
100                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListView(QWidget *pParent = NULL);
101    
102            // Destructor.
103            ~InstrumentListView();
104    
105            // Map selector.
106            void setMidiMap(int iMidiMap);
107            int midiMap() const;
108    
109            // Own methods
110            const Instrument *addInstrument(int iMap, int iBank, int iProg);
111            void removeInstrument(Instrument *pInstrument);
112            void updateInstrument(Instrument *pInstrument);
113            void resortInstrument(Instrument *pInstrument);
114    
115            // General reloader.
116            void refresh();
117    
118          void setEditorData(QWidget *pEditor,  private:
                 const QModelIndex& index) const;  
         void setModelData(QWidget *pEditor,  
                 QAbstractItemModel* model, const QModelIndex& index) const;  
119    
120          void updateEditorGeometry(QWidget* pEditor,          // Instance variables.
121                  const QStyleOptionViewItem& option, const QModelIndex& index) const;          InstrumentListModel *m_pListModel;
122  };  };
123    
124    
125    } // namespace QSampler
126    
127  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
128    
129    

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

  ViewVC Help
Powered by ViewVC