1 |
// qsamplerInstrumentList.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
Copyright (C) 2003-2010, 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 |
8 |
modify it under the terms of the GNU General Public License |
9 |
as published by the Free Software Foundation; either version 2 |
10 |
of the License, or (at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#ifndef __qsamplerInstrumentList_h |
24 |
#define __qsamplerInstrumentList_h |
25 |
|
26 |
#include <QTreeView> |
27 |
|
28 |
namespace QSampler { |
29 |
|
30 |
class Instrument; |
31 |
|
32 |
//------------------------------------------------------------------------- |
33 |
// QSampler:InstrumentListModel - data model for MIDI prog mappings |
34 |
// |
35 |
|
36 |
class InstrumentListModel : public QAbstractItemModel |
37 |
{ |
38 |
Q_OBJECT |
39 |
|
40 |
public: |
41 |
|
42 |
// Constructor. |
43 |
InstrumentListModel(QObject *pParent = NULL); |
44 |
|
45 |
// Destructor. |
46 |
~InstrumentListModel(); |
47 |
|
48 |
// Overridden methods from subclass(es) |
49 |
int rowCount(const QModelIndex& parent) const; |
50 |
int columnCount(const QModelIndex& parent) const; |
51 |
|
52 |
QVariant data(const QModelIndex& index, int role) const; |
53 |
QVariant headerData(int section, Qt::Orientation orientation, |
54 |
int role = Qt::DisplayRole) const; |
55 |
|
56 |
// Map selector. |
57 |
void setMidiMap(int iMidiMap); |
58 |
int midiMap() const; |
59 |
|
60 |
// Own methods |
61 |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
62 |
void removeInstrument(const Instrument *pInstrument); |
63 |
void updateInstrument(const Instrument *pInstrument); |
64 |
|
65 |
// General reloader. |
66 |
void refresh(); |
67 |
|
68 |
// Make the following method public |
69 |
void beginReset(); |
70 |
void endReset(); |
71 |
|
72 |
// Map clear. |
73 |
void clear(); |
74 |
|
75 |
protected: |
76 |
|
77 |
QModelIndex index(int row, int col, const QModelIndex& parent) const; |
78 |
QModelIndex parent(const QModelIndex& child) const; |
79 |
|
80 |
private: |
81 |
|
82 |
typedef QList<Instrument *> InstrumentList; |
83 |
typedef QMap<int, InstrumentList> InstrumentMap; |
84 |
|
85 |
InstrumentMap m_instruments; |
86 |
|
87 |
// Current map selection. |
88 |
int m_iMidiMap; |
89 |
}; |
90 |
|
91 |
|
92 |
//------------------------------------------------------------------------- |
93 |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
94 |
// |
95 |
|
96 |
class InstrumentListView : public QTreeView |
97 |
{ |
98 |
Q_OBJECT |
99 |
|
100 |
public: |
101 |
|
102 |
// Constructor. |
103 |
InstrumentListView(QWidget *pParent = 0); |
104 |
|
105 |
// Destructor. |
106 |
~InstrumentListView(); |
107 |
|
108 |
// Map selector. |
109 |
void setMidiMap(int iMidiMap); |
110 |
int midiMap() const; |
111 |
|
112 |
// Own methods |
113 |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
114 |
void removeInstrument(const Instrument *pInstrument); |
115 |
void updateInstrument(const Instrument *pInstrument); |
116 |
|
117 |
// General reloader. |
118 |
void refresh(); |
119 |
|
120 |
private: |
121 |
|
122 |
// Instance variables. |
123 |
InstrumentListModel *m_pListModel; |
124 |
}; |
125 |
|
126 |
|
127 |
} // namespace QSampler |
128 |
|
129 |
#endif // __qsamplerInstrumentList_h |
130 |
|
131 |
|
132 |
// end of qsamplerInstrumentList.h |