35 |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
36 |
// |
// |
37 |
|
|
38 |
class MidiInstrumentsModel : public QAbstractTableModel { |
class MidiInstrumentsModel : public QAbstractTableModel |
39 |
Q_OBJECT |
{ |
40 |
|
Q_OBJECT |
41 |
|
|
42 |
public: |
public: |
|
MidiInstrumentsModel(QObject* parent = 0); |
|
43 |
|
|
44 |
// overridden methods from subclass(es) |
MidiInstrumentsModel(QObject* pParent = NULL); |
45 |
int rowCount(const QModelIndex &parent) const; |
|
46 |
int columnCount(const QModelIndex &parent) const; |
// Overridden methods from subclass(es) |
47 |
QVariant data(const QModelIndex &index, int role) const; |
int rowCount(const QModelIndex& parent) const; |
48 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
int columnCount(const QModelIndex& parent) const; |
49 |
|
|
50 |
// make the following method public |
QVariant data(const QModelIndex& index, int role) const; |
51 |
QAbstractTableModel::reset; |
QVariant headerData(int section, Qt::Orientation orientation, |
52 |
|
int role = Qt::DisplayRole) const; |
53 |
// own methods |
|
54 |
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
// Make the following method public |
55 |
void removeInstrument(const qsamplerInstrument& instrument); |
QAbstractTableModel::reset; |
56 |
void resort(const qsamplerInstrument instrument); |
|
57 |
|
// Own methods |
58 |
// Map selector. |
qsamplerInstrument* addInstrument(int iMap = 0, |
59 |
void setMidiMap(int iMidiMap); |
int iBank = -1, int iProg = -1); |
60 |
int midiMap() const; |
void removeInstrument(const qsamplerInstrument& instrument); |
61 |
|
|
62 |
|
void resort(const qsamplerInstrument instrument); |
63 |
|
|
64 |
|
// Map selector. |
65 |
|
void setMidiMap(int iMidiMap); |
66 |
|
int midiMap() const; |
67 |
|
|
68 |
signals: |
signals: |
69 |
// Instrument map/session change signal. |
|
70 |
void instrumentsChanged(); |
// Instrument map/session change signal. |
71 |
|
void instrumentsChanged(); |
72 |
|
|
73 |
public slots: |
public slots: |
74 |
// General reloader. |
|
75 |
void refresh(); |
// General reloader. |
76 |
|
void refresh(); |
77 |
|
|
78 |
private: |
private: |
|
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
79 |
|
|
80 |
// Current map selection. |
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
int m_iMidiMap; |
|
81 |
|
|
82 |
InstrumentsMap instruments; |
// Current map selection. |
83 |
|
int m_iMidiMap; |
84 |
|
|
85 |
|
InstrumentsMap m_instruments; |
86 |
}; |
}; |
87 |
|
|
88 |
|
|
91 |
// (doesn't actually do anything ATM, but is already there for a future |
// (doesn't actually do anything ATM, but is already there for a future |
92 |
// cell editor widget implementation) |
// cell editor widget implementation) |
93 |
|
|
94 |
class MidiInstrumentsDelegate : public QItemDelegate { |
class MidiInstrumentsDelegate : public QItemDelegate |
95 |
Q_OBJECT |
{ |
96 |
|
Q_OBJECT |
97 |
|
|
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 |
|
|