1 |
// qsamplerInstrumentList.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
Copyright (C) 2003-2007, 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 <QListWidget> |
27 |
#include <QItemDelegate> |
28 |
|
29 |
#include <lscp/client.h> |
30 |
|
31 |
#include "qsamplerInstrument.h" |
32 |
|
33 |
|
34 |
//------------------------------------------------------------------------- |
35 |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
36 |
// |
37 |
|
38 |
class MidiInstrumentsModel : public QAbstractTableModel |
39 |
{ |
40 |
Q_OBJECT |
41 |
|
42 |
public: |
43 |
|
44 |
MidiInstrumentsModel(QObject* pParent = NULL); |
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 |
// Make the following method public |
55 |
QAbstractTableModel::reset; |
56 |
|
57 |
// Own methods |
58 |
qsamplerInstrument* addInstrument(int iMap = 0, |
59 |
int iBank = -1, int iProg = -1); |
60 |
void removeInstrument(const qsamplerInstrument& instrument); |
61 |
|
62 |
void resort(const qsamplerInstrument instrument); |
63 |
|
64 |
// Map selector. |
65 |
void setMidiMap(int iMidiMap); |
66 |
int midiMap() const; |
67 |
|
68 |
signals: |
69 |
|
70 |
// Instrument map/session change signal. |
71 |
void instrumentsChanged(); |
72 |
|
73 |
public slots: |
74 |
|
75 |
// General reloader. |
76 |
void refresh(); |
77 |
|
78 |
private: |
79 |
|
80 |
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
81 |
|
82 |
// Current map selection. |
83 |
int m_iMidiMap; |
84 |
|
85 |
InstrumentsMap m_instruments; |
86 |
}; |
87 |
|
88 |
|
89 |
//------------------------------------------------------------------------- |
90 |
// MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings |
91 |
// (doesn't actually do anything ATM, but is already there for a future |
92 |
// cell editor widget implementation) |
93 |
|
94 |
class MidiInstrumentsDelegate : public QItemDelegate |
95 |
{ |
96 |
Q_OBJECT |
97 |
|
98 |
public: |
99 |
MidiInstrumentsDelegate(QObject *pParent = NULL); |
100 |
|
101 |
QWidget* createEditor(QWidget *pParent, |
102 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
103 |
|
104 |
void setEditorData(QWidget *pEditor, |
105 |
const QModelIndex& index) const; |
106 |
void setModelData(QWidget *pEditor, |
107 |
QAbstractItemModel* model, const QModelIndex& index) const; |
108 |
|
109 |
void updateEditorGeometry(QWidget* pEditor, |
110 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
111 |
}; |
112 |
|
113 |
|
114 |
#endif // __qsamplerInstrumentList_h |
115 |
|
116 |
|
117 |
// end of qsamplerInstrumentList.h |