/[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 433 by capela, Wed Mar 9 16:44:04 2005 UTC revision 436 by capela, Wed Mar 9 20:55:04 2005 UTC
# Line 39  void qsamplerDeviceForm::init (void) Line 39  void qsamplerDeviceForm::init (void)
39          m_iDirtySetup = 0;          m_iDirtySetup = 0;
40          m_iDirtyCount = 0;          m_iDirtyCount = 0;
41          m_bNewDevice  = false;          m_bNewDevice  = false;
42            m_deviceType  = qsamplerDevice::None;
43    
44          // This an outsider (from designer), but rather important.          // This an outsider (from designer), but rather important.
45          QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)),          QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)),
46              this, SLOT(changeValue(int,int)));                  this, SLOT(changeValue(int,int)));
47                    
48          // Try to restore normal window positioning.          // Try to restore normal window positioning.
49          adjustSize();          adjustSize();
# Line 109  void qsamplerDeviceForm::createDevice (v Line 110  void qsamplerDeviceForm::createDevice (v
110          // Build the parameter list...          // Build the parameter list...
111          qsamplerDeviceParamMap& params = device.params();          qsamplerDeviceParamMap& params = device.params();
112          lscp_param_t *pParams = new lscp_param_t [params.count() + 1];          lscp_param_t *pParams = new lscp_param_t [params.count() + 1];
113          int i = 0;          int iParam = 0;
114          qsamplerDeviceParamMap::ConstIterator iter;          qsamplerDeviceParamMap::ConstIterator iter;
115          for (iter = params.begin(); iter != params.end(); ++iter) {          for (iter = params.begin(); iter != params.end(); ++iter) {
116                  pParams[i].key   = (char *) iter.key().latin1();                  pParams[iParam].key   = (char *) iter.key().latin1();
117                  pParams[i].value = (char *) iter.data().value.latin1();                  pParams[iParam].value = (char *) iter.data().value.latin1();
118                    ++iParam;
119          }          }
120          // Null terminated.          // Null terminated.
121          pParams[i].key   = NULL;          pParams[iParam].key   = NULL;
122          pParams[i].value = NULL;          pParams[iParam].value = NULL;
123    
124          // Now it depends on the device type...          // Now it depends on the device type...
125          int iDeviceID = -1;          int iDeviceID = -1;
126          switch (device.deviceType()) {          switch (device.deviceType()) {
127          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
128              if ((iDeviceID = ::lscp_create_audio_device(m_pClient,                  if ((iDeviceID = ::lscp_create_audio_device(m_pClient,
129                                  device.driverName().latin1(), pParams)) < 0)                                  device.driverName().latin1(), pParams)) < 0)
130                          m_pMainForm->appendMessagesClient("lscp_create_audio_device");                          m_pMainForm->appendMessagesClient("lscp_create_audio_device");
131                  break;                  break;
132          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
133              if ((iDeviceID = ::lscp_create_midi_device(m_pClient,                  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.          // Show result.
145          if (iDeviceID >= 0) {          if (iDeviceID >= 0) {
# Line 166  void qsamplerDeviceForm::deleteDevice (v Line 170  void qsamplerDeviceForm::deleteDevice (v
170          lscp_status_t ret = LSCP_FAILED;          lscp_status_t ret = LSCP_FAILED;
171          switch (device.deviceType()) {          switch (device.deviceType()) {
172          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
173              if ((ret = ::lscp_destroy_audio_device(m_pClient,                  if ((ret = ::lscp_destroy_audio_device(m_pClient,
174                                  device.deviceID())) != LSCP_OK)                                  device.deviceID())) != LSCP_OK)
175                          m_pMainForm->appendMessagesClient("lscp_destroy_audio_device");                          m_pMainForm->appendMessagesClient("lscp_destroy_audio_device");
176                  break;                  break;
177          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
178              if ((ret = ::lscp_destroy_midi_device(m_pClient,                  if ((ret = ::lscp_destroy_midi_device(m_pClient,
179                                  device.deviceID())) != LSCP_OK)                                  device.deviceID())) != LSCP_OK)
180                          m_pMainForm->appendMessagesClient("lscp_destroy_midi_device");                          m_pMainForm->appendMessagesClient("lscp_destroy_midi_device");
181                  break;                  break;
182            case qsamplerDevice::None:
183                    break;
184          }          }
185    
186          // Show result.          // Show result.
# Line 232  void qsamplerDeviceForm::refreshDevices Line 238  void qsamplerDeviceForm::refreshDevices
238          // Done.          // Done.
239          m_iDirtyCount = 0;          m_iDirtyCount = 0;
240          m_iDirtySetup--;          m_iDirtySetup--;
241            
242          // Show something.          // Show something.
243          selectDevice();          selectDevice();
244  }  }
# Line 242  void qsamplerDeviceForm::refreshDevices Line 248  void qsamplerDeviceForm::refreshDevices
248  void qsamplerDeviceForm::selectDriver ( const QString& sDriverName )  void qsamplerDeviceForm::selectDriver ( const QString& sDriverName )
249  {  {
250          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
251              return;                  return;
252    
253          //          //
254          //  TODO: Driver name has changed for a new device...          //  TODO: Driver name has changed for a new device...
# Line 254  void qsamplerDeviceForm::selectDriver ( Line 260  void qsamplerDeviceForm::selectDriver (
260                  return;                  return;
261    
262          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
263    
264            // Driver change is only valid for scratch devices...
265          if (m_bNewDevice) {          if (m_bNewDevice) {
266                  device.setDriver(m_pClient, sDriverName);                  device.setDriver(m_pClient, sDriverName);
267                    DeviceParamTable->refresh(device);
268                  m_iDirtyCount++;                  m_iDirtyCount++;
269                    // Done.
270                    stabilizeForm();
271          }          }
   
         // Done.  
         stabilizeForm();  
272  }  }
273    
274    
# Line 268  void qsamplerDeviceForm::selectDriver ( Line 276  void qsamplerDeviceForm::selectDriver (
276  void qsamplerDeviceForm::selectDevice (void)  void qsamplerDeviceForm::selectDevice (void)
277  {  {
278          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
279              return;                  return;
280    
281          //          //
282          //  TODO: Device selection has changed...          //  TODO: Device selection has changed...
# Line 277  void qsamplerDeviceForm::selectDevice (v Line 285  void qsamplerDeviceForm::selectDevice (v
285    
286          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
287          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {
288              DeviceNameTextLabel->setText(QString::null);                  m_deviceType = qsamplerDevice::None;
289              DeviceParamTable->setNumRows(0);                  DeviceNameTextLabel->setText(QString::null);
290                    DeviceParamTable->setNumRows(0);
291                  stabilizeForm();                  stabilizeForm();
292                  return;                  return;
293          }          }
294    
295          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
296    
297            // Flag whether this is a new device.
298          m_bNewDevice = (device.deviceID() < 0);          m_bNewDevice = (device.deviceID() < 0);
299    
300          // Fill the device/driver heading...          // Fill the device/driver heading...
301          DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName());          DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName());
302          DriverNameComboBox->clear();          // The driver combobox is only rebuilt if device type has changed...
303          DriverNameComboBox->insertStringList(          if (device.deviceType() != m_deviceType) {
304                  qsamplerDevice::getDrivers(m_pClient, device.deviceType()));                  DriverNameComboBox->clear();
305          const QString& sDriverName = device.driverName();                  DriverNameComboBox->insertStringList(
306          if (m_bNewDevice || sDriverName.isEmpty()) {                          qsamplerDevice::getDrivers(m_pClient, device.deviceType()));
307                  device.setDriver(m_pClient, DriverNameComboBox->currentText());                  m_deviceType = device.deviceType();
         } else {  
                 if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL)  
                         DriverNameComboBox->insertItem(sDriverName);  
                 DriverNameComboBox->setCurrentText(sDriverName);  
308          }          }
309            // Do we need a driver name?
310            if (m_bNewDevice || device.driverName().isEmpty())
311                    device.setDriver(m_pClient, DriverNameComboBox->currentText());
312            const QString& sDriverName = device.driverName();
313            if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL)
314                    DriverNameComboBox->insertItem(sDriverName);
315            DriverNameComboBox->setCurrentText(sDriverName);
316          DriverNameTextLabel->setEnabled(m_bNewDevice);          DriverNameTextLabel->setEnabled(m_bNewDevice);
317          DriverNameComboBox->setEnabled(m_bNewDevice);          DriverNameComboBox->setEnabled(m_bNewDevice);
   
318          // Fill the device parameter table...          // Fill the device parameter table...
319          DeviceParamTable->refresh(device);          DeviceParamTable->refresh(device);
   
320          // Done.          // Done.
321          stabilizeForm();          stabilizeForm();
322  }  }
# Line 324  void qsamplerDeviceForm::changeValue ( i Line 336  void qsamplerDeviceForm::changeValue ( i
336    
337          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
338    
339          // Table 3rd column has the parameter name;          // Table 1st column has the parameter name;
340          qsamplerDeviceParamMap& params = device.params();          qsamplerDeviceParamMap& params = device.params();
341          const QString sParam = DeviceParamTable->text(iRow, 2);          const QString sParam = DeviceParamTable->text(iRow, 0);
342          const QString sValue = DeviceParamTable->text(iRow, iCol);          const QString sValue = DeviceParamTable->text(iRow, iCol);
343          params[sParam].value = sValue;          params[sParam].value = sValue;
344    
# Line 340  void qsamplerDeviceForm::changeValue ( i Line 352  void qsamplerDeviceForm::changeValue ( i
352                  lscp_status_t ret = LSCP_FAILED;                  lscp_status_t ret = LSCP_FAILED;
353                  switch (device.deviceType()) {                  switch (device.deviceType()) {
354                  case qsamplerDevice::Audio:                  case qsamplerDevice::Audio:
355                      if ((ret = ::lscp_set_audio_device_param(m_pClient,                          if ((ret = ::lscp_set_audio_device_param(m_pClient,
356                                          device.deviceID(), &param)) != LSCP_OK)                                          device.deviceID(), &param)) != LSCP_OK)
357                                  m_pMainForm->appendMessagesClient("lscp_set_audio_device_param");                                  m_pMainForm->appendMessagesClient("lscp_set_audio_device_param");
358                          break;                          break;
359                  case qsamplerDevice::Midi:                  case qsamplerDevice::Midi:
360                      if ((ret = ::lscp_set_midi_device_param(m_pClient,                          if ((ret = ::lscp_set_midi_device_param(m_pClient,
361                                          device.deviceID(), &param)) != LSCP_OK)                                          device.deviceID(), &param)) != LSCP_OK)
362                                  m_pMainForm->appendMessagesClient("lscp_set_midi_device_param");                                  m_pMainForm->appendMessagesClient("lscp_set_midi_device_param");
363                          break;                          break;
364                    case qsamplerDevice::None:
365                            break;
366                  }                  }
367                  // Show result.                  // Show result.
368                  if (ret == LSCP_OK) {                  if (ret == LSCP_OK) {
# Line 356  void qsamplerDeviceForm::changeValue ( i Line 370  void qsamplerDeviceForm::changeValue ( i
370                                  QString("%1: %2.").arg(sParam).arg(sValue));                                  QString("%1: %2.").arg(sParam).arg(sValue));
371                  }                  }
372          }          }
373            
374          // Done.          // Done.
375          m_iDirtyCount++;          m_iDirtyCount++;
376          stabilizeForm();          stabilizeForm();
# Line 380  void qsamplerDeviceForm::stabilizeForm ( Line 394  void qsamplerDeviceForm::stabilizeForm (
394    
395    
396  // end of qsamplerDeviceForm.ui.h  // end of qsamplerDeviceForm.ui.h
   

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

  ViewVC Help
Powered by ViewVC