/[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 987 by capela, Tue Dec 19 11:19:55 2006 UTC revision 1464 by capela, Thu Nov 1 17:14:21 2007 UTC
# Line 1  Line 1 
1  // qsamplerInstrumentList.cpp  // qsamplerInstrumentList.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5       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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 28  Line 29 
29  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
30  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
31    
32    #include <qapplication.h>
33  #include <qmessagebox.h>  #include <qmessagebox.h>
34    #include <qeventloop.h>
35  #include <qaction.h>  #include <qaction.h>
36    #include <qcursor.h>
37  #include <qfileinfo.h>  #include <qfileinfo.h>
38  #include <qpopupmenu.h>  
39    #include <QMenu>
40    
41  // Needed for lroundf()  // Needed for lroundf()
42  #include <math.h>  #include <math.h>
# Line 46  static inline long lroundf ( float x ) Line 51  static inline long lroundf ( float x )
51  }  }
52  #endif  #endif
53    
54    using namespace QSampler;
55    
56  //----------------------------------------------------------------------  //----------------------------------------------------------------------
57  // class qsamplerInstrumentGroup -- custom group list view item.  // class qsamplerInstrumentGroup -- custom group list view item.
58  //  //
59    
60    #if 0
61  // Constructors.  // Constructors.
62  qsamplerInstrumentGroup::qsamplerInstrumentGroup (  qsamplerInstrumentGroup::qsamplerInstrumentGroup (
63          qsamplerInstrumentList *pListView, const QString& sName,          qsamplerInstrumentList *pListView, const QString& sName,
# Line 59  qsamplerInstrumentGroup::qsamplerInstrum Line 66  qsamplerInstrumentGroup::qsamplerInstrum
66  {  {
67          QListViewItem::setRenameEnabled(0, true);          QListViewItem::setRenameEnabled(0, true);
68    
69          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemGroup.png"));          QListViewItem::setPixmap(0, QPixmap(":/icons/itemGroup.png"));
70          QListViewItem::setText(0, sName);          QListViewItem::setText(0, sName);
71  }  }
72    
# Line 70  qsamplerInstrumentGroup::qsamplerInstrum Line 77  qsamplerInstrumentGroup::qsamplerInstrum
77  {  {
78          QListViewItem::setRenameEnabled(0, true);          QListViewItem::setRenameEnabled(0, true);
79    
80          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemGroup.png"));          QListViewItem::setPixmap(0, QPixmap(":/icons/itemGroup.png"));
81  }  }
82    
83    
# Line 113  void qsamplerInstrumentGroup::setOpen ( Line 120  void qsamplerInstrumentGroup::setOpen (
120  {  {
121          // Set the proper pixmap of this...          // Set the proper pixmap of this...
122          if (rtti() == qsamplerInstrumentList::Group) {          if (rtti() == qsamplerInstrumentList::Group) {
123                  QListViewItem::setPixmap(0, QPixmap::fromMimeSource(                  QListViewItem::setPixmap(0, QPixmap(bOpen ?
124                          bOpen ? "itemGroupOpen.png" : "itemGroup.png"));                          ":/icons/itemGroupOpen.png" : ":/icons/itemGroup.png"));
125          }          }
126          // Open it up...          // Open it up...
127          QListViewItem::setOpen(bOpen);          QListViewItem::setOpen(bOpen);
# Line 184  qsamplerInstrument *qsamplerInstrumentIt Line 191  qsamplerInstrument *qsamplerInstrumentIt
191  // Item refreshment.  // Item refreshment.
192  void qsamplerInstrumentItem::update (void)  void qsamplerInstrumentItem::update (void)
193  {  {
194          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemFile.png"));          QListViewItem::setPixmap(0, QPixmap(":/icons/itemFile.png"));
195    
196          const QString s = "-";          const QString s = "-";
197          if (m_pInstrument) {          if (m_pInstrument) {
# Line 225  qsamplerInstrumentList::qsamplerInstrume Line 232  qsamplerInstrumentList::qsamplerInstrume
232          QWidget *pParent, const char *pszName )          QWidget *pParent, const char *pszName )
233          : QListView(pParent, pszName)          : QListView(pParent, pszName)
234  {  {
235            m_iMidiMap = LSCP_MIDI_MAP_ALL;
236    
237  //  QListView::setRootIsDecorated(true);  //  QListView::setRootIsDecorated(true);
238            QListView::setAllColumnsShowFocus(true);
239          QListView::setResizeMode(QListView::NoColumn);          QListView::setResizeMode(QListView::NoColumn);
240  //      QListView::setAcceptDrops(true);  //      QListView::setAcceptDrops(true);
241          QListView::setDragAutoScroll(true);          QListView::setDragAutoScroll(true);
# Line 253  qsamplerInstrumentList::qsamplerInstrume Line 263  qsamplerInstrumentList::qsamplerInstrume
263          QListView::setColumnWidth(0, 120);      // Name          QListView::setColumnWidth(0, 120);      // Name
264          QListView::setColumnWidth(5, 240);      // File          QListView::setColumnWidth(5, 240);      // File
265    
266          m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this);          m_pNewGroupAction = new QAction(
267          m_pNewItemAction  = new QAction(tr("New &Instrument..."), tr("Ins"), this);                  QIcon(":/icons/itemGroupNew.png"),
268          m_pEditItemAction = new QAction(tr("&Edit..."), tr("Enter"), this);                  tr("New &Group"), tr("Ctrl+G"), this);
269            m_pNewItemAction  = new QAction(
270                    QIcon(":/icons/itemNew.png"),
271                    tr("New &Instrument..."), tr("Ins"), this);
272            m_pEditItemAction = new QAction(
273                    QIcon(":/icons/formEdit.png"),
274                    tr("&Edit..."), tr("Enter"), this);
275          m_pRenameAction   = new QAction(tr("&Rename"), tr("F2"), this);          m_pRenameAction   = new QAction(tr("&Rename"), tr("F2"), this);
276          m_pDeleteAction   = new QAction(tr("&Delete"), tr("Del"), this);          m_pDeleteAction   = new QAction(
277          m_pRefreshAction  = new QAction(tr("Re&fresh"), tr("F5"), this);                  QIcon(":/icons/formRemove.png"),
278                    tr("&Delete"), tr("Del"), this);
279            m_pRefreshAction  = new QAction(
280                    QIcon(":/icons/formRefresh.png"),
281                    tr("Re&fresh"), tr("F5"), this);
282    
283            m_pNewGroupAction->setToolTip(tr("New Group"));
284            m_pNewItemAction->setToolTip(tr("New Instrument"));
285            m_pEditItemAction->setToolTip(tr("Edit"));
286            m_pRenameAction->setToolTip(tr("Rename"));
287            m_pDeleteAction->setToolTip(tr("Delete"));
288            m_pRefreshAction->setToolTip(tr("Refresh"));
289    
290          QObject::connect(m_pNewGroupAction,          QObject::connect(m_pNewGroupAction,
291                  SIGNAL(activated()),                  SIGNAL(activated()),
# Line 312  qsamplerInstrumentItem *qsamplerInstrume Line 339  qsamplerInstrumentItem *qsamplerInstrume
339          qsamplerInstrument *pInstrument,          qsamplerInstrument *pInstrument,
340          qsamplerInstrumentGroup *pParentGroup )          qsamplerInstrumentGroup *pParentGroup )
341  {  {
342            // Check it there's already one instrument item
343            // with the very same key (bank, program);
344            // if yes, just remove it without prejudice...
345          qsamplerInstrumentItem *pItem = findItem(pInstrument);          qsamplerInstrumentItem *pItem = findItem(pInstrument);
346          if (pItem == NULL) {          if (pItem) {
347                  if (pParentGroup)                  // If exactly the same, just update view and bail out...
348                          pItem = new qsamplerInstrumentItem(pParentGroup, pInstrument);                  if (pItem->instrument() == pInstrument) {
349                  else                          pItem->update();
350                          pItem = new qsamplerInstrumentItem(this, pInstrument);                          return pItem;
351                    }
352                    // Remove it, as instrument keys must be unique.
353                    delete pItem;
354            }
355    
356            // Add the new item under proper group one, if any...
357            if (pParentGroup) {
358                    pParentGroup->setOpen(true);
359                    pItem = new qsamplerInstrumentItem(pParentGroup, pInstrument);
360            } else {
361                    pItem = new qsamplerInstrumentItem(this, pInstrument);
362          }          }
363    
364            // Set it as current selection...
365          QListView::setSelected(pItem, true);          QListView::setSelected(pItem, true);
366    
367          return pItem;          return pItem;
368  }  }
369    
# Line 330  qsamplerInstrumentGroup *qsamplerInstrum Line 374  qsamplerInstrumentGroup *qsamplerInstrum
374  {  {
375          qsamplerInstrumentGroup *pGroup = findGroup(sName);          qsamplerInstrumentGroup *pGroup = findGroup(sName);
376          if (pGroup == NULL) {          if (pGroup == NULL) {
377                  if (pParentGroup)                  if (pParentGroup) {
378                            pParentGroup->setOpen(true);
379                          pGroup = new qsamplerInstrumentGroup(pParentGroup, sName);                          pGroup = new qsamplerInstrumentGroup(pParentGroup, sName);
380                  else                  } else {
381                          pGroup = new qsamplerInstrumentGroup(this, sName);                          pGroup = new qsamplerInstrumentGroup(this, sName);
382                    }
383          }          }
384          QListView::setSelected(pGroup, true);          QListView::setSelected(pGroup, true);
385          return pGroup;          return pGroup;
# Line 397  qsamplerInstrumentGroup *qsamplerInstrum Line 443  qsamplerInstrumentGroup *qsamplerInstrum
443  // Add a new group item below the current one.  // Add a new group item below the current one.
444  void qsamplerInstrumentList::newGroupSlot (void)  void qsamplerInstrumentList::newGroupSlot (void)
445  {  {
         qsamplerInstrumentGroup *pParentGroup  
                 = groupItem(QListView::selectedItem());  
446          qsamplerInstrumentGroup *pNewGroup          qsamplerInstrumentGroup *pNewGroup
447                  = addGroup(tr("New Group"), pParentGroup);                  = addGroup(tr("New Group"), groupItem(QListView::selectedItem()));
         if (pParentGroup)  
                 pParentGroup->setOpen(true);  
448          if (pNewGroup)          if (pNewGroup)
449                  pNewGroup->startRename(0);                  pNewGroup->startRename(0);
450    
# Line 410  void qsamplerInstrumentList::newGroupSlo Line 452  void qsamplerInstrumentList::newGroupSlo
452  }  }
453    
454    
455    // Map selector.
456    void qsamplerInstrumentList::setMidiMap ( int iMidiMap )
457    {
458            if (iMidiMap < 0)
459                    iMidiMap = LSCP_MIDI_MAP_ALL;
460    
461            m_iMidiMap = iMidiMap;
462    }
463    
464    int qsamplerInstrumentList::midiMap (void) const
465    {
466            return m_iMidiMap;
467    }
468    
469    
470    // List actions accessors.
471    QAction *qsamplerInstrumentList::newGroupAction (void) const
472    {
473            return m_pNewGroupAction;
474    }
475    
476    QAction *qsamplerInstrumentList::newItemAction (void) const
477    {
478            return m_pNewItemAction;
479    }
480    
481    QAction *qsamplerInstrumentList::editItemAction (void) const
482    {
483            return m_pEditItemAction;
484    }
485    
486    QAction *qsamplerInstrumentList::renameAction (void) const
487    {
488            return m_pRenameAction;
489    }
490    
491    QAction *qsamplerInstrumentList::deleteAction (void) const
492    {
493            return m_pDeleteAction;
494    }
495    
496    QAction *qsamplerInstrumentList::refreshAction (void) const
497    {
498            return m_pRefreshAction;
499    }
500    
501    
502  // Add a new instrument item below the current one.  // Add a new instrument item below the current one.
503  void qsamplerInstrumentList::newItemSlot (void)  void qsamplerInstrumentList::newItemSlot (void)
504  {  {
# Line 422  void qsamplerInstrumentList::newItemSlot Line 511  void qsamplerInstrumentList::newItemSlot
511                  return;                  return;
512          }          }
513    
514          // Check it there's already one instrument item          // Commit...
         // with the very same key (bank, program);  
         // if yes, just remove it without prejudice...  
         qsamplerInstrumentItem *pItem = findItem(pInstrument);  
         if (pItem)  
                 delete pItem;  
   
515          pInstrument->mapInstrument();          pInstrument->mapInstrument();
516            // add new item to the tree...
517            addItem(pInstrument, groupItem(QListView::selectedItem()));
518            // Notify we've changes...
519          emit instrumentsChanged();          emit instrumentsChanged();
520    
         qsamplerInstrumentGroup *pParentGroup  
                 = groupItem(QListView::selectedItem());  
         addItem(pInstrument, pParentGroup);  
         if (pParentGroup)  
                 pParentGroup->setOpen(true);  
   
521          selectionChangedSlot();          selectionChangedSlot();
522  }  }
523    
# Line 449  void qsamplerInstrumentList::editItemSlo Line 529  void qsamplerInstrumentList::editItemSlo
529          if (pListItem == NULL)          if (pListItem == NULL)
530                  return;                  return;
531          if (pListItem->rtti() == Item) {          if (pListItem->rtti() == Item) {
532                    qsamplerInstrument *pInstrument = NULL;
533                  qsamplerInstrumentItem *pItem                  qsamplerInstrumentItem *pItem
534                          = static_cast<qsamplerInstrumentItem *> (pListItem);                          = static_cast<qsamplerInstrumentItem *> (pListItem);
535                  if (pItem && pItem->instrument()) {                  if (pItem)
536                            pInstrument = pItem->instrument();
537                    if (pInstrument) {
538                            // Save current key values...
539                            qsamplerInstrument oldInstrument(*pInstrument);
540                            // Do the edit dance...
541                          qsamplerInstrumentForm form(this);                          qsamplerInstrumentForm form(this);
542                          form.setup(pItem->instrument());                          form.setup(pInstrument);
543                          if (form.exec()) {                          if (form.exec()) {
544                                  pItem->instrument()->mapInstrument();                                  // Commit...
545                                    pInstrument->mapInstrument();
546                                    // Check whether we changed instrument key...
547                                    if (oldInstrument.map()  == pInstrument->map()  &&
548                                            oldInstrument.bank() == pInstrument->bank() &&
549                                            oldInstrument.prog() == pInstrument->prog()) {
550                                            // just update tree item...
551                                            pItem->update();
552                                    } else {
553                                            // Unmap old instance...
554                                            oldInstrument.unmapInstrument();
555                                            // Change item tree, whether applicable...
556                                            if (m_iMidiMap < 0 || m_iMidiMap == pInstrument->map()) {
557                                                    // Add new brand item into view...
558                                                    addItem(pInstrument, groupItem(pListItem));
559                                            } else {
560                                                    // Just remove/hide old one.
561                                                    delete pItem;
562                                            }
563                                    }
564                                    // Notify we've changes...
565                                  emit instrumentsChanged();                                  emit instrumentsChanged();
                                 pItem->update();  
566                          }                          }
567                  }                  }
568          }          }
# Line 537  void qsamplerInstrumentList::selectionCh Line 642  void qsamplerInstrumentList::selectionCh
642  void qsamplerInstrumentList::activatedSlot ( QListViewItem *pListItem )  void qsamplerInstrumentList::activatedSlot ( QListViewItem *pListItem )
643  {  {
644          // FIXME: Hope the list view item is the one selected.          // FIXME: Hope the list view item is the one selected.
645          if (pListItem->rtti() == Item)          if (pListItem && pListItem->rtti() == Item)
646                  editItemSlot();                  editItemSlot();
647  }  }
648    
# Line 592  void qsamplerInstrumentList::refresh (vo Line 697  void qsamplerInstrumentList::refresh (vo
697          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
698                  return;                  return;
699    
700            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
701    
702            // Load the whole bunch of instrument items...
703          qsamplerInstrumentItem *pItem = NULL;          qsamplerInstrumentItem *pItem = NULL;
704          lscp_midi_instrument_t *pInstrs          lscp_midi_instrument_t *pInstrs
705                  = ::lscp_list_midi_instruments(pMainForm->client(), LSCP_MIDI_MAP_ALL);                  = ::lscp_list_midi_instruments(pMainForm->client(), m_iMidiMap);
706          for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; ++iInstr) {          for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; ++iInstr) {
707                  int iMap  = pInstrs[iInstr].map;                  int iMap  = pInstrs[iInstr].map;
708                  int iBank = pInstrs[iInstr].bank;                  int iBank = pInstrs[iInstr].bank;
# Line 603  void qsamplerInstrumentList::refresh (vo Line 711  void qsamplerInstrumentList::refresh (vo
711                          = new qsamplerInstrument(iMap, iBank, iProg);                          = new qsamplerInstrument(iMap, iBank, iProg);
712                  if (pInstrument->getInstrument())                  if (pInstrument->getInstrument())
713                          pItem = new qsamplerInstrumentItem(this, pInstrument, pItem);                          pItem = new qsamplerInstrumentItem(this, pInstrument, pItem);
714                    // Try to keep it snappy :)
715                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
716          }          }
717    
718            QApplication::restoreOverrideCursor();
719    
720          if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) {          if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) {
721                  pMainForm->appendMessagesClient("lscp_list_midi_instruments");                  pMainForm->appendMessagesClient("lscp_list_midi_instruments");
722                  pMainForm->appendMessagesError(tr("Could not get current list of MIDI instrument mappings.\n\nSorry."));                  pMainForm->appendMessagesError(tr("Could not get current list of MIDI instrument mappings.\n\nSorry."));
# Line 612  void qsamplerInstrumentList::refresh (vo Line 724  void qsamplerInstrumentList::refresh (vo
724    
725          selectionChangedSlot();          selectionChangedSlot();
726  }  }
727    #endif
728    
729    MidiInstrumentsModel::MidiInstrumentsModel(QObject* parent) : QAbstractTableModel(parent) {
730        m_iMidiMap = LSCP_MIDI_MAP_ALL;
731    }
732    
733  // end of qsamplerInstrumentList.cpp  int MidiInstrumentsModel::rowCount(const QModelIndex& /*parent*/) const {
734        if (m_iMidiMap == LSCP_MIDI_MAP_ALL) {
735            int n = 0;
736            for (InstrumentsMap::const_iterator itMap = instruments.begin(); itMap != instruments.end(); ++itMap)
737                n += (*itMap).size();
738            return n;
739        }
740        InstrumentsMap::const_iterator itMap = instruments.find(m_iMidiMap);
741        if (itMap == instruments.end()) return 0;
742        return (*itMap).size();
743    }
744    
745    int MidiInstrumentsModel::columnCount(const QModelIndex& /*parent*/) const {
746        return 9;
747    }
748    
749    QVariant MidiInstrumentsModel::data(const QModelIndex &index, int role) const {
750        if (!index.isValid() || role != Qt::DisplayRole) return QVariant();
751    
752        if (m_iMidiMap == LSCP_MIDI_MAP_ALL) {
753            int n = 0;
754            for (InstrumentsMap::const_iterator itMap = instruments.begin(); itMap != instruments.end(); ++itMap) {
755                n += (*itMap).size();
756                if (index.row() < n)
757                    return QVariant::fromValue(
758                        (*itMap)[index.row() + (*itMap).size() - n]
759                    );
760            }
761        } else {
762            // resolve MIDI instrument map
763            InstrumentsMap::const_iterator itMap = instruments.find(m_iMidiMap);
764            if (itMap == instruments.end()) return QVariant();
765            // resolve instrument in that map
766            if (index.row() >= (*itMap).size()) return QVariant();
767            return QVariant::fromValue(
768                (*itMap)[index.row()]
769            );
770        }
771    
772        return QVariant();
773    }
774    
775    QVariant MidiInstrumentsModel::headerData(int section, Qt::Orientation orientation, int role) const {
776        if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
777            return QVariant();
778    
779        switch (section) {
780            case 0: return tr("Name");
781            case 1: return tr("Map");
782            case 2: return tr("Bank");
783            case 3: return tr("Prog");
784            case 4: return tr("Engine");
785            case 5: return tr("File");
786            case 6: return tr("Nr");
787            case 7: return tr("Vol");
788            case 8: return tr("Mode");
789            default: return QVariant();
790        }
791    }
792    
793    qsamplerInstrument* MidiInstrumentsModel::addInstrument(int iMap, int iBank, int iProg) {
794        // Check it there's already one instrument item
795        // with the very same key (bank, program);
796        // if yes, just remove it without prejudice...
797        for (int i = 0; i < instruments[iMap].size(); i++) {
798            if (
799                instruments[iMap][i].bank() == iBank &&
800                instruments[iMap][i].prog() == iProg
801            ) {
802                instruments[iMap].removeAt(i);
803                break;
804            }
805        }
806    
807        // resolve the appropriate place, we keep the list sorted that way ...
808        int i = 0;
809        for (; i < instruments[iMap].size(); i++)
810            if (
811                iBank > instruments[iMap][i].bank() ||
812                ( iBank == instruments[iMap][i].bank() &&
813                  iProg > instruments[iMap][i].prog() )
814            ) break;
815    
816        qsamplerInstrument& instr = instruments[iMap][i] = qsamplerInstrument(iMap, iBank, iProg);
817    
818        return &instr;
819    }
820    
821    void MidiInstrumentsModel::setMidiMap(int iMidiMap) {
822        if (iMidiMap < 0)
823            iMidiMap = LSCP_MIDI_MAP_ALL;
824    
825        m_iMidiMap = iMidiMap;
826    }
827    
828    int MidiInstrumentsModel::midiMap() const {
829        return m_iMidiMap;
830    }
831    
832    void MidiInstrumentsModel::refresh() {
833            instruments.clear();
834    
835            MainForm* pMainForm = MainForm::getInstance();
836            if (pMainForm == NULL)
837                    return;
838            if (pMainForm->client() == NULL)
839                    return;
840    
841            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
842    
843            // Load the whole bunch of instrument items...
844            lscp_midi_instrument_t* pInstrs
845                    = ::lscp_list_midi_instruments(pMainForm->client(), m_iMidiMap);
846            for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; ++iInstr) {
847                    const int iMap  = pInstrs[iInstr].map;
848                    const int iBank = pInstrs[iInstr].bank;
849                    const int iProg = pInstrs[iInstr].prog;
850                    addInstrument(iMap, iBank, iProg);
851                    // Try to keep it snappy :)
852                    QApplication::processEvents(QEventLoop::ExcludeUserInput);
853            }
854    
855            QApplication::restoreOverrideCursor();
856    
857            if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) {
858                    pMainForm->appendMessagesClient("lscp_list_midi_instruments");
859                    pMainForm->appendMessagesError(tr("Could not get current list of MIDI instrument mappings.\n\nSorry."));
860            }
861    
862            //selectionChangedSlot();
863    }
864    
865    
866    MidiInstrumentsDelegate::MidiInstrumentsDelegate(QObject* parent) : QItemDelegate(parent) {
867    }
868    
869    QWidget* MidiInstrumentsDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const {
870        return new QLabel(index.model()->data(index, Qt::DisplayRole).toString(), parent);
871    }
872    
873    void MidiInstrumentsDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const {
874    }
875    
876    void MidiInstrumentsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const {
877    }
878    
879    void MidiInstrumentsDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const {
880        if (editor) editor->setGeometry(option.rect);
881    }
882    
883    
884    // end of qsamplerInstrumentList.cpp

Legend:
Removed from v.987  
changed lines
  Added in v.1464

  ViewVC Help
Powered by ViewVC