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