/[svn]/qsampler/trunk/src/qsamplerDeviceForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerDeviceForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 436 by capela, Wed Mar 9 20:55:04 2005 UTC revision 622 by capela, Thu Jun 9 09:28:20 2005 UTC
# Line 24  Line 24 
24  #include <qfiledialog.h>  #include <qfiledialog.h>
25  #include <qfileinfo.h>  #include <qfileinfo.h>
26  #include <qlistbox.h>  #include <qlistbox.h>
27    #include <qptrlist.h>
28    #include <qpopupmenu.h>
29    
30  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
31    
# Line 34  Line 36 
36  void qsamplerDeviceForm::init (void)  void qsamplerDeviceForm::init (void)
37  {  {
38          // Initialize locals.          // Initialize locals.
39          m_pMainForm   = (qsamplerMainForm *) QWidget::parentWidget();          m_pMainForm   = NULL;
40          m_pClient     = NULL;          m_pClient     = NULL;
41          m_iDirtySetup = 0;          m_iDirtySetup = 0;
42          m_iDirtyCount = 0;          m_iDirtyCount = 0;
43          m_bNewDevice  = false;          m_bNewDevice  = false;
44          m_deviceType  = qsamplerDevice::None;          m_deviceType  = qsamplerDevice::None;
45            m_pAudioItems = NULL;
46            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(changeValue(int,int)));                  this, SLOT(changeDeviceParam(int,int)));
53                    QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)),
54                    this, SLOT(changeDevicePortParam(int,int)));
55    
56            // Initial contents.
57            refreshDevices();
58          // Try to restore normal window positioning.          // Try to restore normal window positioning.
59          adjustSize();          adjustSize();
60  }  }
# Line 75  void qsamplerDeviceForm::hideEvent ( QHi Line 85  void qsamplerDeviceForm::hideEvent ( QHi
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.
90            if (m_iDirtyCount > 0) {
91                    m_iDirtyCount = 0;
92                    emit devicesChanged();
93            }
94    }
95    
96    
97    // Application main form settler (life depends on it).
98    void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm )
99    {
100            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    
# Line 87  void qsamplerDeviceForm::setClient ( lsc Line 125  void qsamplerDeviceForm::setClient ( lsc
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  // Create a new device from current table view.  // Device driver name setup formal initializer.
135  void qsamplerDeviceForm::createDevice (void)  void qsamplerDeviceForm::setDriverName ( const QString& sDriverName )
136  {  {
137          //          if (DriverNameComboBox->listBox()->findItem(sDriverName,
138          // TODO: Create a new device from current table view...                          Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
139          //                  DriverNameComboBox->insertItem(sDriverName);
140          m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()");          }
141            DriverNameComboBox->setCurrentText(sDriverName);
142          QListViewItem *pItem = DeviceListView->selectedItem();  }
         if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)  
                 return;  
   
         qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();  
143    
         // Build the parameter list...  
         qsamplerDeviceParamMap& params = device.params();  
         lscp_param_t *pParams = new lscp_param_t [params.count() + 1];  
         int iParam = 0;  
         qsamplerDeviceParamMap::ConstIterator iter;  
         for (iter = params.begin(); iter != params.end(); ++iter) {  
                 pParams[iParam].key   = (char *) iter.key().latin1();  
                 pParams[iParam].value = (char *) iter.data().value.latin1();  
                 ++iParam;  
         }  
         // Null terminated.  
         pParams[iParam].key   = NULL;  
         pParams[iParam].value = NULL;  
144    
145          // Now it depends on the device type...  // Set current selected device by type and id.
146          int iDeviceID = -1;  void qsamplerDeviceForm::setDevice ( qsamplerDevice *pDevice )
147          switch (device.deviceType()) {  {
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...
154            qsamplerDeviceItem *pRootItem = NULL;
155            switch (deviceType) {
156          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
157                  if ((iDeviceID = ::lscp_create_audio_device(m_pClient,                  pRootItem = m_pAudioItems;
                                 device.driverName().latin1(), pParams)) < 0)  
                         m_pMainForm->appendMessagesClient("lscp_create_audio_device");  
158                  break;                  break;
159          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
160                  if ((iDeviceID = ::lscp_create_midi_device(m_pClient,                  pRootItem = m_pMidiItems;
                                 device.driverName().latin1(), pParams)) < 0)  
                         m_pMainForm->appendMessagesClient("lscp_create_midi_device");  
161                  break;                  break;
162          case qsamplerDevice::None:          case qsamplerDevice::None:
163                  break;                  break;
164          }          }
165    
166          // Free used parameter array.          // Is the root present?
167          delete pParams;          if (pRootItem == NULL)
168                    return;
169    
170          // Show result.          // So there's no device huh?
171          if (iDeviceID >= 0) {          if (pDevice == NULL) {
172                  m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("created."));                  DeviceListView->setSelected(pRootItem, true);
173                  // Done.                  return;
174                  refreshDevices();          }
175    
176            // For each child, test for identity...
177            qsamplerDeviceItem *pDeviceItem =
178                    (qsamplerDeviceItem *) pRootItem->firstChild();
179            while (pDeviceItem) {
180                    // If identities match, select as current device item.
181                    if (pDeviceItem->device().deviceID() == pDevice->deviceID()) {
182                            DeviceListView->setSelected(pDeviceItem, true);
183                            break;
184                    }
185                    pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling();
186            }
187    }
188    
189    
190    
191    // Create a new device from current table view.
192    void qsamplerDeviceForm::createDevice (void)
193    {
194            if (m_pMainForm == NULL)
195                    return;
196    
197            QListViewItem *pItem = DeviceListView->selectedItem();
198            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
199                    return;
200    
201            // About a brand new device instance...
202            qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device());
203            if (device.createDevice()) {
204                    // Now it depends on the device type...
205                    qsamplerDeviceItem *pRootItem = NULL;
206                    switch (device.deviceType()) {
207                    case qsamplerDevice::Audio:
208                            pRootItem = m_pAudioItems;
209                            break;
210                    case qsamplerDevice::Midi:
211                            pRootItem = m_pMidiItems;
212                            break;
213                    case qsamplerDevice::None:
214                            break;
215                    }
216                    // Append the new device item.
217                    qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem,
218                            m_pMainForm, device.deviceType(), device.deviceID());
219                    // Just make it the new selection...
220                    DeviceListView->setSelected(pDeviceItem, true);
221                  // Main session should be marked dirty.                  // Main session should be marked dirty.
222                  m_pMainForm->sessionDirty();                  m_pMainForm->sessionDirty();
223                    m_iDirtyCount++;
224          }          }
225  }  }
226    
# Line 155  void qsamplerDeviceForm::createDevice (v Line 228  void qsamplerDeviceForm::createDevice (v
228  // Delete current device in table view.  // Delete current device in table view.
229  void qsamplerDeviceForm::deleteDevice (void)  void qsamplerDeviceForm::deleteDevice (void)
230  {  {
231          //          if (m_pMainForm == NULL)
232          // TODO: Delete current device in table view...                  return;
         //  
         m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()");  
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)
# Line 166  void qsamplerDeviceForm::deleteDevice (v Line 237  void qsamplerDeviceForm::deleteDevice (v
237    
238          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
239    
240          // Now it depends on the device type...          // Prompt user if this is for real...
241          lscp_status_t ret = LSCP_FAILED;          qsamplerOptions *pOptions = m_pMainForm->options();
242          switch (device.deviceType()) {          if (pOptions && pOptions->bConfirmRemove) {
243          case qsamplerDevice::Audio:                  if (QMessageBox::warning(this, tr("Warning"),
244                  if ((ret = ::lscp_destroy_audio_device(m_pClient,                          tr("Delete device:\n\n"
245                                  device.deviceID())) != LSCP_OK)                          "%1\n\n"
246                          m_pMainForm->appendMessagesClient("lscp_destroy_audio_device");                          "Are you sure?")
247                  break;                          .arg(device.deviceName()),
248          case qsamplerDevice::Midi:                          tr("OK"), tr("Cancel")) > 0)
249                  if ((ret = ::lscp_destroy_midi_device(m_pClient,                          return;
                                 device.deviceID())) != LSCP_OK)  
                         m_pMainForm->appendMessagesClient("lscp_destroy_midi_device");  
                 break;  
         case qsamplerDevice::None:  
                 break;  
250          }          }
251    
252          // Show result.          // Go and destroy...
253          if (ret == LSCP_OK) {          if (device.deleteDevice()) {
254                  m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("deleted."));                  // Remove it from the device view...
255                  // Done.                  delete pItem;
                 refreshDevices();  
256                  // Main session should be marked dirty.                  // Main session should be marked dirty.
257                  m_pMainForm->sessionDirty();                  m_pMainForm->sessionDirty();
258                    m_iDirtyCount++;
259          }          }
260  }  }
261    
# Line 197  void qsamplerDeviceForm::deleteDevice (v Line 263  void qsamplerDeviceForm::deleteDevice (v
263  // Refresh all device list and views.  // Refresh all device list and views.
264  void qsamplerDeviceForm::refreshDevices (void)  void qsamplerDeviceForm::refreshDevices (void)
265  {  {
266            if (m_pMainForm == NULL)
267                    return;
268    
269          // Avoid nested changes.          // Avoid nested changes.
270          m_iDirtySetup++;          m_iDirtySetup++;
271    
272          //          //
273          // TODO: Load device configuration data ...          // (Re)Load complete device configuration data ...
274          //          //
275          m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()");          m_pAudioItems = NULL;
276            m_pMidiItems = NULL;
277          DeviceListView->clear();          DeviceListView->clear();
278          if (m_pClient) {          if (m_pClient) {
                 qsamplerDeviceItem *pItem;  
279                  int *piDeviceIDs;                  int *piDeviceIDs;
280                  // Grab and pop Audio devices...                  // Grab and pop Audio devices...
281                  pItem = new qsamplerDeviceItem(DeviceListView, m_pClient,                  if (m_deviceTypeMode == qsamplerDevice::None ||
282                          qsamplerDevice::Audio);                          m_deviceTypeMode == qsamplerDevice::Audio) {
283                  if (pItem) {                          m_pAudioItems = new qsamplerDeviceItem(DeviceListView,
284                          pItem->setText(0, tr("Audio"));                                  m_pMainForm, qsamplerDevice::Audio);
285                    }
286                    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++) {
289                                  new qsamplerDeviceItem(pItem, m_pClient,                                  new qsamplerDeviceItem(m_pAudioItems, m_pMainForm,
290                                          qsamplerDevice::Audio, piDeviceIDs[i]);                                          qsamplerDevice::Audio, piDeviceIDs[i]);
291                          }                          }
292                          pItem->setOpen(true);                          m_pAudioItems->setOpen(true);
293                  }                  }
294                  // Grab and pop MIDI devices...                  // Grab and pop MIDI devices...
295                  pItem = new qsamplerDeviceItem(DeviceListView, m_pClient,                  if (m_deviceTypeMode == qsamplerDevice::None ||
296                          qsamplerDevice::Midi);                          m_deviceTypeMode == qsamplerDevice::Midi) {
297                  if (pItem) {                          m_pMidiItems = new qsamplerDeviceItem(DeviceListView,
298                          pItem->setText(0, tr("MIDI"));                                  m_pMainForm, qsamplerDevice::Midi);
299                    }
300                    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++) {
303                                  new qsamplerDeviceItem(pItem, m_pClient,                                  new qsamplerDeviceItem(m_pMidiItems, m_pMainForm,
304                                          qsamplerDevice::Midi, piDeviceIDs[i]);                                          qsamplerDevice::Midi, piDeviceIDs[i]);
305                          }                          }
306                          pItem->setOpen(true);                          m_pMidiItems->setOpen(true);
307                  }                  }
308          }          }
309    
310          // Done.          // Done.
         m_iDirtyCount = 0;  
311          m_iDirtySetup--;          m_iDirtySetup--;
312    
313          // Show something.          // Show something.
# Line 251  void qsamplerDeviceForm::selectDriver ( Line 322  void qsamplerDeviceForm::selectDriver (
322                  return;                  return;
323    
324          //          //
325          //  TODO: Driver name has changed for a new device...          //  Driver name has changed for a new device...
326          //          //
         m_pMainForm->appendMessages("qsamplerDeviceForm::selectDriver()");  
327    
328          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
329          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
# Line 263  void qsamplerDeviceForm::selectDriver ( Line 333  void qsamplerDeviceForm::selectDriver (
333    
334          // Driver change is only valid for scratch devices...          // Driver change is only valid for scratch devices...
335          if (m_bNewDevice) {          if (m_bNewDevice) {
336                  device.setDriver(m_pClient, sDriverName);                  m_iDirtySetup++;
337                  DeviceParamTable->refresh(device);                  device.setDriver(sDriverName);
338                  m_iDirtyCount++;                  DeviceParamTable->refresh(device.params(), m_bNewDevice);
339                    m_iDirtySetup--;
340                  // Done.                  // Done.
341                  stabilizeForm();                  stabilizeForm();
342          }          }
# Line 279  void qsamplerDeviceForm::selectDevice (v Line 350  void qsamplerDeviceForm::selectDevice (v
350                  return;                  return;
351    
352          //          //
353          //  TODO: Device selection has changed...          //  Device selection has changed...
354          //          //
         m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice()");  
355    
356          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
357          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {
358                  m_deviceType = qsamplerDevice::None;                  m_deviceType = qsamplerDevice::None;
359                  DeviceNameTextLabel->setText(QString::null);                  DeviceNameTextLabel->setText(QString::null);
360                  DeviceParamTable->setNumRows(0);                  DeviceParamTable->setNumRows(0);
361                    DevicePortComboBox->clear();
362                    DevicePortParamTable->setNumRows(0);
363                    DevicePortTextLabel->setEnabled(false);
364                    DevicePortComboBox->setEnabled(false);
365                    DevicePortParamTable->setEnabled(false);
366                  stabilizeForm();                  stabilizeForm();
367                  return;                  return;
368          }          }
369    
370          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
371    
372            m_iDirtySetup++;
373          // Flag whether this is a new device.          // Flag whether this is a new device.
374          m_bNewDevice = (device.deviceID() < 0);          m_bNewDevice = (device.deviceID() < 0);
375    
376          // Fill the device/driver heading...          // Fill the device/driver heading...
377          DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName());          DeviceNameTextLabel->setText(device.deviceName());
378          // The driver combobox is only rebuilt if device type has changed...          // The driver combobox is only rebuilt if device type has changed...
379          if (device.deviceType() != m_deviceType) {          if (device.deviceType() != m_deviceType) {
380                  DriverNameComboBox->clear();                  DriverNameComboBox->clear();
# Line 308  void qsamplerDeviceForm::selectDevice (v Line 384  void qsamplerDeviceForm::selectDevice (v
384          }          }
385          // Do we need a driver name?          // Do we need a driver name?
386          if (m_bNewDevice || device.driverName().isEmpty())          if (m_bNewDevice || device.driverName().isEmpty())
387                  device.setDriver(m_pClient, DriverNameComboBox->currentText());                  device.setDriver(DriverNameComboBox->currentText());
388          const QString& sDriverName = device.driverName();          setDriverName(device.driverName());
         if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL)  
                 DriverNameComboBox->insertItem(sDriverName);  
         DriverNameComboBox->setCurrentText(sDriverName);  
389          DriverNameTextLabel->setEnabled(m_bNewDevice);          DriverNameTextLabel->setEnabled(m_bNewDevice);
390          DriverNameComboBox->setEnabled(m_bNewDevice);          DriverNameComboBox->setEnabled(m_bNewDevice);
391          // Fill the device parameter table...          // Fill the device parameter table...
392          DeviceParamTable->refresh(device);          DeviceParamTable->refresh(device.params(), m_bNewDevice);
393            // And now the device port/channel parameter table...
394            switch (device.deviceType()) {
395            case qsamplerDevice::Audio:
396                    DevicePortTextLabel->setText(tr("Ch&annel:"));
397                    break;
398            case qsamplerDevice::Midi:
399                    DevicePortTextLabel->setText(tr("P&ort:"));
400                    break;
401            case qsamplerDevice::None:
402                    break;
403            }
404            DevicePortComboBox->clear();
405            DevicePortParamTable->setNumRows(0);
406            if (m_bNewDevice) {
407                    DevicePortTextLabel->setEnabled(false);
408                    DevicePortComboBox->setEnabled(false);
409                    DevicePortParamTable->setEnabled(false);
410            } else {
411                    QPixmap pixmap;
412                    switch (device.deviceType()) {
413                    case qsamplerDevice::Audio:
414                            pixmap = QPixmap::fromMimeSource("audio2.png");
415                            break;
416                    case qsamplerDevice::Midi:
417                            pixmap = QPixmap::fromMimeSource("midi2.png");
418                            break;
419                    case qsamplerDevice::None:
420                            break;
421                    }
422                    qsamplerDevicePortList& ports = device.ports();
423                    qsamplerDevicePort *pPort;
424                    for (pPort = ports.first(); pPort; pPort = ports.next()) {
425                            DevicePortComboBox->insertItem(pixmap, device.deviceTypeName()
426                                    + ' ' + device.driverName()
427                                    + ' ' + pPort->portName());
428                    }
429                    bool bEnabled = (ports.count() > 0);
430                    DevicePortTextLabel->setEnabled(bEnabled);
431                    DevicePortComboBox->setEnabled(bEnabled);
432                    DevicePortParamTable->setEnabled(bEnabled);
433            }
434            // Done.
435            m_iDirtySetup--;
436    
437            // Make the device port/channel selection effective.
438            selectDevicePort(DevicePortComboBox->currentItem());
439    }
440    
441    
442    // Device port/channel selection slot.
443    void qsamplerDeviceForm::selectDevicePort ( int iPort )
444    {
445            if (m_iDirtySetup > 0)
446                    return;
447    
448            //
449            //  Device port/channel selection has changed...
450            //
451    
452            QListViewItem *pItem = DeviceListView->selectedItem();
453            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
454                    return;
455    
456            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
457            qsamplerDevicePort *pPort = device.ports().at(iPort);
458            if (pPort) {
459                    m_iDirtySetup++;
460                    DevicePortParamTable->refresh(pPort->params(), false);
461                    m_iDirtySetup--;
462            }
463          // Done.          // Done.
464          stabilizeForm();          stabilizeForm();
465  }  }
466    
467    
468  // parameter value change slot.  // Device parameter value change slot.
469  void qsamplerDeviceForm::changeValue ( int iRow, int iCol )  void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol )
470  {  {
471            if (m_pMainForm == NULL)
472                    return;
473            if (m_iDirtySetup > 0)
474                    return;
475            if (iRow < 0 || iCol < 0)
476                    return;
477    
478          //          //
479          //  TODO: Device parameter change...          //  Device parameter change...
480          //          //
481          m_pMainForm->appendMessages("qsamplerDeviceForm::changeValue()");  
           
482          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
483          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
484                  return;                  return;
# Line 337  void qsamplerDeviceForm::changeValue ( i Line 486  void qsamplerDeviceForm::changeValue ( i
486          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
487    
488          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
         qsamplerDeviceParamMap& params = device.params();  
489          const QString sParam = DeviceParamTable->text(iRow, 0);          const QString sParam = DeviceParamTable->text(iRow, 0);
490          const QString sValue = DeviceParamTable->text(iRow, iCol);          const QString sValue = DeviceParamTable->text(iRow, iCol);
491          params[sParam].value = sValue;          // Set the local device parameter value.
492            if (device.setParam(sParam, sValue)) {
493          // Set proper device parameter, on existing device ...                  selectDevice();
494          if (device.deviceID() >= 0) {          } else {
495                  // Prepare parameter struct.                  stabilizeForm();
                 lscp_param_t param;  
                 param.key   = (char *) sParam.latin1();  
                 param.value = (char *) sValue.latin1();  
                 // Now it depends on the device type...  
                 lscp_status_t ret = LSCP_FAILED;  
                 switch (device.deviceType()) {  
                 case qsamplerDevice::Audio:  
                         if ((ret = ::lscp_set_audio_device_param(m_pClient,  
                                         device.deviceID(), &param)) != LSCP_OK)  
                                 m_pMainForm->appendMessagesClient("lscp_set_audio_device_param");  
                         break;  
                 case qsamplerDevice::Midi:  
                         if ((ret = ::lscp_set_midi_device_param(m_pClient,  
                                         device.deviceID(), &param)) != LSCP_OK)  
                                 m_pMainForm->appendMessagesClient("lscp_set_midi_device_param");  
                         break;  
                 case qsamplerDevice::None:  
                         break;  
                 }  
                 // Show result.  
                 if (ret == LSCP_OK) {  
                         m_pMainForm->appendMessages(device.deviceName() + ' ' +  
                                 QString("%1: %2.").arg(sParam).arg(sValue));  
                 }  
496          }          }
497            // Main session should be dirtier...
498            m_pMainForm->sessionDirty();
499    }
500    
501    
502    // Device port/channel parameter value change slot.
503    void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol )
504    {
505            if (m_pMainForm == NULL)
506                    return;
507            if (m_iDirtySetup > 0)
508                    return;
509            if (iRow < 0 || iCol < 0)
510                    return;
511    
512            //
513            //  Device port/channel parameter change...
514            //
515    
516            QListViewItem *pItem = DeviceListView->selectedItem();
517            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
518                    return;
519    
520            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
521    
522            int iPort = DevicePortComboBox->currentItem();
523            qsamplerDevicePort *pPort = device.ports().at(iPort);
524            if (pPort == NULL)
525                    return;
526    
527            // Table 1st column has the parameter name;
528            const QString sParam = DevicePortParamTable->text(iRow, 0);
529            const QString sValue = DevicePortParamTable->text(iRow, iCol);
530            // Set the local device port/channel parameter value.
531            pPort->setParam(sParam, sValue);
532          // Done.          // Done.
         m_iDirtyCount++;  
533          stabilizeForm();          stabilizeForm();
534          // Main session should be dirtier...          // Main session should be dirtier...
535          m_pMainForm->sessionDirty();          m_pMainForm->sessionDirty();
536  }  }
537    
538    
539    // Device list view context menu handler.
540    void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int )
541    {
542            int iItemID;
543    
544            // Build the device context menu...
545            QPopupMenu* pContextMenu = new QPopupMenu(this);
546    
547            bool bClient = (m_pClient != NULL);
548            bool bEnabled = (pItem != NULL);
549            iItemID = pContextMenu->insertItem(
550                    QIconSet(QPixmap::fromMimeSource("deviceCreate.png")),
551                    tr("&Create device"), this, SLOT(createDevice()));
552            pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice));
553            iItemID = pContextMenu->insertItem(
554                    QIconSet(QPixmap::fromMimeSource("deviceDelete.png")),
555                    tr("&Delete device"), this, SLOT(deleteDevice()));
556            pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice);
557            pContextMenu->insertSeparator();
558            iItemID = pContextMenu->insertItem(
559                    QIconSet(QPixmap::fromMimeSource("formRefresh.png")),
560                    tr("&Refresh"), this, SLOT(refreshDevices()));
561            pContextMenu->setItemEnabled(iItemID, bClient);
562    
563            pContextMenu->exec(pos);
564    
565            delete pContextMenu;
566    }
567    
568    
569  // Stabilize current form state.  // Stabilize current form state.
570  void qsamplerDeviceForm::stabilizeForm (void)  void qsamplerDeviceForm::stabilizeForm (void)
571  {  {
572          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
573            bool bClient = (m_pClient != NULL);
574          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != NULL);
575          DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);          DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
576          DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);          DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
577          DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);          DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
578          DeviceParamTable->setEnabled(bEnabled);          DeviceParamTable->setEnabled(bEnabled);
579          CreateDevicePushButton->setEnabled(bEnabled ||  m_bNewDevice);          RefreshDevicesPushButton->setEnabled(bClient);
580            CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
581          DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);          DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
582  }  }
583    

Legend:
Removed from v.436  
changed lines
  Added in v.622

  ViewVC Help
Powered by ViewVC