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 |
} |
} |
121 |
qsamplerDeviceType deviceType, int iDeviceID ) |
qsamplerDeviceType deviceType, int iDeviceID ) |
122 |
{ |
{ |
123 |
// Device id and type should be always set. |
// Device id and type should be always set. |
124 |
m_iDeviceID = iDeviceID; |
m_iDeviceID = iDeviceID; |
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/settler. |
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; |
257 |
} |
} |
258 |
|
|
259 |
// Device parameter accessor. |
// Device parameter accessor. |
260 |
qsamplerDeviceParamMap& qsamplerDevice::params (void) |
const qsamplerDeviceParamMap& qsamplerDevice::params (void) const |
261 |
{ |
{ |
262 |
return m_params; |
return m_params; |
263 |
} |
} |
264 |
|
|
265 |
|
|
266 |
// Update/refresh device/driver data. |
// Set the proper device parameter value. |
267 |
void qsamplerDevice::refresh (void) |
void qsamplerDevice::setParam ( const QString& sParam, |
268 |
|
const QString& sValue ) |
269 |
{ |
{ |
270 |
|
m_params[sParam].value = sValue; |
271 |
} |
} |
272 |
|
|
273 |
|
|
274 |
// Device ids enumerator. |
// Device ids enumerator. |
275 |
int *qsamplerDevice::getDevices ( lscp_client_t *pClient, |
int *qsamplerDevice::getDevices ( lscp_client_t *pClient, |
276 |
qsamplerDeviceType deviceType ) |
qsamplerDeviceType deviceType ) |
277 |
{ |
{ |
278 |
int *piDeviceIDs = NULL; |
int *piDeviceIDs = NULL; |
279 |
switch (deviceType) { |
switch (deviceType) { |
280 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
281 |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
282 |
break; |
break; |
283 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
284 |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
285 |
|
break; |
286 |
|
case qsamplerDevice::None: |
287 |
break; |
break; |
288 |
} |
} |
289 |
return piDeviceIDs; |
return piDeviceIDs; |
298 |
|
|
299 |
const char **ppszDrivers = NULL; |
const char **ppszDrivers = NULL; |
300 |
switch (deviceType) { |
switch (deviceType) { |
301 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
302 |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
303 |
break; |
break; |
304 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
305 |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
306 |
|
break; |
307 |
|
case qsamplerDevice::None: |
308 |
break; |
break; |
309 |
} |
} |
310 |
|
|
311 |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
312 |
drivers.append(ppszDrivers[iDriver]); |
drivers.append(ppszDrivers[iDriver]); |
313 |
|
|
314 |
return drivers; |
return drivers; |
315 |
} |
} |
316 |
|
|
317 |
|
|
318 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
319 |
|
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
320 |
|
// |
321 |
|
|
322 |
|
// Constructor. |
323 |
|
qsamplerDevicePort::qsamplerDevicePort ( lscp_client_t *pClient, |
324 |
|
const qsamplerDevice& device, int iPortID ) |
325 |
|
{ |
326 |
|
setDevicePort(pClient, device, iPortID); |
327 |
|
} |
328 |
|
|
329 |
|
// Default destructor. |
330 |
|
qsamplerDevicePort::~qsamplerDevicePort (void) |
331 |
|
{ |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
// Initializer. |
336 |
|
void qsamplerDevicePort::setDevicePort ( lscp_client_t *pClient, |
337 |
|
const qsamplerDevice& device, int iPortID ) |
338 |
|
{ |
339 |
|
// Device port id should be always set. |
340 |
|
m_iPortID = iPortID; |
341 |
|
|
342 |
|
// Retrieve device port/channel info, if any. |
343 |
|
lscp_device_port_info_t *pPortInfo = NULL; |
344 |
|
switch (device.deviceType()) { |
345 |
|
case qsamplerDevice::Audio: |
346 |
|
pPortInfo = ::lscp_get_audio_channel_info(pClient, device.deviceID(), iPortID); |
347 |
|
break; |
348 |
|
case qsamplerDevice::Midi: |
349 |
|
pPortInfo = ::lscp_get_midi_port_info(pClient, device.deviceID(), iPortID); |
350 |
|
break; |
351 |
|
case qsamplerDevice::None: |
352 |
|
break; |
353 |
|
} |
354 |
|
|
355 |
|
// If we're bogus, bail out... |
356 |
|
if (pPortInfo == NULL) { |
357 |
|
m_sPortName = QString::null; |
358 |
|
return; |
359 |
|
} |
360 |
|
|
361 |
|
// Set device port/channel properties... |
362 |
|
m_sPortName = pPortInfo->name; |
363 |
|
|
364 |
|
// Grab device port/channel parameters... |
365 |
|
m_params.clear(); |
366 |
|
for (int i = 0; pPortInfo->params && pPortInfo->params[i].key; i++) { |
367 |
|
const char *pszParam = pPortInfo->params[i].key; |
368 |
|
lscp_param_info_t *pParamInfo = NULL; |
369 |
|
switch (device.deviceType()) { |
370 |
|
case qsamplerDevice::Audio: |
371 |
|
pParamInfo = ::lscp_get_audio_channel_param_info(pClient, |
372 |
|
device.deviceID(), iPortID, pszParam); |
373 |
|
break; |
374 |
|
case qsamplerDevice::Midi: |
375 |
|
pParamInfo = ::lscp_get_midi_port_param_info(pClient, |
376 |
|
device.deviceID(), iPortID, pszParam); |
377 |
|
break; |
378 |
|
case qsamplerDevice::None: |
379 |
|
break; |
380 |
|
} |
381 |
|
if (pParamInfo) { |
382 |
|
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, |
383 |
|
pPortInfo->params[i].value); |
384 |
|
} |
385 |
|
} |
386 |
|
} |
387 |
|
|
388 |
|
|
389 |
|
// Device port/channel property accessors. |
390 |
|
int qsamplerDevicePort::portID (void) const |
391 |
|
{ |
392 |
|
return m_iPortID; |
393 |
|
} |
394 |
|
|
395 |
|
const QString& qsamplerDevicePort::portName (void) const |
396 |
|
{ |
397 |
|
return m_sPortName; |
398 |
|
} |
399 |
|
|
400 |
|
// Device port/channel parameter accessor. |
401 |
|
const qsamplerDeviceParamMap& qsamplerDevicePort::params (void) const |
402 |
|
{ |
403 |
|
return m_params; |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
// Set the proper device port/channel parameter value. |
408 |
|
void qsamplerDevicePort::setParam ( const QString& sParam, |
409 |
|
const QString& sValue ) |
410 |
|
{ |
411 |
|
m_params[sParam].value = sValue; |
412 |
|
} |
413 |
|
|
414 |
|
|
415 |
|
//------------------------------------------------------------------------- |
416 |
// qsamplerDeviceItem - QListView device item. |
// qsamplerDeviceItem - QListView device item. |
417 |
// |
// |
418 |
|
|
419 |
// Constructors. |
// Constructors. |
420 |
qsamplerDeviceItem::qsamplerDeviceItem ( QListView *pListView, lscp_client_t *pClient, |
qsamplerDeviceItem::qsamplerDeviceItem ( QListView *pListView, |
421 |
qsamplerDevice::qsamplerDeviceType deviceType ) |
lscp_client_t *pClient, qsamplerDevice::qsamplerDeviceType deviceType ) |
422 |
: QListViewItem(pListView), m_device(pClient, deviceType) |
: QListViewItem(pListView), m_device(pClient, deviceType) |
423 |
{ |
{ |
424 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
425 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
426 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
427 |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
428 |
break; |
break; |
429 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
430 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
431 |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
432 |
break; |
break; |
433 |
|
case qsamplerDevice::None: |
434 |
|
break; |
435 |
} |
} |
436 |
} |
} |
437 |
|
|
438 |
qsamplerDeviceItem::qsamplerDeviceItem ( QListViewItem *pItem, lscp_client_t *pClient, |
qsamplerDeviceItem::qsamplerDeviceItem ( QListViewItem *pItem, |
439 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
lscp_client_t *pClient, qsamplerDevice::qsamplerDeviceType deviceType, |
440 |
|
int iDeviceID ) |
441 |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
442 |
{ |
{ |
443 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
444 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
445 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
446 |
break; |
break; |
447 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
448 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
449 |
break; |
break; |
450 |
|
case qsamplerDevice::None: |
451 |
|
break; |
452 |
} |
} |
453 |
|
|
454 |
QListViewItem::setText(0, m_device.deviceName()); |
QListViewItem::setText(0, m_device.deviceName()); |
460 |
} |
} |
461 |
|
|
462 |
// Instance accessors. |
// Instance accessors. |
463 |
const qsamplerDevice& qsamplerDeviceItem::device (void) |
qsamplerDevice& qsamplerDeviceItem::device (void) |
464 |
{ |
{ |
465 |
return m_device; |
return m_device; |
466 |
} |
} |
478 |
// |
// |
479 |
|
|
480 |
// Constructor. |
// Constructor. |
481 |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, const char *pszName ) |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, |
482 |
|
const char *pszName ) |
483 |
: QTable(pParent, pszName) |
: QTable(pParent, pszName) |
484 |
{ |
{ |
|
m_pClient = NULL; |
|
|
m_iDeviceID = -1; |
|
|
|
|
485 |
// Set fixed number of columns. |
// Set fixed number of columns. |
486 |
QTable::setNumCols(3); |
QTable::setNumCols(3); |
487 |
QTable::setShowGrid(false); |
QTable::setShowGrid(false); |
500 |
QTable::setColumnReadOnly(0, true); |
QTable::setColumnReadOnly(0, true); |
501 |
QTable::setColumnReadOnly(1, true); |
QTable::setColumnReadOnly(1, true); |
502 |
// QTable::setColumnReadOnly(2, true); -- of course not. |
// QTable::setColumnReadOnly(2, true); -- of course not. |
503 |
|
QTable::setColumnStretchable(1, true); |
504 |
} |
} |
505 |
|
|
506 |
// Default destructor. |
// Default destructor. |
509 |
} |
} |
510 |
|
|
511 |
|
|
512 |
// Client/device descriptor selector. |
// Common parameter table renderer. |
513 |
void qsamplerDeviceParamTable::setDevice ( lscp_client_t *pClient, |
void qsamplerDeviceParamTable::refresh ( const qsamplerDeviceParamMap& params, |
514 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
bool bEditable ) |
515 |
|
{ |
516 |
|
// Always (re)start it empty. |
517 |
|
QTable::setUpdatesEnabled(false); |
518 |
|
QTable::setNumRows(0); |
519 |
|
|
520 |
|
// Fill the parameter table... |
521 |
|
QTable::insertRows(0, params.count()); |
522 |
|
int iRow = 0; |
523 |
|
qsamplerDeviceParamMap::ConstIterator iter; |
524 |
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
525 |
|
const qsamplerDeviceParam& param = iter.data(); |
526 |
|
bool bEnabled = (bEditable || !param.fix); |
527 |
|
QTable::setText(iRow, 0, iter.key()); |
528 |
|
QTable::setText(iRow, 1, param.description); |
529 |
|
if (param.type == LSCP_TYPE_BOOL) { |
530 |
|
QStringList opts; |
531 |
|
opts.append(tr("False")); |
532 |
|
opts.append(tr("True")); |
533 |
|
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
534 |
|
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
535 |
|
pComboItem->setEnabled(bEnabled); |
536 |
|
QTable::setItem(iRow, 2, pComboItem); |
537 |
|
} else if (param.possibilities.count() > 0 && bEnabled) { |
538 |
|
QComboTableItem *pComboItem = new QComboTableItem(this, |
539 |
|
param.possibilities); |
540 |
|
pComboItem->setCurrentItem(param.value); |
541 |
|
pComboItem->setEnabled(bEnabled); |
542 |
|
pComboItem->setEditable(bEnabled && param.multiplicity); |
543 |
|
QTable::setItem(iRow, 2, pComboItem); |
544 |
|
} else if (param.type == LSCP_TYPE_INT && bEnabled |
545 |
|
&& !param.range_min.isEmpty() |
546 |
|
&& !param.range_max.isEmpty()) { |
547 |
|
qsamplerDeviceParamTableSpinBox *pSpinItem = |
548 |
|
new qsamplerDeviceParamTableSpinBox(this, |
549 |
|
bEnabled ? QTableItem::OnTyping : QTableItem::Never, |
550 |
|
param.value); |
551 |
|
pSpinItem->setMinValue(param.range_min.toInt()); |
552 |
|
pSpinItem->setMaxValue(param.range_max.toInt()); |
553 |
|
QTable::setItem(iRow, 2, pSpinItem); |
554 |
|
} else { |
555 |
|
qsamplerDeviceParamTableEditBox *pEditItem = |
556 |
|
new qsamplerDeviceParamTableEditBox(this, |
557 |
|
bEnabled ? QTableItem::OnTyping : QTableItem::Never, |
558 |
|
param.value); |
559 |
|
QTable::setItem(iRow, 2, pEditItem); |
560 |
|
} |
561 |
|
++iRow; |
562 |
|
} |
563 |
|
|
564 |
|
// Adjust optimal column widths. |
565 |
|
QTable::adjustColumn(0); |
566 |
|
QTable::adjustColumn(2); |
567 |
|
|
568 |
|
QTable::setUpdatesEnabled(true); |
569 |
|
QTable::updateContents(); |
570 |
|
} |
571 |
|
|
572 |
|
|
573 |
|
//------------------------------------------------------------------------- |
574 |
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
575 |
|
// |
576 |
|
|
577 |
|
// Constructor. |
578 |
|
qsamplerDeviceParamTableSpinBox::qsamplerDeviceParamTableSpinBox ( |
579 |
|
QTable *pTable, EditType editType, const QString& sText ) |
580 |
|
: QTableItem(pTable, editType, sText) |
581 |
{ |
{ |
582 |
if (m_pClient |
m_iValue = sText.toInt(); |
583 |
&& m_pClient == pClient |
m_iMinValue = m_iMaxValue = 0; |
|
&& m_deviceType == deviceType |
|
|
&& m_iDeviceID == iDeviceID) |
|
|
return; |
|
|
|
|
|
m_pClient = pClient; |
|
|
m_deviceType = deviceType; |
|
|
m_iDeviceID = iDeviceID; |
|
|
|
|
|
refresh(); |
|
584 |
} |
} |
585 |
|
|
586 |
|
// Public accessors. |
587 |
|
void qsamplerDeviceParamTableSpinBox::setValue ( int iValue ) |
588 |
|
{ |
589 |
|
m_iValue = iValue; |
590 |
|
QTableItem::setText(QString::number(m_iValue)); |
591 |
|
} |
592 |
|
|
593 |
// Client/device descriptor accessors. |
void qsamplerDeviceParamTableSpinBox::setMinValue ( int iMinValue ) |
|
lscp_client_t *qsamplerDeviceParamTable::client (void) |
|
594 |
{ |
{ |
595 |
return m_pClient; |
m_iMinValue = iMinValue; |
596 |
} |
} |
597 |
|
|
598 |
int qsamplerDeviceParamTable::deviceID (void) |
void qsamplerDeviceParamTableSpinBox::setMaxValue ( int iMaxValue ) |
599 |
{ |
{ |
600 |
return m_iDeviceID; |
m_iMaxValue = iMaxValue; |
601 |
} |
} |
602 |
|
|
603 |
|
// Virtual implemetations. |
604 |
|
QWidget *qsamplerDeviceParamTableSpinBox::createEditor (void) const |
605 |
|
{ |
606 |
|
QSpinBox *pSpinBox = new QSpinBox(QTableItem::table()->viewport()); |
607 |
|
QObject::connect(pSpinBox, SIGNAL(valueChanged(int)), |
608 |
|
QTableItem::table(), SLOT(doValueChanged())); |
609 |
|
if (m_iValue >= m_iMinValue && m_iMaxValue >= m_iValue) { |
610 |
|
pSpinBox->setMinValue(m_iMinValue); |
611 |
|
pSpinBox->setMaxValue(m_iMaxValue); |
612 |
|
} |
613 |
|
pSpinBox->setValue(m_iValue); |
614 |
|
return pSpinBox; |
615 |
|
} |
616 |
|
|
617 |
// The main table refresher. |
void qsamplerDeviceParamTableSpinBox::setContentFromEditor ( QWidget *pWidget ) |
|
void qsamplerDeviceParamTable::refresh (void) |
|
618 |
{ |
{ |
619 |
// Always (re)start it empty. |
if (pWidget->inherits("QSpinBox")) |
620 |
QTable::setNumRows(0); |
QTableItem::setText(QString::number(((QSpinBox *) pWidget)->value())); |
621 |
|
else |
622 |
|
QTableItem::setContentFromEditor(pWidget); |
623 |
|
} |
624 |
|
|
|
if (m_pClient == NULL) |
|
|
return; |
|
|
|
|
|
// Construct the local device object here. |
|
|
qsamplerDevice device(m_pClient, m_deviceType, m_iDeviceID); |
|
625 |
|
|
626 |
|
//------------------------------------------------------------------------- |
627 |
|
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
628 |
|
// |
629 |
|
|
630 |
// Now fill the parameter table... |
// Constructor. |
631 |
QHeader *pHeader = QTable::verticalHeader(); |
qsamplerDeviceParamTableEditBox::qsamplerDeviceParamTableEditBox ( |
632 |
qsamplerDeviceParamMap& params = device.params(); |
QTable *pTable, EditType editType, const QString& sText ) |
633 |
QTable::insertRows(0, params.count()); |
: QTableItem(pTable, editType, sText) |
634 |
int iRow = 0; |
{ |
635 |
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; |
|
|
} |
|
636 |
|
|
637 |
// Adjust optimal column width. |
// Virtual implemetations. |
638 |
for (int iCol = 0; iCol < QTable::numCols(); iCol++) |
QWidget *qsamplerDeviceParamTableEditBox::createEditor (void) const |
639 |
QTable::adjustColumn(iCol); |
{ |
640 |
|
QLineEdit *pEditBox = new QLineEdit(QTableItem::table()->viewport()); |
641 |
|
QObject::connect(pEditBox, SIGNAL(returnPressed()), |
642 |
|
QTableItem::table(), SLOT(doValueChanged())); |
643 |
|
pEditBox->setText(QTableItem::text()); |
644 |
|
return pEditBox; |
645 |
|
} |
646 |
|
|
647 |
|
void qsamplerDeviceParamTableEditBox::setContentFromEditor ( QWidget *pWidget ) |
648 |
|
{ |
649 |
|
if (pWidget->inherits("QLineEdit")) |
650 |
|
QTableItem::setText(((QLineEdit *) pWidget)->text()); |
651 |
|
else |
652 |
|
QTableItem::setContentFromEditor(pWidget); |
653 |
} |
} |
654 |
|
|
655 |
|
|