25 |
|
|
26 |
#include <QListWidget> |
#include <QListWidget> |
27 |
#include <QListWidgetItem> |
#include <QListWidgetItem> |
|
//#include <qheader.h> |
|
28 |
#include <QAbstractTableModel> |
#include <QAbstractTableModel> |
29 |
#include <QItemDelegate> |
#include <QItemDelegate> |
30 |
|
|
34 |
|
|
35 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
36 |
|
|
|
// Forward declarations. |
|
|
//class qsamplerInstrument; |
|
|
//class qsamplerInstrumentList; |
|
37 |
|
|
38 |
class QAction; |
//------------------------------------------------------------------------- |
39 |
|
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
|
|
|
|
//---------------------------------------------------------------------- |
|
|
// class qsamplerInstrumentGroup -- custom group list view item. |
|
|
// |
|
|
|
|
|
class qsamplerInstrumentGroup : public QListWidgetItem |
|
|
{ |
|
|
public: |
|
|
|
|
|
// 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. |
|
|
// |
|
|
|
|
|
class qsamplerInstrumentItem : public qsamplerInstrumentGroup |
|
|
{ |
|
|
public: |
|
|
|
|
|
// Constructors. |
|
|
qsamplerInstrumentItem(QListWidget *pListView, |
|
|
qsamplerInstrument *pInstrument, |
|
|
QListWidgetItem *pItemAfter = NULL); |
|
|
qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem, |
|
|
qsamplerInstrument *pInstrument); |
|
|
// Default destructor. |
|
|
virtual ~qsamplerInstrumentItem(); |
|
|
|
|
|
// To virtually distinguish between list view items. |
|
|
virtual int rtti() const; |
|
|
|
|
|
// Payload accessor. |
|
|
qsamplerInstrument *instrument() const; |
|
|
|
|
|
// View refreshment. |
|
|
void update(); |
|
|
|
|
|
private: |
|
|
|
|
|
// File item full path. |
|
|
qsamplerInstrument *m_pInstrument; |
|
|
}; |
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------- |
|
|
// qsamplerInstrumentList -- MIDI instrument list view. |
|
40 |
// |
// |
41 |
|
|
|
#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; |
|
|
|
|
|
// Map selector. |
|
|
void setMidiMap(int iMidiMap); |
|
|
int midiMap() const; |
|
|
|
|
|
// List actions accessors. |
|
|
QAction *newGroupAction() const; |
|
|
QAction *newItemAction() const; |
|
|
QAction *editItemAction() const; |
|
|
QAction *renameAction() const; |
|
|
QAction *deleteAction() const; |
|
|
QAction *refreshAction() const; |
|
|
|
|
|
signals: |
|
|
|
|
|
// Instrument map/session change signal. |
|
|
void instrumentsChanged(); |
|
|
|
|
|
public slots: |
|
|
|
|
|
// General reloader. |
|
|
void refresh(); |
|
|
|
|
|
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); |
|
|
|
|
|
private: |
|
|
|
|
|
// List view actions. |
|
|
QAction *m_pNewGroupAction; |
|
|
QAction *m_pNewItemAction; |
|
|
QAction *m_pEditItemAction; |
|
|
QAction *m_pRenameAction; |
|
|
QAction *m_pDeleteAction; |
|
|
QAction *m_pRefreshAction; |
|
|
|
|
|
// Current map selection. |
|
|
int m_iMidiMap; |
|
|
}; |
|
|
#endif |
|
|
|
|
42 |
class MidiInstrumentsModel : public QAbstractTableModel { |
class MidiInstrumentsModel : public QAbstractTableModel { |
43 |
Q_OBJECT |
Q_OBJECT |
44 |
public: |
public: |
50 |
QVariant data(const QModelIndex &index, int role) const; |
QVariant data(const QModelIndex &index, int role) const; |
51 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
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); |
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. |
// Map selector. |
62 |
void setMidiMap(int iMidiMap); |
void setMidiMap(int iMidiMap); |
79 |
InstrumentsMap instruments; |
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 { |
class MidiInstrumentsDelegate : public QItemDelegate { |
89 |
Q_OBJECT |
Q_OBJECT |
90 |
public: |
public: |