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

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

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

revision 1504 by capela, Wed Nov 21 11:46:40 2007 UTC revision 1513 by capela, Fri Nov 23 09:32:06 2007 UTC
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24  #include "qsamplerInstrumentListForm.h"  #include "qsamplerInstrumentListForm.h"
25    
26  #include "qsamplerInstrumentForm.h"  #include "qsamplerInstrumentForm.h"
27  #include "qsamplerMainForm.h"  
28  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
29  #include "qsamplerInstrument.h"  #include "qsamplerInstrument.h"
30    #include "qsamplerMainForm.h"
31    
32    
33  namespace QSampler {  namespace QSampler {
# Line 34  InstrumentListForm::InstrumentListForm ( Line 36  InstrumentListForm::InstrumentListForm (
36          QWidget* pParent, Qt::WindowFlags wflags )          QWidget* pParent, Qt::WindowFlags wflags )
37          : QMainWindow(pParent, wflags)          : QMainWindow(pParent, wflags)
38  {  {
39      ui.setupUi(this);          m_ui.setupUi(this);
40    
41      // Setup toolbar widgets.          // Setup toolbar widgets.
42      m_pMapComboBox = new QComboBox(ui.InstrumentToolbar);          m_pMapComboBox = new QComboBox(m_ui.InstrumentToolbar);
43      m_pMapComboBox->setMinimumWidth(120);          m_pMapComboBox->setMinimumWidth(120);
44      m_pMapComboBox->setEnabled(false);          m_pMapComboBox->setEnabled(false);
45      m_pMapComboBox->setToolTip(tr("Instrument Map"));          m_pMapComboBox->setToolTip(tr("Instrument Map"));
46      ui.InstrumentToolbar->addWidget(m_pMapComboBox);          m_ui.InstrumentToolbar->addWidget(m_pMapComboBox);
47    
48      ui.InstrumentToolbar->addSeparator();          m_ui.InstrumentToolbar->addSeparator();
49      ui.InstrumentToolbar->addAction(ui.newInstrumentAction);          m_ui.InstrumentToolbar->addAction(m_ui.newInstrumentAction);
50      ui.InstrumentToolbar->addAction(ui.editInstrumentAction);          m_ui.InstrumentToolbar->addAction(m_ui.editInstrumentAction);
51      ui.InstrumentToolbar->addAction(ui.deleteInstrumentAction);          m_ui.InstrumentToolbar->addAction(m_ui.deleteInstrumentAction);
52      ui.InstrumentToolbar->addSeparator();          m_ui.InstrumentToolbar->addSeparator();
53      ui.InstrumentToolbar->addAction(ui.refreshInstrumentsAction);          m_ui.InstrumentToolbar->addAction(m_ui.refreshInstrumentsAction);
54    
55      ui.InstrumentTable->setModel(&model);          m_ui.InstrumentTable->setModel(&m_model);
56      ui.InstrumentTable->setItemDelegate(&delegate);          m_ui.InstrumentTable->setItemDelegate(&m_delegate);
57    
58          QObject::connect(m_pMapComboBox,          QObject::connect(m_pMapComboBox,
59                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
60                  SLOT(activateMap(int)));                  SLOT(activateMap(int)));
   
61          QObject::connect(          QObject::connect(
62                  ui.refreshInstrumentsAction,                  m_ui.refreshInstrumentsAction,
63                  SIGNAL(triggered()),                  SIGNAL(triggered()),
64                  SLOT(refreshInstruments(void))                  SLOT(refreshInstruments(void)));
     );  
   
65          QObject::connect(          QObject::connect(
66                  ui.InstrumentTable,                  m_ui.InstrumentTable,
67                  SIGNAL(activated(const QModelIndex&)),                  SIGNAL(activated(const QModelIndex&)),
68                  SLOT(editInstrument(const QModelIndex&))                  SLOT(editInstrument(const QModelIndex&)));
         );  
69          QObject::connect(          QObject::connect(
70                  ui.newInstrumentAction,                  m_ui.newInstrumentAction,
71                  SIGNAL(triggered()),                  SIGNAL(triggered()),
72                  SLOT(newInstrument())                  SLOT(newInstrument()));
         );  
73          QObject::connect(          QObject::connect(
74                  ui.deleteInstrumentAction,                  m_ui.deleteInstrumentAction,
75                  SIGNAL(triggered()),                  SIGNAL(triggered()),
76                  SLOT(deleteInstrument())                  SLOT(deleteInstrument()));
         );  
77          QObject::connect(          QObject::connect(
78                  ui.editInstrumentAction,                  m_ui.editInstrumentAction,
79                  SIGNAL(triggered()),                  SIGNAL(triggered()),
80                  SLOT(editInstrument())                  SLOT(editInstrument()));
81          );  
82            MainForm *pMainForm = MainForm::getInstance();
83            if (pMainForm) {
84                    QObject::connect(&m_model,
85                            SIGNAL(instrumentsChanged()),
86                            pMainForm, SLOT(sessionDirty()));
87            }
88  }  }
89    
90    
# Line 171  void InstrumentListForm::activateMap ( i Line 173  void InstrumentListForm::activateMap ( i
173          if (iMidiMap >= 0)          if (iMidiMap >= 0)
174                  pOptions->iMidiMap = iMidiMap;                  pOptions->iMidiMap = iMidiMap;
175    
176          model.setMidiMap(iMidiMap);          m_model.setMidiMap(iMidiMap);
177          model.refresh();          m_model.refresh();
178  }  }
179    
180    
181  void InstrumentListForm::editInstrument (void)  void InstrumentListForm::editInstrument (void)
182  {  {
183          editInstrument(ui.InstrumentTable->currentIndex());          editInstrument(m_ui.InstrumentTable->currentIndex());
184  }  }
185    
186    
# Line 212  void InstrumentListForm::editInstrument Line 214  void InstrumentListForm::editInstrument
214                          // Unmap old instance...                          // Unmap old instance...
215                          oldInstrument.unmapInstrument();                          oldInstrument.unmapInstrument();
216                          // correct the position of the instrument in the model                          // correct the position of the instrument in the model
217                          model.resort(*pInstrument);                          m_model.resort(*pInstrument);
218                  }                  }
219                  // Notify we've changes...                  // Notify we've changes...
220                  emit model.reset();                  emit m_model.reset();
221          }          }
222  }  }
223    
# Line 232  void InstrumentListForm::newInstrument ( Line 234  void InstrumentListForm::newInstrument (
234          // Commit...          // Commit...
235          instrument.mapInstrument();          instrument.mapInstrument();
236          // add new item to the table model          // add new item to the table model
237          model.resort(instrument);          m_model.resort(instrument);
238          // Notify we've changes...          // Notify we've changes...
239          //emit model.reset();          //emit model.reset();
240          //FIXME: call above didnt really refresh, so we use this for now ...          //FIXME: call above didnt really refresh, so we use this for now ...
# Line 242  void InstrumentListForm::newInstrument ( Line 244  void InstrumentListForm::newInstrument (
244    
245  void InstrumentListForm::deleteInstrument (void)  void InstrumentListForm::deleteInstrument (void)
246  {  {
247          const QModelIndex& index = ui.InstrumentTable->currentIndex();          const QModelIndex& index = m_ui.InstrumentTable->currentIndex();
248          if (!index.isValid() || !index.data(Qt::UserRole).isValid())          if (!index.isValid() || !index.data(Qt::UserRole).isValid())
249                  return;                  return;
250    
# Line 255  void InstrumentListForm::deleteInstrumen Line 257  void InstrumentListForm::deleteInstrumen
257    
258          pInstrument->unmapInstrument();          pInstrument->unmapInstrument();
259          // let the instrument vanish from the table model          // let the instrument vanish from the table model
260          model.removeInstrument(*pInstrument);          m_model.removeInstrument(*pInstrument);
261          // Notify we've changes...          // Notify we've changes...
262          emit model.reset();          emit m_model.reset();
263  }  }
264    
265  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1504  
changed lines
  Added in v.1513

  ViewVC Help
Powered by ViewVC