21 |
|
|
22 |
#include "qsamplerDevice.h" |
#include "qsamplerDevice.h" |
23 |
|
|
24 |
|
#include <qspinbox.h> |
25 |
|
#include <qlineedit.h> |
26 |
|
|
27 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
28 |
#include "qsamplerDeviceForm.h" |
#include "qsamplerDeviceForm.h" |
29 |
|
|
53 |
const char *pszValue ) |
const char *pszValue ) |
54 |
{ |
{ |
55 |
if (pParamInfo == NULL) |
if (pParamInfo == NULL) |
56 |
return; |
return; |
57 |
|
|
58 |
// Info structure field members. |
// Info structure field members. |
59 |
|
|
60 |
type = pParamInfo->type; |
type = pParamInfo->type; |
61 |
|
|
62 |
if (pParamInfo->description) |
if (pParamInfo->description) |
63 |
description = pParamInfo->description; |
description = pParamInfo->description; |
64 |
else |
else |
65 |
description = QString::null; |
description = QString::null; |
66 |
|
|
67 |
mandatory = (bool) pParamInfo->multiplicity; |
mandatory = (bool) pParamInfo->multiplicity; |
68 |
fix = (bool) pParamInfo->fix; |
fix = (bool) pParamInfo->fix; |
69 |
multiplicity = (bool) pParamInfo->multiplicity; |
multiplicity = (bool) pParamInfo->multiplicity; |
70 |
|
|
71 |
depends.clear(); |
depends.clear(); |
72 |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
73 |
depends.append(pParamInfo->depends[i]); |
depends.append(pParamInfo->depends[i]); |
74 |
|
|
75 |
if (pParamInfo->defaultv) |
if (pParamInfo->defaultv) |
76 |
defaultv = pParamInfo->defaultv; |
defaultv = pParamInfo->defaultv; |
77 |
else |
else |
78 |
defaultv = QString::null; |
defaultv = QString::null; |
79 |
|
|
80 |
if (pParamInfo->range_min) |
if (pParamInfo->range_min) |
81 |
range_min = pParamInfo->range_min; |
range_min = pParamInfo->range_min; |
82 |
else |
else |
83 |
range_min = QString::null; |
range_min = QString::null; |
84 |
|
|
85 |
if (pParamInfo->range_max) |
if (pParamInfo->range_max) |
86 |
range_max = pParamInfo->range_max; |
range_max = pParamInfo->range_max; |
87 |
else |
else |
88 |
range_max = QString::null; |
range_max = QString::null; |
89 |
|
|
90 |
possibilities.clear(); |
possibilities.clear(); |
91 |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
92 |
possibilities.append(pParamInfo->possibilities[i]); |
possibilities.append(pParamInfo->possibilities[i]); |
93 |
|
|
94 |
// The current parameter value. |
// The current parameter value. |
95 |
if (pszValue) |
if (pszValue) |
96 |
value = pszValue; |
value = pszValue; |
97 |
else |
else |
98 |
value = QString::null; |
value = QString::null; |
99 |
} |
} |
125 |
m_deviceType = deviceType; |
m_deviceType = deviceType; |
126 |
|
|
127 |
// Retrieve device info, if any. |
// Retrieve device info, if any. |
|
QString sDeviceType; |
|
128 |
lscp_device_info_t *pDeviceInfo = NULL; |
lscp_device_info_t *pDeviceInfo = NULL; |
129 |
switch (deviceType) { |
switch (deviceType) { |
130 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
131 |
sDeviceType = QObject::tr("Audio"); |
m_sDeviceType = QObject::tr("Audio"); |
132 |
pDeviceInfo = ::lscp_get_audio_device_info(pClient, iDeviceID); |
pDeviceInfo = ::lscp_get_audio_device_info(pClient, iDeviceID); |
133 |
break; |
break; |
134 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
135 |
sDeviceType = QObject::tr("MIDI"); |
m_sDeviceType = QObject::tr("MIDI"); |
136 |
pDeviceInfo = ::lscp_get_midi_device_info(pClient, iDeviceID); |
pDeviceInfo = ::lscp_get_midi_device_info(pClient, iDeviceID); |
137 |
break; |
break; |
138 |
|
case qsamplerDevice::None: |
139 |
|
m_sDeviceType = QString::null; |
140 |
|
break; |
141 |
} |
} |
142 |
|
|
143 |
// If we're bogus, bail out... |
// If we're bogus, bail out... |
144 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
145 |
m_sDriverName = QString::null; |
m_sDriverName = QString::null; |
146 |
m_sDeviceName = QObject::tr("New %1 device").arg(sDeviceType); |
m_sDeviceName = QObject::tr("New %1 device").arg(m_sDeviceType); |
147 |
return; |
return; |
148 |
} |
} |
149 |
|
|
150 |
// Other device properties... |
// Other device properties... |
151 |
m_sDriverName = pDeviceInfo->driver; |
m_sDriverName = pDeviceInfo->driver; |
152 |
m_sDeviceName = m_sDriverName + ' ' |
m_sDeviceName = m_sDriverName + ' ' |
153 |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
154 |
|
|
155 |
// Grab device/driver parameters... |
// Grab device parameters... |
156 |
m_params.clear(); |
m_params.clear(); |
157 |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
158 |
const char *pszParam = pDeviceInfo->params[i].key; |
const char *pszParam = pDeviceInfo->params[i].key; |
159 |
lscp_param_info_t *pParamInfo = NULL; |
lscp_param_info_t *pParamInfo = NULL; |
160 |
switch (deviceType) { |
switch (deviceType) { |
161 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
162 |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
163 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), pszParam, NULL); |
164 |
break; |
break; |
165 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
166 |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
167 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), pszParam, NULL); |
168 |
break; |
break; |
169 |
|
case qsamplerDevice::None: |
170 |
|
break; |
171 |
|
} |
172 |
|
if (pParamInfo) { |
173 |
|
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, |
174 |
|
pDeviceInfo->params[i].value); |
175 |
} |
} |
176 |
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, pDeviceInfo->params[i].value); |
} |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
// Driver name initializer. |
181 |
|
void qsamplerDevice::setDriver ( lscp_client_t *pClient, |
182 |
|
const QString& sDriverName ) |
183 |
|
{ |
184 |
|
// Valid only for scratch devices. |
185 |
|
if (m_sDriverName == sDriverName) |
186 |
|
return; |
187 |
|
|
188 |
|
// Retrieve driver info, if any. |
189 |
|
lscp_driver_info_t *pDriverInfo = NULL; |
190 |
|
switch (m_deviceType) { |
191 |
|
case qsamplerDevice::Audio: |
192 |
|
pDriverInfo = ::lscp_get_audio_driver_info(pClient, |
193 |
|
sDriverName.latin1()); |
194 |
|
break; |
195 |
|
case qsamplerDevice::Midi: |
196 |
|
pDriverInfo = ::lscp_get_midi_driver_info(pClient, |
197 |
|
sDriverName.latin1()); |
198 |
|
break; |
199 |
|
case qsamplerDevice::None: |
200 |
|
break; |
201 |
|
} |
202 |
|
|
203 |
|
// If we're bogus, bail out... |
204 |
|
if (pDriverInfo == NULL) |
205 |
|
return; |
206 |
|
|
207 |
|
// Remember device parameters... |
208 |
|
m_sDriverName = sDriverName; |
209 |
|
|
210 |
|
// Grab driver parameters... |
211 |
|
m_params.clear(); |
212 |
|
for (int i = 0; pDriverInfo->parameters && pDriverInfo->parameters[i]; i++) { |
213 |
|
const char *pszParam = pDriverInfo->parameters[i]; |
214 |
|
lscp_param_info_t *pParamInfo = NULL; |
215 |
|
switch (m_deviceType) { |
216 |
|
case qsamplerDevice::Audio: |
217 |
|
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
218 |
|
sDriverName.latin1(), pszParam, NULL); |
219 |
|
break; |
220 |
|
case qsamplerDevice::Midi: |
221 |
|
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
222 |
|
sDriverName.latin1(), pszParam, NULL); |
223 |
|
break; |
224 |
|
case qsamplerDevice::None: |
225 |
|
break; |
226 |
|
} |
227 |
|
if (pParamInfo) |
228 |
|
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, pParamInfo->defaultv); |
229 |
} |
} |
230 |
} |
} |
231 |
|
|
241 |
return m_deviceType; |
return m_deviceType; |
242 |
} |
} |
243 |
|
|
244 |
|
const QString& qsamplerDevice::deviceTypeName (void) const |
245 |
|
{ |
246 |
|
return m_sDeviceType; |
247 |
|
} |
248 |
|
|
249 |
const QString& qsamplerDevice::driverName (void) const |
const QString& qsamplerDevice::driverName (void) const |
250 |
{ |
{ |
251 |
return m_sDriverName; |
return m_sDriverName; |
274 |
{ |
{ |
275 |
int *piDeviceIDs = NULL; |
int *piDeviceIDs = NULL; |
276 |
switch (deviceType) { |
switch (deviceType) { |
277 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
278 |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
279 |
break; |
break; |
280 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
281 |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
282 |
|
break; |
283 |
|
case qsamplerDevice::None: |
284 |
break; |
break; |
285 |
} |
} |
286 |
return piDeviceIDs; |
return piDeviceIDs; |
295 |
|
|
296 |
const char **ppszDrivers = NULL; |
const char **ppszDrivers = NULL; |
297 |
switch (deviceType) { |
switch (deviceType) { |
298 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
299 |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
300 |
break; |
break; |
301 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
302 |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
303 |
|
break; |
304 |
|
case qsamplerDevice::None: |
305 |
break; |
break; |
306 |
} |
} |
307 |
|
|
308 |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
309 |
drivers.append(ppszDrivers[iDriver]); |
drivers.append(ppszDrivers[iDriver]); |
310 |
|
|
311 |
return drivers; |
return drivers; |
312 |
} |
} |
317 |
// |
// |
318 |
|
|
319 |
// Constructors. |
// Constructors. |
320 |
qsamplerDeviceItem::qsamplerDeviceItem ( QListView *pListView, lscp_client_t *pClient, |
qsamplerDeviceItem::qsamplerDeviceItem ( QListView *pListView, |
321 |
qsamplerDevice::qsamplerDeviceType deviceType ) |
lscp_client_t *pClient, qsamplerDevice::qsamplerDeviceType deviceType ) |
322 |
: QListViewItem(pListView), m_device(pClient, deviceType) |
: QListViewItem(pListView), m_device(pClient, deviceType) |
323 |
{ |
{ |
324 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
325 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
326 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
327 |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
328 |
break; |
break; |
329 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
330 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
331 |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
332 |
break; |
break; |
333 |
|
case qsamplerDevice::None: |
334 |
|
break; |
335 |
} |
} |
336 |
} |
} |
337 |
|
|
338 |
qsamplerDeviceItem::qsamplerDeviceItem ( QListViewItem *pItem, lscp_client_t *pClient, |
qsamplerDeviceItem::qsamplerDeviceItem ( QListViewItem *pItem, |
339 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
lscp_client_t *pClient, qsamplerDevice::qsamplerDeviceType deviceType, |
340 |
|
int iDeviceID ) |
341 |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
342 |
{ |
{ |
343 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
344 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
345 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
346 |
break; |
break; |
347 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
348 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
349 |
break; |
break; |
350 |
|
case qsamplerDevice::None: |
351 |
|
break; |
352 |
} |
} |
353 |
|
|
354 |
QListViewItem::setText(0, m_device.deviceName()); |
QListViewItem::setText(0, m_device.deviceName()); |
360 |
} |
} |
361 |
|
|
362 |
// Instance accessors. |
// Instance accessors. |
363 |
const qsamplerDevice& qsamplerDeviceItem::device (void) |
qsamplerDevice& qsamplerDeviceItem::device (void) |
364 |
{ |
{ |
365 |
return m_device; |
return m_device; |
366 |
} |
} |
378 |
// |
// |
379 |
|
|
380 |
// Constructor. |
// Constructor. |
381 |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, const char *pszName ) |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, |
382 |
|
const char *pszName ) |
383 |
: QTable(pParent, pszName) |
: QTable(pParent, pszName) |
384 |
{ |
{ |
|
m_pClient = NULL; |
|
|
m_iDeviceID = -1; |
|
|
|
|
385 |
// Set fixed number of columns. |
// Set fixed number of columns. |
386 |
QTable::setNumCols(3); |
QTable::setNumCols(3); |
387 |
QTable::setShowGrid(false); |
QTable::setShowGrid(false); |
400 |
QTable::setColumnReadOnly(0, true); |
QTable::setColumnReadOnly(0, true); |
401 |
QTable::setColumnReadOnly(1, true); |
QTable::setColumnReadOnly(1, true); |
402 |
// QTable::setColumnReadOnly(2, true); -- of course not. |
// QTable::setColumnReadOnly(2, true); -- of course not. |
403 |
|
QTable::setColumnStretchable(1, true); |
404 |
} |
} |
405 |
|
|
406 |
// Default destructor. |
// Default destructor. |
409 |
} |
} |
410 |
|
|
411 |
|
|
412 |
// Client/device descriptor selector. |
// The main table refresher. |
413 |
void qsamplerDeviceParamTable::setDevice ( lscp_client_t *pClient, |
void qsamplerDeviceParamTable::refresh ( qsamplerDevice& device ) |
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
|
414 |
{ |
{ |
415 |
if (m_pClient |
// Always (re)start it empty. |
416 |
&& m_pClient == pClient |
QTable::setUpdatesEnabled(false); |
417 |
&& m_deviceType == deviceType |
QTable::setNumRows(0); |
418 |
&& m_iDeviceID == iDeviceID) |
|
419 |
return; |
// Now fill the parameter table... |
420 |
|
qsamplerDeviceParamMap& params = device.params(); |
421 |
m_pClient = pClient; |
QTable::insertRows(0, params.count()); |
422 |
m_deviceType = deviceType; |
int iRow = 0; |
423 |
m_iDeviceID = iDeviceID; |
qsamplerDeviceParamMap::ConstIterator iter; |
424 |
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
425 |
refresh(); |
const qsamplerDeviceParam& param = iter.data(); |
426 |
|
bool bEnabled = (device.deviceID() < 0 || !param.fix); |
427 |
|
QTable::setText(iRow, 0, iter.key()); |
428 |
|
QTable::setText(iRow, 1, param.description); |
429 |
|
if (param.type == LSCP_TYPE_BOOL && bEnabled) { |
430 |
|
QStringList opts; |
431 |
|
opts.append(tr("false")); |
432 |
|
opts.append(tr("true")); |
433 |
|
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
434 |
|
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
435 |
|
pComboItem->setEnabled(bEnabled); |
436 |
|
QTable::setItem(iRow, 2, pComboItem); |
437 |
|
} else if (param.possibilities.count() > 0 && bEnabled) { |
438 |
|
QComboTableItem *pComboItem = new QComboTableItem(this, |
439 |
|
param.possibilities); |
440 |
|
pComboItem->setCurrentItem(param.value); |
441 |
|
pComboItem->setEnabled(bEnabled); |
442 |
|
pComboItem->setEditable(bEnabled && param.multiplicity); |
443 |
|
QTable::setItem(iRow, 2, pComboItem); |
444 |
|
} else if (param.type == LSCP_TYPE_INT && bEnabled |
445 |
|
&& !param.range_min.isEmpty() |
446 |
|
&& !param.range_max.isEmpty()) { |
447 |
|
qsamplerDeviceParamTableSpinBox *pSpinItem = |
448 |
|
new qsamplerDeviceParamTableSpinBox(this, |
449 |
|
bEnabled ? QTableItem::OnTyping : QTableItem::Never, |
450 |
|
param.value); |
451 |
|
pSpinItem->setMinValue(param.range_min.toInt()); |
452 |
|
pSpinItem->setMaxValue(param.range_max.toInt()); |
453 |
|
QTable::setItem(iRow, 2, pSpinItem); |
454 |
|
} else { |
455 |
|
qsamplerDeviceParamTableEditBox *pEditItem = |
456 |
|
new qsamplerDeviceParamTableEditBox(this, |
457 |
|
bEnabled ? QTableItem::OnTyping : QTableItem::Never, |
458 |
|
param.value); |
459 |
|
QTable::setItem(iRow, 2, pEditItem); |
460 |
|
} |
461 |
|
++iRow; |
462 |
|
} |
463 |
|
|
464 |
|
// Adjust optimal column widths. |
465 |
|
QTable::adjustColumn(0); |
466 |
|
QTable::adjustColumn(2); |
467 |
|
|
468 |
|
QTable::setUpdatesEnabled(true); |
469 |
|
QTable::updateContents(); |
470 |
} |
} |
471 |
|
|
472 |
|
|
473 |
// Client/device descriptor accessors. |
//------------------------------------------------------------------------- |
474 |
lscp_client_t *qsamplerDeviceParamTable::client (void) |
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
475 |
|
// |
476 |
|
|
477 |
|
// Constructor. |
478 |
|
qsamplerDeviceParamTableSpinBox::qsamplerDeviceParamTableSpinBox ( |
479 |
|
QTable *pTable, EditType editType, const QString& sText ) |
480 |
|
: QTableItem(pTable, editType, sText) |
481 |
{ |
{ |
482 |
return m_pClient; |
m_iValue = sText.toInt(); |
483 |
|
m_iMinValue = m_iMaxValue = 0; |
484 |
} |
} |
485 |
|
|
486 |
int qsamplerDeviceParamTable::deviceID (void) |
// Public accessors. |
487 |
|
void qsamplerDeviceParamTableSpinBox::setValue ( int iValue ) |
488 |
{ |
{ |
489 |
return m_iDeviceID; |
m_iValue = iValue; |
490 |
|
QTableItem::setText(QString::number(m_iValue)); |
491 |
} |
} |
492 |
|
|
493 |
|
void qsamplerDeviceParamTableSpinBox::setMinValue ( int iMinValue ) |
494 |
|
{ |
495 |
|
m_iMinValue = iMinValue; |
496 |
|
} |
497 |
|
|
498 |
// The main table refresher. |
void qsamplerDeviceParamTableSpinBox::setMaxValue ( int iMaxValue ) |
|
void qsamplerDeviceParamTable::refresh (void) |
|
499 |
{ |
{ |
500 |
// Always (re)start it empty. |
m_iMaxValue = iMaxValue; |
501 |
QTable::setNumRows(0); |
} |
502 |
|
|
503 |
if (m_pClient == NULL) |
// Virtual implemetations. |
504 |
return; |
QWidget *qsamplerDeviceParamTableSpinBox::createEditor (void) const |
505 |
|
{ |
506 |
// Construct the local device object here. |
QSpinBox *pSpinBox = new QSpinBox(QTableItem::table()->viewport()); |
507 |
qsamplerDevice device(m_pClient, m_deviceType, m_iDeviceID); |
QObject::connect(pSpinBox, SIGNAL(valueChanged(int)), |
508 |
|
QTableItem::table(), SLOT(doValueChanged())); |
509 |
|
if (m_iValue >= m_iMinValue && m_iMaxValue >= m_iValue) { |
510 |
|
pSpinBox->setMinValue(m_iMinValue); |
511 |
|
pSpinBox->setMaxValue(m_iMaxValue); |
512 |
|
} |
513 |
|
pSpinBox->setValue(m_iValue); |
514 |
|
return pSpinBox; |
515 |
|
} |
516 |
|
|
517 |
|
void qsamplerDeviceParamTableSpinBox::setContentFromEditor ( QWidget *pWidget ) |
518 |
|
{ |
519 |
|
if (pWidget->inherits("QSpinBox")) |
520 |
|
QTableItem::setText(QString::number(((QSpinBox *) pWidget)->value())); |
521 |
|
else |
522 |
|
QTableItem::setContentFromEditor(pWidget); |
523 |
|
} |
524 |
|
|
|
// Now fill the parameter table... |
|
|
QHeader *pHeader = QTable::verticalHeader(); |
|
|
qsamplerDeviceParamMap& params = device.params(); |
|
|
QTable::insertRows(0, params.count()); |
|
|
int iRow = 0; |
|
|
qsamplerDeviceParamMap::Iterator iter; |
|
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
|
|
QTable::setText(iRow, 0, iter.key()); |
|
|
QTable::setText(iRow, 1, iter.data().description); |
|
|
QTable::setText(iRow, 2, iter.data().value); |
|
|
++iRow; |
|
|
} |
|
525 |
|
|
526 |
// Adjust optimal column width. |
//------------------------------------------------------------------------- |
527 |
for (int iCol = 0; iCol < QTable::numCols(); iCol++) |
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
528 |
QTable::adjustColumn(iCol); |
// |
529 |
|
|
530 |
|
// Constructor. |
531 |
|
qsamplerDeviceParamTableEditBox::qsamplerDeviceParamTableEditBox ( |
532 |
|
QTable *pTable, EditType editType, const QString& sText ) |
533 |
|
: QTableItem(pTable, editType, sText) |
534 |
|
{ |
535 |
|
} |
536 |
|
|
537 |
|
// Virtual implemetations. |
538 |
|
QWidget *qsamplerDeviceParamTableEditBox::createEditor (void) const |
539 |
|
{ |
540 |
|
QLineEdit *pEditBox = new QLineEdit(QTableItem::table()->viewport()); |
541 |
|
QObject::connect(pEditBox, SIGNAL(returnPressed()), |
542 |
|
QTableItem::table(), SLOT(doValueChanged())); |
543 |
|
pEditBox->setText(QTableItem::text()); |
544 |
|
return pEditBox; |
545 |
|
} |
546 |
|
|
547 |
|
void qsamplerDeviceParamTableEditBox::setContentFromEditor ( QWidget *pWidget ) |
548 |
|
{ |
549 |
|
if (pWidget->inherits("QLineEdit")) |
550 |
|
QTableItem::setText(((QLineEdit *) pWidget)->text()); |
551 |
|
else |
552 |
|
QTableItem::setContentFromEditor(pWidget); |
553 |
} |
} |
554 |
|
|
555 |
|
|