/[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 1509 by capela, Thu Nov 22 11:10:44 2007 UTC revision 2110 by capela, Sat Jul 17 12:21:01 2010 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-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 38  Line 38 
38    
39  namespace QSampler {  namespace QSampler {
40    
41    //-------------------------------------------------------------------------
42    // QSampler::Channelform -- Channel form implementation.
43    //
44    
45  ChannelForm::ChannelForm ( QWidget* pParent )  ChannelForm::ChannelForm ( QWidget* pParent )
46          : QDialog(pParent)          : QDialog(pParent)
47  {  {
48      m_ui.setupUi(this);          m_ui.setupUi(this);
49    
50          // Initialize locals.          // Initialize locals.
51          m_pChannel = NULL;          m_pChannel = NULL;
# Line 54  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;
62            m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
63            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          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
68  //      m_ui.AudioRoutingTable->verticalHeader()->hide();  //      m_ui.AudioRoutingTable->verticalHeader()->hide();
69    
70          // This goes initially hidden, and will be shown          // This goes initially hidden, and will be shown
71      // on setup() for currently existing channels...          // on setup() for currently existing channels...
72          m_ui.AudioRoutingTable->hide();          m_ui.AudioRoutingTable->hide();
73    
74          // Try to restore normal window positioning.          // Try to restore normal window positioning.
# Line 99  ChannelForm::ChannelForm ( QWidget* pPar Line 107  ChannelForm::ChannelForm ( QWidget* pPar
107          QObject::connect(m_ui.AudioDeviceComboBox,          QObject::connect(m_ui.AudioDeviceComboBox,
108                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
109                  SLOT(selectAudioDevice(int)));                  SLOT(selectAudioDevice(int)));
110          QObject::connect(m_ui.OkPushButton,          QObject::connect(m_ui.DialogButtonBox,
111                  SIGNAL(clicked()),                  SIGNAL(accepted()),
112                  SLOT(accept()));                  SLOT(accept()));
113          QObject::connect(m_ui.CancelPushButton,          QObject::connect(m_ui.DialogButtonBox,
114                  SIGNAL(clicked()),                  SIGNAL(rejected()),
115                  SLOT(reject()));                  SLOT(reject()));
116          QObject::connect(m_ui.MidiDeviceToolButton,          QObject::connect(m_ui.MidiDeviceToolButton,
117                  SIGNAL(clicked()),                  SIGNAL(clicked()),
# Line 137  ChannelForm::~ChannelForm() Line 145  ChannelForm::~ChannelForm()
145    
146    
147  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
148  void ChannelForm::setup ( qsamplerChannel *pChannel )  void ChannelForm::setup ( Channel *pChannel )
149  {  {
150          m_pChannel = pChannel;          m_pChannel = pChannel;
151    
# Line 148  void ChannelForm::setup ( qsamplerChanne Line 156  void ChannelForm::setup ( qsamplerChanne
156                  return;                  return;
157    
158          // It can be a brand new channel, remember?          // It can be a brand new channel, remember?
159          bool bNew = (m_pChannel->channelID() < 0);          const bool bNew = (m_pChannel->channelID() < 0);
160          setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName());          setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName());
161    
162          // Check if we're up and connected.          // Check if we're up and connected.
# Line 158  void ChannelForm::setup ( qsamplerChanne Line 166  void ChannelForm::setup ( qsamplerChanne
166          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
167                  return;                  return;
168    
169          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
170          if (pOptions == NULL)          if (pOptions == NULL)
171                  return;                  return;
172    
# Line 180  void ChannelForm::setup ( qsamplerChanne Line 188  void ChannelForm::setup ( qsamplerChanne
188          // Populate Audio output type list.          // Populate Audio output type list.
189          m_ui.AudioDriverComboBox->clear();          m_ui.AudioDriverComboBox->clear();
190          m_ui.AudioDriverComboBox->insertItems(0,          m_ui.AudioDriverComboBox->insertItems(0,
191                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));                  Device::getDrivers(pMainForm->client(), Device::Audio));
192    
193          // Populate MIDI input type list.          // Populate MIDI input type list.
194          m_ui.MidiDriverComboBox->clear();          m_ui.MidiDriverComboBox->clear();
195          m_ui.MidiDriverComboBox->insertItems(0,          m_ui.MidiDriverComboBox->insertItems(0,
196                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));                  Device::getDrivers(pMainForm->client(), Device::Midi));
197    
198          // Populate Maps list.          // Populate Maps list.
199          m_ui.MidiMapComboBox->clear();          m_ui.MidiMapComboBox->clear();
200          m_ui.MidiMapComboBox->insertItems(0,          m_ui.MidiMapComboBox->insertItems(0,
201                  qsamplerInstrument::getMapNames());                  Instrument::getMapNames());
202    
203          // Read proper channel information,          // Read proper channel information,
204          // and populate the channel form fields.          // and populate the channel form fields.
# Line 200  void ChannelForm::setup ( qsamplerChanne Line 208  void ChannelForm::setup ( qsamplerChanne
208          if (sEngineName.isEmpty() || bNew)          if (sEngineName.isEmpty() || bNew)
209                  sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
210          if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
211                  sEngineName = qsamplerChannel::noEngineName();                  sEngineName = Channel::noEngineName();
212          if (m_ui.EngineNameComboBox->findText(sEngineName,          if (m_ui.EngineNameComboBox->findText(sEngineName,
213                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
214                  m_ui.EngineNameComboBox->addItem(sEngineName);                  m_ui.EngineNameComboBox->addItem(sEngineName);
# Line 212  void ChannelForm::setup ( qsamplerChanne Line 220  void ChannelForm::setup ( qsamplerChanne
220          // Instrument filename and index...          // Instrument filename and index...
221          QString sInstrumentFile = pChannel->instrumentFile();          QString sInstrumentFile = pChannel->instrumentFile();
222          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
223                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = Channel::noInstrumentName();
224          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
225          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
226          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
227                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  Channel::getInstrumentList(sInstrumentFile,
228                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
229          m_ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr());          int iInstrumentNr = pChannel->instrumentNr();
230            if (iInstrumentNr < 0)
231                    iInstrumentNr = 0;
232            m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);
233    
234          // MIDI input device...          // MIDI input device...
235          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          Device midiDevice(Device::Midi, m_pChannel->midiDevice());
236          // MIDI input driver...          // MIDI input driver...
237          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
238          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
# Line 231  void ChannelForm::setup ( qsamplerChanne Line 242  void ChannelForm::setup ( qsamplerChanne
242                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
243                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
244                  }                  }
245                  m_ui.MidiDriverComboBox->setItemText(                  m_ui.MidiDriverComboBox->setCurrentIndex(
246                          m_ui.MidiDriverComboBox->currentIndex(),                          m_ui.MidiDriverComboBox->findText(sMidiDriver,
247                          sMidiDriver);                                  Qt::MatchExactly | Qt::MatchCaseSensitive)
248                    );
249          }          }
250          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
251          if (!bNew) {          if (!bNew) {
# Line 255  void ChannelForm::setup ( qsamplerChanne Line 267  void ChannelForm::setup ( qsamplerChanne
267          // When new, try to suggest a sensible MIDI map...          // When new, try to suggest a sensible MIDI map...
268          if (iMidiMap < 0)          if (iMidiMap < 0)
269                  iMidiMap = 0;                  iMidiMap = 0;
270          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = Instrument::getMapName(iMidiMap);
271          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
272                  m_ui.MidiMapComboBox->setItemText(                  m_ui.MidiMapComboBox->setItemText(
273                          m_ui.MidiMapComboBox->currentIndex(),                          m_ui.MidiMapComboBox->currentIndex(),
# Line 267  void ChannelForm::setup ( qsamplerChanne Line 279  void ChannelForm::setup ( qsamplerChanne
279          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
280    
281          // Audio output device...          // Audio output device...
282          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());          Device audioDevice(Device::Audio, m_pChannel->audioDevice());
283          // Audio output driver...          // Audio output driver...
284          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
285          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
# Line 277  void ChannelForm::setup ( qsamplerChanne Line 289  void ChannelForm::setup ( qsamplerChanne
289                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
290                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
291                  }                  }
292                  m_ui.AudioDriverComboBox->setItemText(                  m_ui.AudioDriverComboBox->setCurrentIndex(
293                          m_ui.AudioDriverComboBox->currentIndex(),                          m_ui.AudioDriverComboBox->findText(sAudioDriver,
294                          sAudioDriver);                                  Qt::MatchExactly | Qt::MatchCaseSensitive)
295                    );
296          }          }
297          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
298          if (!bNew) {          if (!bNew) {
# Line 293  void ChannelForm::setup ( qsamplerChanne Line 306  void ChannelForm::setup ( qsamplerChanne
306          // if we're editing an existing sampler channel...          // if we're editing an existing sampler channel...
307          m_ui.AudioRoutingTable->setVisible(!bNew);          m_ui.AudioRoutingTable->setVisible(!bNew);
308    
309            const QString sInstrumentNrToolTip =
310                    (pOptions->bInstrumentNames) ?
311                            "Select an instrument of the file" :
312                            "You might want to enable instrument name retrieval in the "
313                            "settings dialog";
314            m_ui.InstrumentNrComboBox->setToolTip(
315                    QObject::tr(sInstrumentNrToolTip.toUtf8().data())
316            );
317    
318          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
319          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
320  /*      if (sEngineName != qsamplerChannel::noEngineName() &&  /*      if (sEngineName != Channel::noEngineName() &&
321                  sInstrumentFile != qsamplerChannel::noInstrumentName())                  sInstrumentFile != Channel::noInstrumentName())
322                  m_iDirtyCount++; */                  m_iDirtyCount++; */
323          // Done.          // Done.
324          m_iDirtySetup--;          m_iDirtySetup--;
# Line 316  void ChannelForm::accept (void) Line 338  void ChannelForm::accept (void)
338          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
339                  return;                  return;
340    
341          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
342          if (pOptions == NULL)          if (pOptions == NULL)
343                  return;                  return;
344    
# Line 334  void ChannelForm::accept (void) Line 356  void ChannelForm::accept (void)
356                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
357                                  iErrors++;                                  iErrors++;
358                  } else {                  } else {
359                          qsamplerDevice *pDevice = NULL;                          Device *pDevice = NULL;
360                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
361                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
362                                  pDevice = m_audioDevices.at(iAudioItem);                                  pDevice = m_audioDevices.at(iAudioItem);
363                          qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap();                          ChannelRoutingMap routingMap = m_routingModel.routingMap();
364                          if (pDevice == NULL)                          if (pDevice == NULL)
365                                  iErrors++;                                  iErrors++;
366                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
367                                  iErrors++;                                  iErrors++;
368                          else if (!routingMap.isEmpty()) {                          else if (!routingMap.isEmpty()) {
369                                  // Set the audio route changes...                                  // Set the audio route changes...
370                                  qsamplerChannelRoutingMap::ConstIterator iter;                                  ChannelRoutingMap::ConstIterator iter;
371                                  for (iter = routingMap.begin();                                  for (iter = routingMap.begin();
372                                                  iter != routingMap.end(); ++iter) {                                                  iter != routingMap.end(); ++iter) {
373                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.value()))                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.value()))
# Line 358  void ChannelForm::accept (void) Line 380  void ChannelForm::accept (void)
380                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
381                                  iErrors++;                                  iErrors++;
382                  } else {                  } else {
383                          qsamplerDevice *pDevice = NULL;                          Device *pDevice = NULL;
384                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
385                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
386                                  pDevice = m_midiDevices.at(iMidiItem);                                  pDevice = m_midiDevices.at(iMidiItem);
# Line 386  void ChannelForm::accept (void) Line 408  void ChannelForm::accept (void)
408                  if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex()))                  if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex()))
409                          iErrors++;                          iErrors++;
410                  // Show error messages?                  // Show error messages?
411                  if (iErrors > 0)                  if (iErrors > 0) {
412                          m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));                          m_pChannel->appendMessagesError(
413                                    tr("Some channel settings could not be set.\n\nSorry."));
414                    }
415          }          }
416    
417          // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
# Line 410  void ChannelForm::reject (void) Line 434  void ChannelForm::reject (void)
434          bool bReject = true;          bool bReject = true;
435    
436          // Check if there's any pending changes...          // Check if there's any pending changes...
437          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0) {
438                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
439                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
440                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
441                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
442                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Apply |
443                  case 0:     // Apply...                          QMessageBox::Discard |
444                            QMessageBox::Cancel)) {
445                    case QMessageBox::Apply:
446                          accept();                          accept();
447                          return;                          return;
448                  case 1:     // Discard                  case QMessageBox::Discard:
449                          break;                          break;
450                  default:    // Cancel.                  default:    // Cancel.
451                          bReject = false;                          bReject = false;
# Line 441  void ChannelForm::openInstrumentFile (vo Line 467  void ChannelForm::openInstrumentFile (vo
467          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
468                  return;                  return;
469    
470          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
471          if (pOptions == NULL)          if (pOptions == NULL)
472                  return;                  return;
473    
474          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
475          // depending on the current engine.          // depending on the current engine.
476            QStringList filters;
477            const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper();
478            if (sEngineName.contains("GIG"))
479                    filters << tr("GIG Instrument files") + " (*.gig *.dls)";
480            if (sEngineName.contains("SFZ"))
481                    filters << tr("SFZ Instrument files") + " (*.sfz)";
482            if (sEngineName.contains("SF2"))
483                    filters << tr("SF2 Instrument files") + " (*.sf2)";
484            filters << tr("All files") + " (*.*)";
485            const QString& filter = filters.join(";;");
486    
487          QString sInstrumentFile = QFileDialog::getOpenFileName(this,          QString sInstrumentFile = QFileDialog::getOpenFileName(this,
488                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.
489                  pOptions->sInstrumentDir,                 // Start here.                  pOptions->sInstrumentDir, // Start here.
490                  tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files)                  filter                    // File filter.
491          );          );
492    
493          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
# Line 470  void ChannelForm::updateInstrumentName ( Line 507  void ChannelForm::updateInstrumentName (
507          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
508                  return;                  return;
509    
510          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
511          if (pOptions == NULL)          if (pOptions == NULL)
512                  return;                  return;
513    
# Line 478  void ChannelForm::updateInstrumentName ( Line 515  void ChannelForm::updateInstrumentName (
515          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
516          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
517          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
518                  qsamplerChannel::getInstrumentList(                  Channel::getInstrumentList(
519                          m_ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
520                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
521          );          );
# Line 488  void ChannelForm::updateInstrumentName ( Line 525  void ChannelForm::updateInstrumentName (
525    
526    
527  // Show device options dialog.  // Show device options dialog.
528  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,  void ChannelForm::setupDevice ( Device *pDevice,
529          qsamplerDevice::DeviceType deviceTypeMode,          Device::DeviceType deviceTypeMode,
530          const QString& sDriverName )          const QString& sDriverName )
531  {  {
         if (pDevice == NULL)  
                 return;  
   
532          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
533          if (pMainForm == NULL)          if (pMainForm == NULL)
534                  return;                  return;
# Line 504  void ChannelForm::setupDevice ( qsampler Line 538  void ChannelForm::setupDevice ( qsampler
538          // Create the device form if not already...          // Create the device form if not already...
539          if (m_pDeviceForm == NULL) {          if (m_pDeviceForm == NULL) {
540                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);
541          m_pDeviceForm->setAttribute(Qt::WA_ShowModal);                  m_pDeviceForm->setAttribute(Qt::WA_ShowModal);
542                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
543                          this, SLOT(updateDevices()));                          this, SLOT(updateDevices()));
544          }          }
# Line 534  void ChannelForm::selectMidiDriverItem ( Line 568  void ChannelForm::selectMidiDriverItem (
568          // Save current device id.          // Save current device id.
569          // Save current device id.          // Save current device id.
570          int iDeviceID = 0;          int iDeviceID = 0;
571          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
572          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
573          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
574                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
# Line 547  void ChannelForm::selectMidiDriverItem ( Line 581  void ChannelForm::selectMidiDriverItem (
581          m_midiDevices.clear();          m_midiDevices.clear();
582    
583          // Populate with the current ones...          // Populate with the current ones...
584          const QPixmap midiPixmap(":/icons/midi2.png");          const QPixmap midiPixmap(":/images/midi2.png");
585          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = Device::getDevices(pMainForm->client(),
586                  qsamplerDevice::Midi);                  Device::Midi);
587          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
588                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new Device(Device::Midi, piDeviceIDs[i]);
589                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
590                          m_ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());                          m_ui.MidiDeviceComboBox->insertItem(0,
591                                    midiPixmap, pDevice->deviceName());
592                          m_midiDevices.append(pDevice);                          m_midiDevices.append(pDevice);
593                  } else {                  } else {
594                          delete pDevice;                          delete pDevice;
# Line 565  void ChannelForm::selectMidiDriverItem ( Line 600  void ChannelForm::selectMidiDriverItem (
600          if (bEnabled) {          if (bEnabled) {
601                  // Select the previous current device...                  // Select the previous current device...
602                  iMidiItem = 0;                  iMidiItem = 0;
603                  QListIterator<qsamplerDevice *> iter(m_midiDevices);                  QListIterator<Device *> iter(m_midiDevices);
604                  while (iter.hasNext()) {                  while (iter.hasNext()) {
605                          pDevice = iter.next();                          pDevice = iter.next();
606                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
# Line 598  void ChannelForm::selectMidiDriver ( con Line 633  void ChannelForm::selectMidiDriver ( con
633  // Select MIDI device item.  // Select MIDI device item.
634  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )
635  {  {
636          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
637          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
638                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
639          if (pDevice) {          if (pDevice) {
640                  const qsamplerDeviceParamMap& params = pDevice->params();                  const DeviceParamMap& params = pDevice->params();
641                  int iPorts = params["PORTS"].value.toInt();                  int iPorts = params["PORTS"].value.toInt();
642                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
643                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
# Line 626  void ChannelForm::selectMidiDevice ( int Line 661  void ChannelForm::selectMidiDevice ( int
661  // MIDI device options.  // MIDI device options.
662  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
663  {  {
664          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
665          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
666          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
667                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
668          setupDevice(pDevice,          setupDevice(pDevice,
669                  qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText());                  Device::Midi, m_ui.MidiDriverComboBox->currentText());
670  }  }
671    
672    
# Line 648  void ChannelForm::selectAudioDriverItem Line 683  void ChannelForm::selectAudioDriverItem
683    
684          // Save current device id.          // Save current device id.
685          int iDeviceID = 0;          int iDeviceID = 0;
686          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
687          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
688          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
689                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
# Line 661  void ChannelForm::selectAudioDriverItem Line 696  void ChannelForm::selectAudioDriverItem
696          m_audioDevices.clear();          m_audioDevices.clear();
697    
698          // Populate with the current ones...          // Populate with the current ones...
699          const QPixmap audioPixmap(":/icons/audio2.png");          const QPixmap audioPixmap(":/images/audio2.png");
700          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = Device::getDevices(pMainForm->client(),
701                  qsamplerDevice::Audio);                  Device::Audio);
702          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
703                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new Device(Device::Audio, piDeviceIDs[i]);
704                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
705                          m_ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());                          m_ui.AudioDeviceComboBox->insertItem(0,
706                                    audioPixmap, pDevice->deviceName());
707                          m_audioDevices.append(pDevice);                          m_audioDevices.append(pDevice);
708                  } else {                  } else {
709                          delete pDevice;                          delete pDevice;
# Line 679  void ChannelForm::selectAudioDriverItem Line 715  void ChannelForm::selectAudioDriverItem
715          if (bEnabled) {          if (bEnabled) {
716                  // Select the previous current device...                  // Select the previous current device...
717                  iAudioItem = 0;                  iAudioItem = 0;
718                  QListIterator<qsamplerDevice *> iter(m_audioDevices);                  QListIterator<Device *> iter(m_audioDevices);
719                  while (iter.hasNext()) {                  while (iter.hasNext()) {
720                          pDevice = iter.next();                          pDevice = iter.next();
721                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
# Line 714  void ChannelForm::selectAudioDriver ( co Line 750  void ChannelForm::selectAudioDriver ( co
750  // Select Audio device item.  // Select Audio device item.
751  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )
752  {  {
753          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
754          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
755                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
756          if (pDevice) {          if (pDevice) {
# Line 740  void ChannelForm::selectAudioDevice ( in Line 776  void ChannelForm::selectAudioDevice ( in
776  // Audio device options.  // Audio device options.
777  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
778  {  {
779          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
780          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
781          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
782                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
783          setupDevice(pDevice,          setupDevice(pDevice,
784                  qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText());                  Device::Audio, m_ui.AudioDriverComboBox->currentText());
785  }  }
786    
787  // UPdate all device lists slot.  // UPdate all device lists slot.
# Line 776  void ChannelForm::stabilizeForm (void) Line 812  void ChannelForm::stabilizeForm (void)
812  {  {
813          const bool bValid =          const bool bValid =
814                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&
815                  m_ui.EngineNameComboBox->currentText() !=                  m_ui.EngineNameComboBox->currentText()
816                  qsamplerChannel::noEngineName();                          != Channel::noEngineName();
817  #if 0  #if 0
818          const QString& sPath = InstrumentFileComboBox->currentText();          const QString& sPath = InstrumentFileComboBox->currentText();
819          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
820  #endif  #endif
821          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.DialogButtonBox->button(
822                    QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid);
823  }  }
824    
825    
826  void ChannelForm::updateTableCellRenderers (void)  void ChannelForm::updateTableCellRenderers (void)
827  {  {
828      const int rows = m_routingModel.rowCount();          const int rows = m_routingModel.rowCount();
829      const int cols = m_routingModel.columnCount();          const int cols = m_routingModel.columnCount();
830      updateTableCellRenderers(          updateTableCellRenderers(
831                  m_routingModel.index(0, 0),                  m_routingModel.index(0, 0),
832                  m_routingModel.index(rows - 1, cols - 1));                  m_routingModel.index(rows - 1, cols - 1));
833  }  }
# Line 799  void ChannelForm::updateTableCellRendere Line 836  void ChannelForm::updateTableCellRendere
836  void ChannelForm::updateTableCellRenderers (  void ChannelForm::updateTableCellRenderers (
837          const QModelIndex& topLeft, const QModelIndex& bottomRight )          const QModelIndex& topLeft, const QModelIndex& bottomRight )
838  {  {
839      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {          for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
840          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {                  for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
841              const QModelIndex index = m_routingModel.index(r, c);                          const QModelIndex index = m_routingModel.index(r, c);
842              m_ui.AudioRoutingTable->openPersistentEditor(index);                          m_ui.AudioRoutingTable->openPersistentEditor(index);
843          }                  }
844      }          }
845  }  }
846    
847  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1509  
changed lines
  Added in v.2110

  ViewVC Help
Powered by ViewVC