/[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 1506 by schoenebeck, Wed Nov 21 19:57:18 2007 UTC revision 1510 by capela, Thu Nov 22 14:17:24 2007 UTC
# Line 38  Line 38 
38    
39  namespace QSampler {  namespace QSampler {
40    
41  ChannelForm::ChannelForm(QWidget* parent) : QDialog(parent) {  ChannelForm::ChannelForm ( QWidget* pParent )
42      ui.setupUi(this);          : QDialog(pParent)
43    {
44            m_ui.setupUi(this);
45    
46          // Initialize locals.          // Initialize locals.
47          m_pChannel = NULL;          m_pChannel = NULL;
# Line 52  ChannelForm::ChannelForm(QWidget* parent Line 54  ChannelForm::ChannelForm(QWidget* parent
54    
55          m_pDeviceForm = NULL;          m_pDeviceForm = NULL;
56    
57            m_ui.AudioRoutingTable->setModel(&m_routingModel);
58            m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);
59            m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
60    //      m_ui.AudioRoutingTable->verticalHeader()->hide();
61    
62            // This goes initially hidden, and will be shown
63            // on setup() for currently existing channels...
64            m_ui.AudioRoutingTable->hide();
65    
66          // Try to restore normal window positioning.          // Try to restore normal window positioning.
67          adjustSize();          adjustSize();
68    
69          ui.AudioRoutingTable->setModel(&routingModel);          QObject::connect(m_ui.EngineNameComboBox,
         ui.AudioRoutingTable->setItemDelegate(&routingDelegate);  
         ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);  
   
         QObject::connect(ui.EngineNameComboBox,  
70                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
71                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
72          QObject::connect(ui.InstrumentFileComboBox,          QObject::connect(m_ui.InstrumentFileComboBox,
73                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
74                  SLOT(updateInstrumentName()));                  SLOT(updateInstrumentName()));
75          QObject::connect(ui.InstrumentFileToolButton,          QObject::connect(m_ui.InstrumentFileToolButton,
76                  SIGNAL(clicked()),                  SIGNAL(clicked()),
77                  SLOT(openInstrumentFile()));                  SLOT(openInstrumentFile()));
78          QObject::connect(ui.InstrumentNrComboBox,          QObject::connect(m_ui.InstrumentNrComboBox,
79                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
80                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
81          QObject::connect(ui.MidiDriverComboBox,          QObject::connect(m_ui.MidiDriverComboBox,
82                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
83                  SLOT(selectMidiDriver(const QString&)));                  SLOT(selectMidiDriver(const QString&)));
84          QObject::connect(ui.MidiDeviceComboBox,          QObject::connect(m_ui.MidiDeviceComboBox,
85                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
86                  SLOT(selectMidiDevice(int)));                  SLOT(selectMidiDevice(int)));
87          QObject::connect(ui.MidiPortSpinBox,          QObject::connect(m_ui.MidiPortSpinBox,
88                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
89                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
90          QObject::connect(ui.MidiChannelComboBox,          QObject::connect(m_ui.MidiChannelComboBox,
91                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
92                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
93          QObject::connect(ui.MidiMapComboBox,          QObject::connect(m_ui.MidiMapComboBox,
94                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
95                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
96          QObject::connect(ui.AudioDriverComboBox,          QObject::connect(m_ui.AudioDriverComboBox,
97                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
98                  SLOT(selectAudioDriver(const QString&)));                  SLOT(selectAudioDriver(const QString&)));
99          QObject::connect(ui.AudioDeviceComboBox,          QObject::connect(m_ui.AudioDeviceComboBox,
100                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
101                  SLOT(selectAudioDevice(int)));                  SLOT(selectAudioDevice(int)));
102          QObject::connect(ui.OkPushButton,          QObject::connect(m_ui.OkPushButton,
103                  SIGNAL(clicked()),                  SIGNAL(clicked()),
104                  SLOT(accept()));                  SLOT(accept()));
105          QObject::connect(ui.CancelPushButton,          QObject::connect(m_ui.CancelPushButton,
106                  SIGNAL(clicked()),                  SIGNAL(clicked()),
107                  SLOT(reject()));                  SLOT(reject()));
108          QObject::connect(ui.MidiDeviceToolButton,          QObject::connect(m_ui.MidiDeviceToolButton,
109                  SIGNAL(clicked()),                  SIGNAL(clicked()),
110                  SLOT(setupMidiDevice()));                  SLOT(setupMidiDevice()));
111          QObject::connect(ui.AudioDeviceToolButton,          QObject::connect(m_ui.AudioDeviceToolButton,
112                  SIGNAL(clicked()),                  SIGNAL(clicked()),
113                  SLOT(setupAudioDevice()));                  SLOT(setupAudioDevice()));
114          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
115                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
116                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
117          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
118                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
119                  SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&)));
120          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
121                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
122                  SLOT(updateTableCellRenderers()));                  SLOT(updateTableCellRenderers()));
123  }  }
# Line 159  void ChannelForm::setup ( qsamplerChanne Line 166  void ChannelForm::setup ( qsamplerChanne
166          m_iDirtySetup++;          m_iDirtySetup++;
167    
168          // Load combo box history...          // Load combo box history...
169          pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);
170    
171          // Populate Engines list.          // Populate Engines list.
172          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
173          if (ppszEngines) {          if (ppszEngines) {
174                  ui.EngineNameComboBox->clear();                  m_ui.EngineNameComboBox->clear();
175                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
176                          ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine]));                          m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine]));
177          }          }
178          else m_pChannel->appendMessagesClient("lscp_list_available_engines");          else m_pChannel->appendMessagesClient("lscp_list_available_engines");
179    
180          // Populate Audio output type list.          // Populate Audio output type list.
181          ui.AudioDriverComboBox->clear();          m_ui.AudioDriverComboBox->clear();
182          ui.AudioDriverComboBox->insertItems(0,          m_ui.AudioDriverComboBox->insertItems(0,
183                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));
184    
185          // Populate MIDI input type list.          // Populate MIDI input type list.
186          ui.MidiDriverComboBox->clear();          m_ui.MidiDriverComboBox->clear();
187          ui.MidiDriverComboBox->insertItems(0,          m_ui.MidiDriverComboBox->insertItems(0,
188                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));
189    
190          // Populate Maps list.          // Populate Maps list.
191          ui.MidiMapComboBox->clear();          m_ui.MidiMapComboBox->clear();
192          ui.MidiMapComboBox->insertItems(0,          m_ui.MidiMapComboBox->insertItems(0,
193                  qsamplerInstrument::getMapNames());                  qsamplerInstrument::getMapNames());
194    
195          // Read proper channel information,          // Read proper channel information,
# Line 194  void ChannelForm::setup ( qsamplerChanne Line 201  void ChannelForm::setup ( qsamplerChanne
201                  sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
202          if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
203                  sEngineName = qsamplerChannel::noEngineName();                  sEngineName = qsamplerChannel::noEngineName();
204          if (ui.EngineNameComboBox->findText(sEngineName,          if (m_ui.EngineNameComboBox->findText(sEngineName,
205                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
206                  ui.EngineNameComboBox->addItem(sEngineName);                  m_ui.EngineNameComboBox->addItem(sEngineName);
207          }          }
208          ui.EngineNameComboBox->setCurrentIndex(          m_ui.EngineNameComboBox->setCurrentIndex(
209                  ui.EngineNameComboBox->findText(sEngineName,                  m_ui.EngineNameComboBox->findText(sEngineName,
210                          Qt::MatchExactly | Qt::MatchCaseSensitive));                          Qt::MatchExactly | Qt::MatchCaseSensitive));
211    
212          // Instrument filename and index...          // Instrument filename and index...
213          QString sInstrumentFile = pChannel->instrumentFile();          QString sInstrumentFile = pChannel->instrumentFile();
214          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
215                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = qsamplerChannel::noInstrumentName();
216          ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
217          ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
218          ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
219                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  qsamplerChannel::getInstrumentList(sInstrumentFile,
220                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
221          ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr());          int iInstrumentNr = pChannel->instrumentNr();
222            if (iInstrumentNr < 0)
223                    iInstrumentNr = 0;
224            m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);
225    
226          // MIDI input device...          // MIDI input device...
227          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());
# Line 220  void ChannelForm::setup ( qsamplerChanne Line 230  void ChannelForm::setup ( qsamplerChanne
230          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
231                  sMidiDriver = pOptions->sMidiDriver.toUpper();                  sMidiDriver = pOptions->sMidiDriver.toUpper();
232          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
233                  if (ui.MidiDriverComboBox->findText(sMidiDriver,                  if (m_ui.MidiDriverComboBox->findText(sMidiDriver,
234                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
235                          ui.MidiDriverComboBox->insertItem(0, sMidiDriver);                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
236                  }                  }
237                  ui.MidiDriverComboBox->setItemText(                  m_ui.MidiDriverComboBox->setItemText(
238                          ui.MidiDriverComboBox->currentIndex(),                          m_ui.MidiDriverComboBox->currentIndex(),
239                          sMidiDriver);                          sMidiDriver);
240          }          }
241          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
242          if (!bNew) {          if (!bNew) {
243                  ui.MidiDeviceComboBox->setItemText(                  m_ui.MidiDeviceComboBox->setItemText(
244                          ui.MidiDeviceComboBox->currentIndex(),                          m_ui.MidiDeviceComboBox->currentIndex(),
245                          midiDevice.deviceName());                          midiDevice.deviceName());
246          }          }
247          selectMidiDeviceItem(ui.MidiDeviceComboBox->currentIndex());          selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex());
248          // MIDI input port...          // MIDI input port...
249          ui.MidiPortSpinBox->setValue(pChannel->midiPort());          m_ui.MidiPortSpinBox->setValue(pChannel->midiPort());
250          // MIDI input channel...          // MIDI input channel...
251          int iMidiChannel = pChannel->midiChannel();          int iMidiChannel = pChannel->midiChannel();
252          // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
253          if (iMidiChannel < 0)          if (iMidiChannel < 0)
254                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);
255          ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);          m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);
256          // MIDI instrument map...          // MIDI instrument map...
257          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());
258          // When new, try to suggest a sensible MIDI map...          // When new, try to suggest a sensible MIDI map...
# Line 250  void ChannelForm::setup ( qsamplerChanne Line 260  void ChannelForm::setup ( qsamplerChanne
260                  iMidiMap = 0;                  iMidiMap = 0;
261          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);
262          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
263                  ui.MidiMapComboBox->setItemText(                  m_ui.MidiMapComboBox->setItemText(
264                          ui.MidiMapComboBox->currentIndex(),                          m_ui.MidiMapComboBox->currentIndex(),
265                          sMapName);                          sMapName);
266          }          }
267          // It might be no maps around...          // It might be no maps around...
268          bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0);          bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);
269          ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
270          ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
271    
272          // Audio output device...          // Audio output device...
273          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());
# Line 266  void ChannelForm::setup ( qsamplerChanne Line 276  void ChannelForm::setup ( qsamplerChanne
276          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
277                  sAudioDriver = pOptions->sAudioDriver.toUpper();                  sAudioDriver = pOptions->sAudioDriver.toUpper();
278          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
279                  if (ui.AudioDriverComboBox->findText(sAudioDriver,                  if (m_ui.AudioDriverComboBox->findText(sAudioDriver,
280                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
281                          ui.AudioDriverComboBox->insertItem(0, sAudioDriver);                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
282                  }                  }
283                  ui.AudioDriverComboBox->setItemText(                  m_ui.AudioDriverComboBox->setItemText(
284                          ui.AudioDriverComboBox->currentIndex(),                          m_ui.AudioDriverComboBox->currentIndex(),
285                          sAudioDriver);                          sAudioDriver);
286          }          }
287          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
288          if (!bNew) {          if (!bNew) {
289                  ui.AudioDeviceComboBox->setItemText(                  m_ui.AudioDeviceComboBox->setItemText(
290                          ui.AudioDeviceComboBox->currentIndex(),                          m_ui.AudioDeviceComboBox->currentIndex(),
291                          audioDevice.deviceName());                          audioDevice.deviceName());
292          }          }
293          selectAudioDeviceItem(ui.AudioDeviceComboBox->currentIndex());          selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex());
294    
295            // Let the audio routing table see the light,
296            // if we're editing an existing sampler channel...
297            m_ui.AudioRoutingTable->setVisible(!bNew);
298    
299          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
300          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
# Line 310  void ChannelForm::accept (void) Line 324  void ChannelForm::accept (void)
324                  return;                  return;
325    
326          // Flush any pending editing...          // Flush any pending editing...
327          //ui.AudioRoutingTable->flush();          //m_ui.AudioRoutingTable->flush();
328    
329          // We'll go for it!          // We'll go for it!
330          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
# Line 320  void ChannelForm::accept (void) Line 334  void ChannelForm::accept (void)
334                          iErrors++;                          iErrors++;
335                  // Accept Audio driver or device selection...                  // Accept Audio driver or device selection...
336                  if (m_audioDevices.isEmpty()) {                  if (m_audioDevices.isEmpty()) {
337                          if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
338                                  iErrors++;                                  iErrors++;
339                  } else {                  } else {
340                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
341                          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
342                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
343                                  pDevice = m_audioDevices.at(iAudioItem);                                  pDevice = m_audioDevices.at(iAudioItem);
344                          qsamplerChannelRoutingMap routingMap = routingModel.routingMap();                          qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap();
345                          if (pDevice == NULL)                          if (pDevice == NULL)
346                                  iErrors++;                                  iErrors++;
347                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
# Line 344  void ChannelForm::accept (void) Line 358  void ChannelForm::accept (void)
358                  }                  }
359                  // Accept MIDI driver or device selection...                  // Accept MIDI driver or device selection...
360                  if (m_midiDevices.isEmpty()) {                  if (m_midiDevices.isEmpty()) {
361                          if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
362                                  iErrors++;                                  iErrors++;
363                  } else {                  } else {
364                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
365                          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
366                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
367                                  pDevice = m_midiDevices.at(iMidiItem);                                  pDevice = m_midiDevices.at(iMidiItem);
368                          if (pDevice == NULL)                          if (pDevice == NULL)
# Line 357  void ChannelForm::accept (void) Line 371  void ChannelForm::accept (void)
371                                  iErrors++;                                  iErrors++;
372                  }                  }
373                  // MIDI input port number...                  // MIDI input port number...
374                  if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value()))
375                          iErrors++;                          iErrors++;
376                  // MIDI input channel...                  // MIDI input channel...
377                  if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentIndex()))                  if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex()))
378                          iErrors++;                          iErrors++;
379                  // Engine name...                  // Engine name...
380                  if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText()))
381                          iErrors++;                          iErrors++;
382                  // Instrument file and index...                  // Instrument file and index...
383                  const QString& sPath = ui.InstrumentFileComboBox->currentText();                  const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
384                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {
385                          if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentIndex()))                          if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex()))
386                                  iErrors++;                                  iErrors++;
387                  }                  }
388                  // MIDI intrument map...                  // MIDI intrument map...
389                  if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentIndex()))                  if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex()))
390                          iErrors++;                          iErrors++;
391                  // Show error messages?                  // Show error messages?
392                  if (iErrors > 0)                  if (iErrors > 0) {
393                          m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));                          m_pChannel->appendMessagesError(
394                                    tr("Some channel settings could not be set.\n\nSorry."));
395                    }
396          }          }
397    
398          // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
399          pOptions->sInstrumentDir = QFileInfo(          pOptions->sInstrumentDir = QFileInfo(
400                  ui.InstrumentFileComboBox->currentText()).dir().absolutePath();                  m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath();
401          pOptions->sEngineName  = ui.EngineNameComboBox->currentText();          pOptions->sEngineName  = m_ui.EngineNameComboBox->currentText();
402          pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText();          pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText();
403          pOptions->sMidiDriver  = ui.MidiDriverComboBox->currentText();          pOptions->sMidiDriver  = m_ui.MidiDriverComboBox->currentText();
404          pOptions->iMidiMap     = ui.MidiMapComboBox->currentIndex();          pOptions->iMidiMap     = m_ui.MidiMapComboBox->currentIndex();
405          pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox);
406    
407          // Just go with dialog acceptance.          // Just go with dialog acceptance.
408          QDialog::accept();          QDialog::accept();
# Line 399  void ChannelForm::reject (void) Line 415  void ChannelForm::reject (void)
415          bool bReject = true;          bool bReject = true;
416    
417          // Check if there's any pending changes...          // Check if there's any pending changes...
418          if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {
419                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
420                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
421                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
# Line 445  void ChannelForm::openInstrumentFile (vo Line 461  void ChannelForm::openInstrumentFile (vo
461          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
462                  return;                  return;
463    
464          ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
465          updateInstrumentName();          updateInstrumentName();
466  }  }
467    
# Line 465  void ChannelForm::updateInstrumentName ( Line 481  void ChannelForm::updateInstrumentName (
481    
482          // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
483          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
484          ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
485          ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
486                  qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
487                          ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
488                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
489          );          );
490    
# Line 478  void ChannelForm::updateInstrumentName ( Line 494  void ChannelForm::updateInstrumentName (
494    
495  // Show device options dialog.  // Show device options dialog.
496  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,
497          qsamplerDevice::qsamplerDeviceType deviceTypeMode,          qsamplerDevice::DeviceType deviceTypeMode,
498          const QString& sDriverName )          const QString& sDriverName )
499  {  {
500          if (pDevice == NULL)          if (pDevice == NULL)
# Line 493  void ChannelForm::setupDevice ( qsampler Line 509  void ChannelForm::setupDevice ( qsampler
509          // Create the device form if not already...          // Create the device form if not already...
510          if (m_pDeviceForm == NULL) {          if (m_pDeviceForm == NULL) {
511                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);
512          m_pDeviceForm->setAttribute(Qt::WA_ShowModal);                  m_pDeviceForm->setAttribute(Qt::WA_ShowModal);
513                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
514                          this, SLOT(updateDevices()));                          this, SLOT(updateDevices()));
515          }          }
# Line 524  void ChannelForm::selectMidiDriverItem ( Line 540  void ChannelForm::selectMidiDriverItem (
540          // Save current device id.          // Save current device id.
541          int iDeviceID = 0;          int iDeviceID = 0;
542          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
543          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
544          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
545                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
546          if (pDevice)          if (pDevice)
547                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
548    
549          // Clean maplist.          // Clean maplist.
550          ui.MidiDeviceComboBox->clear();          m_ui.MidiDeviceComboBox->clear();
551          qDeleteAll(m_midiDevices);          qDeleteAll(m_midiDevices);
552          m_midiDevices.clear();          m_midiDevices.clear();
553    
# Line 542  void ChannelForm::selectMidiDriverItem ( Line 558  void ChannelForm::selectMidiDriverItem (
558          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
559                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);
560                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
561                          ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());                          m_ui.MidiDeviceComboBox->insertItem(0,
562                                    midiPixmap, pDevice->deviceName());
563                          m_midiDevices.append(pDevice);                          m_midiDevices.append(pDevice);
564                  } else {                  } else {
565                          delete pDevice;                          delete pDevice;
# Line 558  void ChannelForm::selectMidiDriverItem ( Line 575  void ChannelForm::selectMidiDriverItem (
575                  while (iter.hasNext()) {                  while (iter.hasNext()) {
576                          pDevice = iter.next();                          pDevice = iter.next();
577                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
578                                  ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);                                  m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);
579                                  selectMidiDeviceItem(iMidiItem);                                  selectMidiDeviceItem(iMidiItem);
580                                  break;                                  break;
581                          }                          }
582                          iMidiItem++;                          iMidiItem++;
583                  }                  }
584          } else {          } else {
585                  ui.MidiDeviceComboBox->insertItem(0,                  m_ui.MidiDeviceComboBox->insertItem(0,
586                          tr("(New MIDI %1 device)").arg(sMidiDriver));                          tr("(New MIDI %1 device)").arg(sMidiDriver));
587          }          }
588          ui.MidiDeviceTextLabel->setEnabled(bEnabled);          m_ui.MidiDeviceTextLabel->setEnabled(bEnabled);
589          ui.MidiDeviceComboBox->setEnabled(bEnabled);          m_ui.MidiDeviceComboBox->setEnabled(bEnabled);
590  }  }
591    
592    
# Line 593  void ChannelForm::selectMidiDeviceItem ( Line 610  void ChannelForm::selectMidiDeviceItem (
610          if (pDevice) {          if (pDevice) {
611                  const qsamplerDeviceParamMap& params = pDevice->params();                  const qsamplerDeviceParamMap& params = pDevice->params();
612                  int iPorts = params["PORTS"].value.toInt();                  int iPorts = params["PORTS"].value.toInt();
613                  ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
614                  ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
615                  if (iPorts > 0)                  if (iPorts > 0)
616                          ui.MidiPortSpinBox->setMaximum(iPorts - 1);                          m_ui.MidiPortSpinBox->setMaximum(iPorts - 1);
617          }          }
618  }  }
619    
# Line 616  void ChannelForm::selectMidiDevice ( int Line 633  void ChannelForm::selectMidiDevice ( int
633  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
634  {  {
635          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
636          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
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          setupDevice(pDevice,          setupDevice(pDevice,
640                  qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText());                  qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText());
641  }  }
642    
643    
# Line 638  void ChannelForm::selectAudioDriverItem Line 655  void ChannelForm::selectAudioDriverItem
655          // Save current device id.          // Save current device id.
656          int iDeviceID = 0;          int iDeviceID = 0;
657          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
658          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
659          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
660                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
661          if (pDevice)          if (pDevice)
662                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
663    
664          // Clean maplist.          // Clean maplist.
665          ui.AudioDeviceComboBox->clear();          m_ui.AudioDeviceComboBox->clear();
666          qDeleteAll(m_audioDevices);          qDeleteAll(m_audioDevices);
667          m_audioDevices.clear();          m_audioDevices.clear();
668    
# Line 656  void ChannelForm::selectAudioDriverItem Line 673  void ChannelForm::selectAudioDriverItem
673          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
674                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);
675                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
676                          ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());                          m_ui.AudioDeviceComboBox->insertItem(0,
677                                    audioPixmap, pDevice->deviceName());
678                          m_audioDevices.append(pDevice);                          m_audioDevices.append(pDevice);
679                  } else {                  } else {
680                          delete pDevice;                          delete pDevice;
# Line 672  void ChannelForm::selectAudioDriverItem Line 690  void ChannelForm::selectAudioDriverItem
690                  while (iter.hasNext()) {                  while (iter.hasNext()) {
691                          pDevice = iter.next();                          pDevice = iter.next();
692                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
693                                  ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);                                  m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);
694                                  selectAudioDeviceItem(iAudioItem);                                  selectAudioDeviceItem(iAudioItem);
695                                  break;                                  break;
696                          }                          }
697                          iAudioItem++;                          iAudioItem++;
698                  }                  }
699          } else {          } else {
700                  ui.AudioDeviceComboBox->insertItem(0,                  m_ui.AudioDeviceComboBox->insertItem(0,
701                          tr("(New Audio %1 device)").arg(sAudioDriver));                          tr("(New Audio %1 device)").arg(sAudioDriver));
702                  //ui.AudioRoutingTable->setNumRows(0);                  //m_ui.AudioRoutingTable->setNumRows(0);
703          }          }
704          ui.AudioDeviceTextLabel->setEnabled(bEnabled);          m_ui.AudioDeviceTextLabel->setEnabled(bEnabled);
705          ui.AudioDeviceComboBox->setEnabled(bEnabled);          m_ui.AudioDeviceComboBox->setEnabled(bEnabled);
706          ui.AudioRoutingTable->setEnabled(bEnabled);          m_ui.AudioRoutingTable->setEnabled(bEnabled);
707  }  }
708    
709    
# Line 708  void ChannelForm::selectAudioDeviceItem Line 726  void ChannelForm::selectAudioDeviceItem
726                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
727          if (pDevice) {          if (pDevice) {
728                  // Refresh the audio routing table.                  // Refresh the audio routing table.
729                  routingModel.refresh(pDevice, m_pChannel->audioRouting());                  m_routingModel.refresh(pDevice, m_pChannel->audioRouting());
730                  // Reset routing change map.                  // Reset routing change map.
731                  routingModel.clear();                  m_routingModel.clear();
732          }          }
733  }  }
734    
# Line 730  void ChannelForm::selectAudioDevice ( in Line 748  void ChannelForm::selectAudioDevice ( in
748  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
749  {  {
750          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
751          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
752          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
753                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
754          setupDevice(pDevice,          setupDevice(pDevice,
755                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());                  qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText());
756  }  }
757    
758  // UPdate all device lists slot.  // UPdate all device lists slot.
# Line 743  void ChannelForm::updateDevices (void) Line 761  void ChannelForm::updateDevices (void)
761          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
762                  return;                  return;
763    
764          selectMidiDriverItem(ui.MidiDriverComboBox->currentText());          selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText());
765          selectAudioDriverItem(ui.AudioDriverComboBox->currentText());          selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText());
766          optionsChanged();          optionsChanged();
767  }  }
768    
# Line 764  void ChannelForm::optionsChanged (void) Line 782  void ChannelForm::optionsChanged (void)
782  void ChannelForm::stabilizeForm (void)  void ChannelForm::stabilizeForm (void)
783  {  {
784          const bool bValid =          const bool bValid =
785                  ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&
786                  ui.EngineNameComboBox->currentText() !=                  m_ui.EngineNameComboBox->currentText()
787                  qsamplerChannel::noEngineName();                          != qsamplerChannel::noEngineName();
788  #if 0  #if 0
789          const QString& sPath = InstrumentFileComboBox->currentText();          const QString& sPath = InstrumentFileComboBox->currentText();
790          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
791  #endif  #endif
792          ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);
793  }  }
794    
795  void ChannelForm::updateTableCellRenderers() {  
796      const int rows = routingModel.rowCount();  void ChannelForm::updateTableCellRenderers (void)
797      const int cols = routingModel.columnCount();  {
798      updateTableCellRenderers(routingModel.index(0,0),routingModel.index(rows-1,cols-1));          const int rows = m_routingModel.rowCount();
799  }          const int cols = m_routingModel.columnCount();
800            updateTableCellRenderers(
801  void ChannelForm::updateTableCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {                  m_routingModel.index(0, 0),
802      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {                  m_routingModel.index(rows - 1, cols - 1));
803          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  }
804              const QModelIndex index = routingModel.index(r,c);  
805              ui.AudioRoutingTable->openPersistentEditor(index);  
806          }  void ChannelForm::updateTableCellRenderers (
807      }          const QModelIndex& topLeft, const QModelIndex& bottomRight )
808    {
809            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
810                    for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
811                            const QModelIndex index = m_routingModel.index(r, c);
812                            m_ui.AudioRoutingTable->openPersistentEditor(index);
813                    }
814            }
815  }  }
816    
817  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1506  
changed lines
  Added in v.1510

  ViewVC Help
Powered by ViewVC