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 <QListWidgetItem> |
28 |
#include <QAbstractTableModel> |
29 |
#include <QItemDelegate> |
30 |
|
31 |
#include <lscp/client.h> |
32 |
|
33 |
#include <string.h> |
34 |
|
35 |
#include "qsamplerInstrument.h" |
36 |
|
37 |
|
38 |
//------------------------------------------------------------------------- |
39 |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
40 |
// |
41 |
|
42 |
class MidiInstrumentsModel : public QAbstractTableModel { |
43 |
Q_OBJECT |
44 |
public: |
45 |
MidiInstrumentsModel(QObject* parent = 0); |
46 |
|
47 |
// overridden methods from subclass(es) |
48 |
int rowCount(const QModelIndex &parent) const; |
49 |
int columnCount(const QModelIndex &parent) const; |
50 |
QVariant data(const QModelIndex &index, int role) const; |
51 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
52 |
|
53 |
// make the following method public |
54 |
QAbstractTableModel::reset; |
55 |
|
56 |
// own methods |
57 |
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
58 |
void removeInstrument(const qsamplerInstrument& instrument); |
59 |
void resort(const qsamplerInstrument instrument); |
60 |
|
61 |
// Map selector. |
62 |
void setMidiMap(int iMidiMap); |
63 |
int midiMap() const; |
64 |
|
65 |
signals: |
66 |
// Instrument map/session change signal. |
67 |
void instrumentsChanged(); |
68 |
|
69 |
public slots: |
70 |
// General reloader. |
71 |
void refresh(); |
72 |
|
73 |
private: |
74 |
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
75 |
|
76 |
// Current map selection. |
77 |
int m_iMidiMap; |
78 |
|
79 |
InstrumentsMap instruments; |
80 |
}; |
81 |
|
82 |
|
83 |
//------------------------------------------------------------------------- |
84 |
// MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings |
85 |
// (doesn't actually do anything ATM, but is already there for a future |
86 |
// cell editor widget implementation) |
87 |
|
88 |
class MidiInstrumentsDelegate : public QItemDelegate { |
89 |
Q_OBJECT |
90 |
public: |
91 |
MidiInstrumentsDelegate(QObject* parent = 0); |
92 |
|
93 |
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
94 |
const QModelIndex& index) const; |
95 |
|
96 |
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
97 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
98 |
const QModelIndex& index) const; |
99 |
|
100 |
void updateEditorGeometry(QWidget* editor, |
101 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
102 |
}; |
103 |
|
104 |
|
105 |
#endif // __qsamplerInstrumentList_h |
106 |
|
107 |
|
108 |
// end of qsamplerInstrumentList.h |