/[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 3554 by capela, Mon Jul 1 10:53:41 2019 UTC revision 3555 by capela, Tue Aug 13 10:19:32 2019 UTC
# Line 1  Line 1 
1  // qsamplerChannelForm.cpp  // qsamplerChannelForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2018, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, 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 48  ChannelForm::ChannelForm ( QWidget* pPar Line 48  ChannelForm::ChannelForm ( QWidget* pPar
48          m_ui.setupUi(this);          m_ui.setupUi(this);
49    
50          // Initialize locals.          // Initialize locals.
51          m_pChannel = NULL;          m_pChannel = nullptr;
52    
53          m_iDirtySetup = 0;          m_iDirtySetup = 0;
54          m_iDirtyCount = 0;          m_iDirtyCount = 0;
# Line 56  ChannelForm::ChannelForm ( QWidget* pPar Line 56  ChannelForm::ChannelForm ( QWidget* pPar
56  //      m_midiDevices.setAutoDelete(true);  //      m_midiDevices.setAutoDelete(true);
57  //      m_audioDevices.setAutoDelete(true);  //      m_audioDevices.setAutoDelete(true);
58    
59          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
60    
61          const 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);
# Line 142  ChannelForm::~ChannelForm() Line 142  ChannelForm::~ChannelForm()
142  {  {
143          if (m_pDeviceForm)          if (m_pDeviceForm)
144                  delete m_pDeviceForm;                  delete m_pDeviceForm;
145          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
146    
147          qDeleteAll(m_midiDevices);          qDeleteAll(m_midiDevices);
148          m_midiDevices.clear();          m_midiDevices.clear();
# Line 160  void ChannelForm::setup ( Channel *pChan Line 160  void ChannelForm::setup ( Channel *pChan
160          m_iDirtySetup = 0;          m_iDirtySetup = 0;
161          m_iDirtyCount = 0;          m_iDirtyCount = 0;
162    
163          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
164                  return;                  return;
165    
166          // It can be a brand new channel, remember?          // It can be a brand new channel, remember?
# Line 169  void ChannelForm::setup ( Channel *pChan Line 169  void ChannelForm::setup ( Channel *pChan
169    
170          // Check if we're up and connected.          // Check if we're up and connected.
171          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
172          if (pMainForm == NULL)          if (pMainForm == nullptr)
173                  return;                  return;
174          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
175                  return;                  return;
176    
177          Options *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
178          if (pOptions == NULL)          if (pOptions == nullptr)
179                  return;                  return;
180    
181          // Avoid nested changes.          // Avoid nested changes.
# Line 348  void ChannelForm::setup ( Channel *pChan Line 348  void ChannelForm::setup ( Channel *pChan
348  // Accept settings (OK button slot).  // Accept settings (OK button slot).
349  void ChannelForm::accept (void)  void ChannelForm::accept (void)
350  {  {
351          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
352                  return;                  return;
353    
354          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
355          if (pMainForm == NULL)          if (pMainForm == nullptr)
356                  return;                  return;
357          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
358                  return;                  return;
359    
360          Options *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
361          if (pOptions == NULL)          if (pOptions == nullptr)
362                  return;                  return;
363    
364          // Flush any pending editing...          // Flush any pending editing...
# Line 375  void ChannelForm::accept (void) Line 375  void ChannelForm::accept (void)
375                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
376                                  iErrors++;                                  iErrors++;
377                  } else {                  } else {
378                          Device *pDevice = NULL;                          Device *pDevice = nullptr;
379                          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();                          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
380                          if (iAudioItem >= 0) {                          if (iAudioItem >= 0) {
381                                  const int iAudioDevice                                  const int iAudioDevice
382                                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();                                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
383                                  pDevice = m_audioDevices.value(iAudioDevice, NULL);                                  pDevice = m_audioDevices.value(iAudioDevice, nullptr);
384                          }                          }
385                          ChannelRoutingMap routingMap = m_routingModel.routingMap();                          ChannelRoutingMap routingMap = m_routingModel.routingMap();
386                          if (pDevice == NULL)                          if (pDevice == nullptr)
387                                  iErrors++;                                  iErrors++;
388                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
389                                  iErrors++;                                  iErrors++;
# Line 402  void ChannelForm::accept (void) Line 402  void ChannelForm::accept (void)
402                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
403                                  iErrors++;                                  iErrors++;
404                  } else {                  } else {
405                          Device *pDevice = NULL;                          Device *pDevice = nullptr;
406                          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();                          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
407                          if (iMidiItem >= 0) {                          if (iMidiItem >= 0) {
408                                  const int iMidiDevice                                  const int iMidiDevice
409                                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();                                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
410                                  pDevice = m_midiDevices.value(iMidiDevice, NULL);                                  pDevice = m_midiDevices.value(iMidiDevice, nullptr);
411                          }                          }
412                          if (pDevice == NULL)                          if (pDevice == nullptr)
413                                  iErrors++;                                  iErrors++;
414                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
415                                  iErrors++;                                  iErrors++;
# Line 487  void ChannelForm::reject (void) Line 487  void ChannelForm::reject (void)
487  void ChannelForm::openInstrumentFile (void)  void ChannelForm::openInstrumentFile (void)
488  {  {
489          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
490          if (pMainForm == NULL)          if (pMainForm == nullptr)
491                  return;                  return;
492          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
493                  return;                  return;
494    
495          Options *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
496          if (pOptions == NULL)          if (pOptions == nullptr)
497                  return;                  return;
498    
499          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
# Line 527  void ChannelForm::openInstrumentFile (vo Line 527  void ChannelForm::openInstrumentFile (vo
527  void ChannelForm::updateInstrumentName (void)  void ChannelForm::updateInstrumentName (void)
528  {  {
529          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
530          if (pMainForm == NULL)          if (pMainForm == nullptr)
531                  return;                  return;
532          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
533                  return;                  return;
534    
535          Options *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
536          if (pOptions == NULL)          if (pOptions == nullptr)
537                  return;                  return;
538    
539          // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
# Line 555  void ChannelForm::setupDevice ( Device * Line 555  void ChannelForm::setupDevice ( Device *
555          const QString& sDriverName )          const QString& sDriverName )
556  {  {
557          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
558          if (pMainForm == NULL)          if (pMainForm == nullptr)
559                  return;                  return;
560          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
561                  return;                  return;
562    
563          // Create the device form if not already...          // Create the device form if not already...
564          if (m_pDeviceForm == NULL) {          if (m_pDeviceForm == nullptr) {
565                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);
566                  m_pDeviceForm->setAttribute(Qt::WA_ShowModal);                  m_pDeviceForm->setAttribute(Qt::WA_ShowModal);
567                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
# Line 583  void ChannelForm::setupDevice ( Device * Line 583  void ChannelForm::setupDevice ( Device *
583  void ChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )  void ChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )
584  {  {
585          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
586          if (pMainForm == NULL)          if (pMainForm == nullptr)
587                  return;                  return;
588          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
589                  return;                  return;
590    
591          const QString sDriverName = sMidiDriver.toUpper();          const QString sDriverName = sMidiDriver.toUpper();
# Line 602  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          Device *pDevice = NULL;          Device *pDevice = nullptr;
606          const QPixmap midiPixmap(":/images/midi2.png");          const QPixmap midiPixmap(":/images/midi2.png");
607          int *piDeviceIDs = Device::getDevices(pMainForm->client(), 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) {
# Line 650  void ChannelForm::selectMidiDriver ( con Line 650  void ChannelForm::selectMidiDriver ( con
650  // Select MIDI device item.  // Select MIDI device item.
651  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )
652  {  {
653          Device *pDevice = NULL;          Device *pDevice = nullptr;
654          if (iMidiItem >= 0) {          if (iMidiItem >= 0) {
655                  const int iMidiDevice                  const int iMidiDevice
656                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
657                  pDevice = m_midiDevices.value(iMidiDevice, NULL);                  pDevice = m_midiDevices.value(iMidiDevice, nullptr);
658          }          }
659          if (pDevice) {          if (pDevice) {
660                  const DeviceParamMap& params = pDevice->params();                  const DeviceParamMap& params = pDevice->params();
# Line 681  void ChannelForm::selectMidiDevice ( int Line 681  void ChannelForm::selectMidiDevice ( int
681  // MIDI device options.  // MIDI device options.
682  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
683  {  {
684          Device *pDevice = NULL;          Device *pDevice = nullptr;
685          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
686          if (iMidiItem >= 0) {          if (iMidiItem >= 0) {
687                  const int iMidiDevice                  const int iMidiDevice
688                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();                          = m_ui.MidiDeviceComboBox->itemData(iMidiItem).toInt();
689                  pDevice = m_midiDevices.value(iMidiDevice, NULL);                  pDevice = m_midiDevices.value(iMidiDevice, nullptr);
690          }          }
691          setupDevice(pDevice,          setupDevice(pDevice,
692                  Device::Midi, m_ui.MidiDriverComboBox->currentText());                  Device::Midi, m_ui.MidiDriverComboBox->currentText());
# Line 697  void ChannelForm::setupMidiDevice (void) Line 697  void ChannelForm::setupMidiDevice (void)
697  void ChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )  void ChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )
698  {  {
699          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
700          if (pMainForm == NULL)          if (pMainForm == nullptr)
701                  return;                  return;
702          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
703                  return;                  return;
704    
705          const QString sDriverName = sAudioDriver.toUpper();          const QString sDriverName = sAudioDriver.toUpper();
# Line 716  void ChannelForm::selectAudioDriverItem Line 716  void ChannelForm::selectAudioDriverItem
716          m_audioDevices.clear();          m_audioDevices.clear();
717    
718          // Populate with the current ones...          // Populate with the current ones...
719          Device *pDevice = NULL;          Device *pDevice = nullptr;
720          const QPixmap audioPixmap(":/images/audio2.png");          const QPixmap audioPixmap(":/images/audio2.png");
721          int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Audio);          int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Audio);
722          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
# Line 765  void ChannelForm::selectAudioDriver ( co Line 765  void ChannelForm::selectAudioDriver ( co
765  // Select Audio device item.  // Select Audio device item.
766  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )
767  {  {
768          Device *pDevice = NULL;          Device *pDevice = nullptr;
769          if (iAudioItem >= 0) {          if (iAudioItem >= 0) {
770                  const int iAudioDevice                  const int iAudioDevice
771                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
772                  pDevice = m_audioDevices.value(iAudioDevice, NULL);                  pDevice = m_audioDevices.value(iAudioDevice, nullptr);
773          }          }
774          if (pDevice) {          if (pDevice) {
775                  // Refresh the audio routing table.                  // Refresh the audio routing table.
# Line 794  void ChannelForm::selectAudioDevice ( in Line 794  void ChannelForm::selectAudioDevice ( in
794  // Audio device options.  // Audio device options.
795  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
796  {  {
797          Device *pDevice = NULL;          Device *pDevice = nullptr;
798          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
799          if (iAudioItem >= 0) {          if (iAudioItem >= 0) {
800                  const int iAudioDevice                  const int iAudioDevice
801                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();                          = m_ui.AudioDeviceComboBox->itemData(iAudioItem).toInt();
802                  pDevice = m_audioDevices.value(iAudioDevice, NULL);                  pDevice = m_audioDevices.value(iAudioDevice, nullptr);
803          }          }
804          setupDevice(pDevice,          setupDevice(pDevice,
805                  Device::Audio, m_ui.AudioDriverComboBox->currentText());                  Device::Audio, m_ui.AudioDriverComboBox->currentText());

Legend:
Removed from v.3554  
changed lines
  Added in v.3555

  ViewVC Help
Powered by ViewVC