1 |
// qsamplerDevice.h |
// qsamplerDevice.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2005, 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 |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
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 <QMetaType> |
33 |
|
#include <QItemDelegate> |
34 |
|
#include <QFontMetrics> |
35 |
|
#include <QModelIndex> |
36 |
|
#include <QSize> |
37 |
|
#include <QList> |
38 |
|
#include <Q3PtrList> |
39 |
|
|
40 |
#include <lscp/client.h> |
#include <lscp/client.h> |
41 |
#include <lscp/device.h> |
#include <lscp/device.h> |
87 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
88 |
|
|
89 |
// Typedef'd device port/channels QptrList. |
// Typedef'd device port/channels QptrList. |
90 |
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
typedef Q3PtrList<qsamplerDevicePort> qsamplerDevicePortList; |
91 |
|
|
92 |
|
|
93 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
102 |
enum qsamplerDeviceType { None, Midi, Audio }; |
enum qsamplerDeviceType { None, Midi, Audio }; |
103 |
|
|
104 |
// Constructor. |
// Constructor. |
105 |
qsamplerDevice(qsamplerMainForm *pMainForm, |
qsamplerDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); |
|
qsamplerDeviceType deviceType, int iDeviceID = -1); |
|
106 |
// Copy constructor. |
// Copy constructor. |
107 |
qsamplerDevice(const qsamplerDevice& device); |
qsamplerDevice(const qsamplerDevice& device); |
108 |
// Default destructor. |
// Default destructor. |
114 |
// Driver name initializer. |
// Driver name initializer. |
115 |
void setDriver(const QString& sDriverName); |
void setDriver(const QString& sDriverName); |
116 |
|
|
|
// LSCP client descriptor accessor. |
|
|
lscp_client_t *client() const; |
|
|
|
|
117 |
// Device property accessors. |
// Device property accessors. |
118 |
int deviceID() const; |
int deviceID() const; |
119 |
qsamplerDeviceType deviceType() const; |
qsamplerDeviceType deviceType() const; |
224 |
// qsamplerDeviceItem - QListView device item. |
// qsamplerDeviceItem - QListView device item. |
225 |
// |
// |
226 |
|
|
227 |
class qsamplerDeviceItem : public QListViewItem |
class qsamplerDeviceItem : public QTreeWidgetItem |
228 |
{ |
{ |
229 |
public: |
public: |
230 |
|
|
231 |
// Constructors. |
// Constructors. |
232 |
qsamplerDeviceItem(QListView *pListView, qsamplerMainForm *pMainForm, |
qsamplerDeviceItem(QTreeWidget* pTreeWidget, |
233 |
qsamplerDevice::qsamplerDeviceType deviceType); |
qsamplerDevice::qsamplerDeviceType deviceType); |
234 |
qsamplerDeviceItem(QListViewItem *pItem, qsamplerMainForm *pMainForm, |
qsamplerDeviceItem(QTreeWidgetItem* pItem, |
235 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
236 |
// Default destructor. |
// Default destructor. |
237 |
~qsamplerDeviceItem(); |
~qsamplerDeviceItem(); |
239 |
// Instance accessors. |
// Instance accessors. |
240 |
qsamplerDevice& device(); |
qsamplerDevice& device(); |
241 |
|
|
|
// To virtually distinguish between list view items. |
|
|
virtual int rtti() const; |
|
|
|
|
242 |
private: |
private: |
243 |
|
|
244 |
// Instance variables. |
// Instance variables. |
250 |
// qsamplerDeviceParamTable - Device parameter view table. |
// qsamplerDeviceParamTable - Device parameter view table. |
251 |
// |
// |
252 |
|
|
253 |
|
#if 0 |
254 |
class qsamplerDeviceParamTable : public QTable |
class qsamplerDeviceParamTable : public QTable |
255 |
{ |
{ |
256 |
Q_OBJECT |
Q_OBJECT |
265 |
// Common parameter table renderer. |
// Common parameter table renderer. |
266 |
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
267 |
}; |
}; |
268 |
|
#endif |
269 |
|
|
270 |
|
struct DeviceParameterRow { |
271 |
|
QString name; |
272 |
|
qsamplerDeviceParam param; |
273 |
|
}; |
274 |
|
|
275 |
|
// so we can use it i.e. through QVariant |
276 |
|
Q_DECLARE_METATYPE(DeviceParameterRow) |
277 |
|
|
278 |
|
class DeviceParamModel : public QAbstractTableModel { |
279 |
|
Q_OBJECT |
280 |
|
public: |
281 |
|
DeviceParamModel(QObject* parent = 0); |
282 |
|
|
283 |
|
// overridden methods from subclass(es) |
284 |
|
int rowCount(const QModelIndex &parent) const; |
285 |
|
int columnCount(const QModelIndex &parent) const; |
286 |
|
QVariant data(const QModelIndex &index, int role) const; |
287 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
288 |
|
|
289 |
|
void clear(); |
290 |
|
|
291 |
|
public slots: |
292 |
|
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
293 |
|
|
294 |
|
private: |
295 |
|
qsamplerDeviceParamMap params; |
296 |
|
bool bEditable; |
297 |
|
}; |
298 |
|
|
299 |
|
class DeviceParamDelegate : public QItemDelegate { |
300 |
|
Q_OBJECT |
301 |
|
public: |
302 |
|
DeviceParamDelegate(QObject* parent = 0); |
303 |
|
|
304 |
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
305 |
|
const QModelIndex& index) const; |
306 |
|
|
307 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
308 |
|
void setModelData(QWidget* editor, QAbstractItemModel* model, |
309 |
|
const QModelIndex& index) const; |
310 |
|
|
311 |
|
void updateEditorGeometry(QWidget* editor, |
312 |
|
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
313 |
|
}; |
314 |
|
|
315 |
|
|
316 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
317 |
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
318 |
// |
// |
319 |
|
|
320 |
class qsamplerDeviceParamTableSpinBox : public QTableItem |
#if 0 |
321 |
|
class qsamplerDeviceParamTableSpinBox : public QTableWidgetItem |
322 |
{ |
{ |
323 |
public: |
public: |
324 |
|
|
325 |
// Constructor. |
// Constructor. |
326 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
qsamplerDeviceParamTableSpinBox (QTableWidget *pTable, Qt::ItemFlags flags, |
327 |
const QString& sText); |
const QString& sText); |
328 |
|
|
329 |
// Public accessors. |
// Public accessors. |
350 |
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
351 |
// |
// |
352 |
|
|
353 |
class qsamplerDeviceParamTableEditBox : public QTableItem |
class qsamplerDeviceParamTableEditBox : public QTableWidgetItem |
354 |
{ |
{ |
355 |
public: |
public: |
356 |
|
|
357 |
// Constructor. |
// Constructor. |
358 |
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
qsamplerDeviceParamTableEditBox (QTableWidget *pTable, Qt::ItemFlags flags, |
359 |
const QString& sText); |
const QString& sText); |
360 |
|
|
361 |
protected: |
protected: |
364 |
QWidget *createEditor() const; |
QWidget *createEditor() const; |
365 |
void setContentFromEditor(QWidget *pWidget); |
void setContentFromEditor(QWidget *pWidget); |
366 |
}; |
}; |
367 |
|
#endif |
368 |
|
|
369 |
#endif // __qsamplerDevice_h |
#endif // __qsamplerDevice_h |
370 |
|
|