/[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 1527 by schoenebeck, Mon Nov 26 16:00:21 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            int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4;
58            m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
59            m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
60    
61            m_ui.AudioRoutingTable->setModel(&m_routingModel);
62            m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);
63            m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
64    //      m_ui.AudioRoutingTable->verticalHeader()->hide();
65    
66            // This goes initially hidden, and will be shown
67            // on setup() for currently existing channels...
68            m_ui.AudioRoutingTable->hide();
69    
70          // Try to restore normal window positioning.          // Try to restore normal window positioning.
71          adjustSize();          adjustSize();
72    
73          ui.AudioRoutingTable->setModel(&routingModel);          QObject::connect(m_ui.EngineNameComboBox,
         ui.AudioRoutingTable->setItemDelegate(&routingDelegate);  
         ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);  
   
         QObject::connect(ui.EngineNameComboBox,  
74                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
75                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
76          QObject::connect(ui.InstrumentFileComboBox,          QObject::connect(m_ui.InstrumentFileComboBox,
77                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
78                  SLOT(updateInstrumentName()));                  SLOT(updateInstrumentName()));
79          QObject::connect(ui.InstrumentFileToolButton,          QObject::connect(m_ui.InstrumentFileToolButton,
80                  SIGNAL(clicked()),                  SIGNAL(clicked()),
81                  SLOT(openInstrumentFile()));                  SLOT(openInstrumentFile()));
82          QObject::connect(ui.InstrumentNrComboBox,          QObject::connect(m_ui.InstrumentNrComboBox,
83                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
84                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
85          QObject::connect(ui.MidiDriverComboBox,          QObject::connect(m_ui.MidiDriverComboBox,
86                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
87                  SLOT(selectMidiDriver(const QString&)));                  SLOT(selectMidiDriver(const QString&)));
88          QObject::connect(ui.MidiDeviceComboBox,          QObject::connect(m_ui.MidiDeviceComboBox,
89                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
90                  SLOT(selectMidiDevice(int)));                  SLOT(selectMidiDevice(int)));
91          QObject::connect(ui.MidiPortSpinBox,          QObject::connect(m_ui.MidiPortSpinBox,
92                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
93                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
94          QObject::connect(ui.MidiChannelComboBox,          QObject::connect(m_ui.MidiChannelComboBox,
95                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
96                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
97          QObject::connect(ui.MidiMapComboBox,          QObject::connect(m_ui.MidiMapComboBox,
98                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
99                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
100          QObject::connect(ui.AudioDriverComboBox,          QObject::connect(m_ui.AudioDriverComboBox,
101                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
102                  SLOT(selectAudioDriver(const QString&)));                  SLOT(selectAudioDriver(const QString&)));
103          QObject::connect(ui.AudioDeviceComboBox,          QObject::connect(m_ui.AudioDeviceComboBox,
104                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
105                  SLOT(selectAudioDevice(int)));                  SLOT(selectAudioDevice(int)));
106          QObject::connect(ui.OkPushButton,          QObject::connect(m_ui.OkPushButton,
107                  SIGNAL(clicked()),                  SIGNAL(clicked()),
108                  SLOT(accept()));                  SLOT(accept()));
109          QObject::connect(ui.CancelPushButton,          QObject::connect(m_ui.CancelPushButton,
110                  SIGNAL(clicked()),                  SIGNAL(clicked()),
111                  SLOT(reject()));                  SLOT(reject()));
112          QObject::connect(ui.MidiDeviceToolButton,          QObject::connect(m_ui.MidiDeviceToolButton,
113                  SIGNAL(clicked()),                  SIGNAL(clicked()),
114                  SLOT(setupMidiDevice()));                  SLOT(setupMidiDevice()));
115          QObject::connect(ui.AudioDeviceToolButton,          QObject::connect(m_ui.AudioDeviceToolButton,
116                  SIGNAL(clicked()),                  SIGNAL(clicked()),
117                  SLOT(setupAudioDevice()));                  SLOT(setupAudioDevice()));
118          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
119                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
120                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
121          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
122                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
123                  SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&)));
124          QObject::connect(&routingModel,          QObject::connect(&m_routingModel,
125                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
126                  SLOT(updateTableCellRenderers()));                  SLOT(updateTableCellRenderers()));
127  }  }
# Line 159  void ChannelForm::setup ( qsamplerChanne Line 170  void ChannelForm::setup ( qsamplerChanne
170          m_iDirtySetup++;          m_iDirtySetup++;
171    
172          // Load combo box history...          // Load combo box history...
173          pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);
174    
175          // Populate Engines list.          // Populate Engines list.
176          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
177          if (ppszEngines) {          if (ppszEngines) {
178                  ui.EngineNameComboBox->clear();                  m_ui.EngineNameComboBox->clear();
179                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
180                          ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine]));                          m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine]));
181          }          }
182          else m_pChannel->appendMessagesClient("lscp_list_available_engines");          else m_pChannel->appendMessagesClient("lscp_list_available_engines");
183    
184          // Populate Audio output type list.          // Populate Audio output type list.
185          ui.AudioDriverComboBox->clear();          m_ui.AudioDriverComboBox->clear();
186          ui.AudioDriverComboBox->insertItems(0,          m_ui.AudioDriverComboBox->insertItems(0,
187                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));
188    
189          // Populate MIDI input type list.          // Populate MIDI input type list.
190          ui.MidiDriverComboBox->clear();          m_ui.MidiDriverComboBox->clear();
191          ui.MidiDriverComboBox->insertItems(0,          m_ui.MidiDriverComboBox->insertItems(0,
192                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));
193    
194          // Populate Maps list.          // Populate Maps list.
195          ui.MidiMapComboBox->clear();          m_ui.MidiMapComboBox->clear();
196          ui.MidiMapComboBox->insertItems(0,          m_ui.MidiMapComboBox->insertItems(0,
197                  qsamplerInstrument::getMapNames());                  qsamplerInstrument::getMapNames());
198    
199          // Read proper channel information,          // Read proper channel information,
# Line 194  void ChannelForm::setup ( qsamplerChanne Line 205  void ChannelForm::setup ( qsamplerChanne
205                  sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
206          if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
207                  sEngineName = qsamplerChannel::noEngineName();                  sEngineName = qsamplerChannel::noEngineName();
208          if (ui.EngineNameComboBox->findText(sEngineName,          if (m_ui.EngineNameComboBox->findText(sEngineName,
209                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
210                  ui.EngineNameComboBox->addItem(sEngineName);                  m_ui.EngineNameComboBox->addItem(sEngineName);
211          }          }
212          ui.EngineNameComboBox->setCurrentIndex(          m_ui.EngineNameComboBox->setCurrentIndex(
213                  ui.EngineNameComboBox->findText(sEngineName,                  m_ui.EngineNameComboBox->findText(sEngineName,
214                          Qt::MatchExactly | Qt::MatchCaseSensitive));                          Qt::MatchExactly | Qt::MatchCaseSensitive));
215    
216          // Instrument filename and index...          // Instrument filename and index...
217          QString sInstrumentFile = pChannel->instrumentFile();          QString sInstrumentFile = pChannel->instrumentFile();
218          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
219                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = qsamplerChannel::noInstrumentName();
220          ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
221          ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
222          ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
223                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  qsamplerChannel::getInstrumentList(sInstrumentFile,
224                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
225          ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr());          int iInstrumentNr = pChannel->instrumentNr();
226            if (iInstrumentNr < 0)
227                    iInstrumentNr = 0;
228            m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);
229    
230          // MIDI input device...          // MIDI input device...
231          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());
# Line 220  void ChannelForm::setup ( qsamplerChanne Line 234  void ChannelForm::setup ( qsamplerChanne
234          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
235                  sMidiDriver = pOptions->sMidiDriver.toUpper();                  sMidiDriver = pOptions->sMidiDriver.toUpper();
236          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
237                  if (ui.MidiDriverComboBox->findText(sMidiDriver,                  if (m_ui.MidiDriverComboBox->findText(sMidiDriver,
238                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
239                          ui.MidiDriverComboBox->insertItem(0, sMidiDriver);                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
240                  }                  }
241                  ui.MidiDriverComboBox->setItemText(                  m_ui.MidiDriverComboBox->setItemText(
242                          ui.MidiDriverComboBox->currentIndex(),                          m_ui.MidiDriverComboBox->currentIndex(),
243                          sMidiDriver);                          sMidiDriver);
244          }          }
245          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
246          if (!bNew) {          if (!bNew) {
247                  ui.MidiDeviceComboBox->setItemText(                  m_ui.MidiDeviceComboBox->setItemText(
248                          ui.MidiDeviceComboBox->currentIndex(),                          m_ui.MidiDeviceComboBox->currentIndex(),
249                          midiDevice.deviceName());                          midiDevice.deviceName());
250          }          }
251          selectMidiDeviceItem(ui.MidiDeviceComboBox->currentIndex());          selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex());
252          // MIDI input port...          // MIDI input port...
253          ui.MidiPortSpinBox->setValue(pChannel->midiPort());          m_ui.MidiPortSpinBox->setValue(pChannel->midiPort());
254          // MIDI input channel...          // MIDI input channel...
255          int iMidiChannel = pChannel->midiChannel();          int iMidiChannel = pChannel->midiChannel();
256          // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
257          if (iMidiChannel < 0)          if (iMidiChannel < 0)
258                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);                  iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);
259          ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);          m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel);
260          // MIDI instrument map...          // MIDI instrument map...
261          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());          int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());
262          // 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 264  void ChannelForm::setup ( qsamplerChanne
264                  iMidiMap = 0;                  iMidiMap = 0;
265          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);
266          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
267                  ui.MidiMapComboBox->setItemText(                  m_ui.MidiMapComboBox->setItemText(
268                          ui.MidiMapComboBox->currentIndex(),                          m_ui.MidiMapComboBox->currentIndex(),
269                          sMapName);                          sMapName);
270          }          }
271          // It might be no maps around...          // It might be no maps around...
272          bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0);          bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);
273          ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
274          ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
275    
276          // Audio output device...          // Audio output device...
277          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());
# Line 266  void ChannelForm::setup ( qsamplerChanne Line 280  void ChannelForm::setup ( qsamplerChanne
280          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
281                  sAudioDriver = pOptions->sAudioDriver.toUpper();                  sAudioDriver = pOptions->sAudioDriver.toUpper();
282          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
283                  if (ui.AudioDriverComboBox->findText(sAudioDriver,                  if (m_ui.AudioDriverComboBox->findText(sAudioDriver,
284                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
285                          ui.AudioDriverComboBox->insertItem(0, sAudioDriver);                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
286                  }                  }
287                  ui.AudioDriverComboBox->setItemText(                  m_ui.AudioDriverComboBox->setItemText(
288                          ui.AudioDriverComboBox->currentIndex(),                          m_ui.AudioDriverComboBox->currentIndex(),
289                          sAudioDriver);                          sAudioDriver);
290          }          }
291          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
292          if (!bNew) {          if (!bNew) {
293                  ui.AudioDeviceComboBox->setItemText(                  m_ui.AudioDeviceComboBox->setItemText(
294                          ui.AudioDeviceComboBox->currentIndex(),                          m_ui.AudioDeviceComboBox->currentIndex(),
295                          audioDevice.deviceName());                          audioDevice.deviceName());
296          }          }
297          selectAudioDeviceItem(ui.AudioDeviceComboBox->currentIndex());          selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex());
298    
299            // Let the audio routing table see the light,
300            // if we're editing an existing sampler channel...
301            m_ui.AudioRoutingTable->setVisible(!bNew);
302    
303            const QString sInstrumentNrToolTip =
304                    (pOptions->bInstrumentNames) ?
305                            "Select an instrument of the file" :
306                            "You might want to enable instrument name retrieval in the "
307                            "settings dialog";
308            m_ui.InstrumentNrComboBox->setToolTip(
309                    QObject::tr(sInstrumentNrToolTip.toUtf8().data())
310            );
311    
312          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
313          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
# Line 310  void ChannelForm::accept (void) Line 337  void ChannelForm::accept (void)
337                  return;                  return;
338    
339          // Flush any pending editing...          // Flush any pending editing...
340          //ui.AudioRoutingTable->flush();          //m_ui.AudioRoutingTable->flush();
341    
342          // We'll go for it!          // We'll go for it!
343          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
# Line 320  void ChannelForm::accept (void) Line 347  void ChannelForm::accept (void)
347                          iErrors++;                          iErrors++;
348                  // Accept Audio driver or device selection...                  // Accept Audio driver or device selection...
349                  if (m_audioDevices.isEmpty()) {                  if (m_audioDevices.isEmpty()) {
350                          if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
351                                  iErrors++;                                  iErrors++;
352                  } else {                  } else {
353                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
354                          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
355                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
356                                  pDevice = m_audioDevices.at(iAudioItem);                                  pDevice = m_audioDevices.at(iAudioItem);
357                          qsamplerChannelRoutingMap routingMap = routingModel.routingMap();                          qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap();
358                          if (pDevice == NULL)                          if (pDevice == NULL)
359                                  iErrors++;                                  iErrors++;
360                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
# Line 344  void ChannelForm::accept (void) Line 371  void ChannelForm::accept (void)
371                  }                  }
372                  // Accept MIDI driver or device selection...                  // Accept MIDI driver or device selection...
373                  if (m_midiDevices.isEmpty()) {                  if (m_midiDevices.isEmpty()) {
374                          if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
375                                  iErrors++;                                  iErrors++;
376                  } else {                  } else {
377                          qsamplerDevice *pDevice = NULL;                          qsamplerDevice *pDevice = NULL;
378                          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
379                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
380                                  pDevice = m_midiDevices.at(iMidiItem);                                  pDevice = m_midiDevices.at(iMidiItem);
381                          if (pDevice == NULL)                          if (pDevice == NULL)
# Line 357  void ChannelForm::accept (void) Line 384  void ChannelForm::accept (void)
384                                  iErrors++;                                  iErrors++;
385                  }                  }
386                  // MIDI input port number...                  // MIDI input port number...
387                  if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value()))
388                          iErrors++;                          iErrors++;
389                  // MIDI input channel...                  // MIDI input channel...
390                  if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentIndex()))                  if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex()))
391                          iErrors++;                          iErrors++;
392                  // Engine name...                  // Engine name...
393                  if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText()))
394                          iErrors++;                          iErrors++;
395                  // Instrument file and index...                  // Instrument file and index...
396                  const QString& sPath = ui.InstrumentFileComboBox->currentText();                  const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
397                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {                  if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {
398                          if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentIndex()))                          if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex()))
399                                  iErrors++;                                  iErrors++;
400                  }                  }
401                  // MIDI intrument map...                  // MIDI intrument map...
402                  if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentIndex()))                  if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex()))
403                          iErrors++;                          iErrors++;
404                  // Show error messages?                  // Show error messages?
405                  if (iErrors > 0)                  if (iErrors > 0) {
406                          m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));                          m_pChannel->appendMessagesError(
407                                    tr("Some channel settings could not be set.\n\nSorry."));
408                    }
409          }          }
410    
411          // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
412          pOptions->sInstrumentDir = QFileInfo(          pOptions->sInstrumentDir = QFileInfo(
413                  ui.InstrumentFileComboBox->currentText()).dir().absolutePath();                  m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath();
414          pOptions->sEngineName  = ui.EngineNameComboBox->currentText();          pOptions->sEngineName  = m_ui.EngineNameComboBox->currentText();
415          pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText();          pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText();
416          pOptions->sMidiDriver  = ui.MidiDriverComboBox->currentText();          pOptions->sMidiDriver  = m_ui.MidiDriverComboBox->currentText();
417          pOptions->iMidiMap     = ui.MidiMapComboBox->currentIndex();          pOptions->iMidiMap     = m_ui.MidiMapComboBox->currentIndex();
418          pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox);
419    
420          // Just go with dialog acceptance.          // Just go with dialog acceptance.
421          QDialog::accept();          QDialog::accept();
# Line 399  void ChannelForm::reject (void) Line 428  void ChannelForm::reject (void)
428          bool bReject = true;          bool bReject = true;
429    
430          // Check if there's any pending changes...          // Check if there's any pending changes...
431          if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {
432                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
433                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
434                          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 474  void ChannelForm::openInstrumentFile (vo
474          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
475                  return;                  return;
476    
477          ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
478          updateInstrumentName();          updateInstrumentName();
479  }  }
480    
# Line 465  void ChannelForm::updateInstrumentName ( Line 494  void ChannelForm::updateInstrumentName (
494    
495          // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
496          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
497          ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
498          ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
499                  qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
500                          ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
501                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
502          );          );
503    
# Line 478  void ChannelForm::updateInstrumentName ( Line 507  void ChannelForm::updateInstrumentName (
507    
508  // Show device options dialog.  // Show device options dialog.
509  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,
510          qsamplerDevice::qsamplerDeviceType deviceTypeMode,          qsamplerDevice::DeviceType deviceTypeMode,
511          const QString& sDriverName )          const QString& sDriverName )
512  {  {
         if (pDevice == NULL)  
                 return;  
   
513          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
514          if (pMainForm == NULL)          if (pMainForm == NULL)
515                  return;                  return;
# Line 493  void ChannelForm::setupDevice ( qsampler Line 519  void ChannelForm::setupDevice ( qsampler
519          // Create the device form if not already...          // Create the device form if not already...
520          if (m_pDeviceForm == NULL) {          if (m_pDeviceForm == NULL) {
521                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);                  m_pDeviceForm = new DeviceForm(this, Qt::Dialog);
522          m_pDeviceForm->setAttribute(Qt::WA_ShowModal);                  m_pDeviceForm->setAttribute(Qt::WA_ShowModal);
523                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),                  QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
524                          this, SLOT(updateDevices()));                          this, SLOT(updateDevices()));
525          }          }
# Line 524  void ChannelForm::selectMidiDriverItem ( Line 550  void ChannelForm::selectMidiDriverItem (
550          // Save current device id.          // Save current device id.
551          int iDeviceID = 0;          int iDeviceID = 0;
552          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
553          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
554          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
555                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
556          if (pDevice)          if (pDevice)
557                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
558    
559          // Clean maplist.          // Clean maplist.
560          ui.MidiDeviceComboBox->clear();          m_ui.MidiDeviceComboBox->clear();
561          qDeleteAll(m_midiDevices);          qDeleteAll(m_midiDevices);
562          m_midiDevices.clear();          m_midiDevices.clear();
563    
# Line 542  void ChannelForm::selectMidiDriverItem ( Line 568  void ChannelForm::selectMidiDriverItem (
568          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
569                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);
570                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
571                          ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName());                          m_ui.MidiDeviceComboBox->insertItem(0,
572                                    midiPixmap, pDevice->deviceName());
573                          m_midiDevices.append(pDevice);                          m_midiDevices.append(pDevice);
574                  } else {                  } else {
575                          delete pDevice;                          delete pDevice;
# Line 558  void ChannelForm::selectMidiDriverItem ( Line 585  void ChannelForm::selectMidiDriverItem (
585                  while (iter.hasNext()) {                  while (iter.hasNext()) {
586                          pDevice = iter.next();                          pDevice = iter.next();
587                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
588                                  ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);                                  m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem);
589                                  selectMidiDeviceItem(iMidiItem);                                  selectMidiDeviceItem(iMidiItem);
590                                  break;                                  break;
591                          }                          }
592                          iMidiItem++;                          iMidiItem++;
593                  }                  }
594          } else {          } else {
595                  ui.MidiDeviceComboBox->insertItem(0,                  m_ui.MidiDeviceComboBox->insertItem(0,
596                          tr("(New MIDI %1 device)").arg(sMidiDriver));                          tr("(New MIDI %1 device)").arg(sMidiDriver));
597          }          }
598          ui.MidiDeviceTextLabel->setEnabled(bEnabled);          m_ui.MidiDeviceTextLabel->setEnabled(bEnabled);
599          ui.MidiDeviceComboBox->setEnabled(bEnabled);          m_ui.MidiDeviceComboBox->setEnabled(bEnabled);
600  }  }
601    
602    
# Line 593  void ChannelForm::selectMidiDeviceItem ( Line 620  void ChannelForm::selectMidiDeviceItem (
620          if (pDevice) {          if (pDevice) {
621                  const qsamplerDeviceParamMap& params = pDevice->params();                  const qsamplerDeviceParamMap& params = pDevice->params();
622                  int iPorts = params["PORTS"].value.toInt();                  int iPorts = params["PORTS"].value.toInt();
623                  ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
624                  ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
625                  if (iPorts > 0)                  if (iPorts > 0)
626                          ui.MidiPortSpinBox->setMaximum(iPorts - 1);                          m_ui.MidiPortSpinBox->setMaximum(iPorts - 1);
627          }          }
628  }  }
629    
# Line 616  void ChannelForm::selectMidiDevice ( int Line 643  void ChannelForm::selectMidiDevice ( int
643  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
644  {  {
645          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
646          int iMidiItem = ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
647          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
648                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
649          setupDevice(pDevice,          setupDevice(pDevice,
650                  qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText());                  qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText());
651  }  }
652    
653    
# Line 638  void ChannelForm::selectAudioDriverItem Line 665  void ChannelForm::selectAudioDriverItem
665          // Save current device id.          // Save current device id.
666          int iDeviceID = 0;          int iDeviceID = 0;
667          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
668          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
669          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
670                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
671          if (pDevice)          if (pDevice)
672                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
673    
674          // Clean maplist.          // Clean maplist.
675          ui.AudioDeviceComboBox->clear();          m_ui.AudioDeviceComboBox->clear();
676          qDeleteAll(m_audioDevices);          qDeleteAll(m_audioDevices);
677          m_audioDevices.clear();          m_audioDevices.clear();
678    
# Line 656  void ChannelForm::selectAudioDriverItem Line 683  void ChannelForm::selectAudioDriverItem
683          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
684                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);
685                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
686                          ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName());                          m_ui.AudioDeviceComboBox->insertItem(0,
687                                    audioPixmap, pDevice->deviceName());
688                          m_audioDevices.append(pDevice);                          m_audioDevices.append(pDevice);
689                  } else {                  } else {
690                          delete pDevice;                          delete pDevice;
# Line 672  void ChannelForm::selectAudioDriverItem Line 700  void ChannelForm::selectAudioDriverItem
700                  while (iter.hasNext()) {                  while (iter.hasNext()) {
701                          pDevice = iter.next();                          pDevice = iter.next();
702                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
703                                  ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);                                  m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem);
704                                  selectAudioDeviceItem(iAudioItem);                                  selectAudioDeviceItem(iAudioItem);
705                                  break;                                  break;
706                          }                          }
707                          iAudioItem++;                          iAudioItem++;
708                  }                  }
709          } else {          } else {
710                  ui.AudioDeviceComboBox->insertItem(0,                  m_ui.AudioDeviceComboBox->insertItem(0,
711                          tr("(New Audio %1 device)").arg(sAudioDriver));                          tr("(New Audio %1 device)").arg(sAudioDriver));
712                  //ui.AudioRoutingTable->setNumRows(0);                  //m_ui.AudioRoutingTable->setNumRows(0);
713          }          }
714          ui.AudioDeviceTextLabel->setEnabled(bEnabled);          m_ui.AudioDeviceTextLabel->setEnabled(bEnabled);
715          ui.AudioDeviceComboBox->setEnabled(bEnabled);          m_ui.AudioDeviceComboBox->setEnabled(bEnabled);
716          ui.AudioRoutingTable->setEnabled(bEnabled);          m_ui.AudioRoutingTable->setEnabled(bEnabled);
717  }  }
718    
719    
# Line 708  void ChannelForm::selectAudioDeviceItem Line 736  void ChannelForm::selectAudioDeviceItem
736                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
737          if (pDevice) {          if (pDevice) {
738                  // Refresh the audio routing table.                  // Refresh the audio routing table.
739                  routingModel.refresh(pDevice, m_pChannel->audioRouting());                  m_routingModel.refresh(pDevice, m_pChannel->audioRouting());
740                  // Reset routing change map.                  // Reset routing change map.
741                  routingModel.clear();                  m_routingModel.clear();
742          }          }
743  }  }
744    
# Line 730  void ChannelForm::selectAudioDevice ( in Line 758  void ChannelForm::selectAudioDevice ( in
758  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
759  {  {
760          qsamplerDevice *pDevice = NULL;          qsamplerDevice *pDevice = NULL;
761          int iAudioItem = ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
762          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
763                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
764          setupDevice(pDevice,          setupDevice(pDevice,
765                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());                  qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText());
766  }  }
767    
768  // UPdate all device lists slot.  // UPdate all device lists slot.
# Line 743  void ChannelForm::updateDevices (void) Line 771  void ChannelForm::updateDevices (void)
771          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
772                  return;                  return;
773    
774          selectMidiDriverItem(ui.MidiDriverComboBox->currentText());          selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText());
775          selectAudioDriverItem(ui.AudioDriverComboBox->currentText());          selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText());
776          optionsChanged();          optionsChanged();
777  }  }
778    
# Line 764  void ChannelForm::optionsChanged (void) Line 792  void ChannelForm::optionsChanged (void)
792  void ChannelForm::stabilizeForm (void)  void ChannelForm::stabilizeForm (void)
793  {  {
794          const bool bValid =          const bool bValid =
795                  ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&
796                  ui.EngineNameComboBox->currentText() !=                  m_ui.EngineNameComboBox->currentText()
797                  qsamplerChannel::noEngineName();                          != qsamplerChannel::noEngineName();
798  #if 0  #if 0
799          const QString& sPath = InstrumentFileComboBox->currentText();          const QString& sPath = InstrumentFileComboBox->currentText();
800          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
801  #endif  #endif
802          ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);
803  }  }
804    
805  void ChannelForm::updateTableCellRenderers() {  
806      const int rows = routingModel.rowCount();  void ChannelForm::updateTableCellRenderers (void)
807      const int cols = routingModel.columnCount();  {
808      updateTableCellRenderers(routingModel.index(0,0),routingModel.index(rows-1,cols-1));          const int rows = m_routingModel.rowCount();
809  }          const int cols = m_routingModel.columnCount();
810            updateTableCellRenderers(
811  void ChannelForm::updateTableCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {                  m_routingModel.index(0, 0),
812      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {                  m_routingModel.index(rows - 1, cols - 1));
813          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  }
814              const QModelIndex index = routingModel.index(r,c);  
815              ui.AudioRoutingTable->openPersistentEditor(index);  
816          }  void ChannelForm::updateTableCellRenderers (
817      }          const QModelIndex& topLeft, const QModelIndex& bottomRight )
818    {
819            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
820                    for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
821                            const QModelIndex index = m_routingModel.index(r, c);
822                            m_ui.AudioRoutingTable->openPersistentEditor(index);
823                    }
824            }
825  }  }
826    
827  } // namespace QSampler  } // namespace QSampler

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

  ViewVC Help
Powered by ViewVC