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 |
|
|
423 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
424 |
for (iter = params.begin(); iter != params.end(); ++iter) { |
for (iter = params.begin(); iter != params.end(); ++iter) { |
425 |
const qsamplerDeviceParam& param = iter.data(); |
const qsamplerDeviceParam& param = iter.data(); |
426 |
bool fEnabled = (device.deviceID() < 0 || !param.fix); |
bool bEnabled = (device.deviceID() < 0 || !param.fix); |
427 |
QTable::setText(iRow, 0, iter.key()); |
QTable::setText(iRow, 0, iter.key()); |
428 |
QTable::setText(iRow, 1, param.description); |
QTable::setText(iRow, 1, param.description); |
429 |
if (param.type == LSCP_TYPE_BOOL) { |
if (param.type == LSCP_TYPE_BOOL) { |
432 |
opts.append(tr("true")); |
opts.append(tr("true")); |
433 |
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
434 |
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
435 |
pComboItem->setEnabled(fEnabled); |
pComboItem->setEnabled(bEnabled); |
436 |
QTable::setItem(iRow, 2, pComboItem); |
QTable::setItem(iRow, 2, pComboItem); |
437 |
} else if (param.possibilities.count() > 0 && !param.multiplicity) { |
} else if (param.possibilities.count() > 0) { |
438 |
QComboTableItem *pComboItem = new QComboTableItem(this, |
QComboTableItem *pComboItem = new QComboTableItem(this, |
439 |
param.possibilities); |
param.possibilities); |
440 |
pComboItem->setCurrentItem(param.value); |
pComboItem->setCurrentItem(param.value); |
441 |
pComboItem->setEnabled(fEnabled); |
pComboItem->setEnabled(bEnabled); |
442 |
|
pComboItem->setEditable(bEnabled && param.multiplicity); |
443 |
QTable::setItem(iRow, 2, pComboItem); |
QTable::setItem(iRow, 2, pComboItem); |
444 |
|
} else if (param.type == LSCP_TYPE_INT) { |
445 |
|
qsamplerDeviceParamTableSpinBox *pSpinItem = |
446 |
|
new qsamplerDeviceParamTableSpinBox(this, |
447 |
|
bEnabled ? QTableItem::OnTyping : QTableItem::Never); |
448 |
|
pSpinItem->setMinValue(param.range_min.toInt()); |
449 |
|
pSpinItem->setMaxValue(param.range_max.toInt()); |
450 |
|
pSpinItem->setValue(param.value.toInt()); |
451 |
|
QTable::setItem(iRow, 2, pSpinItem); |
452 |
} else { |
} else { |
453 |
QTableItem* pTableItem = new QTableItem(this, |
qsamplerDeviceParamTableEditBox *pEditItem = |
454 |
fEnabled ? QTableItem::OnTyping : QTableItem::Never, |
new qsamplerDeviceParamTableEditBox(this, |
455 |
param.value); |
bEnabled ? QTableItem::OnTyping : QTableItem::Never, |
456 |
QTable::setItem(iRow, 2, pTableItem); |
param.value); |
457 |
|
QTable::setItem(iRow, 2, pEditItem); |
458 |
} |
} |
459 |
++iRow; |
++iRow; |
460 |
} |
} |
468 |
} |
} |
469 |
|
|
470 |
|
|
471 |
|
//------------------------------------------------------------------------- |
472 |
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
473 |
|
// |
474 |
|
|
475 |
|
// Constructor. |
476 |
|
qsamplerDeviceParamTableSpinBox::qsamplerDeviceParamTableSpinBox ( |
477 |
|
QTable *pTable, EditType editType ) |
478 |
|
: QTableItem(pTable, editType, QString::null) |
479 |
|
{ |
480 |
|
m_iValue = m_iMinValue = m_iMaxValue = 0; |
481 |
|
} |
482 |
|
|
483 |
|
// Public accessors. |
484 |
|
void qsamplerDeviceParamTableSpinBox::setValue ( int iValue ) |
485 |
|
{ |
486 |
|
m_iValue = iValue; |
487 |
|
QTableItem::setText(QString::number(m_iValue)); |
488 |
|
} |
489 |
|
|
490 |
|
void qsamplerDeviceParamTableSpinBox::setMinValue ( int iMinValue ) |
491 |
|
{ |
492 |
|
m_iMinValue = iMinValue; |
493 |
|
} |
494 |
|
|
495 |
|
void qsamplerDeviceParamTableSpinBox::setMaxValue ( int iMaxValue ) |
496 |
|
{ |
497 |
|
m_iMaxValue = iMaxValue; |
498 |
|
} |
499 |
|
|
500 |
|
// Virtual implemetations. |
501 |
|
QWidget *qsamplerDeviceParamTableSpinBox::createEditor (void) const |
502 |
|
{ |
503 |
|
QSpinBox *pSpinBox = new QSpinBox(QTableItem::table()->viewport()); |
504 |
|
QObject::connect(pSpinBox, SIGNAL(valueChanged(int)), |
505 |
|
QTableItem::table(), SLOT(doValueChanged())); |
506 |
|
if (m_iValue >= m_iMinValue && m_iMaxValue >= m_iValue) { |
507 |
|
pSpinBox->setMinValue(m_iMinValue); |
508 |
|
pSpinBox->setMaxValue(m_iMaxValue); |
509 |
|
} |
510 |
|
pSpinBox->setValue(m_iValue); |
511 |
|
// pSpinBox->setEnabled(QTableItem::isEnabled()); |
512 |
|
return pSpinBox; |
513 |
|
} |
514 |
|
|
515 |
|
void qsamplerDeviceParamTableSpinBox::setContentFromEditor ( QWidget *pWidget ) |
516 |
|
{ |
517 |
|
if (pWidget->inherits("QSpinBox")) |
518 |
|
QTableItem::setText(QString::number(((QSpinBox *) pWidget)->value())); |
519 |
|
else |
520 |
|
QTableItem::setContentFromEditor(pWidget); |
521 |
|
} |
522 |
|
|
523 |
|
|
524 |
|
//------------------------------------------------------------------------- |
525 |
|
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
526 |
|
// |
527 |
|
|
528 |
|
// Constructor. |
529 |
|
qsamplerDeviceParamTableEditBox::qsamplerDeviceParamTableEditBox ( |
530 |
|
QTable *pTable, EditType editType, const QString& sText ) |
531 |
|
: QTableItem(pTable, editType, sText) |
532 |
|
{ |
533 |
|
} |
534 |
|
|
535 |
|
// Virtual implemetations. |
536 |
|
QWidget *qsamplerDeviceParamTableEditBox::createEditor (void) const |
537 |
|
{ |
538 |
|
QLineEdit *pEditBox = new QLineEdit(QTableItem::table()->viewport()); |
539 |
|
QObject::connect(pEditBox, SIGNAL(returnPressed()), |
540 |
|
QTableItem::table(), SLOT(doValueChanged())); |
541 |
|
pEditBox->setText(QTableItem::text()); |
542 |
|
// pEditBox->setEnabled(QTableItem::isEnabled()); |
543 |
|
return pEditBox; |
544 |
|
} |
545 |
|
|
546 |
|
void qsamplerDeviceParamTableEditBox::setContentFromEditor ( QWidget *pWidget ) |
547 |
|
{ |
548 |
|
if (pWidget->inherits("QLineEdit")) |
549 |
|
QTableItem::setText(((QLineEdit *) pWidget)->text()); |
550 |
|
else |
551 |
|
QTableItem::setContentFromEditor(pWidget); |
552 |
|
} |
553 |
|
|
554 |
|
|
555 |
// end of qsamplerDevice.cpp |
// end of qsamplerDevice.cpp |