/[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 968 by capela, Sun Dec 3 18:27:23 2006 UTC revision 969 by capela, Wed Dec 6 19:38:02 2006 UTC
# Line 31  Line 31 
31  #include <qfileinfo.h>  #include <qfileinfo.h>
32  #include <qpopupmenu.h>  #include <qpopupmenu.h>
33    
34    // Needed for lroundf()
35    #include <math.h>
36    
37    
38  //----------------------------------------------------------------------  //----------------------------------------------------------------------
39  // class qsamplerInstrumentGroup -- custom group list view item.  // class qsamplerInstrumentGroup -- custom group list view item.
# Line 160  int qsamplerInstrumentItem::rtti (void) Line 163  int qsamplerInstrumentItem::rtti (void)
163    
164    
165  // Payload accessor.  // Payload accessor.
166  qsamplerInstrument *qsamplerInstrumentItem::Instrument (void) const  qsamplerInstrument *qsamplerInstrumentItem::instrument (void) const
167  {  {
168          return m_pInstrument;          return m_pInstrument;
169  }  }
# Line 179  void qsamplerInstrumentItem::update (voi Line 182  void qsamplerInstrumentItem::update (voi
182                  setText(3, m_pInstrument->engineName());                  setText(3, m_pInstrument->engineName());
183                  setText(4, QFileInfo(m_pInstrument->instrumentFile()).fileName());                  setText(4, QFileInfo(m_pInstrument->instrumentFile()).fileName());
184                  setText(5, QString::number(m_pInstrument->instrumentNr()));                  setText(5, QString::number(m_pInstrument->instrumentNr()));
185                  setText(6, QString::number(int(m_pInstrument->volume() * 100.0f)));                  setText(6, QString::number(::lroundf(100.0f * m_pInstrument->volume())));
186                  QString sLoadMode = s;                  QString sLoadMode = s;
187                  switch (m_pInstrument->loadMode()) {                  switch (m_pInstrument->loadMode()) {
188                  case 3:                  case 3:
# Line 343  qsamplerInstrumentGroup *qsamplerInstrum Line 346  qsamplerInstrumentGroup *qsamplerInstrum
346  qsamplerInstrumentItem *qsamplerInstrumentList::findItem (  qsamplerInstrumentItem *qsamplerInstrumentList::findItem (
347          qsamplerInstrument *pInstrument ) const          qsamplerInstrument *pInstrument ) const
348  {  {
349            if (pInstrument == NULL)
350                    return NULL;
351    
352          // Iterate all over the place to search for the group.          // Iterate all over the place to search for the group.
353          QListViewItemIterator iter((QListView *) this);          QListViewItemIterator iter((QListView *) this);
354          while (iter.current()) {          while (iter.current()) {
# Line 350  qsamplerInstrumentItem *qsamplerInstrume Line 356  qsamplerInstrumentItem *qsamplerInstrume
356                  if (pListItem->rtti() == Item) {                  if (pListItem->rtti() == Item) {
357                          qsamplerInstrumentItem *pItem                          qsamplerInstrumentItem *pItem
358                                  = static_cast<qsamplerInstrumentItem *> (pListItem);                                  = static_cast<qsamplerInstrumentItem *> (pListItem);
359                          if (pItem && pItem->Instrument() == pInstrument)                          if (pItem && pItem->instrument()
360                                    && pItem->instrument()->bank() == pInstrument->bank()
361                                    && pItem->instrument()->program() == pInstrument->program())
362                                  return pItem;                                  return pItem;
363                  }                  }
364                  ++iter;                  ++iter;
# Line 398  void qsamplerInstrumentList::newItemSlot Line 406  void qsamplerInstrumentList::newItemSlot
406                  return;                  return;
407          }          }
408    
409            // Check it there's already one for the same key (bank, program)
410            qsamplerInstrumentItem *pItem = findItem(pInstrument);
411            if (pItem)
412                    delete pItem;
413    
414          pInstrument->map();          pInstrument->map();
415          emit instrumentsChanged();          emit instrumentsChanged();
416    
# Line 420  void qsamplerInstrumentList::editItemSlo Line 433  void qsamplerInstrumentList::editItemSlo
433          if (pListItem->rtti() == Item) {          if (pListItem->rtti() == Item) {
434                  qsamplerInstrumentItem *pItem                  qsamplerInstrumentItem *pItem
435                          = static_cast<qsamplerInstrumentItem *> (pListItem);                          = static_cast<qsamplerInstrumentItem *> (pListItem);
436                  if (pItem && pItem->Instrument()) {                  if (pItem && pItem->instrument()) {
437                          qsamplerInstrumentForm form(this);                          qsamplerInstrumentForm form(this);
438                          form.setup(pItem->Instrument());                          form.setup(pItem->instrument());
439                          if (form.exec()) {                          if (form.exec()) {
440                                  pItem->Instrument()->map();                                  pItem->instrument()->map();
441                                  emit instrumentsChanged();                                  emit instrumentsChanged();
442                                  pItem->update();                                  pItem->update();
443                          }                          }
# Line 454  void qsamplerInstrumentList::deleteSlot Line 467  void qsamplerInstrumentList::deleteSlot
467                  if (pListItem->rtti() == Item) {                  if (pListItem->rtti() == Item) {
468                          qsamplerInstrumentItem *pItem                          qsamplerInstrumentItem *pItem
469                                  = static_cast<qsamplerInstrumentItem *> (pListItem);                                  = static_cast<qsamplerInstrumentItem *> (pListItem);
470                          if (pItem && pItem->Instrument()) {                          if (pItem && pItem->instrument()) {
471                                  pItem->Instrument()->unmap();                                  pItem->instrument()->unmap();
472                                  emit instrumentsChanged();                                  emit instrumentsChanged();
473                          }                          }
474                  }                  }
# Line 495  void qsamplerInstrumentList::renamedSlot Line 508  void qsamplerInstrumentList::renamedSlot
508          if (pListItem->rtti() == Item) {          if (pListItem->rtti() == Item) {
509                  qsamplerInstrumentItem *pItem                  qsamplerInstrumentItem *pItem
510                          = static_cast<qsamplerInstrumentItem *> (pListItem);                          = static_cast<qsamplerInstrumentItem *> (pListItem);
511                  if (pItem && pItem->Instrument()) {                  if (pItem && pItem->instrument()) {
512                          pItem->Instrument()->setName(pListItem->text(0));                          pItem->instrument()->setName(pListItem->text(0));
513                          pItem->Instrument()->map();                          pItem->instrument()->map();
514                          emit instrumentsChanged();                          emit instrumentsChanged();
515                          pItem->update();                          pItem->update();
516                  }                  }

Legend:
Removed from v.968  
changed lines
  Added in v.969

  ViewVC Help
Powered by ViewVC