/[svn]/qsampler/trunk/src/qsamplerInstrumentForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerInstrumentForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1509 by capela, Thu Nov 22 11:10:44 2007 UTC revision 2069 by capela, Mon Mar 15 10:45:35 2010 UTC
# Line 1  Line 1 
1  // qsamplerInstrumentForm.cpp  // qsamplerInstrumentForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2003-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24  #include "qsamplerInstrumentForm.h"  #include "qsamplerInstrumentForm.h"
25    
26  #include "qsamplerAbout.h"  #include "qsamplerOptions.h"
27    #include "qsamplerChannel.h"
28  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
29    
30  #include <QFileDialog>  #include <QFileDialog>
# Line 31  Line 33 
33  // Needed for lroundf()  // Needed for lroundf()
34  #include <math.h>  #include <math.h>
35    
   
 namespace QSampler {  
   
36  #ifndef CONFIG_ROUND  #ifndef CONFIG_ROUND
37  static inline long lroundf ( float x )  static inline long lroundf ( float x )
38  {  {
# Line 44  static inline long lroundf ( float x ) Line 43  static inline long lroundf ( float x )
43  }  }
44  #endif  #endif
45    
46  InstrumentForm::InstrumentForm ( QWidget* pParent )  
47    namespace QSampler {
48    
49    //-------------------------------------------------------------------------
50    // QSampler::InstrumentForm -- Instrument map item form implementation.
51    //
52    
53    InstrumentForm::InstrumentForm ( QWidget *pParent )
54          : QDialog(pParent)          : QDialog(pParent)
55  {  {
56          m_ui.setupUi(this);          m_ui.setupUi(this);
# Line 105  InstrumentForm::~InstrumentForm (void) Line 111  InstrumentForm::~InstrumentForm (void)
111    
112    
113  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
114  void InstrumentForm::setup ( qsamplerInstrument *pInstrument )  void InstrumentForm::setup ( Instrument *pInstrument )
115  {  {
116          m_pInstrument = pInstrument;          m_pInstrument = pInstrument;
117    
# Line 123  void InstrumentForm::setup ( qsamplerIns Line 129  void InstrumentForm::setup ( qsamplerIns
129          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
130                  return;                  return;
131    
132          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
133          if (pOptions == NULL)          if (pOptions == NULL)
134                  return;                  return;
135    
# Line 142  void InstrumentForm::setup ( qsamplerIns Line 148  void InstrumentForm::setup ( qsamplerIns
148    
149          // Populate maps list.          // Populate maps list.
150          m_ui.MapComboBox->clear();          m_ui.MapComboBox->clear();
151          m_ui.MapComboBox->insertItems(0, qsamplerInstrument::getMapNames());          m_ui.MapComboBox->insertItems(0, Instrument::getMapNames());
152    
153          // Populate Engines list.          // Populate Engines list.
154          const char **ppszEngines          const char **ppszEngines
# Line 161  void InstrumentForm::setup ( qsamplerIns Line 167  void InstrumentForm::setup ( qsamplerIns
167          int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map());          int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map());
168          if (iMap < 0)          if (iMap < 0)
169                  iMap = 0;                  iMap = 0;
170          const QString& sMapName = qsamplerInstrument::getMapName(iMap);          const QString& sMapName = Instrument::getMapName(iMap);
171          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
172                  m_ui.MapComboBox->setItemText(                  m_ui.MapComboBox->setCurrentIndex(
173                          m_ui.MapComboBox->currentIndex(),                          m_ui.MapComboBox->findText(sMapName,
174                          sMapName);                                  Qt::MatchExactly | Qt::MatchCaseSensitive));
175          }          }
176    
177          // It might be no maps around...          // It might be no maps around...
178          bool bMapEnabled = (m_ui.MapComboBox->count() > 0);          bool bMapEnabled = (m_ui.MapComboBox->count() > 0);
179          m_ui.MapTextLabel->setEnabled(bMapEnabled);          m_ui.MapTextLabel->setEnabled(bMapEnabled);
# Line 190  void InstrumentForm::setup ( qsamplerIns Line 197  void InstrumentForm::setup ( qsamplerIns
197          if (sEngineName.isEmpty() || bNew)          if (sEngineName.isEmpty() || bNew)
198                  sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
199          if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
200                  sEngineName = qsamplerChannel::noEngineName();                  sEngineName = Channel::noEngineName();
201          if (m_ui.EngineNameComboBox->findText(sEngineName,          if (m_ui.EngineNameComboBox->findText(sEngineName,
202                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
203                  m_ui.EngineNameComboBox->addItem(sEngineName);                  m_ui.EngineNameComboBox->addItem(sEngineName);
# Line 202  void InstrumentForm::setup ( qsamplerIns Line 209  void InstrumentForm::setup ( qsamplerIns
209          // Instrument filename and index...          // Instrument filename and index...
210          QString sInstrumentFile = m_pInstrument->instrumentFile();          QString sInstrumentFile = m_pInstrument->instrumentFile();
211          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
212                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = Channel::noInstrumentName();
213          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
214          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
215          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
216                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  Channel::getInstrumentList(sInstrumentFile,
217                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
218          m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr());          m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr());
219    
# Line 223  void InstrumentForm::setup ( qsamplerIns Line 230  void InstrumentForm::setup ( qsamplerIns
230          // Done.          // Done.
231          m_iDirtySetup--;          m_iDirtySetup--;
232          stabilizeForm();          stabilizeForm();
   
         // Done.  
         m_iDirtySetup--;  
         stabilizeForm();  
233  }  }
234    
235    
# Line 248  void InstrumentForm::openInstrumentFile Line 251  void InstrumentForm::openInstrumentFile
251          if (pMainForm == NULL)          if (pMainForm == NULL)
252                  return;                  return;
253    
254          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
255          if (pOptions == NULL)          if (pOptions == NULL)
256                  return;                  return;
257    
# Line 275  void InstrumentForm::updateInstrumentNam Line 278  void InstrumentForm::updateInstrumentNam
278          if (pMainForm == NULL)          if (pMainForm == NULL)
279                  return;                  return;
280    
281          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
282          if (pOptions == NULL)          if (pOptions == NULL)
283                  return;                  return;
284    
# Line 283  void InstrumentForm::updateInstrumentNam Line 286  void InstrumentForm::updateInstrumentNam
286          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
287          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
288          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
289                  qsamplerChannel::getInstrumentList(                  Channel::getInstrumentList(
290                          m_ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
291                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
292          );          );
# Line 319  void InstrumentForm::accept (void) Line 322  void InstrumentForm::accept (void)
322          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
323                  return;                  return;
324    
325          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
326          if (pOptions == NULL)          if (pOptions == NULL)
327                  return;                  return;
328    
# Line 362  void InstrumentForm::reject (void) Line 365  void InstrumentForm::reject (void)
365                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
366                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
367                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
368                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Apply |
369                  case 0:     // Apply...                          QMessageBox::Discard |
370                            QMessageBox::Cancel)) {
371                    case QMessageBox::Apply:
372                          accept();                          accept();
373                          return;                          return;
374                  case 1:     // Discard                  case QMessageBox::Discard:
375                          break;                          break;
376                  default:    // Cancel.                  default:    // Cancel.
377                          bReject = false;                          bReject = false;
# Line 393  void InstrumentForm::changed (void) Line 398  void InstrumentForm::changed (void)
398  // Stabilize current form state.  // Stabilize current form state.
399  void InstrumentForm::stabilizeForm (void)  void InstrumentForm::stabilizeForm (void)
400  {  {
401          bool bValid =          bool bValid = !m_ui.NameLineEdit->text().isEmpty()
402                  !m_ui.NameLineEdit->text().isEmpty() &&                  && m_ui.EngineNameComboBox->currentIndex() >= 0
403                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&                  && m_ui.EngineNameComboBox->currentText() != Channel::noEngineName();
                 m_ui.EngineNameComboBox->currentText() !=  
                 qsamplerChannel::noEngineName();  
404    
405          const QString& sPath = m_ui.InstrumentFileComboBox->currentText();          const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
406          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();

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

  ViewVC Help
Powered by ViewVC