24 |
#define __qsamplerInstrumentList_h |
#define __qsamplerInstrumentList_h |
25 |
|
|
26 |
#include <QListWidget> |
#include <QListWidget> |
|
#include <QListWidgetItem> |
|
|
//#include <qheader.h> |
|
|
#include <QAbstractTableModel> |
|
27 |
#include <QItemDelegate> |
#include <QItemDelegate> |
28 |
|
|
29 |
#include <lscp/client.h> |
#include <lscp/client.h> |
30 |
|
|
|
#include <string.h> |
|
|
|
|
31 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
32 |
|
|
|
// Forward declarations. |
|
|
//class qsamplerInstrument; |
|
|
//class qsamplerInstrumentList; |
|
|
|
|
|
class QAction; |
|
|
|
|
33 |
|
|
34 |
//---------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
35 |
// class qsamplerInstrumentGroup -- custom group list view item. |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
36 |
// |
// |
37 |
|
|
38 |
class qsamplerInstrumentGroup : public QListWidgetItem |
class MidiInstrumentsModel : public QAbstractTableModel |
39 |
{ |
{ |
40 |
public: |
Q_OBJECT |
|
|
|
|
// Constructors. |
|
|
qsamplerInstrumentGroup(QListWidget *pListView, |
|
|
const QString& sName, QListWidgetItem *pItemAfter = NULL); |
|
|
qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem, |
|
|
const QString& sName); |
|
|
// Default destructor. |
|
|
virtual ~qsamplerInstrumentGroup(); |
|
|
|
|
|
// Instance accessors. |
|
|
void setName(const QString& sName); |
|
|
QString name() const; |
|
|
|
|
|
QListWidget *listView() const; |
|
|
qsamplerInstrumentGroup *groupItem() const; |
|
|
|
|
|
// To show up whether its open or not. |
|
|
virtual void setOpen(bool bOpen); |
|
|
|
|
|
// To virtually distinguish between list view items. |
|
|
virtual int rtti() const; |
|
|
}; |
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------- |
|
|
// class qsamplerInstrumentItem -- custom file list view item. |
|
|
// |
|
41 |
|
|
|
class qsamplerInstrumentItem : public qsamplerInstrumentGroup |
|
|
{ |
|
42 |
public: |
public: |
43 |
|
|
44 |
// Constructors. |
MidiInstrumentsModel(QObject* pParent = NULL); |
|
qsamplerInstrumentItem(QListWidget *pListView, |
|
|
qsamplerInstrument *pInstrument, |
|
|
QListWidgetItem *pItemAfter = NULL); |
|
|
qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem, |
|
|
qsamplerInstrument *pInstrument); |
|
|
// Default destructor. |
|
|
virtual ~qsamplerInstrumentItem(); |
|
45 |
|
|
46 |
// To virtually distinguish between list view items. |
// Overridden methods from subclass(es) |
47 |
virtual int rtti() const; |
int rowCount(const QModelIndex& parent) const; |
48 |
|
int columnCount(const QModelIndex& parent) const; |
49 |
|
|
50 |
// Payload accessor. |
QVariant data(const QModelIndex& index, int role) const; |
51 |
qsamplerInstrument *instrument() const; |
QVariant headerData(int section, Qt::Orientation orientation, |
52 |
|
int role = Qt::DisplayRole) const; |
53 |
|
|
54 |
// View refreshment. |
// Make the following method public |
55 |
void update(); |
QAbstractTableModel::reset; |
56 |
|
|
57 |
private: |
// Own methods |
58 |
|
qsamplerInstrument* addInstrument(int iMap = 0, |
59 |
// File item full path. |
int iBank = -1, int iProg = -1); |
60 |
qsamplerInstrument *m_pInstrument; |
void removeInstrument(const qsamplerInstrument& instrument); |
|
}; |
|
61 |
|
|
62 |
|
void resort(const qsamplerInstrument instrument); |
|
//---------------------------------------------------------------------------- |
|
|
// qsamplerInstrumentList -- MIDI instrument list view. |
|
|
// |
|
|
|
|
|
#if 0 |
|
|
class qsamplerInstrumentList : public QListView |
|
|
{ |
|
|
Q_OBJECT |
|
|
|
|
|
public: |
|
|
|
|
|
// Constructor. |
|
|
qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL); |
|
|
// Default destructor. |
|
|
~qsamplerInstrumentList(); |
|
|
|
|
|
// QListViewItem::rtti() return values. |
|
|
enum ItemType { Group = 1001, Item = 1002 }; |
|
|
|
|
|
// Add a new group/file item, optionally under a given group. |
|
|
qsamplerInstrumentGroup *addGroup(const QString& sName, |
|
|
qsamplerInstrumentGroup *pParentGroup = NULL); |
|
|
qsamplerInstrumentItem *addItem( |
|
|
qsamplerInstrument *pInstrument, |
|
|
qsamplerInstrumentGroup *pParentGroup = NULL); |
|
|
|
|
|
// Find a group/file item, given its name. |
|
|
qsamplerInstrumentGroup *findGroup(const QString& sName) const; |
|
|
qsamplerInstrumentItem *findItem( |
|
|
qsamplerInstrument *pInstrument) const; |
|
63 |
|
|
64 |
// Map selector. |
// Map selector. |
65 |
void setMidiMap(int iMidiMap); |
void setMidiMap(int iMidiMap); |
66 |
int midiMap() const; |
int midiMap() const; |
67 |
|
|
|
// List actions accessors. |
|
|
QAction *newGroupAction() const; |
|
|
QAction *newItemAction() const; |
|
|
QAction *editItemAction() const; |
|
|
QAction *renameAction() const; |
|
|
QAction *deleteAction() const; |
|
|
QAction *refreshAction() const; |
|
|
|
|
68 |
signals: |
signals: |
69 |
|
|
70 |
// Instrument map/session change signal. |
// Instrument map/session change signal. |
75 |
// General reloader. |
// General reloader. |
76 |
void refresh(); |
void refresh(); |
77 |
|
|
|
protected slots: |
|
|
|
|
|
// Add a new group item below the current one. |
|
|
void newGroupSlot(); |
|
|
// Add a instrument item below the current one. |
|
|
void newItemSlot(); |
|
|
// Change current instrument item. |
|
|
void editItemSlot(); |
|
|
// Rename current group/item. |
|
|
void renameSlot(); |
|
|
// Remove current group/item. |
|
|
void deleteSlot(); |
|
|
|
|
|
// In-place selection slot. |
|
|
void selectionChangedSlot(); |
|
|
|
|
|
// In-place activation slot. |
|
|
void activatedSlot(QListWidgetItem *pListItem); |
|
|
|
|
|
// In-place aliasing slot. |
|
|
void renamedSlot(QListWidgetItem *pItem); |
|
|
|
|
|
protected: |
|
|
|
|
|
// Find and return the nearest group item... |
|
|
qsamplerInstrumentGroup *groupItem(QListWidgetItem *pListItem) const; |
|
|
|
|
|
// Context menu request event handler. |
|
|
void contextMenuEvent(QContextMenuEvent *pContextMenuEvent); |
|
|
|
|
78 |
private: |
private: |
79 |
|
|
80 |
// List view actions. |
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
QAction *m_pNewGroupAction; |
|
|
QAction *m_pNewItemAction; |
|
|
QAction *m_pEditItemAction; |
|
|
QAction *m_pRenameAction; |
|
|
QAction *m_pDeleteAction; |
|
|
QAction *m_pRefreshAction; |
|
81 |
|
|
82 |
// Current map selection. |
// Current map selection. |
83 |
int m_iMidiMap; |
int m_iMidiMap; |
|
}; |
|
|
#endif |
|
84 |
|
|
85 |
class MidiInstrumentsModel : public QAbstractTableModel { |
InstrumentsMap m_instruments; |
86 |
Q_OBJECT |
}; |
|
public: |
|
|
MidiInstrumentsModel(QObject* parent = 0); |
|
|
|
|
|
// overridden methods from subclass(es) |
|
|
int rowCount(const QModelIndex &parent) const; |
|
|
int columnCount(const QModelIndex &parent) const; |
|
|
QVariant data(const QModelIndex &index, int role) const; |
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
|
|
|
|
|
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
|
|
|
|
|
// Map selector. |
|
|
void setMidiMap(int iMidiMap); |
|
|
int midiMap() const; |
|
|
|
|
|
signals: |
|
|
// Instrument map/session change signal. |
|
|
void instrumentsChanged(); |
|
|
|
|
|
public slots: |
|
|
// General reloader. |
|
|
void refresh(); |
|
87 |
|
|
|
private: |
|
|
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
88 |
|
|
89 |
// Current map selection. |
//------------------------------------------------------------------------- |
90 |
int m_iMidiMap; |
// 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 |
InstrumentsMap instruments; |
class MidiInstrumentsDelegate : public QItemDelegate |
95 |
}; |
{ |
96 |
|
Q_OBJECT |
97 |
|
|
|
class MidiInstrumentsDelegate : public QItemDelegate { |
|
|
Q_OBJECT |
|
98 |
public: |
public: |
99 |
MidiInstrumentsDelegate(QObject* parent = 0); |
MidiInstrumentsDelegate(QObject *pParent = NULL); |
100 |
|
|
101 |
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
QWidget* createEditor(QWidget *pParent, |
102 |
const QModelIndex& index) const; |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
103 |
|
|
104 |
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
void setEditorData(QWidget *pEditor, |
105 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
const QModelIndex& index) const; |
106 |
const QModelIndex& index) const; |
void setModelData(QWidget *pEditor, |
107 |
|
QAbstractItemModel* model, const QModelIndex& index) const; |
108 |
|
|
109 |
void updateEditorGeometry(QWidget* editor, |
void updateEditorGeometry(QWidget* pEditor, |
110 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
111 |
}; |
}; |
112 |
|
|
113 |
|
|