1 |
// qsamplerDevice.h |
// qsamplerDevice.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 __qsamplerDevice_h |
#ifndef __qsamplerDevice_h |
24 |
#define __qsamplerDevice_h |
#define __qsamplerDevice_h |
25 |
|
|
26 |
#include <qlistview.h> |
#include <QListWidget> |
27 |
#include <qtable.h> |
#include <QListWidgetItem> |
28 |
|
#include <QTreeWidgetItem> |
29 |
|
#include <QTableWidget> |
30 |
|
#include <QTableWidgetItem> |
31 |
|
#include <QAbstractTableModel> |
32 |
|
#include <QItemDelegate> |
33 |
|
#include <QFontMetrics> |
34 |
|
#include <QModelIndex> |
35 |
|
#include <QSize> |
36 |
|
#include <QList> |
37 |
|
|
38 |
#include <lscp/client.h> |
#include <lscp/client.h> |
39 |
#include <lscp/device.h> |
#include <lscp/device.h> |
85 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
86 |
|
|
87 |
// Typedef'd device port/channels QptrList. |
// Typedef'd device port/channels QptrList. |
88 |
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
typedef QList<qsamplerDevicePort *> qsamplerDevicePortList; |
89 |
|
|
90 |
|
|
91 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
222 |
// qsamplerDeviceItem - QListView device item. |
// qsamplerDeviceItem - QListView device item. |
223 |
// |
// |
224 |
|
|
225 |
class qsamplerDeviceItem : public QListViewItem |
class qsamplerDeviceItem : public QTreeWidgetItem |
226 |
{ |
{ |
227 |
public: |
public: |
228 |
|
|
229 |
// Constructors. |
// Constructors. |
230 |
qsamplerDeviceItem(QListView *pListView, |
qsamplerDeviceItem(QTreeWidget* pTreeWidget, |
231 |
qsamplerDevice::qsamplerDeviceType deviceType); |
qsamplerDevice::qsamplerDeviceType deviceType); |
232 |
qsamplerDeviceItem(QListViewItem *pItem, |
qsamplerDeviceItem(QTreeWidgetItem* pItem, |
233 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
234 |
// Default destructor. |
// Default destructor. |
235 |
~qsamplerDeviceItem(); |
~qsamplerDeviceItem(); |
237 |
// Instance accessors. |
// Instance accessors. |
238 |
qsamplerDevice& device(); |
qsamplerDevice& device(); |
239 |
|
|
|
// To virtually distinguish between list view items. |
|
|
virtual int rtti() const; |
|
|
|
|
240 |
private: |
private: |
241 |
|
|
242 |
// Instance variables. |
// Instance variables. |
243 |
qsamplerDevice m_device; |
qsamplerDevice m_device; |
244 |
}; |
}; |
245 |
|
|
246 |
|
struct DeviceParameterRow { |
247 |
|
QString name; |
248 |
|
qsamplerDeviceParam param; |
249 |
|
}; |
250 |
|
|
251 |
|
// so we can use it i.e. through QVariant |
252 |
|
Q_DECLARE_METATYPE(DeviceParameterRow) |
253 |
|
|
254 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
255 |
// qsamplerDeviceParamTable - Device parameter view table. |
// AbstractDeviceParamModel - data model base class for device parameters |
256 |
// |
// |
257 |
|
class AbstractDeviceParamModel : public QAbstractTableModel { |
258 |
class qsamplerDeviceParamTable : public QTable |
Q_OBJECT |
259 |
{ |
public: |
260 |
Q_OBJECT |
AbstractDeviceParamModel(QObject* parent = 0); |
261 |
|
|
262 |
public: |
// overridden methods from subclass(es) |
263 |
|
int rowCount(const QModelIndex& parent = QModelIndex()) const; |
264 |
// Constructor. |
int columnCount(const QModelIndex& parent = QModelIndex() ) const; |
265 |
qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0); |
QVariant data(const QModelIndex &index, int role) const; |
266 |
// Default destructor. |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
267 |
~qsamplerDeviceParamTable(); |
Qt::ItemFlags flags(const QModelIndex& index) const; |
268 |
|
|
269 |
// Common parameter table renderer. |
virtual void clear(); |
270 |
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
|
271 |
|
void refresh(const qsamplerDeviceParamMap* params, bool bEditable); |
272 |
|
|
273 |
|
protected: |
274 |
|
const qsamplerDeviceParamMap* params; |
275 |
|
bool bEditable; |
276 |
}; |
}; |
277 |
|
|
|
|
|
278 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
279 |
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
// DeviceParamModel - data model for device parameters (used for QTableView) |
280 |
// |
// |
281 |
|
class DeviceParamModel : public AbstractDeviceParamModel { |
282 |
|
Q_OBJECT |
283 |
|
public: |
284 |
|
DeviceParamModel(QObject* parent = 0); |
285 |
|
|
286 |
|
// overridden methods from subclass(es) |
287 |
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); |
288 |
|
void clear(); |
289 |
|
|
290 |
class qsamplerDeviceParamTableSpinBox : public QTableItem |
public slots: |
291 |
{ |
void refresh(qsamplerDevice* pDevice, bool bEditable); |
|
public: |
|
292 |
|
|
293 |
// Constructor. |
private: |
294 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
qsamplerDevice* device; |
|
const QString& sText); |
|
|
|
|
|
// Public accessors. |
|
|
void setMinValue(int iMinValue); |
|
|
void setMaxValue(int iMaxValue); |
|
|
void setValue(int iValue); |
|
|
|
|
|
protected: |
|
|
|
|
|
// Virtual implemetations. |
|
|
QWidget *createEditor() const; |
|
|
void setContentFromEditor(QWidget *pWidget); |
|
|
|
|
|
private: |
|
|
|
|
|
// Initial value holders. |
|
|
int m_iValue; |
|
|
int m_iMinValue; |
|
|
int m_iMaxValue; |
|
295 |
}; |
}; |
296 |
|
|
|
|
|
297 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
298 |
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
// PortParamModel - data model for port parameters (used for QTableView) |
299 |
// |
// |
300 |
|
class PortParamModel : public AbstractDeviceParamModel { |
301 |
|
Q_OBJECT |
302 |
|
public: |
303 |
|
PortParamModel(QObject* parent = 0); |
304 |
|
|
305 |
|
// overridden methods from subclass(es) |
306 |
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); |
307 |
|
void clear(); |
308 |
|
|
309 |
class qsamplerDeviceParamTableEditBox : public QTableItem |
public slots: |
310 |
{ |
void refresh(qsamplerDevicePort* pPort, bool bEditable); |
|
public: |
|
|
|
|
|
// Constructor. |
|
|
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
|
|
const QString& sText); |
|
|
|
|
|
protected: |
|
311 |
|
|
312 |
// Virtual implemetations. |
private: |
313 |
QWidget *createEditor() const; |
qsamplerDevicePort* port; |
|
void setContentFromEditor(QWidget *pWidget); |
|
314 |
}; |
}; |
315 |
|
|
316 |
|
//------------------------------------------------------------------------- |
317 |
|
// DeviceParamDelegate - table cell renderer for device/port parameters |
318 |
|
// |
319 |
|
class DeviceParamDelegate : public QItemDelegate { |
320 |
|
Q_OBJECT |
321 |
|
public: |
322 |
|
DeviceParamDelegate(QObject* parent = 0); |
323 |
|
QWidget* createEditor(QWidget* parent, |
324 |
|
const QStyleOptionViewItem& option, |
325 |
|
const QModelIndex& index) const; |
326 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
327 |
|
void setModelData(QWidget* editor, QAbstractItemModel* model, |
328 |
|
const QModelIndex& index) const; |
329 |
|
void updateEditorGeometry(QWidget* editor, |
330 |
|
const QStyleOptionViewItem& option, |
331 |
|
const QModelIndex& index) const; |
332 |
|
}; |
333 |
|
|
334 |
#endif // __qsamplerDevice_h |
#endif // __qsamplerDevice_h |
335 |
|
|
|
|
|
336 |
// end of qsamplerDevice.h |
// end of qsamplerDevice.h |