/[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 2064 by capela, Fri Mar 12 16:02:32 2010 UTC revision 2070 by capela, Mon Mar 15 17:06:46 2010 UTC
# Line 39  namespace QSampler { Line 39  namespace QSampler {
39  //  //
40    
41  InstrumentListModel::InstrumentListModel ( QObject *pParent )  InstrumentListModel::InstrumentListModel ( QObject *pParent )
42          : QAbstractItemModel(pParent)          : QAbstractItemModel(pParent), m_iMidiMap(LSCP_MIDI_MAP_ALL)
43  {  {
44          m_iMidiMap = LSCP_MIDI_MAP_ALL;  //      QAbstractItemModel::reset();
   
         QAbstractItemModel::reset();  
45  }  }
46    
47  InstrumentListModel::~InstrumentListModel (void)  InstrumentListModel::~InstrumentListModel (void)
# Line 81  QVariant InstrumentListModel::data ( Line 79  QVariant InstrumentListModel::data (
79  {  {
80          if (!index.isValid())          if (!index.isValid())
81                  return QVariant();                  return QVariant();
   
82          const Instrument *pInstr          const Instrument *pInstr
83                  = static_cast<Instrument *> (index.internalPointer());                  = static_cast<Instrument *> (index.internalPointer());
84    
# Line 132  QModelIndex InstrumentListModel::index ( Line 129  QModelIndex InstrumentListModel::index (
129                  InstrumentMap::const_iterator itMap     = m_instruments.find(m_iMidiMap);                  InstrumentMap::const_iterator itMap     = m_instruments.find(m_iMidiMap);
130                  if (itMap != m_instruments.constEnd()) {                  if (itMap != m_instruments.constEnd()) {
131                          const InstrumentList& list = *itMap;                          const InstrumentList& list = *itMap;
                         // resolve instrument in that map  
132                          if (row < list.size())                          if (row < list.size())
133                                  pInstr = list.at(row);                                  pInstr = list.at(row);
134                  }                  }
# Line 145  QModelIndex InstrumentListModel::index ( Line 141  QModelIndex InstrumentListModel::index (
141  }  }
142    
143    
144  QModelIndex InstrumentListModel::parent ( const QModelIndex& child ) const  QModelIndex InstrumentListModel::parent ( const QModelIndex& /*child*/ ) const
145  {  {
146          return QModelIndex();          return QModelIndex();
147  }  }
# Line 225  const Instrument *InstrumentListModel::a Line 221  const Instrument *InstrumentListModel::a
221  }  }
222    
223    
224  void InstrumentListModel::removeInstrument ( const Instrument *pInstrument )  void InstrumentListModel::removeInstrument ( Instrument *pInstrument )
225  {  {
226          const int iMap  = pInstrument->map();          const int iMap  = pInstrument->map();
227          const int iBank = pInstrument->bank();          const int iBank = pInstrument->bank();
# Line 245  void InstrumentListModel::removeInstrume Line 241  void InstrumentListModel::removeInstrume
241  }  }
242    
243    
244    void InstrumentListModel::updateInstrument ( Instrument *pInstrument )
245    {
246            pInstrument->getInstrument();
247    }
248    
249    
250  // Reposition the instrument in the model (called when map/bank/prg changed)  // Reposition the instrument in the model (called when map/bank/prg changed)
251  void InstrumentListModel::updateInstrument ( const Instrument *pInstrument )  void InstrumentListModel::resortInstrument ( Instrument *pInstrument )
252  {  {
253          const int iMap  = pInstrument->map();          const int iMap  = pInstrument->map();
254          const int iBank = pInstrument->bank();          const int iBank = pInstrument->bank();
# Line 335  InstrumentListView::InstrumentListView ( Line 337  InstrumentListView::InstrumentListView (
337          m_pListModel = new InstrumentListModel(this);          m_pListModel = new InstrumentListModel(this);
338    
339          QTreeView::setModel(m_pListModel);          QTreeView::setModel(m_pListModel);
340    
341            QTreeView::setRootIsDecorated(false);
342            QTreeView::setUniformRowHeights(true);
343            QTreeView::setAlternatingRowColors(true);
344            QTreeView::setSelectionBehavior(QAbstractItemView::SelectRows);
345            QTreeView::setSelectionMode(QAbstractItemView::SingleSelection);
346            QTreeView::setItemsExpandable(false);
347    
348            QHeaderView *pHeader = QTreeView::header();
349            pHeader->setDefaultAlignment(Qt::AlignLeft);
350            pHeader->setMovable(false);
351            pHeader->setStretchLastSection(true);
352            pHeader->resizeSection(0, 120);                 // Name
353            QTreeView::resizeColumnToContents(1);   // Map
354            QTreeView::resizeColumnToContents(2);   // Bank
355            QTreeView::resizeColumnToContents(3);   // Prog
356            QTreeView::resizeColumnToContents(4);   // Engine
357            pHeader->resizeSection(5, 240);                 // File
358            QTreeView::resizeColumnToContents(6);   // Nr
359            pHeader->resizeSection(7, 60);                  // Vol
360  }  }
361    
362    
# Line 369  const Instrument *InstrumentListView::ad Line 391  const Instrument *InstrumentListView::ad
391  }  }
392    
393    
394  void InstrumentListView::removeInstrument ( const Instrument *pInstrument )  void InstrumentListView::removeInstrument ( Instrument *pInstrument )
395  {  {
396          m_pListModel->beginReset();          m_pListModel->beginReset();
397          m_pListModel->removeInstrument(pInstrument);          m_pListModel->removeInstrument(pInstrument);
# Line 377  void InstrumentListView::removeInstrumen Line 399  void InstrumentListView::removeInstrumen
399  }  }
400    
401    
402  // Reposition the instrument in the model (called when map/bank/prg changed)  void InstrumentListView::updateInstrument ( Instrument *pInstrument )
 void InstrumentListView::updateInstrument ( const Instrument *pInstrument )  
403  {  {
404          m_pListModel->beginReset();          m_pListModel->beginReset();
405          m_pListModel->updateInstrument(pInstrument);          m_pListModel->updateInstrument(pInstrument);
406          m_pListModel->endReset();}          m_pListModel->endReset();
407    }
408    
409    
410    // Reposition the instrument in the model (called when map/bank/prg changed)
411    void InstrumentListView::resortInstrument ( Instrument *pInstrument )
412    {
413            m_pListModel->beginReset();
414            m_pListModel->resortInstrument(pInstrument);
415            m_pListModel->endReset();
416    }
417    
418    
419  // Refreshener.  // Refreshener.

Legend:
Removed from v.2064  
changed lines
  Added in v.2070

  ViewVC Help
Powered by ViewVC