1 |
// qsamplerChannel.h |
// qsamplerChannel.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
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 |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
23 |
#ifndef __qsamplerChannel_h |
#ifndef __qsamplerChannel_h |
24 |
#define __qsamplerChannel_h |
#define __qsamplerChannel_h |
25 |
|
|
26 |
#include <qtable.h> |
#include <QTableWidgetItem> |
27 |
|
#include <QItemDelegate> |
28 |
|
|
29 |
#include <lscp/client.h> |
#include <lscp/client.h> |
30 |
#include <lscp/device.h> |
#include <lscp/device.h> |
31 |
|
|
32 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
33 |
|
|
34 |
class qsamplerDevice; |
namespace QSampler { |
35 |
|
|
36 |
|
class Device; |
37 |
|
|
38 |
// Typedef'd QMap. |
// Typedef'd QMap. |
39 |
typedef QMap<int, int> qsamplerChannelRoutingMap; |
typedef QMap<int, int> ChannelRoutingMap; |
40 |
|
|
41 |
|
|
42 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
43 |
// qsamplerChannel - Sampler channel structure. |
// QSampler::Channel - Sampler channel structure. |
44 |
// |
// |
45 |
|
|
46 |
class qsamplerChannel |
class Channel |
47 |
{ |
{ |
48 |
public: |
public: |
49 |
|
|
50 |
// Constructor. |
// Constructor. |
51 |
qsamplerChannel(int iChannelID = -1); |
Channel(int iChannelID = -1); |
52 |
// Default destructor. |
// Default destructor. |
53 |
~qsamplerChannel(); |
~Channel(); |
54 |
|
|
55 |
// Add/remove sampler channel methods. |
// Add/remove sampler channel methods. |
56 |
bool addChannel(); |
bool addChannel(); |
122 |
int audioChannel(int iAudioOut) const; |
int audioChannel(int iAudioOut) const; |
123 |
bool setAudioChannel(int iAudioOut, int iAudioIn); |
bool setAudioChannel(int iAudioOut, int iAudioIn); |
124 |
// The audio routing map itself. |
// The audio routing map itself. |
125 |
const qsamplerChannelRoutingMap& audioRouting() const; |
const ChannelRoutingMap& audioRouting() const; |
126 |
|
|
127 |
// Istrument name remapper. |
// Istrument name remapper. |
128 |
void updateInstrumentName(); |
void updateInstrumentName(); |
136 |
// Reset channel method. |
// Reset channel method. |
137 |
bool channelReset(); |
bool channelReset(); |
138 |
|
|
139 |
|
// Spawn instrument editor method. |
140 |
|
bool editChannel(); |
141 |
|
|
142 |
// Message logging methods (brainlessly mapped to main form's). |
// Message logging methods (brainlessly mapped to main form's). |
143 |
void appendMessages (const QString & s) const; |
void appendMessages (const QString & s) const; |
144 |
void appendMessagesColor (const QString & s, const QString & c) const; |
void appendMessagesColor (const QString & s, const QString & c) const; |
186 |
bool m_bSolo; |
bool m_bSolo; |
187 |
|
|
188 |
// The audio routing mapping. |
// The audio routing mapping. |
189 |
qsamplerChannelRoutingMap m_audioRouting; |
ChannelRoutingMap m_audioRouting; |
190 |
}; |
}; |
191 |
|
|
192 |
|
|
193 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
194 |
// qsamplerChannelRoutingTable - Channel routing table widget. |
// QSampler::ChannelRoutingModel - data model for audio routing |
195 |
|
// (used for QTableView) |
196 |
// |
// |
197 |
|
|
198 |
class qsamplerChannelRoutingTable : public QTable |
struct ChannelRoutingItem { |
199 |
|
QStringList options; |
200 |
|
int selection; |
201 |
|
}; |
202 |
|
|
203 |
|
class ChannelRoutingModel : public QAbstractTableModel |
204 |
{ |
{ |
205 |
Q_OBJECT |
Q_OBJECT |
|
|
|
206 |
public: |
public: |
207 |
|
|
208 |
// Constructor. |
ChannelRoutingModel(QObject* pParent = NULL); |
209 |
qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0); |
|
210 |
// Default destructor. |
// overridden methods from subclass(es) |
211 |
~qsamplerChannelRoutingTable(); |
int rowCount(const QModelIndex& parent = QModelIndex()) const; |
212 |
|
int columnCount(const QModelIndex& parent = QModelIndex()) const; |
213 |
|
Qt::ItemFlags flags(const QModelIndex& index) const; |
214 |
|
bool setData(const QModelIndex& index, const QVariant& value, |
215 |
|
int role = Qt::EditRole); |
216 |
|
QVariant data(const QModelIndex &index, int role) const; |
217 |
|
QVariant headerData(int section, Qt::Orientation orientation, |
218 |
|
int role = Qt::DisplayRole) const; |
219 |
|
|
220 |
|
// own methods |
221 |
|
ChannelRoutingMap routingMap() const { return m_routing; } |
222 |
|
|
223 |
|
void clear() { m_routing.clear(); } |
224 |
|
|
225 |
|
public slots: |
226 |
|
|
227 |
// Common parameter table renderer. |
void refresh(Device *pDevice, |
228 |
void refresh(qsamplerDevice *pDevice, |
const ChannelRoutingMap& routing); |
|
const qsamplerChannelRoutingMap& routing); |
|
229 |
|
|
230 |
// Commit any pending editing. |
private: |
231 |
void flush(); |
|
232 |
|
Device *m_pDevice; |
233 |
|
ChannelRoutingMap m_routing; |
234 |
}; |
}; |
235 |
|
|
236 |
|
|
237 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
238 |
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
// QSampler::ChannelRoutingDelegate - table cell renderer for audio routing |
239 |
// |
// |
240 |
|
|
241 |
class qsamplerChannelRoutingComboBox : public QTableItem |
class ChannelRoutingDelegate : public QItemDelegate |
242 |
{ |
{ |
243 |
public: |
Q_OBJECT |
|
|
|
|
// Constructor. |
|
|
qsamplerChannelRoutingComboBox(QTable *pTable, |
|
|
const QStringList& list, const QPixmap& pixmap); |
|
244 |
|
|
245 |
// Public accessors. |
public: |
|
void setCurrentItem(int iCurrentItem); |
|
|
int currentItem() const; |
|
|
|
|
|
protected: |
|
|
|
|
|
// Virtual implemetations. |
|
|
QWidget *createEditor() const; |
|
|
void setContentFromEditor(QWidget *pWidget); |
|
246 |
|
|
247 |
private: |
ChannelRoutingDelegate(QObject* pParent = NULL); |
248 |
|
|
249 |
// Initial value holders |
QWidget* createEditor(QWidget *pParent, |
250 |
QStringList m_list; |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
251 |
int m_iCurrentItem; |
void setEditorData(QWidget *pEditor, const QModelIndex& index) const; |
252 |
|
void setModelData(QWidget *pEditor, QAbstractItemModel* model, |
253 |
|
const QModelIndex& index) const; |
254 |
|
void updateEditorGeometry(QWidget *pEditor, |
255 |
|
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
256 |
}; |
}; |
257 |
|
|
258 |
|
} // namespace QSampler |
259 |
|
|
260 |
|
// So we can use it i.e. through QVariant |
261 |
|
Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem) |
262 |
|
|
263 |
#endif // __qsamplerChannel_h |
#endif // __qsamplerChannel_h |
264 |
|
|