22 |
#ifndef __qsamplerInstrumentList_h |
#ifndef __qsamplerInstrumentList_h |
23 |
#define __qsamplerInstrumentList_h |
#define __qsamplerInstrumentList_h |
24 |
|
|
25 |
#include <qlistview.h> |
#include <QListWidget> |
26 |
#include <qheader.h> |
#include <QListWidgetItem> |
27 |
|
//#include <qheader.h> |
28 |
|
#include <QAbstractTableModel> |
29 |
|
#include <QItemDelegate> |
30 |
|
|
31 |
#include <lscp/client.h> |
#include <lscp/client.h> |
32 |
|
|
33 |
|
#include <string.h> |
34 |
|
|
35 |
|
#include "qsamplerInstrument.h" |
36 |
|
|
37 |
// Forward declarations. |
// Forward declarations. |
38 |
class qsamplerInstrument; |
//class qsamplerInstrument; |
39 |
class qsamplerInstrumentList; |
//class qsamplerInstrumentList; |
40 |
|
|
41 |
class QAction; |
class QAction; |
42 |
|
|
45 |
// class qsamplerInstrumentGroup -- custom group list view item. |
// class qsamplerInstrumentGroup -- custom group list view item. |
46 |
// |
// |
47 |
|
|
48 |
class qsamplerInstrumentGroup : public QListViewItem |
class qsamplerInstrumentGroup : public QListWidgetItem |
49 |
{ |
{ |
50 |
public: |
public: |
51 |
|
|
52 |
// Constructors. |
// Constructors. |
53 |
qsamplerInstrumentGroup(qsamplerInstrumentList *pListView, |
qsamplerInstrumentGroup(QListWidget *pListView, |
54 |
const QString& sName, QListViewItem *pItemAfter = NULL); |
const QString& sName, QListWidgetItem *pItemAfter = NULL); |
55 |
qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem, |
qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem, |
56 |
const QString& sName); |
const QString& sName); |
57 |
// Default destructor. |
// Default destructor. |
61 |
void setName(const QString& sName); |
void setName(const QString& sName); |
62 |
QString name() const; |
QString name() const; |
63 |
|
|
64 |
qsamplerInstrumentList *listView() const; |
QListWidget *listView() const; |
65 |
qsamplerInstrumentGroup *groupItem() const; |
qsamplerInstrumentGroup *groupItem() const; |
66 |
|
|
67 |
// To show up whether its open or not. |
// To show up whether its open or not. |
81 |
public: |
public: |
82 |
|
|
83 |
// Constructors. |
// Constructors. |
84 |
qsamplerInstrumentItem(qsamplerInstrumentList *pListView, |
qsamplerInstrumentItem(QListWidget *pListView, |
85 |
qsamplerInstrument *pInstrument, |
qsamplerInstrument *pInstrument, |
86 |
QListViewItem *pItemAfter = NULL); |
QListWidgetItem *pItemAfter = NULL); |
87 |
qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem, |
qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem, |
88 |
qsamplerInstrument *pInstrument); |
qsamplerInstrument *pInstrument); |
89 |
// Default destructor. |
// Default destructor. |
109 |
// qsamplerInstrumentList -- MIDI instrument list view. |
// qsamplerInstrumentList -- MIDI instrument list view. |
110 |
// |
// |
111 |
|
|
112 |
|
#if 0 |
113 |
class qsamplerInstrumentList : public QListView |
class qsamplerInstrumentList : public QListView |
114 |
{ |
{ |
115 |
Q_OBJECT |
Q_OBJECT |
175 |
void selectionChangedSlot(); |
void selectionChangedSlot(); |
176 |
|
|
177 |
// In-place activation slot. |
// In-place activation slot. |
178 |
void activatedSlot(QListViewItem *pListItem); |
void activatedSlot(QListWidgetItem *pListItem); |
179 |
|
|
180 |
// In-place aliasing slot. |
// In-place aliasing slot. |
181 |
void renamedSlot(QListViewItem *pItem); |
void renamedSlot(QListWidgetItem *pItem); |
182 |
|
|
183 |
protected: |
protected: |
184 |
|
|
185 |
// Find and return the nearest group item... |
// Find and return the nearest group item... |
186 |
qsamplerInstrumentGroup *groupItem(QListViewItem *pListItem) const; |
qsamplerInstrumentGroup *groupItem(QListWidgetItem *pListItem) const; |
187 |
|
|
188 |
// Context menu request event handler. |
// Context menu request event handler. |
189 |
void contextMenuEvent(QContextMenuEvent *pContextMenuEvent); |
void contextMenuEvent(QContextMenuEvent *pContextMenuEvent); |
201 |
// Current map selection. |
// Current map selection. |
202 |
int m_iMidiMap; |
int m_iMidiMap; |
203 |
}; |
}; |
204 |
|
#endif |
205 |
|
|
206 |
|
class MidiInstrumentsModel : public QAbstractTableModel { |
207 |
|
Q_OBJECT |
208 |
|
public: |
209 |
|
MidiInstrumentsModel(QObject* parent = 0); |
210 |
|
|
211 |
|
// overridden methods from subclass(es) |
212 |
|
int rowCount(const QModelIndex &parent) const; |
213 |
|
int columnCount(const QModelIndex &parent) const; |
214 |
|
QVariant data(const QModelIndex &index, int role) const; |
215 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
216 |
|
|
217 |
|
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
218 |
|
|
219 |
|
// Map selector. |
220 |
|
void setMidiMap(int iMidiMap); |
221 |
|
int midiMap() const; |
222 |
|
|
223 |
|
signals: |
224 |
|
// Instrument map/session change signal. |
225 |
|
void instrumentsChanged(); |
226 |
|
|
227 |
|
public slots: |
228 |
|
// General reloader. |
229 |
|
void refresh(); |
230 |
|
|
231 |
|
private: |
232 |
|
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
233 |
|
|
234 |
|
// Current map selection. |
235 |
|
int m_iMidiMap; |
236 |
|
|
237 |
|
InstrumentsMap instruments; |
238 |
|
}; |
239 |
|
|
240 |
|
class MidiInstrumentsDelegate : public QItemDelegate { |
241 |
|
Q_OBJECT |
242 |
|
public: |
243 |
|
MidiInstrumentsDelegate(QObject* parent = 0); |
244 |
|
|
245 |
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
246 |
|
const QModelIndex& index) const; |
247 |
|
|
248 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
249 |
|
void setModelData(QWidget* editor, QAbstractItemModel* model, |
250 |
|
const QModelIndex& index) const; |
251 |
|
|
252 |
|
void updateEditorGeometry(QWidget* editor, |
253 |
|
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
254 |
|
}; |
255 |
|
|
256 |
|
|
257 |
#endif // __qsamplerInstrumentList_h |
#endif // __qsamplerInstrumentList_h |