107 |
// |
// |
108 |
|
|
109 |
// Constructor. |
// Constructor. |
110 |
qsamplerDevice::qsamplerDevice ( qsamplerDeviceType deviceType, int iDeviceID ) |
qsamplerDevice::qsamplerDevice ( DeviceType deviceType, int iDeviceID ) |
111 |
{ |
{ |
112 |
// m_ports.setAutoDelete(true); |
// m_ports.setAutoDelete(true); |
113 |
|
|
134 |
|
|
135 |
|
|
136 |
// Initializer. |
// Initializer. |
137 |
void qsamplerDevice::setDevice ( qsamplerDeviceType deviceType, int iDeviceID ) |
void qsamplerDevice::setDevice ( DeviceType deviceType, int iDeviceID ) |
138 |
{ |
{ |
139 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
140 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
296 |
return m_iDeviceID; |
return m_iDeviceID; |
297 |
} |
} |
298 |
|
|
299 |
qsamplerDevice::qsamplerDeviceType qsamplerDevice::deviceType (void) const |
qsamplerDevice::DeviceType qsamplerDevice::deviceType (void) const |
300 |
{ |
{ |
301 |
return m_deviceType; |
return m_deviceType; |
302 |
} |
} |
316 |
{ |
{ |
317 |
QString sPrefix; |
QString sPrefix; |
318 |
if (m_iDeviceID >= 0) |
if (m_iDeviceID >= 0) |
319 |
sPrefix += m_sDeviceType + ' '; |
sPrefix += m_sDeviceType + ' '; |
320 |
return sPrefix + m_sDeviceName; |
return sPrefix + m_sDeviceName; |
321 |
} |
} |
322 |
|
|
352 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
353 |
switch (m_deviceType) { |
switch (m_deviceType) { |
354 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
355 |
if (sParam == "CHANNELS") iRefresh++; |
if (sParam == "CHANNELS") iRefresh++; |
356 |
if ((ret = ::lscp_set_audio_device_param(pMainForm->client(), |
if ((ret = ::lscp_set_audio_device_param(pMainForm->client(), |
357 |
m_iDeviceID, ¶m)) != LSCP_OK) |
m_iDeviceID, ¶m)) != LSCP_OK) |
358 |
appendMessagesClient("lscp_set_audio_device_param"); |
appendMessagesClient("lscp_set_audio_device_param"); |
359 |
break; |
break; |
360 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
361 |
if (sParam == "PORTS") iRefresh++; |
if (sParam == "PORTS") iRefresh++; |
362 |
if ((ret = ::lscp_set_midi_device_param(pMainForm->client(), |
if ((ret = ::lscp_set_midi_device_param(pMainForm->client(), |
363 |
m_iDeviceID, ¶m)) != LSCP_OK) |
m_iDeviceID, ¶m)) != LSCP_OK) |
364 |
appendMessagesClient("lscp_set_midi_device_param"); |
appendMessagesClient("lscp_set_midi_device_param"); |
511 |
{ |
{ |
512 |
// This should only make sense for scratch devices... |
// This should only make sense for scratch devices... |
513 |
if (m_iDeviceID >= 0) |
if (m_iDeviceID >= 0) |
514 |
return 0; |
return 0; |
515 |
// Refresh all parameters that have dependencies... |
// Refresh all parameters that have dependencies... |
516 |
int iParams = 0; |
int iParams = 0; |
517 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
527 |
{ |
{ |
528 |
// This should only make sense for actual devices... |
// This should only make sense for actual devices... |
529 |
if (m_iDeviceID < 0) |
if (m_iDeviceID < 0) |
530 |
return 0; |
return 0; |
531 |
// Port/channel count determination... |
// Port/channel count determination... |
532 |
int iPorts = 0; |
int iPorts = 0; |
533 |
switch (m_deviceType) { |
switch (m_deviceType) { |
555 |
{ |
{ |
556 |
// This should only make sense for scratch devices... |
// This should only make sense for scratch devices... |
557 |
if (m_iDeviceID >= 0) |
if (m_iDeviceID >= 0) |
558 |
return 0; |
return 0; |
559 |
// Refresh all parameters that depend on this one... |
// Refresh all parameters that depend on this one... |
560 |
int iDepends = 0; |
int iDepends = 0; |
561 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
686 |
|
|
687 |
// Device ids enumerator. |
// Device ids enumerator. |
688 |
int *qsamplerDevice::getDevices ( lscp_client_t *pClient, |
int *qsamplerDevice::getDevices ( lscp_client_t *pClient, |
689 |
qsamplerDeviceType deviceType ) |
DeviceType deviceType ) |
690 |
{ |
{ |
691 |
int *piDeviceIDs = NULL; |
int *piDeviceIDs = NULL; |
692 |
switch (deviceType) { |
switch (deviceType) { |
705 |
|
|
706 |
// Driver names enumerator. |
// Driver names enumerator. |
707 |
QStringList qsamplerDevice::getDrivers ( lscp_client_t *pClient, |
QStringList qsamplerDevice::getDrivers ( lscp_client_t *pClient, |
708 |
qsamplerDeviceType deviceType ) |
DeviceType deviceType ) |
709 |
{ |
{ |
710 |
QStringList drivers; |
QStringList drivers; |
711 |
|
|
899 |
|
|
900 |
// Constructors. |
// Constructors. |
901 |
qsamplerDeviceItem::qsamplerDeviceItem ( QTreeWidget* pTreeWidget, |
qsamplerDeviceItem::qsamplerDeviceItem ( QTreeWidget* pTreeWidget, |
902 |
qsamplerDevice::qsamplerDeviceType deviceType ) |
qsamplerDevice::DeviceType deviceType ) |
903 |
: QTreeWidgetItem(pTreeWidget, QSAMPLER_DEVICE_ITEM), |
: QTreeWidgetItem(pTreeWidget, QSAMPLER_DEVICE_ITEM), |
904 |
m_device(deviceType) |
m_device(deviceType) |
905 |
{ |
{ |
906 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
907 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
918 |
} |
} |
919 |
|
|
920 |
qsamplerDeviceItem::qsamplerDeviceItem ( QTreeWidgetItem* pItem, |
qsamplerDeviceItem::qsamplerDeviceItem ( QTreeWidgetItem* pItem, |
921 |
qsamplerDevice::qsamplerDeviceType deviceType, |
qsamplerDevice::DeviceType deviceType, |
922 |
int iDeviceID ) |
int iDeviceID ) |
923 |
: QTreeWidgetItem(pItem, QSAMPLER_DEVICE_ITEM), |
: QTreeWidgetItem(pItem, QSAMPLER_DEVICE_ITEM), |
924 |
m_device(deviceType, iDeviceID) |
m_device(deviceType, iDeviceID) |
925 |
{ |
{ |
926 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
927 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
953 |
// AbstractDeviceParamModel - data model base class for device parameters |
// AbstractDeviceParamModel - data model base class for device parameters |
954 |
// |
// |
955 |
|
|
956 |
AbstractDeviceParamModel::AbstractDeviceParamModel(QObject* parent) : QAbstractTableModel(parent), bEditable(false) { |
AbstractDeviceParamModel::AbstractDeviceParamModel ( QObject* pParent ) |
957 |
params = NULL; |
: QAbstractTableModel(pParent), m_bEditable(false) |
958 |
|
{ |
959 |
|
m_params = NULL; |
960 |
} |
} |
961 |
|
|
962 |
int AbstractDeviceParamModel::rowCount(const QModelIndex& /*parent*/) const { |
|
963 |
//std::cout << "model size=" << params.size() << "\n" << std::flush; |
int AbstractDeviceParamModel::rowCount ( const QModelIndex& /*parent*/) const |
964 |
return (params) ? params->size() : 0; |
{ |
965 |
|
//std::cout << "model size=" << params.size() << "\n" << std::flush; |
966 |
|
return (m_params) ? m_params->size() : 0; |
967 |
} |
} |
968 |
|
|
969 |
int AbstractDeviceParamModel::columnCount(const QModelIndex& /*parent*/) const { |
|
970 |
return 3; |
int AbstractDeviceParamModel::columnCount ( const QModelIndex& /*parent*/) const |
971 |
|
{ |
972 |
|
return 3; |
973 |
} |
} |
974 |
|
|
975 |
Qt::ItemFlags AbstractDeviceParamModel::flags(const QModelIndex& /*index*/) const { |
|
976 |
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
Qt::ItemFlags AbstractDeviceParamModel::flags ( const QModelIndex& /*index*/) const |
977 |
|
{ |
978 |
|
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
979 |
} |
} |
980 |
|
|
|
QVariant AbstractDeviceParamModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|
|
if (role != Qt::DisplayRole) return QVariant(); |
|
981 |
|
|
982 |
if (orientation == Qt::Horizontal) { |
QVariant AbstractDeviceParamModel::headerData ( |
983 |
switch (section) { |
int section, Qt::Orientation orientation, int role) const |
984 |
case 0: return tr("Parameter"); |
{ |
985 |
case 1: return tr("Value"); |
if (role != Qt::DisplayRole) |
986 |
case 2: return tr("Description"); |
return QVariant(); |
987 |
default: return QVariant(); |
|
988 |
} |
if (orientation == Qt::Horizontal) { |
989 |
} |
switch (section) { |
990 |
|
case 0: return tr("Parameter"); |
991 |
|
case 1: return tr("Value"); |
992 |
|
case 2: return tr("Description"); |
993 |
|
default: return QVariant(); |
994 |
|
} |
995 |
|
} |
996 |
|
|
997 |
return QVariant(); |
return QVariant(); |
998 |
} |
} |
999 |
|
|
1000 |
void AbstractDeviceParamModel::refresh(const qsamplerDeviceParamMap* params, bool bEditable) { |
|
1001 |
this->params = params; |
void AbstractDeviceParamModel::refresh ( |
1002 |
this->bEditable = bEditable; |
const qsamplerDeviceParamMap* params, bool bEditable ) |
1003 |
// inform the outer world (QTableView) that our data changed |
{ |
1004 |
QAbstractTableModel::reset(); |
m_params = params; |
1005 |
|
m_bEditable = bEditable; |
1006 |
|
// inform the outer world (QTableView) that our data changed |
1007 |
|
QAbstractTableModel::reset(); |
1008 |
} |
} |
1009 |
|
|
1010 |
void AbstractDeviceParamModel::clear() { |
|
1011 |
params = NULL; |
void AbstractDeviceParamModel::clear (void) |
1012 |
// inform the outer world (QTableView) that our data changed |
{ |
1013 |
QAbstractTableModel::reset(); |
m_params = NULL; |
1014 |
|
// inform the outer world (QTableView) that our data changed |
1015 |
|
QAbstractTableModel::reset(); |
1016 |
} |
} |
1017 |
|
|
1018 |
|
|
1020 |
// DeviceParamModel - data model for device parameters (used for QTableView) |
// DeviceParamModel - data model for device parameters (used for QTableView) |
1021 |
// |
// |
1022 |
|
|
1023 |
DeviceParamModel::DeviceParamModel(QObject* parent) : AbstractDeviceParamModel(parent) { |
DeviceParamModel::DeviceParamModel ( QObject *pParent ) |
1024 |
device = NULL; |
: AbstractDeviceParamModel(pParent) |
1025 |
|
{ |
1026 |
|
m_device = NULL; |
1027 |
} |
} |
1028 |
|
|
1029 |
QVariant DeviceParamModel::data(const QModelIndex &index, int role) const { |
QVariant DeviceParamModel::data ( |
1030 |
if (!index.isValid()) { |
const QModelIndex &index, int role) const |
1031 |
//std::cout << "inavlid device model index\n" << std::flush; |
{ |
1032 |
return QVariant(); |
if (!index.isValid()) |
1033 |
} |
return QVariant(); |
1034 |
if (role != Qt::DisplayRole) { |
|
1035 |
//std::cout << "inavlid display role\n" << std::flush; |
if (role != Qt::DisplayRole) |
1036 |
return QVariant(); |
return QVariant(); |
1037 |
} |
|
1038 |
|
DeviceParameterRow item; |
1039 |
DeviceParameterRow item; |
item.name = m_params->keys()[index.row()]; |
1040 |
item.name = params->keys()[index.row()]; |
item.param = (*m_params)[item.name]; |
1041 |
item.param = (*params)[item.name]; |
item.alive = m_device != NULL && m_device->deviceID() >= 0; |
1042 |
item.alive = device != NULL && device->deviceID() >= 0; |
|
1043 |
|
return QVariant::fromValue(item); |
1044 |
return QVariant::fromValue(item); |
} |
1045 |
} |
|
1046 |
|
|
1047 |
bool DeviceParamModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/) { |
bool DeviceParamModel::setData ( |
1048 |
if (!index.isValid()) { |
const QModelIndex& index, const QVariant& value, int /*role*/) |
1049 |
return false; |
{ |
1050 |
} |
if (!index.isValid()) |
1051 |
QString key = params->keys()[index.row()]; |
return false; |
1052 |
//params[key].value = value.toString(); |
|
1053 |
device->setParam(key, value.toString()); |
QString key = m_params->keys()[index.row()]; |
1054 |
emit dataChanged(index, index); |
//m_params[key].value = value.toString(); |
1055 |
return true; |
m_device->setParam(key, value.toString()); |
1056 |
} |
emit dataChanged(index, index); |
1057 |
|
return true; |
1058 |
void DeviceParamModel::refresh(qsamplerDevice* pDevice, bool bEditable) { |
} |
1059 |
device = pDevice; |
|
1060 |
AbstractDeviceParamModel::refresh(&pDevice->params(), bEditable); |
|
1061 |
} |
void DeviceParamModel::refresh ( qsamplerDevice* pDevice, bool bEditable ) |
1062 |
|
{ |
1063 |
void DeviceParamModel::clear() { |
m_device = pDevice; |
1064 |
AbstractDeviceParamModel::clear(); |
AbstractDeviceParamModel::refresh(&pDevice->params(), bEditable); |
1065 |
device = NULL; |
} |
1066 |
|
|
1067 |
|
|
1068 |
|
void DeviceParamModel::clear (void) |
1069 |
|
{ |
1070 |
|
AbstractDeviceParamModel::clear(); |
1071 |
|
m_device = NULL; |
1072 |
} |
} |
1073 |
|
|
1074 |
|
|
1076 |
// PortParamModel - data model for port parameters (used for QTableView) |
// PortParamModel - data model for port parameters (used for QTableView) |
1077 |
// |
// |
1078 |
|
|
1079 |
PortParamModel::PortParamModel(QObject* parent) : AbstractDeviceParamModel(parent) { |
PortParamModel::PortParamModel ( QObject *pParent) |
1080 |
port = NULL; |
: AbstractDeviceParamModel(pParent) |
1081 |
|
{ |
1082 |
|
m_port = NULL; |
1083 |
|
} |
1084 |
|
|
1085 |
|
QVariant PortParamModel::data ( const QModelIndex &index, int role ) const |
1086 |
|
{ |
1087 |
|
if (!index.isValid()) |
1088 |
|
return QVariant(); |
1089 |
|
|
1090 |
|
if (role != Qt::DisplayRole) |
1091 |
|
return QVariant(); |
1092 |
|
|
1093 |
|
DeviceParameterRow item; |
1094 |
|
item.name = m_params->keys()[index.row()]; |
1095 |
|
item.param = (*m_params)[item.name]; |
1096 |
|
item.alive = m_port != NULL && m_port->portID() >= 0; |
1097 |
|
|
1098 |
|
return QVariant::fromValue(item); |
1099 |
|
} |
1100 |
|
|
1101 |
|
|
1102 |
|
bool PortParamModel::setData ( |
1103 |
|
const QModelIndex& index, const QVariant& value, int /*role*/) |
1104 |
|
{ |
1105 |
|
if (!index.isValid()) |
1106 |
|
return false; |
1107 |
|
|
1108 |
|
QString key = m_params->keys()[index.row()]; |
1109 |
|
//params[key].value = value.toString(); |
1110 |
|
m_port->setParam(key, value.toString()); |
1111 |
|
emit dataChanged(index, index); |
1112 |
|
return true; |
1113 |
|
} |
1114 |
|
|
1115 |
|
|
1116 |
|
void PortParamModel::refresh ( qsamplerDevicePort* pPort, bool bEditable ) |
1117 |
|
{ |
1118 |
|
m_port = pPort; |
1119 |
|
AbstractDeviceParamModel::refresh(&m_port->params(), bEditable); |
1120 |
} |
} |
1121 |
|
|
1122 |
QVariant PortParamModel::data(const QModelIndex &index, int role) const { |
|
1123 |
if (!index.isValid()) { |
void PortParamModel::clear (void) |
1124 |
//std::cout << "inavlid device model index\n" << std::flush; |
{ |
1125 |
return QVariant(); |
AbstractDeviceParamModel::clear(); |
1126 |
} |
m_port = NULL; |
|
if (role != Qt::DisplayRole) { |
|
|
//std::cout << "inavlid display role\n" << std::flush; |
|
|
return QVariant(); |
|
|
} |
|
|
|
|
|
DeviceParameterRow item; |
|
|
item.name = params->keys()[index.row()]; |
|
|
item.param = (*params)[item.name]; |
|
|
item.alive = port != NULL && port->portID() >= 0; |
|
|
|
|
|
return QVariant::fromValue(item); |
|
|
} |
|
|
|
|
|
bool PortParamModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/) { |
|
|
if (!index.isValid()) { |
|
|
return false; |
|
|
} |
|
|
QString key = params->keys()[index.row()]; |
|
|
//params[key].value = value.toString(); |
|
|
port->setParam(key, value.toString()); |
|
|
emit dataChanged(index, index); |
|
|
return true; |
|
|
} |
|
|
|
|
|
void PortParamModel::refresh(qsamplerDevicePort* pPort, bool bEditable) { |
|
|
port = pPort; |
|
|
AbstractDeviceParamModel::refresh(&pPort->params(), bEditable); |
|
|
} |
|
|
|
|
|
void PortParamModel::clear() { |
|
|
AbstractDeviceParamModel::clear(); |
|
|
port = NULL; |
|
1127 |
} |
} |
1128 |
|
|
1129 |
|
|
1131 |
// DeviceParamDelegate - table cell renderer for device/port parameters |
// DeviceParamDelegate - table cell renderer for device/port parameters |
1132 |
// |
// |
1133 |
|
|
1134 |
DeviceParamDelegate::DeviceParamDelegate(QObject *parent) : QItemDelegate(parent) { |
DeviceParamDelegate::DeviceParamDelegate ( QObject *pParent) |
1135 |
|
: QItemDelegate(pParent) |
1136 |
|
{ |
1137 |
} |
} |
1138 |
|
|
1139 |
QWidget* DeviceParamDelegate::createEditor(QWidget *parent, |
|
1140 |
const QStyleOptionViewItem &/* option */, |
QWidget* DeviceParamDelegate::createEditor ( QWidget *pParent, |
1141 |
const QModelIndex& index) const |
const QStyleOptionViewItem& /* option */, const QModelIndex& index ) const |
1142 |
{ |
{ |
1143 |
if (!index.isValid()) { |
if (!index.isValid()) |
1144 |
return NULL; |
return NULL; |
1145 |
} |
|
1146 |
|
DeviceParameterRow r = index.model()->data(index, |
1147 |
DeviceParameterRow r = index.model()->data(index, Qt::DisplayRole).value<DeviceParameterRow>(); |
Qt::DisplayRole).value<DeviceParameterRow>(); |
1148 |
|
|
1149 |
const bool bEnabled = (r.alive) ? !r.param.fix : true; |
const bool bEnabled = (r.alive) ? !r.param.fix : true; |
1150 |
|
|
1151 |
QString val = (r.alive) ? r.param.value : r.param.defaultv; |
QString val = (r.alive) ? r.param.value : r.param.defaultv; |
1152 |
|
|
1153 |
switch (index.column()) { |
switch (index.column()) { |
1154 |
case 0: |
case 0: |
1155 |
return new QLabel(r.name, parent); |
return new QLabel(r.name, pParent); |
1156 |
case 1: { |
case 1: { |
1157 |
if (r.param.type == LSCP_TYPE_BOOL) { |
if (r.param.type == LSCP_TYPE_BOOL) { |
1158 |
QCheckBox* pCheckBox = new QCheckBox(parent); |
QCheckBox* pCheckBox = new QCheckBox(pParent); |
1159 |
if (val != QString::null) |
if (val != QString::null) |
1160 |
pCheckBox->setChecked(val.toLower() == "true"); |
pCheckBox->setChecked(val.toLower() == "true"); |
1161 |
pCheckBox->setEnabled(bEnabled); |
pCheckBox->setEnabled(bEnabled); |
1162 |
return pCheckBox; |
return pCheckBox; |
1163 |
} else if (r.param.possibilities.count() > 0) { |
} else if (r.param.possibilities.count() > 0) { |
1164 |
QStringList opts = r.param.possibilities; |
QStringList opts = r.param.possibilities; |
1165 |
if (r.param.multiplicity) |
if (r.param.multiplicity) |
1166 |
opts.prepend(tr("(none)")); |
opts.prepend(tr("(none)")); |
1167 |
QComboBox* pComboBox = new QComboBox(parent); |
QComboBox* pComboBox = new QComboBox(pParent); |
1168 |
pComboBox->addItems(opts); |
pComboBox->addItems(opts); |
1169 |
if (r.param.value.isEmpty()) |
if (r.param.value.isEmpty()) |
1170 |
pComboBox->setCurrentIndex(0); |
pComboBox->setCurrentIndex(0); |
1171 |
else |
else |
1172 |
pComboBox->setCurrentIndex(pComboBox->findText(val)); |
pComboBox->setCurrentIndex(pComboBox->findText(val)); |
1173 |
pComboBox->setEnabled(bEnabled); |
pComboBox->setEnabled(bEnabled); |
1174 |
return pComboBox; |
return pComboBox; |
1175 |
} else if (r.param.type == LSCP_TYPE_INT && bEnabled) { |
} else if (r.param.type == LSCP_TYPE_INT && bEnabled) { |
1176 |
QSpinBox* pSpinBox = new QSpinBox(parent); |
QSpinBox* pSpinBox = new QSpinBox(pParent); |
1177 |
pSpinBox->setMinimum( |
pSpinBox->setMinimum( |
1178 |
(!r.param.range_min.isEmpty()) ? |
(!r.param.range_min.isEmpty()) ? |
1179 |
r.param.range_min.toInt() : 0 // or better a negative default min value ? |
r.param.range_min.toInt() : 0 // or better a negative default min value ? |
1180 |
); |
); |
1181 |
pSpinBox->setMaximum( |
pSpinBox->setMaximum( |
1182 |
(!r.param.range_max.isEmpty()) ? |
(!r.param.range_max.isEmpty()) ? |
1183 |
r.param.range_max.toInt() : (1 << 16) // or better a nigher default max value ? |
r.param.range_max.toInt() : (1 << 16) // or better a nigher default max value ? |
1184 |
); |
); |
1185 |
pSpinBox->setValue(val.toInt()); |
pSpinBox->setValue(val.toInt()); |
1186 |
return pSpinBox; |
return pSpinBox; |
1187 |
} else if (bEnabled) { |
} else if (bEnabled) { |
1188 |
QLineEdit* pLineEdit = new QLineEdit(val, parent); |
QLineEdit* pLineEdit = new QLineEdit(val, pParent); |
1189 |
return pLineEdit; |
return pLineEdit; |
1190 |
} else { |
} else { |
1191 |
QLabel* pLabel = new QLabel(val, parent); |
QLabel* pLabel = new QLabel(val, pParent); |
1192 |
return pLabel; |
return pLabel; |
1193 |
} |
} |
1194 |
} |
} |
1195 |
case 2: |
case 2: |
1196 |
return new QLabel(r.param.description, parent); |
return new QLabel(r.param.description, pParent); |
1197 |
default: |
default: |
1198 |
return NULL; |
return NULL; |
1199 |
} |
} |
1200 |
} |
} |
1201 |
|
|
1202 |
void DeviceParamDelegate::setEditorData(QWidget* /*editor*/, const QModelIndex& /*index*/) const { |
|
1203 |
// unused, since we set the editor data already in createEditor() |
void DeviceParamDelegate::setEditorData ( |
1204 |
} |
QWidget* /*pEditor*/, const QModelIndex& /*index*/) const |
1205 |
|
{ |
1206 |
void DeviceParamDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { |
// Unused, since we set the editor data already in createEditor() |
1207 |
if (index.column() == 1) { |
} |
1208 |
DeviceParameterRow r = index.model()->data(index, Qt::DisplayRole).value<DeviceParameterRow>(); |
|
1209 |
if (editor->metaObject()->className() == "QCheckBox") { |
|
1210 |
QCheckBox* pCheckBox = static_cast<QCheckBox*>(editor); |
void DeviceParamDelegate::setModelData ( QWidget *pEditor, |
1211 |
model->setData(index, QVariant(pCheckBox->checkState() == Qt::Checked)); |
QAbstractItemModel *model, const QModelIndex& index ) const |
1212 |
} else if (editor->metaObject()->className() == "QComboBox") { |
{ |
1213 |
QComboBox* pComboBox = static_cast<QComboBox*>(editor); |
if (index.column() == 1) { |
1214 |
model->setData(index, pComboBox->currentText()); |
DeviceParameterRow r = index.model()->data(index, |
1215 |
} else if (editor->metaObject()->className() == "QSpinBox") { |
Qt::DisplayRole).value<DeviceParameterRow> (); |
1216 |
QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); |
if (pEditor->metaObject()->className() == "QCheckBox") { |
1217 |
model->setData(index, pSpinBox->value()); |
QCheckBox* pCheckBox = static_cast<QCheckBox*> (pEditor); |
1218 |
} else if (editor->metaObject()->className() == "QLineEdit") { |
model->setData(index, QVariant(pCheckBox->checkState() == Qt::Checked)); |
1219 |
QLineEdit* pLineEdit = static_cast<QLineEdit*>(editor); |
} else if (pEditor->metaObject()->className() == "QComboBox") { |
1220 |
model->setData(index, pLineEdit->text()); |
QComboBox* pComboBox = static_cast<QComboBox*> (pEditor); |
1221 |
} else if (editor->metaObject()->className() == "QLabel") { |
model->setData(index, pComboBox->currentText()); |
1222 |
QLabel* pLabel = static_cast<QLabel*>(editor); |
} else if (pEditor->metaObject()->className() == "QSpinBox") { |
1223 |
model->setData(index, pLabel->text()); |
QSpinBox* pSpinBox = static_cast<QSpinBox*> (pEditor); |
1224 |
} |
model->setData(index, pSpinBox->value()); |
1225 |
} |
} else if (pEditor->metaObject()->className() == "QLineEdit") { |
1226 |
|
QLineEdit* pLineEdit = static_cast<QLineEdit*> (pEditor); |
1227 |
|
model->setData(index, pLineEdit->text()); |
1228 |
|
} else if (pEditor->metaObject()->className() == "QLabel") { |
1229 |
|
QLabel* pLabel = static_cast<QLabel*> (pEditor); |
1230 |
|
model->setData(index, pLabel->text()); |
1231 |
|
} |
1232 |
|
} |
1233 |
} |
} |
1234 |
|
|
1235 |
void DeviceParamDelegate::updateEditorGeometry(QWidget* editor, |
void DeviceParamDelegate::updateEditorGeometry ( QWidget *pEditor, |
1236 |
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const |
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const |
1237 |
{ |
{ |
1238 |
if (editor) editor->setGeometry(option.rect); |
if (pEditor) |
1239 |
|
pEditor->setGeometry(option.rect); |
1240 |
} |
} |
1241 |
|
|
1242 |
// end of qsamplerDevice.cpp |
// end of qsamplerDevice.cpp |