/[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 1710 by schoenebeck, Tue Feb 26 16:00:00 2008 UTC revision 3435 by capela, Mon Dec 3 12:04:14 2018 UTC
# Line 1  Line 1 
1  // qsamplerChannelForm.cpp  // qsamplerChannelForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2018, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 58  ChannelForm::ChannelForm ( QWidget* pPar Line 58  ChannelForm::ChannelForm ( QWidget* pPar
58    
59          m_pDeviceForm = NULL;          m_pDeviceForm = NULL;
60    
61          int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4;          const int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4;
62          m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);          m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
63          m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);          m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
64    
65          m_ui.AudioRoutingTable->setModel(&m_routingModel);          m_ui.AudioRoutingTable->setModel(&m_routingModel);
66          m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);          m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);
67    #if QT_VERSION >= 0x050000
68            m_ui.AudioRoutingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
69    #else
70          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
71    #endif
72  //      m_ui.AudioRoutingTable->verticalHeader()->hide();  //      m_ui.AudioRoutingTable->verticalHeader()->hide();
73    
74          // This goes initially hidden, and will be shown          // This goes initially hidden, and will be shown
# Line 78  ChannelForm::ChannelForm ( QWidget* pPar Line 82  ChannelForm::ChannelForm ( QWidget* pPar
82                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
83                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
84          QObject::connect(m_ui.InstrumentFileComboBox,          QObject::connect(m_ui.InstrumentFileComboBox,
85                    SIGNAL(editTextChanged(const QString&)),
86                    SLOT(updateInstrumentName()));
87            QObject::connect(m_ui.InstrumentFileComboBox,
88                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
89                  SLOT(updateInstrumentName()));                  SLOT(updateInstrumentName()));
90          QObject::connect(m_ui.InstrumentFileToolButton,          QObject::connect(m_ui.InstrumentFileToolButton,
# Line 107  ChannelForm::ChannelForm ( QWidget* pPar Line 114  ChannelForm::ChannelForm ( QWidget* pPar
114          QObject::connect(m_ui.AudioDeviceComboBox,          QObject::connect(m_ui.AudioDeviceComboBox,
115                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
116                  SLOT(selectAudioDevice(int)));                  SLOT(selectAudioDevice(int)));
117          QObject::connect(m_ui.OkPushButton,          QObject::connect(m_ui.DialogButtonBox,
118                  SIGNAL(clicked()),                  SIGNAL(accepted()),
119                  SLOT(accept()));                  SLOT(accept()));
120          QObject::connect(m_ui.CancelPushButton,          QObject::connect(m_ui.DialogButtonBox,
121                  SIGNAL(clicked()),                  SIGNAL(rejected()),
122                  SLOT(reject()));                  SLOT(reject()));
123          QObject::connect(m_ui.MidiDeviceToolButton,          QObject::connect(m_ui.MidiDeviceToolButton,
124                  SIGNAL(clicked()),                  SIGNAL(clicked()),
# Line 119  ChannelForm::ChannelForm ( QWidget* pPar Line 126  ChannelForm::ChannelForm ( QWidget* pPar
126          QObject::connect(m_ui.AudioDeviceToolButton,          QObject::connect(m_ui.AudioDeviceToolButton,
127                  SIGNAL(clicked()),                  SIGNAL(clicked()),
128                  SLOT(setupAudioDevice()));                  SLOT(setupAudioDevice()));
129    
130          QObject::connect(&m_routingModel,          QObject::connect(&m_routingModel,
131                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
132                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
# Line 175  void ChannelForm::setup ( Channel *pChan Line 183  void ChannelForm::setup ( Channel *pChan
183    
184          // Load combo box history...          // Load combo box history...
185          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);
186            // Remove non-existant instrument file-paths...
187            int i = m_ui.InstrumentFileComboBox->count() - 1;
188            while (i >= 0) {
189                    const QString& sInstrumentFile
190                            = m_ui.InstrumentFileComboBox->itemText(i);
191                    if (sInstrumentFile.isEmpty()
192                            || !QFileInfo(sInstrumentFile).exists())
193                            m_ui.InstrumentFileComboBox->removeItem(i);
194                    --i;
195            }
196    
197          // Populate Engines list.          // Populate Engines list.
198          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
# Line 232  void ChannelForm::setup ( Channel *pChan Line 250  void ChannelForm::setup ( Channel *pChan
250          m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);          m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);
251    
252          // MIDI input device...          // MIDI input device...
253          Device midiDevice(Device::Midi, m_pChannel->midiDevice());          const Device midiDevice(Device::Midi, m_pChannel->midiDevice());
254          // MIDI input driver...          // MIDI input driver...
255          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
256          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
# Line 249  void ChannelForm::setup ( Channel *pChan Line 267  void ChannelForm::setup ( Channel *pChan
267          }          }
268          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
269          if (!bNew) {          if (!bNew) {
270                  m_ui.MidiDeviceComboBox->setItemText(                  m_ui.MidiDeviceComboBox->setCurrentIndex(
271                          m_ui.MidiDeviceComboBox->currentIndex(),                          m_ui.MidiDeviceComboBox->findData(midiDevice.deviceID()));
                         midiDevice.deviceName());  
272          }          }
273          selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex());          selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex());
274          // MIDI input port...          // MIDI input port...
# Line 274  void ChannelForm::setup ( Channel *pChan Line 291  void ChannelForm::setup ( Channel *pChan
291                          sMapName);                          sMapName);
292          }          }
293          // It might be no maps around...          // It might be no maps around...
294          bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);          const bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);
295          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
296          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
297    
298          // Audio output device...          // Audio output device...
299          Device audioDevice(Device::Audio, m_pChannel->audioDevice());          const Device audioDevice(Device::Audio, m_pChannel->audioDevice());
300          // Audio output driver...          // Audio output driver...
301          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
302          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
# Line 296  void ChannelForm::setup ( Channel *pChan Line 313  void ChannelForm::setup ( Channel *pChan
313          }          }
314          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
315          if (!bNew) {          if (!bNew) {
316                  m_ui.AudioDeviceComboBox->setItemText(                  m_ui.AudioDeviceComboBox->setCurrentIndex(
317                          m_ui.AudioDeviceComboBox->currentIndex(),                          m_ui.AudioDeviceComboBox->findData(audioDevice.deviceID()));
                         audioDevice.deviceName());  
318          }          }
319          selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex());          selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex());
320    
# Line 308  void ChannelForm::setup ( Channel *pChan Line 324  void ChannelForm::setup ( Channel *pChan
324    
325          const QString sInstrumentNrToolTip =          const QString sInstrumentNrToolTip =
326                  (pOptions->bInstrumentNames) ?                  (pOptions->bInstrumentNames) ?
327                          "Select an instrument of the file" :                          tr("Select an instrument of the file") :
328                          "You might want to enable instrument name retrieval in the "                          tr("You might want to enable instrument name retrieval in the "
329                          "settings dialog";                          "settings dialog");
330          m_ui.InstrumentNrComboBox->setToolTip(          m_ui.InstrumentNrComboBox->setToolTip(
331                  QObject::tr(sInstrumentNrToolTip.toUtf8().data())                  QObject::tr(sInstrumentNrToolTip.toUtf8().data())
332          );          );
333    
334    #if 0
335          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
336          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
337  /*      if (sEngineName != Channel::noEngineName() &&          if (sEngineName != Channel::noEngineName() &&
338                  sInstrumentFile != Channel::noInstrumentName())                  sInstrumentFile != Channel::noInstrumentName())
339                  m_iDirtyCount++; */                  m_iDirtyCount++;
340    #endif
341    
342          // Done.          // Done.
343          m_iDirtySetup--;          m_iDirtySetup--;
344          stabilizeForm();          stabilizeForm();
# Line 357  void ChannelForm::accept (void) Line 376  void ChannelForm::accept (void)
376                                  iErrors++;                                  iErrors++;
377                  } else {                  } else {
378                          Device *pDevice = NULL;                          Device *pDevice = NULL;
379                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();                          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
380                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0) {
381                                  pDevice = m_audioDevices.at(iAudioItem);                                  const int iAudioDevice
382                                            = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
383                                    pDevice = m_audioDevices.value(iAudioDevice, NULL);
384                            }
385                          ChannelRoutingMap routingMap = m_routingModel.routingMap();                          ChannelRoutingMap routingMap = m_routingModel.routingMap();
386                          if (pDevice == NULL)                          if (pDevice == NULL)
387                                  iErrors++;                                  iErrors++;
# Line 381  void ChannelForm::accept (void) Line 403  void ChannelForm::accept (void)
403                                  iErrors++;                                  iErrors++;
404                  } else {                  } else {
405                          Device *pDevice = NULL;                          Device *pDevice = NULL;
406                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();                          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
407                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0) {
408                                  pDevice = m_midiDevices.at(iMidiItem);                                  const int iMidiDevice
409                                            = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
410                                    pDevice = m_midiDevices.value(iMidiDevice, NULL);
411                            }
412                          if (pDevice == NULL)                          if (pDevice == NULL)
413                                  iErrors++;                                  iErrors++;
414                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
# Line 434  void ChannelForm::reject (void) Line 459  void ChannelForm::reject (void)
459          bool bReject = true;          bool bReject = true;
460    
461          // Check if there's any pending changes...          // Check if there's any pending changes...
462          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0) {
463                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
464                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
465                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
466                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
467                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Apply |
468                  case 0:     // Apply...                          QMessageBox::Discard |
469                            QMessageBox::Cancel)) {
470                    case QMessageBox::Apply:
471                          accept();                          accept();
472                          return;                          return;
473                  case 1:     // Discard                  case QMessageBox::Discard:
474                          break;                          break;
475                  default:    // Cancel.                  default:    // Cancel.
476                          bReject = false;                          bReject = false;
# Line 471  void ChannelForm::openInstrumentFile (vo Line 498  void ChannelForm::openInstrumentFile (vo
498    
499          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
500          // depending on the current engine.          // depending on the current engine.
501            QStringList filters;
502            const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper();
503            if (sEngineName.contains("GIG"))
504                    filters << tr("GIG Instrument files") + " (*.gig *.dls)";
505            if (sEngineName.contains("SFZ"))
506                    filters << tr("SFZ Instrument files") + " (*.sfz)";
507            if (sEngineName.contains("SF2"))
508                    filters << tr("SF2 Instrument files") + " (*.sf2)";
509            filters << tr("All files") + " (*.*)";
510            const QString& filter = filters.join(";;");
511    
512          QString sInstrumentFile = QFileDialog::getOpenFileName(this,          QString sInstrumentFile = QFileDialog::getOpenFileName(this,
513                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.
514                  pOptions->sInstrumentDir,                 // Start here.                  pOptions->sInstrumentDir, // Start here.
515                  tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files)                  filter                    // File filter.
516          );          );
517    
518          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
# Line 553  void ChannelForm::selectMidiDriverItem ( Line 591  void ChannelForm::selectMidiDriverItem (
591          const QString sDriverName = sMidiDriver.toUpper();          const QString sDriverName = sMidiDriver.toUpper();
592    
593          // Save current device id.          // Save current device id.
         // Save current device id.  
594          int iDeviceID = 0;          int iDeviceID = 0;
         Device *pDevice = NULL;  
595          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
596          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0)
597                  pDevice = m_midiDevices.at(iMidiItem);                  iDeviceID = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
         if (pDevice)  
                 iDeviceID = pDevice->deviceID();  
598    
599          // Clean maplist.          // Clean maplist.
600          m_ui.MidiDeviceComboBox->clear();          m_ui.MidiDeviceComboBox->clear();
# Line 568  void ChannelForm::selectMidiDriverItem ( Line 602  void ChannelForm::selectMidiDriverItem (
602          m_midiDevices.clear();          m_midiDevices.clear();
603    
604          // Populate with the current ones...          // Populate with the current ones...
605          const QPixmap midiPixmap(":/icons/midi2.png");          Device *pDevice = NULL;
606          int *piDeviceIDs = Device::getDevices(pMainForm->client(),          const QPixmap midiPixmap(":/images/midi2.png");
607                  Device::Midi);          int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Midi);
608          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
609                  pDevice = new Device(Device::Midi, piDeviceIDs[i]);                  pDevice = new Device(Device::Midi, piDeviceIDs[i]);
610                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
611                          m_ui.MidiDeviceComboBox->insertItem(0,                          const int iMidiDevice = pDevice->deviceID();
612                            m_ui.MidiDeviceComboBox->addItem(
613                                  midiPixmap, pDevice->deviceName());                                  midiPixmap, pDevice->deviceName());
614                          m_midiDevices.append(pDevice);                          m_ui.MidiDeviceComboBox->setItemData(i, iMidiDevice);
615                            m_midiDevices.insert(iMidiDevice, pDevice);
616                            if (iMidiDevice == iDeviceID)
617                                    iMidiItem = i;
618                  } else {                  } else {
619                          delete pDevice;                          delete pDevice;
620                  }                  }
621          }          }
622    
623          // Do proper enabling...          // Do proper enabling...
624          bool bEnabled = !m_midiDevices.isEmpty();          const bool bEnabled = !m_midiDevices.isEmpty();
625          if (bEnabled) {          if (bEnabled) {
626                  // Select the previous current device...                  // Select the previous current device...
627                  iMidiItem = 0;                  m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);
628                  QListIterator<Device *> iter(m_midiDevices);                  selectMidiDeviceItem(iMidiItem);
                 while (iter.hasNext()) {  
                         pDevice = iter.next();  
                         if (pDevice->deviceID() == iDeviceID) {  
                                 m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);  
                                 selectMidiDeviceItem(iMidiItem);  
                                 break;  
                         }  
                         iMidiItem++;  
                 }  
629          } else {          } else {
630                  m_ui.MidiDeviceComboBox->insertItem(0,                  m_ui.MidiDeviceComboBox->insertItem(0,
631                          tr("(New MIDI %1 device)").arg(sMidiDriver));                          tr("(New MIDI %1 device)").arg(sMidiDriver));
632          }          }
633          m_ui.MidiDeviceTextLabel->setEnabled(bEnabled);  //      m_ui.MidiDeviceTextLabel->setEnabled(bEnabled);
634          m_ui.MidiDeviceComboBox->setEnabled(bEnabled);  //      m_ui.MidiDeviceComboBox->setEnabled(bEnabled);
635  }  }
636    
637    
# Line 621  void ChannelForm::selectMidiDriver ( con Line 650  void ChannelForm::selectMidiDriver ( con
650  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )
651  {  {
652          Device *pDevice = NULL;          Device *pDevice = NULL;
653          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0) {
654                  pDevice = m_midiDevices.at(iMidiItem);                  const int iMidiDevice
655                            = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
656                    pDevice = m_midiDevices.value(iMidiDevice, NULL);
657            }
658          if (pDevice) {          if (pDevice) {
659                  const DeviceParamMap& params = pDevice->params();                  const DeviceParamMap& params = pDevice->params();
660                  int iPorts = params["PORTS"].value.toInt();                  const int iPorts = params["PORTS"].value.toInt();
661                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
662                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
663                  if (iPorts > 0)                  if (iPorts > 0)
# Line 649  void ChannelForm::selectMidiDevice ( int Line 681  void ChannelForm::selectMidiDevice ( int
681  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
682  {  {
683          Device *pDevice = NULL;          Device *pDevice = NULL;
684          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
685          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0) {
686                  pDevice = m_midiDevices.at(iMidiItem);                  const int iMidiDevice
687                            = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
688                    pDevice = m_midiDevices.value(iMidiDevice, NULL);
689            }
690          setupDevice(pDevice,          setupDevice(pDevice,
691                  Device::Midi, m_ui.MidiDriverComboBox->currentText());                  Device::Midi, m_ui.MidiDriverComboBox->currentText());
692  }  }
# Line 670  void ChannelForm::selectAudioDriverItem Line 705  void ChannelForm::selectAudioDriverItem
705    
706          // Save current device id.          // Save current device id.
707          int iDeviceID = 0;          int iDeviceID = 0;
         Device *pDevice = NULL;  
708          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
709          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0)
710                  pDevice = m_audioDevices.at(iAudioItem);                  iDeviceID = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
         if (pDevice)  
                 iDeviceID = pDevice->deviceID();  
711    
712          // Clean maplist.          // Clean maplist.
713          m_ui.AudioDeviceComboBox->clear();          m_ui.AudioDeviceComboBox->clear();
# Line 683  void ChannelForm::selectAudioDriverItem Line 715  void ChannelForm::selectAudioDriverItem
715          m_audioDevices.clear();          m_audioDevices.clear();
716    
717          // Populate with the current ones...          // Populate with the current ones...
718          const QPixmap audioPixmap(":/icons/audio2.png");          Device *pDevice = NULL;
719          int *piDeviceIDs = Device::getDevices(pMainForm->client(),          const QPixmap audioPixmap(":/images/audio2.png");
720                  Device::Audio);          int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Audio);
721          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
722                  pDevice = new Device(Device::Audio, piDeviceIDs[i]);                  pDevice = new Device(Device::Audio, piDeviceIDs[i]);
723                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
724                          m_ui.AudioDeviceComboBox->insertItem(0,                          const int iAudioDevice = pDevice->deviceID();
725                            m_ui.AudioDeviceComboBox->addItem(
726                                  audioPixmap, pDevice->deviceName());                                  audioPixmap, pDevice->deviceName());
727                          m_audioDevices.append(pDevice);                          m_ui.AudioDeviceComboBox->setItemData(i, iAudioDevice);
728                            m_audioDevices.insert(iAudioDevice, pDevice);
729                            if (iAudioDevice == iDeviceID)
730                                    iAudioItem = i;
731                  } else {                  } else {
732                          delete pDevice;                          delete pDevice;
733                  }                  }
734          }          }
735    
736          // Do proper enabling...          // Do proper enabling...
737          bool bEnabled = !m_audioDevices.isEmpty();          const bool bEnabled = !m_audioDevices.isEmpty();
738          if (bEnabled) {          if (bEnabled) {
739                  // Select the previous current device...                  // Select the previous current device...
740                  iAudioItem = 0;                  m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);
741                  QListIterator<Device *> iter(m_audioDevices);                  selectAudioDeviceItem(iAudioItem);
                 while (iter.hasNext()) {  
                         pDevice = iter.next();  
                         if (pDevice->deviceID() == iDeviceID) {  
                                 m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);  
                                 selectAudioDeviceItem(iAudioItem);  
                                 break;  
                         }  
                         iAudioItem++;  
                 }  
742          } else {          } else {
743                  m_ui.AudioDeviceComboBox->insertItem(0,                  m_ui.AudioDeviceComboBox->insertItem(0,
744                          tr("(New Audio %1 device)").arg(sAudioDriver));                          tr("(New Audio %1 device)").arg(sAudioDriver));
                 //m_ui.AudioRoutingTable->setNumRows(0);  
745          }          }
746          m_ui.AudioDeviceTextLabel->setEnabled(bEnabled);  //      m_ui.AudioDeviceTextLabel->setEnabled(bEnabled);
747          m_ui.AudioDeviceComboBox->setEnabled(bEnabled);  //      m_ui.AudioDeviceComboBox->setEnabled(bEnabled);
748          m_ui.AudioRoutingTable->setEnabled(bEnabled);          m_ui.AudioRoutingTable->setEnabled(bEnabled);
749  }  }
750    
# Line 738  void ChannelForm::selectAudioDriver ( co Line 764  void ChannelForm::selectAudioDriver ( co
764  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )
765  {  {
766          Device *pDevice = NULL;          Device *pDevice = NULL;
767          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0) {
768                  pDevice = m_audioDevices.at(iAudioItem);                  const int iAudioDevice
769                            = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
770                    pDevice = m_audioDevices.value(iAudioDevice, NULL);
771            }
772          if (pDevice) {          if (pDevice) {
773                  // Refresh the audio routing table.                  // Refresh the audio routing table.
774                  m_routingModel.refresh(pDevice, m_pChannel->audioRouting());                  m_routingModel.refresh(pDevice, m_pChannel->audioRouting());
# Line 764  void ChannelForm::selectAudioDevice ( in Line 793  void ChannelForm::selectAudioDevice ( in
793  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
794  {  {
795          Device *pDevice = NULL;          Device *pDevice = NULL;
796          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
797          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0) {
798                  pDevice = m_audioDevices.at(iAudioItem);                  const int iAudioDevice
799                            = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
800                    pDevice = m_audioDevices.value(iAudioDevice, NULL);
801            }
802          setupDevice(pDevice,          setupDevice(pDevice,
803                  Device::Audio, m_ui.AudioDriverComboBox->currentText());                  Device::Audio, m_ui.AudioDriverComboBox->currentText());
804  }  }
# Line 797  void ChannelForm::optionsChanged (void) Line 829  void ChannelForm::optionsChanged (void)
829  // Stabilize current form state.  // Stabilize current form state.
830  void ChannelForm::stabilizeForm (void)  void ChannelForm::stabilizeForm (void)
831  {  {
832          const bool bValid =          bool bValid = m_ui.EngineNameComboBox->currentIndex() >= 0 &&
833                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentText() != Channel::noEngineName();
834                  m_ui.EngineNameComboBox->currentText()  
835                          != Channel::noEngineName();          const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
 #if 0  
         const QString& sPath = InstrumentFileComboBox->currentText();  
836          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
837  #endif  
838          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.DialogButtonBox->button(
839                    QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid);
840  }  }
841    
842    

Legend:
Removed from v.1710  
changed lines
  Added in v.3435

  ViewVC Help
Powered by ViewVC