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 <QListWidgetItem> |
|
|
#include <QAbstractTableModel> |
|
|
#include <QItemDelegate> |
|
27 |
|
|
28 |
#include <lscp/client.h> |
namespace QSampler { |
|
|
|
|
#include <string.h> |
|
|
|
|
|
#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 |
|
Q_OBJECT |
39 |
|
|
40 |
public: |
public: |
|
MidiInstrumentsModel(QObject* parent = 0); |
|
41 |
|
|
42 |
// overridden methods from subclass(es) |
// Constructor. |
43 |
int rowCount(const QModelIndex &parent) const; |
InstrumentListModel(QObject *pParent = NULL); |
44 |
int columnCount(const QModelIndex &parent) const; |
|
45 |
QVariant data(const QModelIndex &index, int role) const; |
// Destructor. |
46 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
~InstrumentListModel(); |
47 |
|
|
48 |
// make the following method public |
// Overridden methods from subclass(es) |
49 |
QAbstractTableModel::reset; |
int rowCount(const QModelIndex& parent) const; |
50 |
|
int columnCount(const QModelIndex& parent) const; |
51 |
// own methods |
|
52 |
qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1); |
QVariant data(const QModelIndex& index, int role) const; |
53 |
void removeInstrument(const qsamplerInstrument& instrument); |
QVariant headerData(int section, Qt::Orientation orientation, |
54 |
void resort(const qsamplerInstrument instrument); |
int role = Qt::DisplayRole) const; |
55 |
|
|
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 |
// Instrument map/session change signal. |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
62 |
void instrumentsChanged(); |
void removeInstrument(const Instrument *pInstrument); |
63 |
|
void updateInstrument(const Instrument *pInstrument); |
64 |
public slots: |
|
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: |
|
typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap; |
|
81 |
|
|
82 |
// Current map selection. |
typedef QList<Instrument *> InstrumentList; |
83 |
int m_iMidiMap; |
typedef QMap<int, InstrumentList> InstrumentMap; |
84 |
|
|
85 |
|
InstrumentMap m_instruments; |
86 |
|
|
87 |
InstrumentsMap instruments; |
// Current map selection. |
88 |
|
int m_iMidiMap; |
89 |
}; |
}; |
90 |
|
|
91 |
|
|
92 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
93 |
// MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
94 |
// (doesn't actually do anything ATM, but is already there for a future |
// |
95 |
// cell editor widget implementation) |
|
96 |
|
class InstrumentListView : public QTreeView |
97 |
|
{ |
98 |
|
Q_OBJECT |
99 |
|
|
|
class MidiInstrumentsDelegate : public QItemDelegate { |
|
|
Q_OBJECT |
|
100 |
public: |
public: |
|
MidiInstrumentsDelegate(QObject* parent = 0); |
|
101 |
|
|
102 |
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
// Constructor. |
103 |
const QModelIndex& index) const; |
InstrumentListView(QWidget *pParent = 0); |
104 |
|
|
105 |
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
// Destructor. |
106 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
~InstrumentListView(); |
|
const QModelIndex& index) const; |
|
107 |
|
|
108 |
void updateEditorGeometry(QWidget* editor, |
// Map selector. |
109 |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
void setMidiMap(int iMidiMap); |
110 |
|
int midiMap() const; |
111 |
|
|
112 |
|
// Own methods |
113 |
|
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 |
128 |
|
|
129 |
#endif // __qsamplerInstrumentList_h |
#endif // __qsamplerInstrumentList_h |
130 |
|
|
131 |
|
|