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

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

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

revision 2069 by capela, Mon Mar 15 10:45:35 2010 UTC revision 2079 by capela, Wed Mar 31 21:47:57 2010 UTC
# Line 29  Line 29 
29  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
30    
31  #include <QApplication>  #include <QApplication>
32    #include <QHeaderView>
33  #include <QCursor>  #include <QCursor>
34    
35    
# Line 190  const Instrument *InstrumentListModel::a Line 191  const Instrument *InstrumentListModel::a
191          // with the very same key (bank, program);          // with the very same key (bank, program);
192          // if yes, just remove it without prejudice...          // if yes, just remove it without prejudice...
193          InstrumentList& list = m_instruments[iMap];          InstrumentList& list = m_instruments[iMap];
194          for (int i = 0; i < list.size(); ++i) {  
195            int i = 0;
196            for ( ; i < list.size(); ++i) {
197                  const Instrument *pInstr = list.at(i);                  const Instrument *pInstr = list.at(i);
198                  if (pInstr->bank() == iBank && pInstr->prog() == iProg) {                  if (pInstr->bank() == iBank && pInstr->prog() == iProg) {
199                          delete pInstr;                          delete pInstr;
# Line 200  const Instrument *InstrumentListModel::a Line 203  const Instrument *InstrumentListModel::a
203          }          }
204    
205          // Resolve the appropriate place, we keep the list sorted that way...          // Resolve the appropriate place, we keep the list sorted that way...
206          int i = 0;          for (i = 0; i < list.size(); ++i) {
         for ( ; i < list.size(); ++i) {  
207                  const Instrument *pInstr = list.at(i);                  const Instrument *pInstr = list.at(i);
208                  if (iBank < pInstr->bank()                  if (iBank < pInstr->bank()
209                          || (iBank == pInstr->bank() && iProg < pInstr->prog())) {                          || (iBank == pInstr->bank() && iProg < pInstr->prog())) {
# Line 221  const Instrument *InstrumentListModel::a Line 223  const Instrument *InstrumentListModel::a
223  }  }
224    
225    
226  void InstrumentListModel::removeInstrument ( const Instrument *pInstrument )  void InstrumentListModel::removeInstrument ( Instrument *pInstrument )
227  {  {
228          const int iMap  = pInstrument->map();          const int iMap = pInstrument->map();
         const int iBank = pInstrument->bank();  
         const int iProg = pInstrument->prog();  
229    
230          if (m_instruments.contains(iMap)) {          if (m_instruments.contains(iMap)) {
231                  InstrumentList& list = m_instruments[iMap];                  InstrumentList& list = m_instruments[iMap];
232                  for (int i = 0; i < list.size(); ++i) {                  for (int i = 0; i < list.size(); ++i) {
233                          const Instrument *pInstr = list.at(i);                          if (pInstrument == list.at(i)) {
234                          if (pInstr->bank() == iBank && pInstr->prog() == iProg) {                                  delete pInstrument;
                                 delete pInstr;  
235                                  list.removeAt(i);                                  list.removeAt(i);
236                                  break;                                  break;
237                          }                          }
# Line 241  void InstrumentListModel::removeInstrume Line 240  void InstrumentListModel::removeInstrume
240  }  }
241    
242    
243    void InstrumentListModel::updateInstrument ( Instrument *pInstrument )
244    {
245            pInstrument->getInstrument();
246    }
247    
248    
249  // Reposition the instrument in the model (called when map/bank/prg changed)  // Reposition the instrument in the model (called when map/bank/prg changed)
250  void InstrumentListModel::updateInstrument ( const Instrument *pInstrument )  void InstrumentListModel::resortInstrument ( Instrument *pInstrument )
251  {  {
252          const int iMap  = pInstrument->map();          const int iMap  = pInstrument->map();
253          const int iBank = pInstrument->bank();          const int iBank = pInstrument->bank();
# Line 385  const Instrument *InstrumentListView::ad Line 390  const Instrument *InstrumentListView::ad
390  }  }
391    
392    
393  void InstrumentListView::removeInstrument ( const Instrument *pInstrument )  void InstrumentListView::removeInstrument ( Instrument *pInstrument )
394  {  {
395          m_pListModel->beginReset();          m_pListModel->beginReset();
396          m_pListModel->removeInstrument(pInstrument);          m_pListModel->removeInstrument(pInstrument);
# Line 393  void InstrumentListView::removeInstrumen Line 398  void InstrumentListView::removeInstrumen
398  }  }
399    
400    
401  // Reposition the instrument in the model (called when map/bank/prg changed)  void InstrumentListView::updateInstrument ( Instrument *pInstrument )
 void InstrumentListView::updateInstrument ( const Instrument *pInstrument )  
402  {  {
403          m_pListModel->beginReset();          m_pListModel->beginReset();
404          m_pListModel->updateInstrument(pInstrument);          m_pListModel->updateInstrument(pInstrument);
405          m_pListModel->endReset();          m_pListModel->endReset();
406  }  }
407    
408    
409    // Reposition the instrument in the model (called when map/bank/prg changed)
410    void InstrumentListView::resortInstrument ( Instrument *pInstrument )
411    {
412            m_pListModel->beginReset();
413            m_pListModel->resortInstrument(pInstrument);
414            m_pListModel->endReset();
415    }
416    
417    
418  // Refreshener.  // Refreshener.
419  void InstrumentListView::refresh (void)  void InstrumentListView::refresh (void)

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

  ViewVC Help
Powered by ViewVC