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 |
|
|
38 |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
39 |
m_pClient = NULL; |
m_pClient = NULL; |
40 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
|
m_iDirtyCount = 0; |
|
41 |
m_bNewDevice = false; |
m_bNewDevice = false; |
42 |
|
m_deviceType = qsamplerDevice::None; |
43 |
|
m_pAudioItems = NULL; |
44 |
|
m_pMidiItems = NULL; |
45 |
|
|
46 |
// This an outsider (from designer), but rather important. |
// This an outsider (from designer), but rather important. |
47 |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
48 |
this, SLOT(changeValue(int,int))); |
this, SLOT(changeValue(int,int))); |
49 |
|
|
50 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
51 |
adjustSize(); |
adjustSize(); |
98 |
// Create a new device from current table view. |
// Create a new device from current table view. |
99 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::createDevice (void) |
100 |
{ |
{ |
|
// |
|
|
// TODO: Create a new device from current table view... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()"); |
|
|
|
|
101 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
102 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
103 |
return; |
return; |
107 |
// Build the parameter list... |
// Build the parameter list... |
108 |
qsamplerDeviceParamMap& params = device.params(); |
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 i = 0; |
int iParam = 0; |
111 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
112 |
for (iter = params.begin(); iter != params.end(); ++iter) { |
for (iter = params.begin(); iter != params.end(); ++iter) { |
113 |
pParams[i].key = (char *) iter.key().latin1(); |
pParams[iParam].key = (char *) iter.key().latin1(); |
114 |
pParams[i].value = (char *) iter.data().value.latin1(); |
pParams[iParam].value = (char *) iter.data().value.latin1(); |
115 |
|
++iParam; |
116 |
} |
} |
117 |
// Null terminated. |
// Null terminated. |
118 |
pParams[i].key = NULL; |
pParams[iParam].key = NULL; |
119 |
pParams[i].value = NULL; |
pParams[iParam].value = NULL; |
120 |
|
|
121 |
// Now it depends on the device type... |
// Now it depends on the device type... |
122 |
|
qsamplerDeviceItem *pRootItem = NULL; |
123 |
int iDeviceID = -1; |
int iDeviceID = -1; |
124 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
125 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
126 |
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
pRootItem = m_pAudioItems; |
127 |
|
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
128 |
device.driverName().latin1(), pParams)) < 0) |
device.driverName().latin1(), pParams)) < 0) |
129 |
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
130 |
break; |
break; |
131 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
132 |
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
pRootItem = m_pMidiItems; |
133 |
|
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
134 |
device.driverName().latin1(), pParams)) < 0) |
device.driverName().latin1(), pParams)) < 0) |
135 |
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
136 |
break; |
break; |
137 |
|
case qsamplerDevice::None: |
138 |
|
break; |
139 |
} |
} |
140 |
|
|
141 |
// Free used parameter array. |
// Free used parameter array. |
142 |
delete [] pParams; |
delete pParams; |
143 |
|
|
144 |
// Show result. |
// We're on to create the new device item. |
145 |
if (iDeviceID >= 0) { |
if (iDeviceID >= 0) { |
146 |
m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("created.")); |
// Append the new device item. |
147 |
|
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
148 |
|
m_pClient, device.deviceType(), iDeviceID); |
149 |
|
// Just make it the new selection... |
150 |
|
DeviceListView->setSelected(pDeviceItem, true); |
151 |
// Done. |
// Done. |
152 |
refreshDevices(); |
m_pMainForm->appendMessages(pDeviceItem->device().deviceName() + ' ' |
153 |
|
+ tr("created.")); |
154 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
155 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
156 |
} |
} |
160 |
// Delete current device in table view. |
// Delete current device in table view. |
161 |
void qsamplerDeviceForm::deleteDevice (void) |
void qsamplerDeviceForm::deleteDevice (void) |
162 |
{ |
{ |
|
// |
|
|
// TODO: Delete current device in table view... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()"); |
|
|
|
|
163 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
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(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
168 |
|
|
169 |
|
// Prompt user if this is for real... |
170 |
|
qsamplerOptions *pOptions = m_pMainForm->options(); |
171 |
|
if (pOptions && pOptions->bConfirmRemove) { |
172 |
|
if (QMessageBox::warning(this, tr("Warning"), |
173 |
|
tr("Delete %1 device:\n\n" |
174 |
|
"%2\n\n" |
175 |
|
"Are you sure?") |
176 |
|
.arg(device.deviceTypeName()) |
177 |
|
.arg(device.deviceName()), |
178 |
|
tr("OK"), tr("Cancel")) > 0) |
179 |
|
return; |
180 |
|
} |
181 |
|
|
182 |
// Now it depends on the device type... |
// Now it depends on the device type... |
183 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
184 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
185 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
186 |
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
187 |
device.deviceID())) != LSCP_OK) |
device.deviceID())) != LSCP_OK) |
188 |
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
189 |
break; |
break; |
190 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
191 |
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
192 |
device.deviceID())) != LSCP_OK) |
device.deviceID())) != LSCP_OK) |
193 |
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
194 |
break; |
break; |
195 |
|
case qsamplerDevice::None: |
196 |
|
break; |
197 |
} |
} |
198 |
|
|
199 |
// Show result. |
// Show result. |
200 |
if (ret == LSCP_OK) { |
if (ret == LSCP_OK) { |
201 |
m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("deleted.")); |
// Show log message before loosing it. |
202 |
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
203 |
|
+ tr("deleted.")); |
204 |
// Done. |
// Done. |
205 |
refreshDevices(); |
delete pItem; |
206 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
207 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
208 |
} |
} |
216 |
m_iDirtySetup++; |
m_iDirtySetup++; |
217 |
|
|
218 |
// |
// |
219 |
// TODO: Load device configuration data ... |
// (Re)Load complete device configuration data ... |
220 |
// |
// |
221 |
m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()"); |
m_pAudioItems = NULL; |
222 |
|
m_pMidiItems = NULL; |
223 |
DeviceListView->clear(); |
DeviceListView->clear(); |
224 |
if (m_pClient) { |
if (m_pClient) { |
|
qsamplerDeviceItem *pItem; |
|
225 |
int *piDeviceIDs; |
int *piDeviceIDs; |
226 |
// Grab and pop Audio devices... |
// Grab and pop Audio devices... |
227 |
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
228 |
qsamplerDevice::Audio); |
qsamplerDevice::Audio); |
229 |
if (pItem) { |
if (m_pAudioItems) { |
230 |
pItem->setText(0, tr("Audio")); |
m_pAudioItems->setText(0, tr("Audio")); |
231 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
232 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
233 |
new qsamplerDeviceItem(pItem, m_pClient, |
new qsamplerDeviceItem(m_pAudioItems, m_pClient, |
234 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
qsamplerDevice::Audio, piDeviceIDs[i]); |
235 |
} |
} |
236 |
pItem->setOpen(true); |
m_pAudioItems->setOpen(true); |
237 |
} |
} |
238 |
// Grab and pop MIDI devices... |
// Grab and pop MIDI devices... |
239 |
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
240 |
qsamplerDevice::Midi); |
qsamplerDevice::Midi); |
241 |
if (pItem) { |
if (m_pMidiItems) { |
242 |
pItem->setText(0, tr("MIDI")); |
m_pMidiItems->setText(0, tr("MIDI")); |
243 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
244 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
245 |
new qsamplerDeviceItem(pItem, m_pClient, |
new qsamplerDeviceItem(m_pMidiItems, m_pClient, |
246 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
qsamplerDevice::Midi, piDeviceIDs[i]); |
247 |
} |
} |
248 |
pItem->setOpen(true); |
m_pMidiItems->setOpen(true); |
249 |
} |
} |
250 |
} |
} |
251 |
|
|
252 |
// Done. |
// Done. |
|
m_iDirtyCount = 0; |
|
253 |
m_iDirtySetup--; |
m_iDirtySetup--; |
254 |
|
|
255 |
// Show something. |
// Show something. |
256 |
selectDevice(); |
selectDevice(); |
257 |
} |
} |
261 |
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
262 |
{ |
{ |
263 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
264 |
return; |
return; |
265 |
|
|
266 |
// |
// |
267 |
// TODO: Driver name has changed for a new device... |
// Driver name has changed for a new device... |
268 |
// |
// |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDriver()"); |
|
269 |
|
|
270 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
271 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
272 |
return; |
return; |
273 |
|
|
274 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
275 |
|
|
276 |
|
// Driver change is only valid for scratch devices... |
277 |
if (m_bNewDevice) { |
if (m_bNewDevice) { |
278 |
|
m_iDirtySetup++; |
279 |
device.setDriver(m_pClient, sDriverName); |
device.setDriver(m_pClient, sDriverName); |
280 |
m_iDirtyCount++; |
DeviceParamTable->refresh(device); |
281 |
|
m_iDirtySetup--; |
282 |
|
// Done. |
283 |
|
stabilizeForm(); |
284 |
} |
} |
|
|
|
|
// Done. |
|
|
stabilizeForm(); |
|
285 |
} |
} |
286 |
|
|
287 |
|
|
289 |
void qsamplerDeviceForm::selectDevice (void) |
void qsamplerDeviceForm::selectDevice (void) |
290 |
{ |
{ |
291 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
292 |
return; |
return; |
293 |
|
|
294 |
// |
// |
295 |
// TODO: Device selection has changed... |
// Device selection has changed... |
296 |
// |
// |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice()"); |
|
297 |
|
|
298 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
299 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
300 |
DeviceNameTextLabel->setText(QString::null); |
m_deviceType = qsamplerDevice::None; |
301 |
DeviceParamTable->setNumRows(0); |
DeviceNameTextLabel->setText(QString::null); |
302 |
|
DeviceParamTable->setNumRows(0); |
303 |
stabilizeForm(); |
stabilizeForm(); |
304 |
return; |
return; |
305 |
} |
} |
306 |
|
|
307 |
|
m_iDirtySetup++; |
308 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
309 |
|
|
310 |
|
// Flag whether this is a new device. |
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 |
DriverNameComboBox->clear(); |
if (!m_bNewDevice) |
316 |
DriverNameComboBox->insertStringList( |
sPrefix += device.deviceTypeName() + ' '; |
317 |
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
DeviceNameTextLabel->setText(sPrefix + device.deviceName()); |
318 |
const QString& sDriverName = device.driverName(); |
// The driver combobox is only rebuilt if device type has changed... |
319 |
if (m_bNewDevice || sDriverName.isEmpty()) { |
if (device.deviceType() != m_deviceType) { |
320 |
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
DriverNameComboBox->clear(); |
321 |
} else { |
DriverNameComboBox->insertStringList( |
322 |
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
323 |
DriverNameComboBox->insertItem(sDriverName); |
m_deviceType = device.deviceType(); |
|
DriverNameComboBox->setCurrentText(sDriverName); |
|
324 |
} |
} |
325 |
|
// Do we need a driver name? |
326 |
|
if (m_bNewDevice || device.driverName().isEmpty()) |
327 |
|
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
328 |
|
const QString& sDriverName = device.driverName(); |
329 |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
330 |
|
DriverNameComboBox->insertItem(sDriverName); |
331 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
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); |
|
|
|
336 |
// Done. |
// Done. |
337 |
|
m_iDirtySetup--; |
338 |
stabilizeForm(); |
stabilizeForm(); |
339 |
} |
} |
340 |
|
|
342 |
// parameter value change slot. |
// parameter value change slot. |
343 |
void qsamplerDeviceForm::changeValue ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeValue ( int iRow, int iCol ) |
344 |
{ |
{ |
345 |
|
if (m_iDirtySetup > 0) |
346 |
|
return; |
347 |
|
if (iRow < 0 || iCol < 0) |
348 |
|
return; |
349 |
|
|
350 |
// |
// |
351 |
// TODO: Device parameter change... |
// Device parameter change... |
352 |
// |
// |
353 |
m_pMainForm->appendMessages("qsamplerDeviceForm::changeValue()"); |
|
|
|
|
354 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
355 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
356 |
return; |
return; |
357 |
|
|
358 |
|
m_iDirtySetup++; |
359 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
360 |
|
|
361 |
// Table 3rd column has the parameter name; |
// Table 1st column has the parameter name; |
362 |
qsamplerDeviceParamMap& params = device.params(); |
qsamplerDeviceParamMap& params = device.params(); |
363 |
const QString sParam = DeviceParamTable->text(iRow, 2); |
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; |
params[sParam].value = sValue; |
366 |
|
|
374 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
375 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
376 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
377 |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
378 |
device.deviceID(), ¶m)) != LSCP_OK) |
device.deviceID(), ¶m)) != LSCP_OK) |
379 |
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
380 |
break; |
break; |
381 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
382 |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
383 |
device.deviceID(), ¶m)) != LSCP_OK) |
device.deviceID(), ¶m)) != LSCP_OK) |
384 |
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
385 |
break; |
break; |
386 |
|
case qsamplerDevice::None: |
387 |
|
break; |
388 |
} |
} |
389 |
// Show result. |
// Show result. |
390 |
if (ret == LSCP_OK) { |
if (ret == LSCP_OK) { |
391 |
m_pMainForm->appendMessages(device.deviceName() + ' ' + |
m_pMainForm->appendMessages(device.deviceName() + ' ' |
392 |
QString("%1: %2.").arg(sParam).arg(sValue)); |
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
393 |
} |
} |
394 |
} |
} |
395 |
|
|
396 |
// Done. |
// Done. |
397 |
m_iDirtyCount++; |
m_iDirtySetup--; |
398 |
stabilizeForm(); |
stabilizeForm(); |
399 |
// Main session should be dirtier... |
// Main session should be dirtier... |
400 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
401 |
} |
} |
402 |
|
|
403 |
|
|
404 |
|
// Device list view context menu handler. |
405 |
|
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
406 |
|
{ |
407 |
|
int iItemID; |
408 |
|
|
409 |
|
// Build the device context menu... |
410 |
|
QPopupMenu* pContextMenu = new QPopupMenu(this); |
411 |
|
|
412 |
|
bool bClient = (m_pClient != NULL); |
413 |
|
bool bEnabled = (pItem != NULL); |
414 |
|
iItemID = pContextMenu->insertItem( |
415 |
|
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
416 |
|
tr("&Create"), this, SLOT(createDevice())); |
417 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
418 |
|
iItemID = pContextMenu->insertItem( |
419 |
|
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
420 |
|
tr("&Delete"), this, SLOT(deleteDevice())); |
421 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
422 |
|
pContextMenu->insertSeparator(); |
423 |
|
iItemID = pContextMenu->insertItem( |
424 |
|
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
425 |
|
tr("&Refresh"), this, SLOT(refreshDevices())); |
426 |
|
pContextMenu->setItemEnabled(iItemID, bClient); |
427 |
|
|
428 |
|
pContextMenu->exec(pos); |
429 |
|
|
430 |
|
delete pContextMenu; |
431 |
|
} |
432 |
|
|
433 |
|
|
434 |
// Stabilize current form state. |
// Stabilize current form state. |
435 |
void qsamplerDeviceForm::stabilizeForm (void) |
void qsamplerDeviceForm::stabilizeForm (void) |
436 |
{ |
{ |
437 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
438 |
|
bool bClient = (m_pClient != NULL); |
439 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
440 |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
441 |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
442 |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
443 |
DeviceParamTable->setEnabled(bEnabled); |
DeviceParamTable->setEnabled(bEnabled); |
444 |
CreateDevicePushButton->setEnabled(bEnabled || m_bNewDevice); |
RefreshDevicesPushButton->setEnabled(bClient); |
445 |
|
CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice)); |
446 |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
447 |
} |
} |
448 |
|
|
449 |
|
|
450 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
|
|
|