44 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
45 |
m_pAudioItems = NULL; |
m_pAudioItems = NULL; |
46 |
m_pMidiItems = NULL; |
m_pMidiItems = NULL; |
47 |
|
// No exclusive mode as default. |
48 |
|
m_deviceTypeMode = qsamplerDevice::None; |
49 |
|
|
50 |
// This an outsider (from designer), but rather important. |
// This an outsider (from designer), but rather important. |
51 |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
52 |
this, SLOT(changeDeviceParam(int,int))); |
this, SLOT(changeDeviceParam(int,int))); |
85 |
|
|
86 |
if (m_pMainForm) |
if (m_pMainForm) |
87 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
88 |
|
|
89 |
// Signal special whether we changed the device set. |
// Signal special whether we changed the device set. |
90 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
91 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
97 |
// Application main form settler (life depends on it). |
// Application main form settler (life depends on it). |
98 |
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
99 |
{ |
{ |
100 |
m_pMainForm = pMainForm; |
m_pMainForm = pMainForm; |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
// Set device type spacial exclusive mode. |
105 |
|
void qsamplerDeviceForm::setDeviceTypeMode ( |
106 |
|
qsamplerDevice::qsamplerDeviceType deviceTypeMode ) |
107 |
|
{ |
108 |
|
// If it has not changed, do nothing. |
109 |
|
if (m_deviceTypeMode == deviceTypeMode) |
110 |
|
return; |
111 |
|
|
112 |
|
m_deviceTypeMode = deviceTypeMode; |
113 |
|
|
114 |
|
// OK. Do a whole refresh around. |
115 |
|
refreshDevices(); |
116 |
} |
} |
117 |
|
|
118 |
|
|
125 |
|
|
126 |
// Set new reference. |
// Set new reference. |
127 |
m_pClient = pClient; |
m_pClient = pClient; |
128 |
|
|
129 |
// OK. Do a whole refresh around. |
// OK. Do a whole refresh around. |
130 |
refreshDevices(); |
refreshDevices(); |
131 |
} |
} |
132 |
|
|
133 |
|
|
134 |
|
// Device driver name setup formal initializer. |
135 |
|
void qsamplerDeviceForm::setDriverName ( const QString& sDriverName ) |
136 |
|
{ |
137 |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, |
138 |
|
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
139 |
|
DriverNameComboBox->insertItem(sDriverName); |
140 |
|
} |
141 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
// Set current selected device by type and id. |
// Set current selected device by type and id. |
146 |
void qsamplerDeviceForm::setDevice ( |
void qsamplerDeviceForm::setDevice ( qsamplerDevice *pDevice ) |
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
|
147 |
{ |
{ |
148 |
|
// In case no device is given... |
149 |
|
qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode; |
150 |
|
if (pDevice) |
151 |
|
deviceType = pDevice->deviceType(); |
152 |
|
|
153 |
// Get the device view root item... |
// Get the device view root item... |
154 |
qsamplerDeviceItem *pRootItem = NULL; |
qsamplerDeviceItem *pRootItem = NULL; |
155 |
switch (deviceType) { |
switch (deviceType) { |
162 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
163 |
break; |
break; |
164 |
} |
} |
165 |
|
|
166 |
// Is the root present? |
// Is the root present? |
167 |
if (pRootItem == NULL) |
if (pRootItem == NULL) |
168 |
return; |
return; |
169 |
|
|
170 |
|
// So there's no device huh? |
171 |
|
if (pDevice == NULL) { |
172 |
|
DeviceListView->setSelected(pRootItem, true); |
173 |
|
return; |
174 |
|
} |
175 |
|
|
176 |
// For each child, test for identity... |
// For each child, test for identity... |
177 |
qsamplerDeviceItem *pDeviceItem = |
qsamplerDeviceItem *pDeviceItem = |
178 |
(qsamplerDeviceItem *) pRootItem->firstChild(); |
(qsamplerDeviceItem *) pRootItem->firstChild(); |
179 |
while (pDeviceItem) { |
while (pDeviceItem) { |
180 |
// If identities match, select as current device item. |
// If identities match, select as current device item. |
181 |
if (pDeviceItem->device().deviceID() == iDeviceID) { |
if (pDeviceItem->device().deviceID() == pDevice->deviceID()) { |
182 |
DeviceListView->setSelected(pDeviceItem, true); |
DeviceListView->setSelected(pDeviceItem, true); |
183 |
break; |
break; |
184 |
} |
} |
192 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::createDevice (void) |
193 |
{ |
{ |
194 |
if (m_pMainForm == NULL) |
if (m_pMainForm == NULL) |
195 |
return; |
return; |
196 |
|
|
197 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
198 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
229 |
void qsamplerDeviceForm::deleteDevice (void) |
void qsamplerDeviceForm::deleteDevice (void) |
230 |
{ |
{ |
231 |
if (m_pMainForm == NULL) |
if (m_pMainForm == NULL) |
232 |
return; |
return; |
233 |
|
|
234 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
235 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
264 |
void qsamplerDeviceForm::refreshDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
265 |
{ |
{ |
266 |
if (m_pMainForm == NULL) |
if (m_pMainForm == NULL) |
267 |
return; |
return; |
268 |
|
|
269 |
// Avoid nested changes. |
// Avoid nested changes. |
270 |
m_iDirtySetup++; |
m_iDirtySetup++; |
278 |
if (m_pClient) { |
if (m_pClient) { |
279 |
int *piDeviceIDs; |
int *piDeviceIDs; |
280 |
// Grab and pop Audio devices... |
// Grab and pop Audio devices... |
281 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
if (m_deviceTypeMode == qsamplerDevice::None || |
282 |
m_pMainForm, qsamplerDevice::Audio); |
m_deviceTypeMode == qsamplerDevice::Audio) { |
283 |
|
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
284 |
|
m_pMainForm, qsamplerDevice::Audio); |
285 |
|
} |
286 |
if (m_pAudioItems) { |
if (m_pAudioItems) { |
287 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
288 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
292 |
m_pAudioItems->setOpen(true); |
m_pAudioItems->setOpen(true); |
293 |
} |
} |
294 |
// Grab and pop MIDI devices... |
// Grab and pop MIDI devices... |
295 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
if (m_deviceTypeMode == qsamplerDevice::None || |
296 |
m_pMainForm, qsamplerDevice::Midi); |
m_deviceTypeMode == qsamplerDevice::Midi) { |
297 |
|
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
298 |
|
m_pMainForm, qsamplerDevice::Midi); |
299 |
|
} |
300 |
if (m_pMidiItems) { |
if (m_pMidiItems) { |
301 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
302 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
384 |
// Do we need a driver name? |
// Do we need a driver name? |
385 |
if (m_bNewDevice || device.driverName().isEmpty()) |
if (m_bNewDevice || device.driverName().isEmpty()) |
386 |
device.setDriver(DriverNameComboBox->currentText()); |
device.setDriver(DriverNameComboBox->currentText()); |
387 |
const QString& sDriverName = device.driverName(); |
setDriverName(device.driverName()); |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
|
|
DriverNameComboBox->insertItem(sDriverName); |
|
|
DriverNameComboBox->setCurrentText(sDriverName); |
|
388 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
389 |
DriverNameComboBox->setEnabled(m_bNewDevice); |
DriverNameComboBox->setEnabled(m_bNewDevice); |
390 |
// Fill the device parameter table... |
// Fill the device parameter table... |
399 |
QPixmap pixmap; |
QPixmap pixmap; |
400 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
401 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
402 |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
403 |
break; |
break; |
404 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
405 |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
406 |
break; |
break; |
407 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
408 |
break; |
break; |
409 |
} |
} |
410 |
qsamplerDevicePortList& ports = device.ports(); |
qsamplerDevicePortList& ports = device.ports(); |
411 |
qsamplerDevicePort *pPort; |
qsamplerDevicePort *pPort; |
412 |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
413 |
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
414 |
+ ' ' + device.driverName() |
+ ' ' + device.driverName() |
415 |
+ ' ' + pPort->portName()); |
+ ' ' + pPort->portName()); |
416 |
} |
} |
420 |
} |
} |
421 |
// Done. |
// Done. |
422 |
m_iDirtySetup--; |
m_iDirtySetup--; |
423 |
|
|
424 |
// Make the device port/channel selection effective. |
// Make the device port/channel selection effective. |
425 |
selectDevicePort(DevicePortComboBox->currentItem()); |
selectDevicePort(DevicePortComboBox->currentItem()); |
426 |
} |
} |
456 |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
457 |
{ |
{ |
458 |
if (m_pMainForm == NULL) |
if (m_pMainForm == NULL) |
459 |
return; |
return; |
460 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
461 |
return; |
return; |
462 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
463 |
return; |
return; |
464 |
|
|
465 |
// |
// |
466 |
// Device parameter change... |
// Device parameter change... |
467 |
// |
// |
490 |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
491 |
{ |
{ |
492 |
if (m_pMainForm == NULL) |
if (m_pMainForm == NULL) |
493 |
return; |
return; |
494 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
495 |
return; |
return; |
496 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
509 |
int iPort = DevicePortComboBox->currentItem(); |
int iPort = DevicePortComboBox->currentItem(); |
510 |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
511 |
if (pPort == NULL) |
if (pPort == NULL) |
512 |
return; |
return; |
513 |
|
|
514 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
515 |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
527 |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
528 |
{ |
{ |
529 |
int iItemID; |
int iItemID; |
530 |
|
|
531 |
// Build the device context menu... |
// Build the device context menu... |
532 |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
533 |
|
|
534 |
bool bClient = (m_pClient != NULL); |
bool bClient = (m_pClient != NULL); |
535 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
536 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
546 |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
547 |
tr("&Refresh"), this, SLOT(refreshDevices())); |
tr("&Refresh"), this, SLOT(refreshDevices())); |
548 |
pContextMenu->setItemEnabled(iItemID, bClient); |
pContextMenu->setItemEnabled(iItemID, bClient); |
549 |
|
|
550 |
pContextMenu->exec(pos); |
pContextMenu->exec(pos); |
551 |
|
|
552 |
delete pContextMenu; |
delete pContextMenu; |
553 |
} |
} |
554 |
|
|
570 |
|
|
571 |
|
|
572 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
|
|
|
|
|
|
|
|
|