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 |
public: |
39 |
|
40 |
// Constructor. |
41 |
InstrumentListModel(QObject *pParent = NULL); |
42 |
|
43 |
// Destructor. |
44 |
~InstrumentListModel(); |
45 |
|
46 |
// Overridden methods from subclass(es) |
47 |
int rowCount(const QModelIndex& parent) const; |
48 |
int columnCount(const QModelIndex& parent) const; |
49 |
|
50 |
QVariant data(const QModelIndex& index, int role) const; |
51 |
QVariant headerData(int section, Qt::Orientation orientation, |
52 |
int role = Qt::DisplayRole) const; |
53 |
|
54 |
// Map selector. |
55 |
void setMidiMap(int iMidiMap); |
56 |
int midiMap() const; |
57 |
|
58 |
// Own methods |
59 |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
60 |
void removeInstrument(const Instrument *pInstrument); |
61 |
void updateInstrument(const Instrument *pInstrument); |
62 |
|
63 |
// General reloader. |
64 |
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: |
79 |
|
80 |
typedef QList<Instrument *> InstrumentList; |
81 |
typedef QMap<int, InstrumentList> InstrumentMap; |
82 |
|
83 |
InstrumentMap m_instruments; |
84 |
|
85 |
// Current map selection. |
86 |
int m_iMidiMap; |
87 |
}; |
88 |
|
89 |
|
90 |
//------------------------------------------------------------------------- |
91 |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
92 |
// |
93 |
|
94 |
class InstrumentListView : public QTreeView |
95 |
{ |
96 |
public: |
97 |
|
98 |
// Constructor. |
99 |
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 |
private: |
117 |
|
118 |
// Instance variables. |
119 |
InstrumentListModel *m_pListModel; |
120 |
}; |
121 |
|
122 |
|
123 |
} // namespace QSampler |
124 |
|
125 |
#endif // __qsamplerInstrumentList_h |
126 |
|
127 |
|
128 |
// end of qsamplerInstrumentList.h |