1 |
// qsamplerInstrumentList.h |
// qsamplerInstrumentList.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
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 |
23 |
#ifndef __qsamplerInstrumentList_h |
#ifndef __qsamplerInstrumentList_h |
24 |
#define __qsamplerInstrumentList_h |
#define __qsamplerInstrumentList_h |
25 |
|
|
26 |
#include <QListWidget> |
#include <QTreeView> |
|
#include <QItemDelegate> |
|
27 |
|
|
28 |
#include <lscp/client.h> |
namespace QSampler { |
|
|
|
|
#include "qsamplerInstrument.h" |
|
29 |
|
|
30 |
|
class Instrument; |
31 |
|
|
32 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
33 |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
// QSampler:InstrumentListModel - data model for MIDI prog mappings |
34 |
// |
// |
35 |
|
|
36 |
class MidiInstrumentsModel : public QAbstractTableModel { |
class InstrumentListModel : public QAbstractItemModel |
37 |
Q_OBJECT |
{ |
38 |
public: |
public: |
|
MidiInstrumentsModel(QObject* parent = 0); |
|
39 |
|
|
40 |
// overridden methods from subclass(es) |
// Constructor. |
41 |
int rowCount(const QModelIndex &parent) const; |
InstrumentListModel(QObject *pParent = NULL); |
42 |
int columnCount(const QModelIndex &parent) const; |
|
43 |
QVariant data(const QModelIndex &index, int role) const; |
// Destructor. |
44 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
~InstrumentListModel(); |
45 |
|
|
46 |
// make the following method public |
// Overridden methods from subclass(es) |
47 |
QAbstractTableModel::reset; |
int rowCount(const QModelIndex& parent) const; |
48 |
|
int columnCount(const QModelIndex& parent) const; |
49 |
// own methods |
|
50 |
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
QVariant data(const QModelIndex& index, int role) const; |
51 |
void removeInstrument(const qsamplerInstrument& instrument); |
QVariant headerData(int section, Qt::Orientation orientation, |
52 |
void resort(const qsamplerInstrument instrument); |
int role = Qt::DisplayRole) const; |
53 |
|
|
54 |
// Map selector. |
// Map selector. |
55 |
void setMidiMap(int iMidiMap); |
void setMidiMap(int iMidiMap); |
56 |
int midiMap() const; |
int midiMap() const; |
57 |
|
|
58 |
signals: |
// Own methods |
59 |
// Instrument map/session change signal. |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
60 |
void instrumentsChanged(); |
void removeInstrument(Instrument *pInstrument); |
61 |
|
void updateInstrument(Instrument *pInstrument); |
62 |
public slots: |
void resortInstrument(Instrument *pInstrument); |
63 |
// General reloader. |
|
64 |
void refresh(); |
// General reloader. |
65 |
|
void refresh(); |
66 |
|
|
67 |
|
// Make the following method public |
68 |
|
void beginReset(); |
69 |
|
void endReset(); |
70 |
|
|
71 |
|
// Map clear. |
72 |
|
void clear(); |
73 |
|
|
74 |
|
protected: |
75 |
|
|
76 |
|
QModelIndex index(int row, int col, const QModelIndex& parent) const; |
77 |
|
QModelIndex parent(const QModelIndex& child) const; |
78 |
|
|
79 |
private: |
private: |
|
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
80 |
|
|
81 |
// Current map selection. |
typedef QList<Instrument *> InstrumentList; |
82 |
int m_iMidiMap; |
typedef QMap<int, InstrumentList> InstrumentMap; |
83 |
|
|
84 |
|
InstrumentMap m_instruments; |
85 |
|
|
86 |
InstrumentsMap instruments; |
// Current map selection. |
87 |
|
int m_iMidiMap; |
88 |
}; |
}; |
89 |
|
|
90 |
|
|
91 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
92 |
// MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
93 |
// (doesn't actually do anything ATM, but is already there for a future |
// |
|
// cell editor widget implementation) |
|
94 |
|
|
95 |
class MidiInstrumentsDelegate : public QItemDelegate { |
class InstrumentListView : public QTreeView |
96 |
Q_OBJECT |
{ |
97 |
public: |
public: |
|
MidiInstrumentsDelegate(QObject* parent = 0); |
|
98 |
|
|
99 |
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
// Constructor. |
100 |
const QModelIndex& index) const; |
InstrumentListView(QWidget *pParent = NULL); |
101 |
|
|
102 |
|
// Destructor. |
103 |
|
~InstrumentListView(); |
104 |
|
|
105 |
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
// Map selector. |
106 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
void setMidiMap(int iMidiMap); |
107 |
const QModelIndex& index) const; |
int midiMap() const; |
108 |
|
|
109 |
|
// Own methods |
110 |
|
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
111 |
|
void removeInstrument(Instrument *pInstrument); |
112 |
|
void updateInstrument(Instrument *pInstrument); |
113 |
|
void resortInstrument(Instrument *pInstrument); |
114 |
|
|
115 |
void updateEditorGeometry(QWidget* editor, |
// General reloader. |
116 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
void refresh(); |
117 |
|
|
118 |
|
private: |
119 |
|
|
120 |
|
// Instance variables. |
121 |
|
InstrumentListModel *m_pListModel; |
122 |
}; |
}; |
123 |
|
|
124 |
|
|
125 |
|
} // namespace QSampler |
126 |
|
|
127 |
#endif // __qsamplerInstrumentList_h |
#endif // __qsamplerInstrumentList_h |
128 |
|
|
129 |
|
|