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