/[svn]/qsampler/trunk/src/qsamplerChannelForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelForm.cpp

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

revision 1498 by schoenebeck, Mon Nov 19 03:29:57 2007 UTC revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC
# Line 28  Line 28 
28  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
29  #include "qsamplerInstrument.h"  #include "qsamplerInstrument.h"
30    
31  #include <qvalidator.h>  #include <QValidator>
32  #include <qmessagebox.h>  #include <QMessageBox>
33  #include <qfiledialog.h>  #include <QFileDialog>
34  #include <qfileinfo.h>  #include <QFileInfo>
35    
36    #include <QHeaderView>
37    
38    
39  namespace QSampler {  namespace QSampler {
40    
# Line 44  ChannelForm::ChannelForm(QWidget* parent Line 47  ChannelForm::ChannelForm(QWidget* parent
47          m_iDirtySetup = 0;          m_iDirtySetup = 0;
48          m_iDirtyCount = 0;          m_iDirtyCount = 0;
49    
50          m_midiDevices.setAutoDelete(true);  //      m_midiDevices.setAutoDelete(true);
51          m_audioDevices.setAutoDelete(true);  //      m_audioDevices.setAutoDelete(true);
52    
53          m_pDeviceForm = NULL;          m_pDeviceForm = NULL;
54    
# Line 112  ChannelForm::ChannelForm(QWidget* parent Line 115  ChannelForm::ChannelForm(QWidget* parent
115                  SLOT(updateTableCellRenderers()));                  SLOT(updateTableCellRenderers()));
116  }  }
117    
118  ChannelForm::~ChannelForm() {  ChannelForm::~ChannelForm()
119    {
120          if (m_pDeviceForm)          if (m_pDeviceForm)
121                  delete m_pDeviceForm;                  delete m_pDeviceForm;
122          m_pDeviceForm = NULL;          m_pDeviceForm = NULL;
123    
124            qDeleteAll(m_midiDevices);
125            m_midiDevices.clear();
126    
127            qDeleteAll(m_audioDevices);
128            m_audioDevices.clear();
129  }  }
130    
131    
# Line 132  void ChannelForm::setup ( qsamplerChanne Line 142  void ChannelForm::setup ( qsamplerChanne
142    
143          // It can be a brand new channel, remember?          // It can be a brand new channel, remember?
144          bool bNew = (m_pChannel->channelID() < 0);          bool bNew = (m_pChannel->channelID() < 0);
145          setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName());          setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName());
146    
147          // Check if we're up and connected.          // Check if we're up and connected.
148          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
# Line 162  void ChannelForm::setup ( qsamplerChanne Line 172  void ChannelForm::setup ( qsamplerChanne
172    
173          // Populate Audio output type list.          // Populate Audio output type list.
174          ui.AudioDriverComboBox->clear();          ui.AudioDriverComboBox->clear();
175          ui.AudioDriverComboBox->insertStringList(          ui.AudioDriverComboBox->insertItems(0,
176                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));
177    
178          // Populate MIDI input type list.          // Populate MIDI input type list.
179          ui.MidiDriverComboBox->clear();          ui.MidiDriverComboBox->clear();
180          ui.MidiDriverComboBox->insertStringList(          ui.MidiDriverComboBox->insertItems(0,
181                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));
182    
183          // Populate Maps list.          // Populate Maps list.
184          ui.MidiMapComboBox->clear();          ui.MidiMapComboBox->clear();
185          ui.MidiMapComboBox->insertStringList(qsamplerInstrument::getMapNames());          ui.MidiMapComboBox->insertItems(0,
186                    qsamplerInstrument::getMapNames());
187    
188          // Read proper channel information,          // Read proper channel information,
189          // and populate the channel form fields.          // and populate the channel form fields.
# Line 194  void ChannelForm::setup ( qsamplerChanne Line 205  void ChannelForm::setup ( qsamplerChanne
205          QString sInstrumentFile = pChannel->instrumentFile();          QString sInstrumentFile = pChannel->instrumentFile();
206          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
207                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = qsamplerChannel::noInstrumentName();
208          ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile);          ui.InstrumentFileComboBox->setItemText(
209                    ui.InstrumentFileComboBox->currentIndex(),
210                    sInstrumentFile);
211          ui.InstrumentNrComboBox->clear();          ui.InstrumentNrComboBox->clear();
212          ui.InstrumentNrComboBox->insertStringList(          ui.InstrumentNrComboBox->insertItems(0,
213                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  qsamplerChannel::getInstrumentList(sInstrumentFile,
214                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
215          ui.InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());          ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr());
216    
217          // MIDI input device...          // MIDI input device...
218          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());
219          // MIDI input driver...          // MIDI input driver...
220          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
221          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
222                  sMidiDriver = pOptions->sMidiDriver.upper();                  sMidiDriver = pOptions->sMidiDriver.toUpper();
223          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
224                  if (ui.MidiDriverComboBox->findText(sMidiDriver,                  if (ui.MidiDriverComboBox->findText(sMidiDriver,
225                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
226                          ui.MidiDriverComboBox->insertItem(sMidiDriver);                          ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
227                  }                  }
228                  ui.MidiDriverComboBox->setCurrentText(sMidiDriver);                  ui.MidiDriverComboBox->setItemText(
229                            ui.MidiDriverComboBox->currentIndex(),
230                            sMidiDriver);
231          }          }
232          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
233          if (!bNew)          if (!bNew) {
234                  ui.MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());                  ui.MidiDeviceComboBox->setItemText(
235          selectMidiDeviceItem(ui.MidiDeviceComboBox->currentItem());                          ui.MidiDeviceComboBox->currentIndex(),
236                            midiDevice.deviceName());
237            }
238            selectMidiDeviceItem(ui.MidiDeviceComboBox->currentIndex());
239          // MIDI input port...          // MIDI input port...
240          ui.MidiPortSpinBox->setValue(pChannel->midiPort());          ui.MidiPortSpinBox->setValue(pChannel->midiPort());
241          // MIDI input channel...          // MIDI input channel...
# Line 225  void ChannelForm::setup ( qsamplerChanne Line 243  void ChannelForm::setup ( qsamplerChanne
243          // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
244          if (iMidiChannel < 0)          if (iMidiChannel < 0)
245                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);
246          ui.MidiChannelComboBox->setCurrentItem(iMidiChannel);          ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);
247          // MIDI instrument map...          // MIDI instrument map...
248          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());
249          // When new, try to suggest a sensible MIDI map...          // When new, try to suggest a sensible MIDI map...
250          if (iMidiMap < 0)          if (iMidiMap < 0)
251                  iMidiMap = 0;                  iMidiMap = 0;
252          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);
253          if (!sMapName.isEmpty())          if (!sMapName.isEmpty()) {
254                  ui.MidiMapComboBox->setCurrentText(sMapName);                  ui.MidiMapComboBox->setItemText(
255                            ui.MidiMapComboBox->currentIndex(),
256                            sMapName);
257            }
258          // It might be no maps around...          // It might be no maps around...
259          bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0);          bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0);
260          ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
# Line 244  void ChannelForm::setup ( qsamplerChanne Line 265  void ChannelForm::setup ( qsamplerChanne
265          // Audio output driver...          // Audio output driver...
266          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
267          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
268                  sAudioDriver = pOptions->sAudioDriver.upper();                  sAudioDriver = pOptions->sAudioDriver.toUpper();
269          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
270                  if (ui.AudioDriverComboBox->findText(sAudioDriver,                  if (ui.AudioDriverComboBox->findText(sAudioDriver,
271                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
272                          ui.AudioDriverComboBox->insertItem(sAudioDriver);                          ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
273                  }                  }
274                  ui.AudioDriverComboBox->setCurrentText(sAudioDriver);                  ui.AudioDriverComboBox->setItemText(
275                            ui.AudioDriverComboBox->currentIndex(),
276                            sAudioDriver);
277          }          }
278          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
279          if (!bNew)          if (!bNew) {
280                  ui.AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());                  ui.AudioDeviceComboBox->setItemText(
281          selectAudioDeviceItem(ui.AudioDeviceComboBox->currentItem());                          ui.AudioDeviceComboBox->currentIndex(),
282                            audioDevice.deviceName());
283            }
284            selectAudioDeviceItem(ui.AudioDeviceComboBox->currentIndex());
285    
286          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
287          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
# Line 298  void ChannelForm::accept (void) Line 324  void ChannelForm::accept (void)
324                          if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText()))
325                                  iErrors++;                                  iErrors++;
326                  } else {                  } else {
327                          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem());                          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentIndex());
328                          qsamplerChannelRoutingMap routingMap = routingModel.routingMap();                          qsamplerChannelRoutingMap routingMap = routingModel.routingMap();
329                          if (pDevice == NULL)                          if (pDevice == NULL)
330                                  iErrors++;                                  iErrors++;
# Line 309  void ChannelForm::accept (void) Line 335  void ChannelForm::accept (void)
335                                  qsamplerChannelRoutingMap::ConstIterator iter;                                  qsamplerChannelRoutingMap::ConstIterator iter;
336                                  for (iter = routingMap.begin();                                  for (iter = routingMap.begin();
337                                                  iter != routingMap.end(); ++iter) {                                                  iter != routingMap.end(); ++iter) {
338                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.value()))
339                                                  iErrors++;                                                  iErrors++;
340                                  }                                  }
341                          }                          }
# Line 319  void ChannelForm::accept (void) Line 345  void ChannelForm::accept (void)
345                          if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText()))
346                                  iErrors++;                                  iErrors++;
347                  } else {                  } else {
348                          qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem());                          qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentIndex());
349                          if (pDevice == NULL)                          if (pDevice == NULL)
350                                  iErrors++;                                  iErrors++;
351                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
# Line 329  void ChannelForm::accept (void) Line 355  void ChannelForm::accept (void)
355                  if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value()))
356                          iErrors++;                          iErrors++;
357                  // MIDI input channel...                  // MIDI input channel...
358                  if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentItem()))                  if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentIndex()))
359                          iErrors++;                          iErrors++;
360                  // Engine name...                  // Engine name...
361                  if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText()))
# Line 337  void ChannelForm::accept (void) Line 363  void ChannelForm::accept (void)
363                  // Instrument file and index...                  // Instrument file and index...
364                  const QString& sPath = ui.InstrumentFileComboBox->currentText();                  const QString& sPath = ui.InstrumentFileComboBox->currentText();
365                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {
366                          if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentItem()))                          if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentIndex()))
367                                  iErrors++;                                  iErrors++;
368                  }                  }
369                  // MIDI intrument map...                  // MIDI intrument map...
370                  if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentItem()))                  if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentIndex()))
371                          iErrors++;                          iErrors++;
372                  // Show error messages?                  // Show error messages?
373                  if (iErrors > 0)                  if (iErrors > 0)
# Line 349  void ChannelForm::accept (void) Line 375  void ChannelForm::accept (void)
375          }          }
376    
377          // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
378          pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true);          pOptions->sInstrumentDir = QFileInfo(
379                    ui.InstrumentFileComboBox->currentText()).dir().absolutePath();
380          pOptions->sEngineName  = ui.EngineNameComboBox->currentText();          pOptions->sEngineName  = ui.EngineNameComboBox->currentText();
381          pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText();          pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText();
382          pOptions->sMidiDriver  = ui.MidiDriverComboBox->currentText();          pOptions->sMidiDriver  = ui.MidiDriverComboBox->currentText();
383          pOptions->iMidiMap     = ui.MidiMapComboBox->currentItem();          pOptions->iMidiMap     = ui.MidiMapComboBox->currentIndex();
384          pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox);
385    
386          // Just go with dialog acceptance.          // Just go with dialog acceptance.
# Line 404  void ChannelForm::openInstrumentFile (vo Line 431  void ChannelForm::openInstrumentFile (vo
431    
432          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
433          // depending on the current engine.          // depending on the current engine.
434          QString sInstrumentFile = QFileDialog::getOpenFileName(          QString sInstrumentFile = QFileDialog::getOpenFileName(this,
435                  pOptions->sInstrumentDir,                   // Start here.                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.
436                  tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)                  pOptions->sInstrumentDir,                 // Start here.
437                  this, 0,                                    // Parent and name (none)                  tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files)
                 QSAMPLER_TITLE ": " + tr("Instrument files")    // Caption.  
438          );          );
439    
440          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
441                  return;                  return;
442    
443          ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile);          ui.InstrumentFileComboBox->setItemText(
444                    ui.InstrumentFileComboBox->currentIndex(),
445                    sInstrumentFile);
446    
447          updateInstrumentName();          updateInstrumentName();
448  }  }
449    
# Line 435  void ChannelForm::updateInstrumentName ( Line 464  void ChannelForm::updateInstrumentName (
464          // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
465          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
466          ui.InstrumentNrComboBox->clear();          ui.InstrumentNrComboBox->clear();
467          ui.InstrumentNrComboBox->insertStringList(          ui.InstrumentNrComboBox->insertItems(0,
468                  qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
469                          ui.InstrumentFileComboBox->currentText(),                          ui.InstrumentFileComboBox->currentText(),
470                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
# Line 484  void ChannelForm::selectMidiDriverItem ( Line 513  void ChannelForm::selectMidiDriverItem (
513          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
514                  return;                  return;
515    
516          const QString sDriverName = sMidiDriver.upper();          const QString sDriverName = sMidiDriver.toUpper();
517    
518          // Save current device id.          // Save current device id.
519          int iDeviceID = 0;          int iDeviceID = 0;
520          qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem());          qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentIndex());
521          if (pDevice)          if (pDevice)
522                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
523    
524          // Clean maplist.          // Clean maplist.
525          ui.MidiDeviceComboBox->clear();          ui.MidiDeviceComboBox->clear();
526            qDeleteAll(m_midiDevices);
527          m_midiDevices.clear();          m_midiDevices.clear();
528    
529          // Populate with the current ones...          // Populate with the current ones...
# Line 502  void ChannelForm::selectMidiDriverItem ( Line 532  void ChannelForm::selectMidiDriverItem (
532                  qsamplerDevice::Midi);                  qsamplerDevice::Midi);
533          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
534                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);
535                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
536                          ui.MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());                          ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());
537                          m_midiDevices.append(pDevice);                          m_midiDevices.append(pDevice);
538                  } else {                  } else {
539                          delete pDevice;                          delete pDevice;
# Line 515  void ChannelForm::selectMidiDriverItem ( Line 545  void ChannelForm::selectMidiDriverItem (
545          if (bEnabled) {          if (bEnabled) {
546                  // Select the previous current device...                  // Select the previous current device...
547                  int iMidiItem = 0;                  int iMidiItem = 0;
548                  for (pDevice = m_midiDevices.first();                  QListIterator<qsamplerDevice *> iter(m_midiDevices);
549                                  pDevice;                  while (iter.hasNext()) {
550                                          pDevice = m_midiDevices.next()) {                          pDevice = iter.next();
551                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
552                                  ui.MidiDeviceComboBox->setCurrentItem(iMidiItem);                                  ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);
553                                  selectMidiDeviceItem(iMidiItem);                                  selectMidiDeviceItem(iMidiItem);
554                                  break;                                  break;
555                          }                          }
556                          iMidiItem++;                          iMidiItem++;
557                  }                  }
558          } else {          } else {
559                  ui.MidiDeviceComboBox->insertItem(                  ui.MidiDeviceComboBox->insertItem(0,
560                          tr("(New MIDI %1 device)").arg(sMidiDriver));                          tr("(New MIDI %1 device)").arg(sMidiDriver));
561          }          }
562          ui.MidiDeviceTextLabel->setEnabled(bEnabled);          ui.MidiDeviceTextLabel->setEnabled(bEnabled);
# Line 555  void ChannelForm::selectMidiDeviceItem ( Line 585  void ChannelForm::selectMidiDeviceItem (
585                  ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  ui.MidiPortTextLabel->setEnabled(iPorts > 0);
586                  ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  ui.MidiPortSpinBox->setEnabled(iPorts > 0);
587                  if (iPorts > 0)                  if (iPorts > 0)
588                          ui.MidiPortSpinBox->setMaxValue(iPorts - 1);                          ui.MidiPortSpinBox->setMaximum(iPorts - 1);
589          }          }
590  }  }
591    
# Line 574  void ChannelForm::selectMidiDevice ( int Line 604  void ChannelForm::selectMidiDevice ( int
604  // MIDI device options.  // MIDI device options.
605  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
606  {  {
607          setupDevice(m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()),          setupDevice(m_midiDevices.at(ui.MidiDeviceComboBox->currentIndex()),
608                  qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText());                  qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText());
609  }  }
610    
# Line 588  void ChannelForm::selectAudioDriverItem Line 618  void ChannelForm::selectAudioDriverItem
618          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
619                  return;                  return;
620    
621          const QString sDriverName = sAudioDriver.upper();          const QString sDriverName = sAudioDriver.toUpper();
622    
623          // Save current device id.          // Save current device id.
624          int iDeviceID = 0;          int iDeviceID = 0;
625          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem());          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentIndex());
626          if (pDevice)          if (pDevice)
627                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
628    
629          // Clean maplist.          // Clean maplist.
630          ui.AudioDeviceComboBox->clear();          ui.AudioDeviceComboBox->clear();
631            qDeleteAll(m_audioDevices);
632          m_audioDevices.clear();          m_audioDevices.clear();
633    
634          // Populate with the current ones...          // Populate with the current ones...
# Line 606  void ChannelForm::selectAudioDriverItem Line 637  void ChannelForm::selectAudioDriverItem
637                  qsamplerDevice::Audio);                  qsamplerDevice::Audio);
638          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
639                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);
640                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
641                          ui.AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());                          ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());
642                          m_audioDevices.append(pDevice);                          m_audioDevices.append(pDevice);
643                  } else {                  } else {
644                          delete pDevice;                          delete pDevice;
# Line 619  void ChannelForm::selectAudioDriverItem Line 650  void ChannelForm::selectAudioDriverItem
650          if (bEnabled) {          if (bEnabled) {
651                  // Select the previous current device...                  // Select the previous current device...
652                  int iAudioItem = 0;                  int iAudioItem = 0;
653                  for (pDevice = m_audioDevices.first();                  QListIterator<qsamplerDevice *> iter(m_audioDevices);
654                                  pDevice;                  while (iter.hasNext()) {
655                                          pDevice = m_audioDevices.next()) {                          pDevice = iter.next();
656                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
657                                  ui.AudioDeviceComboBox->setCurrentItem(iAudioItem);                                  ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);
658                                  selectAudioDeviceItem(iAudioItem);                                  selectAudioDeviceItem(iAudioItem);
659                                  break;                                  break;
660                          }                          }
661                          iAudioItem++;                          iAudioItem++;
662                  }                  }
663          } else {          } else {
664                  ui.AudioDeviceComboBox->insertItem(                  ui.AudioDeviceComboBox->insertItem(0,
665                          tr("(New Audio %1 device)").arg(sAudioDriver));                          tr("(New Audio %1 device)").arg(sAudioDriver));
666                  //ui.AudioRoutingTable->setNumRows(0);                  //ui.AudioRoutingTable->setNumRows(0);
667          }          }
# Line 678  void ChannelForm::selectAudioDevice ( in Line 709  void ChannelForm::selectAudioDevice ( in
709  // Audio device options.  // Audio device options.
710  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
711  {  {
712          setupDevice(m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()),          setupDevice(m_audioDevices.at(ui.AudioDeviceComboBox->currentIndex()),
713                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());
714  }  }
715    

Legend:
Removed from v.1498  
changed lines
  Added in v.1499

  ViewVC Help
Powered by ViewVC