/[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 1509 by capela, Thu Nov 22 11:10:44 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());          m_ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr());
222    
223          // MIDI input device...          // MIDI input device...
224          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());
# Line 220  void ChannelForm::setup ( qsamplerChanne Line 227  void ChannelForm::setup ( qsamplerChanne
227          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
228                  sMidiDriver = pOptions->sMidiDriver.toUpper();                  sMidiDriver = pOptions->sMidiDriver.toUpper();
229          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
230                  if (ui.MidiDriverComboBox->findText(sMidiDriver,                  if (m_ui.MidiDriverComboBox->findText(sMidiDriver,
231                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
232                          ui.MidiDriverComboBox->insertItem(0, sMidiDriver);                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
233                  }                  }
234                  ui.MidiDriverComboBox->setItemText(                  m_ui.MidiDriverComboBox->setItemText(
235                          ui.MidiDriverComboBox->currentIndex(),                          m_ui.MidiDriverComboBox->currentIndex(),
236                          sMidiDriver);                          sMidiDriver);
237          }          }
238          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
239          if (!bNew) {          if (!bNew) {
240                  ui.MidiDeviceComboBox->setItemText(                  m_ui.MidiDeviceComboBox->setItemText(
241                          ui.MidiDeviceComboBox->currentIndex(),                          m_ui.MidiDeviceComboBox->currentIndex(),
242                          midiDevice.deviceName());                          midiDevice.deviceName());
243          }          }
244          selectMidiDeviceItem(ui.MidiDeviceComboBox->currentIndex());          selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex());
245          // MIDI input port...          // MIDI input port...
246          ui.MidiPortSpinBox->setValue(pChannel->midiPort());          m_ui.MidiPortSpinBox->setValue(pChannel->midiPort());
247          // MIDI input channel...          // MIDI input channel...
248          int iMidiChannel = pChannel->midiChannel();          int iMidiChannel = pChannel->midiChannel();
249          // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
250          if (iMidiChannel < 0)          if (iMidiChannel < 0)
251                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);
252          ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);          m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);
253          // MIDI instrument map...          // MIDI instrument map...
254          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());
255          // 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 257  void ChannelForm::setup ( qsamplerChanne
257                  iMidiMap = 0;                  iMidiMap = 0;
258          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);
259          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
260                  ui.MidiMapComboBox->setItemText(                  m_ui.MidiMapComboBox->setItemText(
261                          ui.MidiMapComboBox->currentIndex(),                          m_ui.MidiMapComboBox->currentIndex(),
262                          sMapName);                          sMapName);
263          }          }
264          // It might be no maps around...          // It might be no maps around...
265          bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0);          bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);
266          ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
267          ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
268    
269          // Audio output device...          // Audio output device...
270          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());
# Line 266  void ChannelForm::setup ( qsamplerChanne Line 273  void ChannelForm::setup ( qsamplerChanne
273          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
274                  sAudioDriver = pOptions->sAudioDriver.toUpper();                  sAudioDriver = pOptions->sAudioDriver.toUpper();
275          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
276                  if (ui.AudioDriverComboBox->findText(sAudioDriver,                  if (m_ui.AudioDriverComboBox->findText(sAudioDriver,
277                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
278                          ui.AudioDriverComboBox->insertItem(0, sAudioDriver);                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
279                  }                  }
280                  ui.AudioDriverComboBox->setItemText(                  m_ui.AudioDriverComboBox->setItemText(
281                          ui.AudioDriverComboBox->currentIndex(),                          m_ui.AudioDriverComboBox->currentIndex(),
282                          sAudioDriver);                          sAudioDriver);
283          }          }
284          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
285          if (!bNew) {          if (!bNew) {
286                  ui.AudioDeviceComboBox->setItemText(                  m_ui.AudioDeviceComboBox->setItemText(
287                          ui.AudioDeviceComboBox->currentIndex(),                          m_ui.AudioDeviceComboBox->currentIndex(),
288                          audioDevice.deviceName());                          audioDevice.deviceName());
289          }          }
290          selectAudioDeviceItem(ui.AudioDeviceComboBox->currentIndex());          selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex());
291    
292            // Let the audio routing table see the light,
293            // if we're editing an existing sampler channel...
294            m_ui.AudioRoutingTable->setVisible(!bNew);
295    
296          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
297          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
# Line 310  void ChannelForm::accept (void) Line 321  void ChannelForm::accept (void)
321                  return;                  return;
322    
323          // Flush any pending editing...          // Flush any pending editing...
324          //ui.AudioRoutingTable->flush();          //m_ui.AudioRoutingTable->flush();
325    
326          // We'll go for it!          // We'll go for it!
327          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
# Line 320  void ChannelForm::accept (void) Line 331  void ChannelForm::accept (void)
331                          iErrors++;                          iErrors++;
332                  // Accept Audio driver or device selection...                  // Accept Audio driver or device selection...
333                  if (m_audioDevices.isEmpty()) {                  if (m_audioDevices.isEmpty()) {
334                          if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
335                                  iErrors++;                                  iErrors++;
336                  } else {                  } else {
337                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
338                          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
339                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
340                                  pDevice = m_audioDevices.at(iAudioItem);                                  pDevice = m_audioDevices.at(iAudioItem);
341                          qsamplerChannelRoutingMap routingMap = routingModel.routingMap();                          qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap();
342                          if (pDevice == NULL)                          if (pDevice == NULL)
343                                  iErrors++;                                  iErrors++;
344                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
# Line 344  void ChannelForm::accept (void) Line 355  void ChannelForm::accept (void)
355                  }                  }
356                  // Accept MIDI driver or device selection...                  // Accept MIDI driver or device selection...
357                  if (m_midiDevices.isEmpty()) {                  if (m_midiDevices.isEmpty()) {
358                          if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
359                                  iErrors++;                                  iErrors++;
360                  } else {                  } else {
361                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
362                          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
363                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
364                                  pDevice = m_midiDevices.at(iMidiItem);                                  pDevice = m_midiDevices.at(iMidiItem);
365                          if (pDevice == NULL)                          if (pDevice == NULL)
# Line 357  void ChannelForm::accept (void) Line 368  void ChannelForm::accept (void)
368                                  iErrors++;                                  iErrors++;
369                  }                  }
370                  // MIDI input port number...                  // MIDI input port number...
371                  if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value()))
372                          iErrors++;                          iErrors++;
373                  // MIDI input channel...                  // MIDI input channel...
374                  if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentIndex()))                  if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex()))
375                          iErrors++;                          iErrors++;
376                  // Engine name...                  // Engine name...
377                  if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText()))
378                          iErrors++;                          iErrors++;
379                  // Instrument file and index...                  // Instrument file and index...
380                  const QString& sPath = ui.InstrumentFileComboBox->currentText();                  const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
381                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {
382                          if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentIndex()))                          if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex()))
383                                  iErrors++;                                  iErrors++;
384                  }                  }
385                  // MIDI intrument map...                  // MIDI intrument map...
386                  if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentIndex()))                  if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex()))
387                          iErrors++;                          iErrors++;
388                  // Show error messages?                  // Show error messages?
389                  if (iErrors > 0)                  if (iErrors > 0)
# Line 381  void ChannelForm::accept (void) Line 392  void ChannelForm::accept (void)
392    
393          // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
394          pOptions->sInstrumentDir = QFileInfo(          pOptions->sInstrumentDir = QFileInfo(
395                  ui.InstrumentFileComboBox->currentText()).dir().absolutePath();                  m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath();
396          pOptions->sEngineName  = ui.EngineNameComboBox->currentText();          pOptions->sEngineName  = m_ui.EngineNameComboBox->currentText();
397          pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText();          pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText();
398          pOptions->sMidiDriver  = ui.MidiDriverComboBox->currentText();          pOptions->sMidiDriver  = m_ui.MidiDriverComboBox->currentText();
399          pOptions->iMidiMap     = ui.MidiMapComboBox->currentIndex();          pOptions->iMidiMap     = m_ui.MidiMapComboBox->currentIndex();
400          pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox);
401    
402          // Just go with dialog acceptance.          // Just go with dialog acceptance.
403          QDialog::accept();          QDialog::accept();
# Line 399  void ChannelForm::reject (void) Line 410  void ChannelForm::reject (void)
410          bool bReject = true;          bool bReject = true;
411    
412          // Check if there's any pending changes...          // Check if there's any pending changes...
413          if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {
414                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
415                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
416                          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 456  void ChannelForm::openInstrumentFile (vo
456          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
457                  return;                  return;
458    
459          ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
460          updateInstrumentName();          updateInstrumentName();
461  }  }
462    
# Line 465  void ChannelForm::updateInstrumentName ( Line 476  void ChannelForm::updateInstrumentName (
476    
477          // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
478          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
479          ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
480          ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
481                  qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
482                          ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
483                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
484          );          );
485    
# Line 478  void ChannelForm::updateInstrumentName ( Line 489  void ChannelForm::updateInstrumentName (
489    
490  // Show device options dialog.  // Show device options dialog.
491  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,
492          qsamplerDevice::qsamplerDeviceType deviceTypeMode,          qsamplerDevice::DeviceType deviceTypeMode,
493          const QString& sDriverName )          const QString& sDriverName )
494  {  {
495          if (pDevice == NULL)          if (pDevice == NULL)
# Line 524  void ChannelForm::selectMidiDriverItem ( Line 535  void ChannelForm::selectMidiDriverItem (
535          // Save current device id.          // Save current device id.
536          int iDeviceID = 0;          int iDeviceID = 0;
537          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
538          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
539          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
540                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
541          if (pDevice)          if (pDevice)
542                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
543    
544          // Clean maplist.          // Clean maplist.
545          ui.MidiDeviceComboBox->clear();          m_ui.MidiDeviceComboBox->clear();
546          qDeleteAll(m_midiDevices);          qDeleteAll(m_midiDevices);
547          m_midiDevices.clear();          m_midiDevices.clear();
548    
# Line 542  void ChannelForm::selectMidiDriverItem ( Line 553  void ChannelForm::selectMidiDriverItem (
553          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
554                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);
555                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
556                          ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());                          m_ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());
557                          m_midiDevices.append(pDevice);                          m_midiDevices.append(pDevice);
558                  } else {                  } else {
559                          delete pDevice;                          delete pDevice;
# Line 558  void ChannelForm::selectMidiDriverItem ( Line 569  void ChannelForm::selectMidiDriverItem (
569                  while (iter.hasNext()) {                  while (iter.hasNext()) {
570                          pDevice = iter.next();                          pDevice = iter.next();
571                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
572                                  ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);                                  m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);
573                                  selectMidiDeviceItem(iMidiItem);                                  selectMidiDeviceItem(iMidiItem);
574                                  break;                                  break;
575                          }                          }
576                          iMidiItem++;                          iMidiItem++;
577                  }                  }
578          } else {          } else {
579                  ui.MidiDeviceComboBox->insertItem(0,                  m_ui.MidiDeviceComboBox->insertItem(0,
580                          tr("(New MIDI %1 device)").arg(sMidiDriver));                          tr("(New MIDI %1 device)").arg(sMidiDriver));
581          }          }
582          ui.MidiDeviceTextLabel->setEnabled(bEnabled);          m_ui.MidiDeviceTextLabel->setEnabled(bEnabled);
583          ui.MidiDeviceComboBox->setEnabled(bEnabled);          m_ui.MidiDeviceComboBox->setEnabled(bEnabled);
584  }  }
585    
586    
# Line 593  void ChannelForm::selectMidiDeviceItem ( Line 604  void ChannelForm::selectMidiDeviceItem (
604          if (pDevice) {          if (pDevice) {
605                  const qsamplerDeviceParamMap& params = pDevice->params();                  const qsamplerDeviceParamMap& params = pDevice->params();
606                  int iPorts = params["PORTS"].value.toInt();                  int iPorts = params["PORTS"].value.toInt();
607                  ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
608                  ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
609                  if (iPorts > 0)                  if (iPorts > 0)
610                          ui.MidiPortSpinBox->setMaximum(iPorts - 1);                          m_ui.MidiPortSpinBox->setMaximum(iPorts - 1);
611          }          }
612  }  }
613    
# Line 616  void ChannelForm::selectMidiDevice ( int Line 627  void ChannelForm::selectMidiDevice ( int
627  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
628  {  {
629          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
630          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
631          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
632                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
633          setupDevice(pDevice,          setupDevice(pDevice,
634                  qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText());                  qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText());
635  }  }
636    
637    
# Line 638  void ChannelForm::selectAudioDriverItem Line 649  void ChannelForm::selectAudioDriverItem
649          // Save current device id.          // Save current device id.
650          int iDeviceID = 0;          int iDeviceID = 0;
651          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
652          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
653          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
654                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
655          if (pDevice)          if (pDevice)
656                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
657    
658          // Clean maplist.          // Clean maplist.
659          ui.AudioDeviceComboBox->clear();          m_ui.AudioDeviceComboBox->clear();
660          qDeleteAll(m_audioDevices);          qDeleteAll(m_audioDevices);
661          m_audioDevices.clear();          m_audioDevices.clear();
662    
# Line 656  void ChannelForm::selectAudioDriverItem Line 667  void ChannelForm::selectAudioDriverItem
667          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
668                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);
669                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
670                          ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());                          m_ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());
671                          m_audioDevices.append(pDevice);                          m_audioDevices.append(pDevice);
672                  } else {                  } else {
673                          delete pDevice;                          delete pDevice;
# Line 672  void ChannelForm::selectAudioDriverItem Line 683  void ChannelForm::selectAudioDriverItem
683                  while (iter.hasNext()) {                  while (iter.hasNext()) {
684                          pDevice = iter.next();                          pDevice = iter.next();
685                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
686                                  ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);                                  m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);
687                                  selectAudioDeviceItem(iAudioItem);                                  selectAudioDeviceItem(iAudioItem);
688                                  break;                                  break;
689                          }                          }
690                          iAudioItem++;                          iAudioItem++;
691                  }                  }
692          } else {          } else {
693                  ui.AudioDeviceComboBox->insertItem(0,                  m_ui.AudioDeviceComboBox->insertItem(0,
694                          tr("(New Audio %1 device)").arg(sAudioDriver));                          tr("(New Audio %1 device)").arg(sAudioDriver));
695                  //ui.AudioRoutingTable->setNumRows(0);                  //m_ui.AudioRoutingTable->setNumRows(0);
696          }          }
697          ui.AudioDeviceTextLabel->setEnabled(bEnabled);          m_ui.AudioDeviceTextLabel->setEnabled(bEnabled);
698          ui.AudioDeviceComboBox->setEnabled(bEnabled);          m_ui.AudioDeviceComboBox->setEnabled(bEnabled);
699          ui.AudioRoutingTable->setEnabled(bEnabled);          m_ui.AudioRoutingTable->setEnabled(bEnabled);
700  }  }
701    
702    
# Line 708  void ChannelForm::selectAudioDeviceItem Line 719  void ChannelForm::selectAudioDeviceItem
719                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
720          if (pDevice) {          if (pDevice) {
721                  // Refresh the audio routing table.                  // Refresh the audio routing table.
722                  routingModel.refresh(pDevice, m_pChannel->audioRouting());                  m_routingModel.refresh(pDevice, m_pChannel->audioRouting());
723                  // Reset routing change map.                  // Reset routing change map.
724                  routingModel.clear();                  m_routingModel.clear();
725          }          }
726  }  }
727    
# Line 730  void ChannelForm::selectAudioDevice ( in Line 741  void ChannelForm::selectAudioDevice ( in
741  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
742  {  {
743          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
744          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
745          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
746                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
747          setupDevice(pDevice,          setupDevice(pDevice,
748                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());                  qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText());
749  }  }
750    
751  // UPdate all device lists slot.  // UPdate all device lists slot.
# Line 743  void ChannelForm::updateDevices (void) Line 754  void ChannelForm::updateDevices (void)
754          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
755                  return;                  return;
756    
757          selectMidiDriverItem(ui.MidiDriverComboBox->currentText());          selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText());
758          selectAudioDriverItem(ui.AudioDriverComboBox->currentText());          selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText());
759          optionsChanged();          optionsChanged();
760  }  }
761    
# Line 764  void ChannelForm::optionsChanged (void) Line 775  void ChannelForm::optionsChanged (void)
775  void ChannelForm::stabilizeForm (void)  void ChannelForm::stabilizeForm (void)
776  {  {
777          const bool bValid =          const bool bValid =
778                  ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&
779                  ui.EngineNameComboBox->currentText() !=                  m_ui.EngineNameComboBox->currentText() !=
780                  qsamplerChannel::noEngineName();                  qsamplerChannel::noEngineName();
781  #if 0  #if 0
782          const QString& sPath = InstrumentFileComboBox->currentText();          const QString& sPath = InstrumentFileComboBox->currentText();
783          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
784  #endif  #endif
785          ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);
786  }  }
787    
788  void ChannelForm::updateTableCellRenderers() {  
789      const int rows = routingModel.rowCount();  void ChannelForm::updateTableCellRenderers (void)
790      const int cols = routingModel.columnCount();  {
791      updateTableCellRenderers(routingModel.index(0,0),routingModel.index(rows-1,cols-1));      const int rows = m_routingModel.rowCount();
792        const int cols = m_routingModel.columnCount();
793        updateTableCellRenderers(
794                    m_routingModel.index(0, 0),
795                    m_routingModel.index(rows - 1, cols - 1));
796  }  }
797    
798  void ChannelForm::updateTableCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {  
799    void ChannelForm::updateTableCellRenderers (
800            const QModelIndex& topLeft, const QModelIndex& bottomRight )
801    {
802      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
803          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
804              const QModelIndex index = routingModel.index(r,c);              const QModelIndex index = m_routingModel.index(r, c);
805              ui.AudioRoutingTable->openPersistentEditor(index);              m_ui.AudioRoutingTable->openPersistentEditor(index);
806          }          }
807      }      }
808  }  }

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

  ViewVC Help
Powered by ViewVC