1 |
capela |
1013 |
// qsamplerInstrumentList.h |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
2064 |
Copyright (C) 2003-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
capela |
1464 |
Copyright (C) 2007, Christian Schoenebeck |
6 |
capela |
1013 |
|
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 |
capela |
2064 |
#include <QTreeView> |
27 |
capela |
1013 |
|
28 |
capela |
2064 |
namespace QSampler { |
29 |
capela |
1013 |
|
30 |
capela |
2064 |
class Instrument; |
31 |
schoenebeck |
1461 |
|
32 |
schoenebeck |
1492 |
//------------------------------------------------------------------------- |
33 |
capela |
2064 |
// QSampler:InstrumentListModel - data model for MIDI prog mappings |
34 |
|
|
// |
35 |
capela |
1013 |
|
36 |
capela |
2064 |
class InstrumentListModel : public QAbstractItemModel |
37 |
capela |
1509 |
{ |
38 |
|
|
Q_OBJECT |
39 |
|
|
|
40 |
schoenebeck |
1461 |
public: |
41 |
capela |
1013 |
|
42 |
capela |
2064 |
// Constructor. |
43 |
|
|
InstrumentListModel(QObject *pParent = NULL); |
44 |
schoenebeck |
1461 |
|
45 |
capela |
2064 |
// Destructor. |
46 |
|
|
~InstrumentListModel(); |
47 |
|
|
|
48 |
capela |
1509 |
// Overridden methods from subclass(es) |
49 |
|
|
int rowCount(const QModelIndex& parent) const; |
50 |
|
|
int columnCount(const QModelIndex& parent) const; |
51 |
schoenebeck |
1492 |
|
52 |
capela |
1509 |
QVariant data(const QModelIndex& index, int role) const; |
53 |
|
|
QVariant headerData(int section, Qt::Orientation orientation, |
54 |
|
|
int role = Qt::DisplayRole) const; |
55 |
schoenebeck |
1461 |
|
56 |
capela |
2064 |
// Map selector. |
57 |
|
|
void setMidiMap(int iMidiMap); |
58 |
|
|
int midiMap() const; |
59 |
schoenebeck |
1461 |
|
60 |
capela |
1509 |
// Own methods |
61 |
capela |
2064 |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
62 |
|
|
void removeInstrument(const Instrument *pInstrument); |
63 |
|
|
void updateInstrument(const Instrument *pInstrument); |
64 |
capela |
1509 |
|
65 |
capela |
2064 |
// General reloader. |
66 |
|
|
void refresh(); |
67 |
capela |
1509 |
|
68 |
capela |
2064 |
// Make the following method public |
69 |
|
|
void beginReset(); |
70 |
|
|
void endReset(); |
71 |
capela |
1509 |
|
72 |
capela |
2064 |
// Map clear. |
73 |
|
|
void clear(); |
74 |
schoenebeck |
1461 |
|
75 |
capela |
2064 |
protected: |
76 |
capela |
1509 |
|
77 |
capela |
2064 |
QModelIndex index(int row, int col, const QModelIndex& parent) const; |
78 |
|
|
QModelIndex parent(const QModelIndex& child) const; |
79 |
schoenebeck |
1461 |
|
80 |
|
|
private: |
81 |
|
|
|
82 |
capela |
2064 |
typedef QList<Instrument *> InstrumentList; |
83 |
|
|
typedef QMap<int, InstrumentList> InstrumentMap; |
84 |
schoenebeck |
1461 |
|
85 |
capela |
2064 |
InstrumentMap m_instruments; |
86 |
capela |
1523 |
|
87 |
capela |
1509 |
// Current map selection. |
88 |
|
|
int m_iMidiMap; |
89 |
schoenebeck |
1461 |
}; |
90 |
|
|
|
91 |
schoenebeck |
1492 |
|
92 |
|
|
//------------------------------------------------------------------------- |
93 |
capela |
2064 |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
94 |
|
|
// |
95 |
schoenebeck |
1492 |
|
96 |
capela |
2064 |
class InstrumentListView : public QTreeView |
97 |
capela |
1509 |
{ |
98 |
|
|
Q_OBJECT |
99 |
|
|
|
100 |
schoenebeck |
1461 |
public: |
101 |
|
|
|
102 |
capela |
2064 |
// Constructor. |
103 |
|
|
InstrumentListView(QWidget *pParent = 0); |
104 |
schoenebeck |
1461 |
|
105 |
capela |
2064 |
// Destructor. |
106 |
|
|
~InstrumentListView(); |
107 |
schoenebeck |
1461 |
|
108 |
capela |
2064 |
// 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 |
schoenebeck |
1461 |
}; |
125 |
|
|
|
126 |
capela |
2064 |
|
127 |
capela |
1558 |
} // namespace QSampler |
128 |
schoenebeck |
1461 |
|
129 |
capela |
1013 |
#endif // __qsamplerInstrumentList_h |
130 |
|
|
|
131 |
capela |
1464 |
|
132 |
capela |
1013 |
// end of qsamplerInstrumentList.h |