24 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
25 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
26 |
#include <qlistbox.h> |
#include <qlistbox.h> |
27 |
|
#include <qpopupmenu.h> |
28 |
|
|
29 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
30 |
|
|
102 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
103 |
return; |
return; |
104 |
|
|
105 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
106 |
|
|
107 |
// Build the parameter list... |
// Build the parameter list... |
108 |
qsamplerDeviceParamMap& params = device.params(); |
const qsamplerDeviceParamMap& params = device.params(); |
109 |
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
110 |
int iParam = 0; |
int iParam = 0; |
111 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
164 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
165 |
return; |
return; |
166 |
|
|
167 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
168 |
|
|
169 |
// Prompt user if this is for real... |
// Prompt user if this is for real... |
170 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
qsamplerOptions *pOptions = m_pMainForm->options(); |
277 |
if (m_bNewDevice) { |
if (m_bNewDevice) { |
278 |
m_iDirtySetup++; |
m_iDirtySetup++; |
279 |
device.setDriver(m_pClient, sDriverName); |
device.setDriver(m_pClient, sDriverName); |
280 |
DeviceParamTable->refresh(device); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
281 |
m_iDirtySetup--; |
m_iDirtySetup--; |
282 |
// Done. |
// Done. |
283 |
stabilizeForm(); |
stabilizeForm(); |
311 |
m_bNewDevice = (device.deviceID() < 0); |
m_bNewDevice = (device.deviceID() < 0); |
312 |
|
|
313 |
// Fill the device/driver heading... |
// Fill the device/driver heading... |
314 |
DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName()); |
QString sPrefix; |
315 |
|
if (!m_bNewDevice) |
316 |
|
sPrefix += device.deviceTypeName() + ' '; |
317 |
|
DeviceNameTextLabel->setText(sPrefix + device.deviceName()); |
318 |
// The driver combobox is only rebuilt if device type has changed... |
// The driver combobox is only rebuilt if device type has changed... |
319 |
if (device.deviceType() != m_deviceType) { |
if (device.deviceType() != m_deviceType) { |
320 |
DriverNameComboBox->clear(); |
DriverNameComboBox->clear(); |
332 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
333 |
DriverNameComboBox->setEnabled(m_bNewDevice); |
DriverNameComboBox->setEnabled(m_bNewDevice); |
334 |
// Fill the device parameter table... |
// Fill the device parameter table... |
335 |
DeviceParamTable->refresh(device); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
336 |
// Done. |
// Done. |
337 |
m_iDirtySetup--; |
m_iDirtySetup--; |
338 |
stabilizeForm(); |
stabilizeForm(); |
359 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
360 |
|
|
361 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
362 |
qsamplerDeviceParamMap& params = device.params(); |
const qsamplerDeviceParamMap& params = device.params(); |
363 |
const QString sParam = DeviceParamTable->text(iRow, 0); |
const QString sParam = DeviceParamTable->text(iRow, 0); |
364 |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
365 |
params[sParam].value = sValue; |
|
366 |
|
// Set the local device parameter value. |
367 |
|
device.setParam(sParam, sValue); |
368 |
|
|
369 |
// Set proper device parameter, on existing device ... |
// Set proper device parameter, on existing device ... |
370 |
if (device.deviceID() >= 0) { |
if (device.deviceID() >= 0) { |
403 |
} |
} |
404 |
|
|
405 |
|
|
406 |
|
// Device list view context menu handler. |
407 |
|
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
408 |
|
{ |
409 |
|
int iItemID; |
410 |
|
|
411 |
|
// Build the device context menu... |
412 |
|
QPopupMenu* pContextMenu = new QPopupMenu(this); |
413 |
|
|
414 |
|
bool bClient = (m_pClient != NULL); |
415 |
|
bool bEnabled = (pItem != NULL); |
416 |
|
iItemID = pContextMenu->insertItem( |
417 |
|
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
418 |
|
tr("&Create"), this, SLOT(createDevice())); |
419 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
420 |
|
iItemID = pContextMenu->insertItem( |
421 |
|
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
422 |
|
tr("&Delete"), this, SLOT(deleteDevice())); |
423 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
424 |
|
pContextMenu->insertSeparator(); |
425 |
|
iItemID = pContextMenu->insertItem( |
426 |
|
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
427 |
|
tr("&Refresh"), this, SLOT(refreshDevices())); |
428 |
|
pContextMenu->setItemEnabled(iItemID, bClient); |
429 |
|
|
430 |
|
pContextMenu->exec(pos); |
431 |
|
|
432 |
|
delete pContextMenu; |
433 |
|
} |
434 |
|
|
435 |
|
|
436 |
// Stabilize current form state. |
// Stabilize current form state. |
437 |
void qsamplerDeviceForm::stabilizeForm (void) |
void qsamplerDeviceForm::stabilizeForm (void) |
438 |
{ |
{ |
439 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
440 |
|
bool bClient = (m_pClient != NULL); |
441 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
442 |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
443 |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
444 |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
445 |
DeviceParamTable->setEnabled(bEnabled); |
DeviceParamTable->setEnabled(bEnabled); |
446 |
CreateDevicePushButton->setEnabled(bEnabled || m_bNewDevice); |
RefreshDevicesPushButton->setEnabled(bClient); |
447 |
|
CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice)); |
448 |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
449 |
} |
} |
450 |
|
|