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 <QAbstractTableModel> |
28 |
|
#include <QMetaType> |
29 |
|
#include <QItemDelegate> |
30 |
|
#include <QFontMetrics> |
31 |
|
#include <QModelIndex> |
32 |
|
#include <QSize> |
33 |
|
|
34 |
#include <lscp/client.h> |
#include <lscp/client.h> |
35 |
#include <lscp/device.h> |
#include <lscp/device.h> |
140 |
// Reset channel method. |
// Reset channel method. |
141 |
bool channelReset(); |
bool channelReset(); |
142 |
|
|
143 |
|
// Spawn instrument editor method. |
144 |
|
bool editChannel(); |
145 |
|
|
146 |
// Message logging methods (brainlessly mapped to main form's). |
// Message logging methods (brainlessly mapped to main form's). |
147 |
void appendMessages (const QString & s) const; |
void appendMessages (const QString & s) const; |
148 |
void appendMessagesColor (const QString & s, const QString & c) const; |
void appendMessagesColor (const QString & s, const QString & c) const; |
195 |
|
|
196 |
|
|
197 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
198 |
// qsamplerChannelRoutingTable - Channel routing table widget. |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
199 |
// |
// |
200 |
|
|
201 |
class qsamplerChannelRoutingTable : public QTable |
struct ChannelRoutingItem { |
202 |
{ |
QStringList options; |
203 |
Q_OBJECT |
int selection; |
204 |
|
}; |
|
public: |
|
|
|
|
|
// Constructor. |
|
|
qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0); |
|
|
// Default destructor. |
|
|
~qsamplerChannelRoutingTable(); |
|
205 |
|
|
206 |
// Common parameter table renderer. |
// so we can use it i.e. through QVariant |
207 |
void refresh(qsamplerDevice *pDevice, |
Q_DECLARE_METATYPE(ChannelRoutingItem) |
|
const qsamplerChannelRoutingMap& routing); |
|
208 |
|
|
209 |
// Commit any pending editing. |
class ChannelRoutingModel : public QAbstractTableModel { |
210 |
void flush(); |
Q_OBJECT |
211 |
|
public: |
212 |
|
ChannelRoutingModel(QObject* parent = 0); |
213 |
|
|
214 |
|
// overridden methods from subclass(es) |
215 |
|
int rowCount(const QModelIndex &parent = QModelIndex()) const; |
216 |
|
int columnCount(const QModelIndex &parent = QModelIndex()) const; |
217 |
|
Qt::ItemFlags flags(const QModelIndex& index) const; |
218 |
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); |
219 |
|
QVariant data(const QModelIndex &index, int role) const; |
220 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
221 |
|
|
222 |
|
// own methods |
223 |
|
qsamplerChannelRoutingMap routingMap() const { |
224 |
|
return routing; |
225 |
|
} |
226 |
|
|
227 |
|
void clear() { routing.clear(); } |
228 |
|
|
229 |
|
public slots: |
230 |
|
void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); |
231 |
|
|
232 |
|
private: |
233 |
|
qsamplerDevice* pDevice; |
234 |
|
qsamplerChannelRoutingMap routing; |
235 |
}; |
}; |
236 |
|
|
237 |
|
|
238 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
239 |
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
// ChannelRoutingDelegate - table cell renderer for audio routing |
240 |
// |
// |
241 |
|
|
242 |
class qsamplerChannelRoutingComboBox : public QTableItem |
class ChannelRoutingDelegate : public QItemDelegate { |
243 |
{ |
Q_OBJECT |
244 |
public: |
public: |
245 |
|
ChannelRoutingDelegate(QObject* parent = 0); |
246 |
// Constructor. |
QWidget* createEditor(QWidget* parent, |
247 |
qsamplerChannelRoutingComboBox(QTable *pTable, |
const QStyleOptionViewItem& option, |
248 |
const QStringList& list, const QPixmap& pixmap); |
const QModelIndex& index) const; |
249 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
250 |
// Public accessors. |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
251 |
void setCurrentItem(int iCurrentItem); |
const QModelIndex& index) const; |
252 |
int currentItem() const; |
void updateEditorGeometry(QWidget* editor, |
253 |
|
const QStyleOptionViewItem& option, |
254 |
protected: |
const QModelIndex& index) const; |
|
|
|
|
// Virtual implemetations. |
|
|
QWidget *createEditor() const; |
|
|
void setContentFromEditor(QWidget *pWidget); |
|
|
|
|
|
private: |
|
|
|
|
|
// Initial value holders |
|
|
QStringList m_list; |
|
|
int m_iCurrentItem; |
|
255 |
}; |
}; |
256 |
|
|
|
|
|
257 |
#endif // __qsamplerChannel_h |
#endif // __qsamplerChannel_h |
258 |
|
|
|
|
|
259 |
// end of qsamplerChannel.h |
// end of qsamplerChannel.h |