1 |
// qsamplerDevice.cpp |
// qsamplerDevice.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 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 |
45 |
} |
} |
46 |
|
|
47 |
|
|
|
// Default destructor. |
|
|
DeviceParam::~DeviceParam (void) |
|
|
{ |
|
|
} |
|
|
|
|
|
|
|
48 |
// Initializer. |
// Initializer. |
49 |
void DeviceParam::setParam ( lscp_param_info_t *pParamInfo, |
void DeviceParam::setParam ( lscp_param_info_t *pParamInfo, |
50 |
const char *pszValue ) |
const char *pszValue ) |
59 |
if (pParamInfo->description) |
if (pParamInfo->description) |
60 |
description = pParamInfo->description; |
description = pParamInfo->description; |
61 |
else |
else |
62 |
description = QString::null; |
description.clear(); |
63 |
|
|
64 |
mandatory = (bool) pParamInfo->mandatory; |
mandatory = bool(pParamInfo->mandatory); |
65 |
fix = (bool) pParamInfo->fix; |
fix = bool(pParamInfo->fix); |
66 |
multiplicity = (bool) pParamInfo->multiplicity; |
multiplicity = bool(pParamInfo->multiplicity); |
67 |
|
|
68 |
depends.clear(); |
depends.clear(); |
69 |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
72 |
if (pParamInfo->defaultv) |
if (pParamInfo->defaultv) |
73 |
defaultv = pParamInfo->defaultv; |
defaultv = pParamInfo->defaultv; |
74 |
else |
else |
75 |
defaultv = QString::null; |
defaultv.clear(); |
76 |
|
|
77 |
if (pParamInfo->range_min) |
if (pParamInfo->range_min) |
78 |
range_min = pParamInfo->range_min; |
range_min = pParamInfo->range_min; |
79 |
else |
else |
80 |
range_min = QString::null; |
range_min.clear(); |
81 |
|
|
82 |
if (pParamInfo->range_max) |
if (pParamInfo->range_max) |
83 |
range_max = pParamInfo->range_max; |
range_max = pParamInfo->range_max; |
84 |
else |
else |
85 |
range_max = QString::null; |
range_max.clear(); |
86 |
|
|
87 |
possibilities.clear(); |
possibilities.clear(); |
88 |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
92 |
if (pszValue) |
if (pszValue) |
93 |
value = pszValue; |
value = pszValue; |
94 |
else |
else |
95 |
value = QString::null; |
value.clear(); |
96 |
} |
} |
97 |
|
|
98 |
|
|
161 |
appendMessagesClient("lscp_get_midi_device_info"); |
appendMessagesClient("lscp_get_midi_device_info"); |
162 |
break; |
break; |
163 |
case Device::None: |
case Device::None: |
164 |
m_sDeviceType = QString::null; |
m_sDeviceType.clear(); |
165 |
break; |
break; |
166 |
} |
} |
167 |
// If we're bogus, bail out... |
// If we're bogus, bail out... |
168 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
169 |
m_sDriverName = QString::null; |
m_sDriverName.clear(); |
170 |
m_sDeviceName = QObject::tr("New %1 device").arg(m_sDeviceType); |
m_sDeviceName = QObject::tr("New %1 device").arg(m_sDeviceType); |
171 |
return; |
return; |
172 |
} |
} |
330 |
|
|
331 |
// If the device already exists, things get immediate... |
// If the device already exists, things get immediate... |
332 |
int iRefresh = 0; |
int iRefresh = 0; |
333 |
if (m_iDeviceID >= 0 && sValue != QString::null) { |
if (m_iDeviceID >= 0 && !sValue.isEmpty()) { |
334 |
|
|
335 |
// we need temporary byte arrrays with the final strings, because |
// we need temporary byte arrrays with the final strings, because |
336 |
// i.e. QString::toUtf8() only returns a temporary object and the |
// i.e. QString::toUtf8() only returns a temporary object and the |
410 |
|
|
411 |
DeviceParamMap::ConstIterator iter; |
DeviceParamMap::ConstIterator iter; |
412 |
for (iter = m_params.begin(); iter != m_params.end(); ++iter) { |
for (iter = m_params.begin(); iter != m_params.end(); ++iter) { |
413 |
if (iter.value().value == QString::null) continue; |
if (iter.value().value.isEmpty()) continue; |
414 |
finalKeys.push_back(iter.key().toUtf8()); |
finalKeys.push_back(iter.key().toUtf8()); |
415 |
finalVals.push_back(iter.value().value.toUtf8()); |
finalVals.push_back(iter.value().value.toUtf8()); |
416 |
} |
} |
445 |
} |
} |
446 |
|
|
447 |
// Free used parameter array. |
// Free used parameter array. |
448 |
delete pParams; |
delete[] pParams; |
449 |
|
|
450 |
// Show result. |
// Show result. |
451 |
if (m_iDeviceID >= 0) { |
if (m_iDeviceID >= 0) { |
633 |
} |
} |
634 |
|
|
635 |
// Free used parameter array. |
// Free used parameter array. |
636 |
delete pDepends; |
delete[] pDepends; |
637 |
|
|
638 |
// Return whether the parameters has been changed... |
// Return whether the parameters has been changed... |
639 |
return iRefresh; |
return iRefresh; |
784 |
|
|
785 |
// If we're bogus, bail out... |
// If we're bogus, bail out... |
786 |
if (pPortInfo == NULL) { |
if (pPortInfo == NULL) { |
787 |
m_sPortName = QString::null; |
m_sPortName.clear(); |
788 |
return; |
return; |
789 |
} |
} |
790 |
|
|
1165 |
Qt::DisplayRole).value<DeviceParameterRow>(); |
Qt::DisplayRole).value<DeviceParameterRow>(); |
1166 |
|
|
1167 |
const bool bEnabled = (r.alive) ? !r.param.fix : true; |
const bool bEnabled = (r.alive) ? !r.param.fix : true; |
1168 |
|
const bool bFix = r.param.fix; |
1169 |
|
|
1170 |
QString val = (r.alive) ? r.param.value : r.param.defaultv; |
QString val = (r.alive) ? r.param.value : r.param.defaultv; |
1171 |
|
|
1175 |
case 1: { |
case 1: { |
1176 |
if (r.param.type == LSCP_TYPE_BOOL) { |
if (r.param.type == LSCP_TYPE_BOOL) { |
1177 |
QCheckBox *pCheckBox = new QCheckBox(pParent); |
QCheckBox *pCheckBox = new QCheckBox(pParent); |
1178 |
if (val != QString::null) |
if (!val.isEmpty()) |
1179 |
pCheckBox->setChecked(val.toLower() == "true"); |
pCheckBox->setChecked(val.toLower() == "true"); |
1180 |
pCheckBox->setEnabled(bEnabled); |
pCheckBox->setEnabled(bEnabled); |
1181 |
|
pCheckBox->setCheckable(!bFix); |
1182 |
return pCheckBox; |
return pCheckBox; |
1183 |
} else if (r.param.possibilities.count() > 0) { |
} else if (r.param.possibilities.count() > 0) { |
1184 |
QStringList opts = r.param.possibilities; |
QStringList opts = r.param.possibilities; |
1191 |
else |
else |
1192 |
pComboBox->setCurrentIndex(pComboBox->findText(val)); |
pComboBox->setCurrentIndex(pComboBox->findText(val)); |
1193 |
pComboBox->setEnabled(bEnabled); |
pComboBox->setEnabled(bEnabled); |
1194 |
|
pComboBox->setEditable(!bFix); |
1195 |
return pComboBox; |
return pComboBox; |
1196 |
} else if (r.param.type == LSCP_TYPE_INT && bEnabled) { |
} else if (r.param.type == LSCP_TYPE_INT && bEnabled) { |
1197 |
QSpinBox *pSpinBox = new QSpinBox(pParent); |
QSpinBox *pSpinBox = new QSpinBox(pParent); |
1204 |
r.param.range_max.toInt() : (1 << 24) // or better a higher default max value ? |
r.param.range_max.toInt() : (1 << 24) // or better a higher default max value ? |
1205 |
); |
); |
1206 |
pSpinBox->setValue(val.toInt()); |
pSpinBox->setValue(val.toInt()); |
1207 |
|
pSpinBox->setReadOnly(bFix); |
1208 |
return pSpinBox; |
return pSpinBox; |
1209 |
} else if (bEnabled) { |
} else if (bEnabled) { |
1210 |
QLineEdit *pLineEdit = new QLineEdit(val, pParent); |
QLineEdit *pLineEdit = new QLineEdit(val, pParent); |
1211 |
|
pLineEdit->setReadOnly(bFix); |
1212 |
return pLineEdit; |
return pLineEdit; |
1213 |
} else { |
} else { |
1214 |
QLabel *pLabel = new QLabel(val, pParent); |
QLabel *pLabel = new QLabel(val, pParent); |