/[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 969 by capela, Wed Dec 6 19:38:02 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     This program is free software; you can redistribute it and/or  
7     modify it under the terms of the GNU General Public License     This program is free software; you can redistribute it and/or
8     as published by the Free Software Foundation; either version 2     modify it under the terms of the GNU General Public License
9     of the License, or (at your option) any later version.     as published by the Free Software Foundation; either version 2
10       of the License, or (at your option) any later version.
11     This program is distributed in the hope that it will be useful,  
12     but WITHOUT ANY WARRANTY; without even the implied warranty of     This program is distributed in the hope that it will be useful,
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     GNU General Public License for more details.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15       GNU General Public License for more details.
16     You should have received a copy of the GNU General Public License  
17     along with this program; if not, write to the Free Software     You should have received a copy of the GNU General Public License
18     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     along with this program; if not, write to the Free Software
19       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *****************************************************************************/  
21    *****************************************************************************/
22  #include "qsamplerAbout.h"  
23  #include "qsamplerInstrumentList.h"  #include "qsamplerAbout.h"
24    #include "qsamplerInstrumentList.h"
25  #include "qsamplerInstrument.h"  
26  #include "qsamplerInstrumentForm.h"  #include "qsamplerInstrument.h"
27    #include "qsamplerInstrumentForm.h"
28  #include "qsamplerMainForm.h"  
29    #include "qsamplerOptions.h"
30  #include <qaction.h>  #include "qsamplerMainForm.h"
31  #include <qfileinfo.h>  
32  #include <qpopupmenu.h>  #include <qapplication.h>
33    #include <qmessagebox.h>
34  // Needed for lroundf()  #include <qeventloop.h>
35  #include <math.h>  #include <qaction.h>
36    #include <qcursor.h>
37    #include <qfileinfo.h>
38  //----------------------------------------------------------------------  
39  // class qsamplerInstrumentGroup -- custom group list view item.  #include <QMenu>
40  //  
41    // Needed for lroundf()
42  // Constructors.  #include <math.h>
43  qsamplerInstrumentGroup::qsamplerInstrumentGroup (  
44          qsamplerInstrumentList *pListView, const QString& sName,  #ifndef CONFIG_ROUND
45          QListViewItem *pItemAfter )  static inline long lroundf ( float x )
46          : QListViewItem(pListView, pItemAfter ? pItemAfter : pListView->lastItem())  {
47  {          if (x >= 0.0f)
48          QListViewItem::setRenameEnabled(0, true);                  return long(x + 0.5f);
49            else
50          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemGroup.png"));                  return long(x - 0.5f);
51          QListViewItem::setText(0, sName);  }
52  }  #endif
53    
54    using namespace QSampler;
55  qsamplerInstrumentGroup::qsamplerInstrumentGroup (  
56          qsamplerInstrumentGroup *pGroupItem, const QString& sName )  //----------------------------------------------------------------------
57          : QListViewItem(pGroupItem, sName)  // class qsamplerInstrumentGroup -- custom group list view item.
58  {  //
59          QListViewItem::setRenameEnabled(0, true);  
60    #if 0
61          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemGroup.png"));  // Constructors.
62  }  qsamplerInstrumentGroup::qsamplerInstrumentGroup (
63            qsamplerInstrumentList *pListView, const QString& sName,
64            QListViewItem *pItemAfter )
65  // Default destructor.          : QListViewItem(pListView, pItemAfter ? pItemAfter : pListView->lastItem())
66  qsamplerInstrumentGroup::~qsamplerInstrumentGroup (void)  {
67  {          QListViewItem::setRenameEnabled(0, true);
68  }  
69            QListViewItem::setPixmap(0, QPixmap(":/icons/itemGroup.png"));
70            QListViewItem::setText(0, sName);
71  // Instance accessors.  }
72  void qsamplerInstrumentGroup::setName ( const QString& sName )  
73  {  
74          QListViewItem::setText(0, sName);  qsamplerInstrumentGroup::qsamplerInstrumentGroup (
75  }          qsamplerInstrumentGroup *pGroupItem, const QString& sName )
76            : QListViewItem(pGroupItem, sName)
77    {
78  QString qsamplerInstrumentGroup::name (void) const          QListViewItem::setRenameEnabled(0, true);
79  {  
80          return QListViewItem::text(0);          QListViewItem::setPixmap(0, QPixmap(":/icons/itemGroup.png"));
81  }  }
82    
83    
84  qsamplerInstrumentGroup *qsamplerInstrumentGroup::groupItem (void) const  // Default destructor.
85  {  qsamplerInstrumentGroup::~qsamplerInstrumentGroup (void)
86          QListViewItem *pParent = QListViewItem::parent();  {
87          while (pParent && pParent->rtti() != qsamplerInstrumentList::Group)  }
88                  pParent = pParent->parent();  
89          return static_cast<qsamplerInstrumentGroup *> (pParent);  
90  }  // Instance accessors.
91    void qsamplerInstrumentGroup::setName ( const QString& sName )
92    {
93  qsamplerInstrumentList *qsamplerInstrumentGroup::listView (void) const          QListViewItem::setText(0, sName);
94  {  }
95          return static_cast<qsamplerInstrumentList *> (QListViewItem::listView());  
96  }  
97    QString qsamplerInstrumentGroup::name (void) const
98    {
99  // To show up whether its open or not.          return QListViewItem::text(0);
100  void qsamplerInstrumentGroup::setOpen ( bool bOpen )  }
101  {  
102          // Set the proper pixmap of this...  
103          if (rtti() == qsamplerInstrumentList::Group) {  qsamplerInstrumentGroup *qsamplerInstrumentGroup::groupItem (void) const
104                  QListViewItem::setPixmap(0, QPixmap::fromMimeSource(  {
105                          bOpen ? "itemGroupOpen.png" : "itemGroup.png"));          QListViewItem *pParent = QListViewItem::parent();
106          }          while (pParent && pParent->rtti() != qsamplerInstrumentList::Group)
107          // Open it up...                  pParent = pParent->parent();
108          QListViewItem::setOpen(bOpen);          return static_cast<qsamplerInstrumentGroup *> (pParent);
109    }
110          // All ancestors should be also visible.  
111          if (bOpen && QListViewItem::parent())  
112                  QListViewItem::parent()->setOpen(true);  qsamplerInstrumentList *qsamplerInstrumentGroup::listView (void) const
113  }  {
114            return static_cast<qsamplerInstrumentList *> (QListViewItem::listView());
115    }
116  // To virtually distinguish between list view items.  
117  int qsamplerInstrumentGroup::rtti (void) const  
118  {  // To show up whether its open or not.
119          return qsamplerInstrumentList::Group;  void qsamplerInstrumentGroup::setOpen ( bool bOpen )
120  }  {
121            // Set the proper pixmap of this...
122            if (rtti() == qsamplerInstrumentList::Group) {
123  //----------------------------------------------------------------------                  QListViewItem::setPixmap(0, QPixmap(bOpen ?
124  // class qsamplerInstrumentItem -- custom file list view item.                          ":/icons/itemGroupOpen.png" : ":/icons/itemGroup.png"));
125  //          }
126            // Open it up...
127  // Constructors.          QListViewItem::setOpen(bOpen);
128  qsamplerInstrumentItem::qsamplerInstrumentItem (  
129          qsamplerInstrumentList *pListView,          // All ancestors should be also visible.
130          qsamplerInstrument *pInstrument,          if (bOpen && QListViewItem::parent())
131          QListViewItem *pItemAfter )                  QListViewItem::parent()->setOpen(true);
132          : qsamplerInstrumentGroup(pListView, pInstrument->name(), pItemAfter)  }
133  {  
134          m_pInstrument = pInstrument;  
135    // To virtually distinguish between list view items.
136          update();  int qsamplerInstrumentGroup::rtti (void) const
137  }  {
138            return qsamplerInstrumentList::Group;
139  qsamplerInstrumentItem::qsamplerInstrumentItem (  }
140          qsamplerInstrumentGroup *pGroupItem,  
141          qsamplerInstrument *pInstrument )  
142          : qsamplerInstrumentGroup(pGroupItem, pInstrument->name())  //----------------------------------------------------------------------
143  {  // class qsamplerInstrumentItem -- custom file list view item.
144          m_pInstrument = pInstrument;  //
145    
146          update();  // Constructors.
147  }  qsamplerInstrumentItem::qsamplerInstrumentItem (
148            qsamplerInstrumentList *pListView,
149            qsamplerInstrument *pInstrument,
150  // Default destructor.          QListViewItem *pItemAfter )
151  qsamplerInstrumentItem::~qsamplerInstrumentItem (void)          : qsamplerInstrumentGroup(pListView, pInstrument->name(), pItemAfter)
152  {  {
153          if (m_pInstrument)          m_pInstrument = pInstrument;
154                  delete m_pInstrument;  
155  }          update();
156    }
157    
158  // To virtually distinguish between list view items.  qsamplerInstrumentItem::qsamplerInstrumentItem (
159  int qsamplerInstrumentItem::rtti (void) const          qsamplerInstrumentGroup *pGroupItem,
160  {          qsamplerInstrument *pInstrument )
161          return qsamplerInstrumentList::Item;          : qsamplerInstrumentGroup(pGroupItem, pInstrument->name())
162  }  {
163            m_pInstrument = pInstrument;
164    
165  // Payload accessor.          update();
166  qsamplerInstrument *qsamplerInstrumentItem::instrument (void) const  }
167  {  
168          return m_pInstrument;  
169  }  // Default destructor.
170    qsamplerInstrumentItem::~qsamplerInstrumentItem (void)
171    {
172  // Item refreshment.          if (m_pInstrument)
173  void qsamplerInstrumentItem::update (void)                  delete m_pInstrument;
174  {  }
175          QListViewItem::setPixmap(0, QPixmap::fromMimeSource("itemFile.png"));  
176    
177          const QString s = "-";  // To virtually distinguish between list view items.
178          if (m_pInstrument) {  int qsamplerInstrumentItem::rtti (void) const
179                  setText(0, m_pInstrument->name());  {
180                  setText(1, QString::number(m_pInstrument->bank()));          return qsamplerInstrumentList::Item;
181                  setText(2, QString::number(m_pInstrument->program()));  }
182                  setText(3, m_pInstrument->engineName());  
183                  setText(4, QFileInfo(m_pInstrument->instrumentFile()).fileName());  
184                  setText(5, QString::number(m_pInstrument->instrumentNr()));  // Payload accessor.
185                  setText(6, QString::number(::lroundf(100.0f * m_pInstrument->volume())));  qsamplerInstrument *qsamplerInstrumentItem::instrument (void) const
186                  QString sLoadMode = s;  {
187                  switch (m_pInstrument->loadMode()) {          return m_pInstrument;
188                  case 3:  }
189                          sLoadMode = QObject::tr("Persistent");  
190                          break;  
191                  case 2:  // Item refreshment.
192                          sLoadMode = QObject::tr("On Demand Hold");  void qsamplerInstrumentItem::update (void)
193                          break;  {
194                  case 1:          QListViewItem::setPixmap(0, QPixmap(":/icons/itemFile.png"));
195                          sLoadMode = QObject::tr("On Demand");  
196                          break;          const QString s = "-";
197                  }          if (m_pInstrument) {
198                  setText(7, sLoadMode);                  setText(0, m_pInstrument->name());
199          } else {                  setText(1, QString::number(m_pInstrument->map()));
200                  for (int i = 0; i < listView()->columns(); i++)                  setText(2, QString::number(m_pInstrument->bank()));
201                          setText(i, s);                  setText(3, QString::number(m_pInstrument->prog() + 1));
202          }                  setText(4, m_pInstrument->engineName());
203  }                  setText(5, QFileInfo(m_pInstrument->instrumentFile()).fileName());
204                    setText(6, QString::number(m_pInstrument->instrumentNr()));
205                    setText(7, QString::number(::lroundf(100.0f * m_pInstrument->volume())));
206  //----------------------------------------------------------------------------                  QString sLoadMode = s;
207  // qsamplerInstrumentList -- MIDI instrument list view.                  switch (m_pInstrument->loadMode()) {
208  //                  case 3:
209                            sLoadMode = QObject::tr("Persistent");
210  // Constructor.                          break;
211  qsamplerInstrumentList::qsamplerInstrumentList (                  case 2:
212          QWidget *pParent, const char *pszName )                          sLoadMode = QObject::tr("On Demand Hold");
213          : QListView(pParent, pszName)                          break;
214  {                  case 1:
215  //  QListView::setRootIsDecorated(true);                          sLoadMode = QObject::tr("On Demand");
216          QListView::setResizeMode(QListView::NoColumn);                          break;
217  //      QListView::setAcceptDrops(true);                  }
218          QListView::setDragAutoScroll(true);                  setText(8, sLoadMode);
219          QListView::setSizePolicy(          } else {
220                  QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));                  for (int i = 0; i < listView()->columns(); i++)
221  //      QListView::setShowToolTips(false);                          setText(i, s);
222          QListView::setSortColumn(-1);          }
223    }
224          QListView::addColumn(tr("Name"));  
225          QListView::addColumn(tr("Bank"));  
226          QListView::addColumn(tr("Prog"));  //----------------------------------------------------------------------------
227          QListView::addColumn(tr("Engine"));  // qsamplerInstrumentList -- MIDI instrument list view.
228          QListView::addColumn(tr("File"));  //
229          QListView::addColumn(tr("Nr"));  
230          QListView::addColumn(tr("Vol"));  // Constructor.
231          QListView::addColumn(tr("Mode"));  qsamplerInstrumentList::qsamplerInstrumentList (
232            QWidget *pParent, const char *pszName )
233          QListView::setColumnAlignment(1, Qt::AlignHCenter);     // Bank          : QListView(pParent, pszName)
234          QListView::setColumnAlignment(2, Qt::AlignHCenter);     // Prog  {
235          QListView::setColumnAlignment(5, Qt::AlignHCenter);     // Nr          m_iMidiMap = LSCP_MIDI_MAP_ALL;
236          QListView::setColumnAlignment(6, Qt::AlignHCenter);     // Vol  
237    //  QListView::setRootIsDecorated(true);
238          QListView::setColumnWidth(0, 60);       // Name          QListView::setAllColumnsShowFocus(true);
239          QListView::setColumnWidth(0, 120);      // File          QListView::setResizeMode(QListView::NoColumn);
240    //      QListView::setAcceptDrops(true);
241          m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this);          QListView::setDragAutoScroll(true);
242          m_pNewItemAction  = new QAction(tr("New &Instrument..."), tr("Ctrl+I"), this);          QListView::setSizePolicy(
243          m_pEditItemAction = new QAction(tr("&Edit..."), tr("Ctrl+E"), this);                  QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
244          m_pRenameAction   = new QAction(tr("&Rename"), tr("Ctrl+R"), this);  //      QListView::setShowToolTips(false);
245          m_pDeleteAction   = new QAction(tr("&Delete"), tr("Ctrl+D"), this);          QListView::setSortColumn(-1);
246          m_pRefreshAction  = new QAction(tr("Re&fresh"), tr("Ctrl+F"), this);  
247            QListView::addColumn(tr("Name"));
248          QObject::connect(m_pNewGroupAction,          QListView::addColumn(tr("Map"));
249                  SIGNAL(activated()),          QListView::addColumn(tr("Bank"));
250                  SLOT(newGroupSlot()));          QListView::addColumn(tr("Prog"));
251          QObject::connect(m_pNewItemAction,          QListView::addColumn(tr("Engine"));
252                  SIGNAL(activated()),          QListView::addColumn(tr("File"));
253                  SLOT(newItemSlot()));          QListView::addColumn(tr("Nr"));
254          QObject::connect(m_pEditItemAction,          QListView::addColumn(tr("Vol"));
255                  SIGNAL(activated()),          QListView::addColumn(tr("Mode"));
256                  SLOT(editItemSlot()));  
257          QObject::connect(m_pRenameAction,          QListView::setColumnAlignment(1, Qt::AlignHCenter);     // Map
258                  SIGNAL(activated()),          QListView::setColumnAlignment(2, Qt::AlignHCenter);     // Bank
259                  SLOT(renameSlot()));          QListView::setColumnAlignment(3, Qt::AlignHCenter);     // Prog
260          QObject::connect(m_pDeleteAction,          QListView::setColumnAlignment(6, Qt::AlignHCenter);     // Nr
261                  SIGNAL(activated()),          QListView::setColumnAlignment(7, Qt::AlignHCenter);     // Vol
262                  SLOT(deleteSlot()));  
263          QObject::connect(m_pRefreshAction,          QListView::setColumnWidth(0, 120);      // Name
264                  SIGNAL(activated()),          QListView::setColumnWidth(5, 240);      // File
265                  SLOT(refresh()));  
266            m_pNewGroupAction = new QAction(
267          QObject::connect(this,                  QIcon(":/icons/itemGroupNew.png"),
268                  SIGNAL(selectionChanged()),                  tr("New &Group"), tr("Ctrl+G"), this);
269                  SLOT(selectionChangedSlot()));          m_pNewItemAction  = new QAction(
270          QObject::connect(this,                  QIcon(":/icons/itemNew.png"),
271                  SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),                  tr("New &Instrument..."), tr("Ins"), this);
272                  SLOT(activatedSlot(QListViewItem*)));          m_pEditItemAction = new QAction(
273          QObject::connect(this,                  QIcon(":/icons/formEdit.png"),
274                  SIGNAL(returnPressed(QListViewItem*)),                  tr("&Edit..."), tr("Enter"), this);
275                  SLOT(activatedSlot(QListViewItem*)));          m_pRenameAction   = new QAction(tr("&Rename"), tr("F2"), this);
276          QObject::connect(this,          m_pDeleteAction   = new QAction(
277                  SIGNAL(itemRenamed(QListViewItem*,int)),                  QIcon(":/icons/formRemove.png"),
278                  SLOT(renamedSlot(QListViewItem*)));                  tr("&Delete"), tr("Del"), this);
279            m_pRefreshAction  = new QAction(
280          selectionChangedSlot();                  QIcon(":/icons/formRefresh.png"),
281  }                  tr("Re&fresh"), tr("F5"), this);
282    
283            m_pNewGroupAction->setToolTip(tr("New Group"));
284  // Default destructor.          m_pNewItemAction->setToolTip(tr("New Instrument"));
285  qsamplerInstrumentList::~qsamplerInstrumentList (void)          m_pEditItemAction->setToolTip(tr("Edit"));
286  {          m_pRenameAction->setToolTip(tr("Rename"));
287          delete m_pNewGroupAction;          m_pDeleteAction->setToolTip(tr("Delete"));
288          delete m_pNewItemAction;          m_pRefreshAction->setToolTip(tr("Refresh"));
289          delete m_pEditItemAction;  
290          delete m_pRenameAction;          QObject::connect(m_pNewGroupAction,
291          delete m_pDeleteAction;                  SIGNAL(activated()),
292  }                  SLOT(newGroupSlot()));
293            QObject::connect(m_pNewItemAction,
294                    SIGNAL(activated()),
295  // Add a new instrument item, optionally under a given group.                  SLOT(newItemSlot()));
296  qsamplerInstrumentItem *qsamplerInstrumentList::addItem (          QObject::connect(m_pEditItemAction,
297          qsamplerInstrument *pInstrument,                  SIGNAL(activated()),
298          qsamplerInstrumentGroup *pParentGroup )                  SLOT(editItemSlot()));
299  {          QObject::connect(m_pRenameAction,
300          qsamplerInstrumentItem *pItem = findItem(pInstrument);                  SIGNAL(activated()),
301          if (pItem == NULL) {                  SLOT(renameSlot()));
302                  if (pParentGroup)          QObject::connect(m_pDeleteAction,
303                          pItem = new qsamplerInstrumentItem(pParentGroup, pInstrument);                  SIGNAL(activated()),
304                  else                  SLOT(deleteSlot()));
305                          pItem = new qsamplerInstrumentItem(this, pInstrument);          QObject::connect(m_pRefreshAction,
306          }                  SIGNAL(activated()),
307          QListView::setSelected(pItem, true);                  SLOT(refresh()));
308          return pItem;  
309  }          QObject::connect(this,
310                    SIGNAL(selectionChanged()),
311                    SLOT(selectionChangedSlot()));
312  // Add a new instrument group, optionally under another group.          QObject::connect(this,
313  qsamplerInstrumentGroup *qsamplerInstrumentList::addGroup (                  SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
314          const QString& sName, qsamplerInstrumentGroup *pParentGroup )                  SLOT(activatedSlot(QListViewItem*)));
315  {          QObject::connect(this,
316          qsamplerInstrumentGroup *pGroup = findGroup(sName);                  SIGNAL(returnPressed(QListViewItem*)),
317          if (pGroup == NULL) {                  SLOT(activatedSlot(QListViewItem*)));
318                  if (pParentGroup)          QObject::connect(this,
319                          pGroup = new qsamplerInstrumentGroup(pParentGroup, sName);                  SIGNAL(itemRenamed(QListViewItem*,int)),
320                  else                  SLOT(renamedSlot(QListViewItem*)));
321                          pGroup = new qsamplerInstrumentGroup(this, sName);  
322          }          selectionChangedSlot();
323          QListView::setSelected(pGroup, true);  }
324          return pGroup;  
325  }  
326    // Default destructor.
327    qsamplerInstrumentList::~qsamplerInstrumentList (void)
328  // Find a group item, given its name.  {
329  qsamplerInstrumentGroup *qsamplerInstrumentList::findGroup (          delete m_pNewGroupAction;
330          const QString& sName ) const          delete m_pNewItemAction;
331  {          delete m_pEditItemAction;
332          // Iterate all over the place to search for the group.          delete m_pRenameAction;
333          QListViewItemIterator iter((QListView *) this);          delete m_pDeleteAction;
334          while (iter.current()) {  }
335                  QListViewItem *pItem = iter.current();  
336                  if (pItem->rtti() == Group && pItem->text(0) == sName)  
337                          return static_cast<qsamplerInstrumentGroup *> (pItem);  // Add a new instrument item, optionally under a given group.
338                  ++iter;  qsamplerInstrumentItem *qsamplerInstrumentList::addItem (
339          }          qsamplerInstrument *pInstrument,
340          // Not found.          qsamplerInstrumentGroup *pParentGroup )
341          return NULL;  {
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  // Find a file item, given its name.          qsamplerInstrumentItem *pItem = findItem(pInstrument);
346  qsamplerInstrumentItem *qsamplerInstrumentList::findItem (          if (pItem) {
347          qsamplerInstrument *pInstrument ) const                  // If exactly the same, just update view and bail out...
348  {                  if (pItem->instrument() == pInstrument) {
349          if (pInstrument == NULL)                          pItem->update();
350                  return NULL;                          return pItem;
351                    }
352          // Iterate all over the place to search for the group.                  // Remove it, as instrument keys must be unique.
353          QListViewItemIterator iter((QListView *) this);                  delete pItem;
354          while (iter.current()) {          }
355                  QListViewItem *pListItem = iter.current();  
356                  if (pListItem->rtti() == Item) {          // Add the new item under proper group one, if any...
357                          qsamplerInstrumentItem *pItem          if (pParentGroup) {
358                                  = static_cast<qsamplerInstrumentItem *> (pListItem);                  pParentGroup->setOpen(true);
359                          if (pItem && pItem->instrument()                  pItem = new qsamplerInstrumentItem(pParentGroup, pInstrument);
360                                  && pItem->instrument()->bank() == pInstrument->bank()          } else {
361                                  && pItem->instrument()->program() == pInstrument->program())                  pItem = new qsamplerInstrumentItem(this, pInstrument);
362                                  return pItem;          }
363                  }  
364                  ++iter;          // Set it as current selection...
365          }          QListView::setSelected(pItem, true);
366          // Not found.  
367          return NULL;          return pItem;
368  }  }
369    
370    
371  // Find and return the nearest group item...  // Add a new instrument group, optionally under another group.
372  qsamplerInstrumentGroup *qsamplerInstrumentList::groupItem (  qsamplerInstrumentGroup *qsamplerInstrumentList::addGroup (
373          QListViewItem *pItem ) const          const QString& sName, qsamplerInstrumentGroup *pParentGroup )
374  {  {
375          while (pItem && pItem->rtti() != Group)          qsamplerInstrumentGroup *pGroup = findGroup(sName);
376                  pItem = pItem->parent();          if (pGroup == NULL) {
377          return static_cast<qsamplerInstrumentGroup *> (pItem);                  if (pParentGroup) {
378  }                          pParentGroup->setOpen(true);
379                            pGroup = new qsamplerInstrumentGroup(pParentGroup, sName);
380                    } else {
381  // Add a new group item below the current one.                          pGroup = new qsamplerInstrumentGroup(this, sName);
382  void qsamplerInstrumentList::newGroupSlot (void)                  }
383  {          }
384          qsamplerInstrumentGroup *pParentGroup          QListView::setSelected(pGroup, true);
385                  = groupItem(QListView::selectedItem());          return pGroup;
386          qsamplerInstrumentGroup *pNewGroup  }
387                  = addGroup(tr("New Group"), pParentGroup);  
388          if (pParentGroup)  
389                  pParentGroup->setOpen(true);  // Find a group item, given its name.
390          if (pNewGroup)  qsamplerInstrumentGroup *qsamplerInstrumentList::findGroup (
391                  pNewGroup->startRename(0);          const QString& sName ) const
392    {
393          selectionChangedSlot();          // Iterate all over the place to search for the group.
394  }          QListViewItemIterator iter((QListView *) this);
395            while (iter.current()) {
396                    QListViewItem *pItem = iter.current();
397  // Add a new instrument item below the current one.                  if (pItem->rtti() == Group && pItem->text(0) == sName)
398  void qsamplerInstrumentList::newItemSlot (void)                          return static_cast<qsamplerInstrumentGroup *> (pItem);
399  {                  ++iter;
400          qsamplerInstrument *pInstrument = new qsamplerInstrument();          }
401            // Not found.
402          qsamplerInstrumentForm form(this);          return NULL;
403          form.setup(pInstrument);  }
404          if (!form.exec()) {  
405                  delete pInstrument;  
406                  return;  // Find a file item, given its name.
407          }  qsamplerInstrumentItem *qsamplerInstrumentList::findItem (
408            qsamplerInstrument *pInstrument ) const
409          // Check it there's already one for the same key (bank, program)  {
410          qsamplerInstrumentItem *pItem = findItem(pInstrument);          if (pInstrument == NULL)
411          if (pItem)                  return NULL;
412                  delete pItem;  
413            // Iterate all over the place to search for the group.
414          pInstrument->map();          QListViewItemIterator iter((QListView *) this);
415          emit instrumentsChanged();          while (iter.current()) {
416                    QListViewItem *pListItem = iter.current();
417          qsamplerInstrumentGroup *pParentGroup                  if (pListItem->rtti() == Item) {
418                  = groupItem(QListView::selectedItem());                          qsamplerInstrumentItem *pItem
419          addItem(pInstrument, pParentGroup);                                  = static_cast<qsamplerInstrumentItem *> (pListItem);
420          if (pParentGroup)                          if (pItem && pItem->instrument()
421                  pParentGroup->setOpen(true);                                  && pItem->instrument()->map()  == pInstrument->map()
422                                    && pItem->instrument()->bank() == pInstrument->bank()
423          selectionChangedSlot();                                  && pItem->instrument()->prog() == pInstrument->prog())
424  }                                  return pItem;
425                    }
426                    ++iter;
427  // Edit current item below the current one.          }
428  void qsamplerInstrumentList::editItemSlot (void)          // Not found.
429  {          return NULL;
430          QListViewItem *pListItem = QListView::selectedItem();  }
431          if (pListItem == NULL)  
432                  return;  
433          if (pListItem->rtti() == Item) {  // Find and return the nearest group item...
434                  qsamplerInstrumentItem *pItem  qsamplerInstrumentGroup *qsamplerInstrumentList::groupItem (
435                          = static_cast<qsamplerInstrumentItem *> (pListItem);          QListViewItem *pItem ) const
436                  if (pItem && pItem->instrument()) {  {
437                          qsamplerInstrumentForm form(this);          while (pItem && pItem->rtti() != Group)
438                          form.setup(pItem->instrument());                  pItem = pItem->parent();
439                          if (form.exec()) {          return static_cast<qsamplerInstrumentGroup *> (pItem);
440                                  pItem->instrument()->map();  }
441                                  emit instrumentsChanged();  
442                                  pItem->update();  
443                          }  // Add a new group item below the current one.
444                  }  void qsamplerInstrumentList::newGroupSlot (void)
445          }  {
446            qsamplerInstrumentGroup *pNewGroup
447          selectionChangedSlot();                  = addGroup(tr("New Group"), groupItem(QListView::selectedItem()));
448  }          if (pNewGroup)
449                    pNewGroup->startRename(0);
450    
451  // Rename current group/item.          selectionChangedSlot();
452  void qsamplerInstrumentList::renameSlot (void)  }
453  {  
454          QListViewItem *pListItem = QListView::selectedItem();  
455          if (pListItem)  // Map selector.
456                  pListItem->startRename(0);  void qsamplerInstrumentList::setMidiMap ( int iMidiMap )
457    {
458          selectionChangedSlot();          if (iMidiMap < 0)
459  }                  iMidiMap = LSCP_MIDI_MAP_ALL;
460    
461            m_iMidiMap = iMidiMap;
462  // Remove current group/item.  }
463  void qsamplerInstrumentList::deleteSlot (void)  
464  {  int qsamplerInstrumentList::midiMap (void) const
465          QListViewItem *pListItem = QListView::selectedItem();  {
466          if (pListItem) {          return m_iMidiMap;
467                  if (pListItem->rtti() == Item) {  }
468                          qsamplerInstrumentItem *pItem  
469                                  = static_cast<qsamplerInstrumentItem *> (pListItem);  
470                          if (pItem && pItem->instrument()) {  // List actions accessors.
471                                  pItem->instrument()->unmap();  QAction *qsamplerInstrumentList::newGroupAction (void) const
472                                  emit instrumentsChanged();  {
473                          }          return m_pNewGroupAction;
474                  }  }
475                  delete pListItem;  
476          }  QAction *qsamplerInstrumentList::newItemAction (void) const
477    {
478          selectionChangedSlot();          return m_pNewItemAction;
479  }  }
480    
481    QAction *qsamplerInstrumentList::editItemAction (void) const
482  // In-place selection slot.  {
483  void qsamplerInstrumentList::selectionChangedSlot (void)          return m_pEditItemAction;
484  {  }
485          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();  
486          QListViewItem *pListItem = QListView::selectedItem();  QAction *qsamplerInstrumentList::renameAction (void) const
487          bool bEnabled = (pMainForm && pMainForm->client());  {
488          m_pNewItemAction->setEnabled(bEnabled);          return m_pRenameAction;
489          bEnabled = (bEnabled && pListItem != NULL);  }
490          m_pEditItemAction->setEnabled(bEnabled && pListItem->rtti() == Item);  
491          m_pRenameAction->setEnabled(bEnabled);  QAction *qsamplerInstrumentList::deleteAction (void) const
492          m_pDeleteAction->setEnabled(bEnabled);  {
493  }          return m_pDeleteAction;
494    }
495    
496  // In-place activation slot.  QAction *qsamplerInstrumentList::refreshAction (void) const
497  void qsamplerInstrumentList::activatedSlot ( QListViewItem *pListItem )  {
498  {          return m_pRefreshAction;
499          // FIXME: Hope the list view item is the one selected.  }
500          if (pListItem->rtti() == Item)  
501                  editItemSlot();  
502  }  // Add a new instrument item below the current one.
503    void qsamplerInstrumentList::newItemSlot (void)
504    {
505  // In-place aliasing slot.          qsamplerInstrument *pInstrument = new qsamplerInstrument();
506  void qsamplerInstrumentList::renamedSlot ( QListViewItem *pListItem )  
507  {          qsamplerInstrumentForm form(this);
508          if (pListItem->rtti() == Item) {          form.setup(pInstrument);
509                  qsamplerInstrumentItem *pItem          if (!form.exec()) {
510                          = static_cast<qsamplerInstrumentItem *> (pListItem);                  delete pInstrument;
511                  if (pItem && pItem->instrument()) {                  return;
512                          pItem->instrument()->setName(pListItem->text(0));          }
513                          pItem->instrument()->map();  
514                          emit instrumentsChanged();          // Commit...
515                          pItem->update();          pInstrument->mapInstrument();
516                  }          // add new item to the tree...
517          }          addItem(pInstrument, groupItem(QListView::selectedItem()));
518  }          // Notify we've changes...
519            emit instrumentsChanged();
520    
521  // Context menu request event handler.          selectionChangedSlot();
522  void qsamplerInstrumentList::contextMenuEvent (  }
523          QContextMenuEvent *pContextMenuEvent )  
524  {  
525          QPopupMenu menu(this);  // Edit current item below the current one.
526    void qsamplerInstrumentList::editItemSlot (void)
527          // Construct context menu.  {
528          m_pNewItemAction->addTo(&menu);          QListViewItem *pListItem = QListView::selectedItem();
529  //      m_pNewGroupAction->addTo(&menu);          if (pListItem == NULL)
530          menu.insertSeparator();                  return;
531          m_pEditItemAction->addTo(&menu);          if (pListItem->rtti() == Item) {
532          m_pRenameAction->addTo(&menu);                  qsamplerInstrument *pInstrument = NULL;
533          m_pDeleteAction->addTo(&menu);                  qsamplerInstrumentItem *pItem
534          menu.insertSeparator();                          = static_cast<qsamplerInstrumentItem *> (pListItem);
535          m_pRefreshAction->addTo(&menu);                  if (pItem)
536                            pInstrument = pItem->instrument();
537          menu.exec(pContextMenuEvent->globalPos());                  if (pInstrument) {
538  }                          // Save current key values...
539                            qsamplerInstrument oldInstrument(*pInstrument);
540                            // Do the edit dance...
541  // General reloader.                          qsamplerInstrumentForm form(this);
542  void qsamplerInstrumentList::refresh (void)                          form.setup(pInstrument);
543  {                          if (form.exec()) {
544          clear();                                  // Commit...
545                                    pInstrument->mapInstrument();
546          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();                                  // Check whether we changed instrument key...
547          if (pMainForm == NULL)                                  if (oldInstrument.map()  == pInstrument->map()  &&
548                  return;                                          oldInstrument.bank() == pInstrument->bank() &&
549          if (pMainForm->client() == NULL)                                          oldInstrument.prog() == pInstrument->prog()) {
550                  return;                                          // just update tree item...
551                                            pItem->update();
552          qsamplerInstrumentItem *pItem = NULL;                                  } else {
553          lscp_midi_instrument_t *pInstrs                                          // Unmap old instance...
554                  = ::lscp_list_midi_instruments(pMainForm->client());                                          oldInstrument.unmapInstrument();
555          for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; ++iInstr) {                                          // Change item tree, whether applicable...
556                  int iBank = (pInstrs[iInstr].bank_msb << 7) | pInstrs[iInstr].bank_lsb;                                          if (m_iMidiMap < 0 || m_iMidiMap == pInstrument->map()) {
557                  int iProgram = pInstrs[iInstr].program;                                                  // Add new brand item into view...
558                  qsamplerInstrument *pInstrument                                                  addItem(pInstrument, groupItem(pListItem));
559                          = new qsamplerInstrument(iBank, iProgram);                                          } else {
560                  if (pInstrument->get())                                                  // Just remove/hide old one.
561                          pItem = new qsamplerInstrumentItem(this, pInstrument, pItem);                                                  delete pItem;
562          }                                          }
563                                    }
564          if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) {                                  // Notify we've changes...
565                  pMainForm->appendMessagesClient("lscp_list_midi_instruments");                                  emit instrumentsChanged();
566                  pMainForm->appendMessagesError(tr("Could not get current list of MIDI instrument mappings.\n\nSorry."));                          }
567          }                  }
568            }
569          selectionChangedSlot();  
570  }          selectionChangedSlot();
571    }
572    
573  // end of qsamplerInstrumentList.cpp  
574    // Rename current group/item.
575    void qsamplerInstrumentList::renameSlot (void)
576    {
577            QListViewItem *pListItem = QListView::selectedItem();
578            if (pListItem)
579                    pListItem->startRename(0);
580    
581            selectionChangedSlot();
582    }
583    
584    
585    // Remove current group/item.
586    void qsamplerInstrumentList::deleteSlot (void)
587    {
588            QListViewItem *pListItem = QListView::selectedItem();
589            if (pListItem == NULL)
590                    return;
591    
592            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
593            if (pMainForm == NULL)
594                    return;
595    
596            // Prompt user if this is for real...
597            qsamplerOptions *pOptions = pMainForm->options();
598            if (pOptions && pOptions->bConfirmRemove) {
599                    if (QMessageBox::warning(this,
600                            QSAMPLER_TITLE ": " + tr("Warning"),
601                            tr("Delete %1:\n\n"
602                            "%2\n\n"
603                            "Are you sure?")
604                            .arg(pListItem->rtti() == Item ? tr("instrument") : tr("group"))
605                            .arg(pListItem->text(0)),
606                            tr("OK"), tr("Cancel")) > 0)
607                            return;
608            }
609    
610            // Unmap instrument entry...
611            if (pListItem->rtti() == Item) {
612                    qsamplerInstrumentItem *pItem
613                            = static_cast<qsamplerInstrumentItem *> (pListItem);
614                    if (pItem && pItem->instrument()) {
615                            pItem->instrument()->unmapInstrument();
616                            emit instrumentsChanged();
617                    }
618            }
619    
620            // Do it for real...
621            delete pListItem;
622    
623            selectionChangedSlot();
624    }
625    
626    
627    // In-place selection slot.
628    void qsamplerInstrumentList::selectionChangedSlot (void)
629    {
630            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
631            QListViewItem *pListItem = QListView::selectedItem();
632            bool bEnabled = (pMainForm && pMainForm->client());
633            m_pNewItemAction->setEnabled(bEnabled);
634            bEnabled = (bEnabled && pListItem != NULL);
635            m_pEditItemAction->setEnabled(bEnabled && pListItem->rtti() == Item);
636            m_pRenameAction->setEnabled(bEnabled);
637            m_pDeleteAction->setEnabled(bEnabled);
638    }
639    
640    
641    // In-place activation slot.
642    void qsamplerInstrumentList::activatedSlot ( QListViewItem *pListItem )
643    {
644            // FIXME: Hope the list view item is the one selected.
645            if (pListItem && pListItem->rtti() == Item)
646                    editItemSlot();
647    }
648    
649    
650    // In-place aliasing slot.
651    void qsamplerInstrumentList::renamedSlot ( QListViewItem *pListItem )
652    {
653            if (pListItem->rtti() == Item) {
654                    qsamplerInstrumentItem *pItem
655                            = static_cast<qsamplerInstrumentItem *> (pListItem);
656                    if (pItem && pItem->instrument()) {
657                            pItem->instrument()->setName(pListItem->text(0));
658                            pItem->instrument()->mapInstrument();
659                            emit instrumentsChanged();
660                            pItem->update();
661                    }
662            }
663    }
664    
665    
666    // Context menu request event handler.
667    void qsamplerInstrumentList::contextMenuEvent (
668            QContextMenuEvent *pContextMenuEvent )
669    {
670            if (!m_pNewItemAction->isEnabled())
671                    return;
672    
673            QPopupMenu menu(this);
674    
675            // Construct context menu.
676            m_pNewItemAction->addTo(&menu);
677    //      m_pNewGroupAction->addTo(&menu);
678            menu.insertSeparator();
679            m_pEditItemAction->addTo(&menu);
680            m_pRenameAction->addTo(&menu);
681            m_pDeleteAction->addTo(&menu);
682            menu.insertSeparator();
683            m_pRefreshAction->addTo(&menu);
684    
685            menu.exec(pContextMenuEvent->globalPos());
686    }
687    
688    
689    // General reloader.
690    void qsamplerInstrumentList::refresh (void)
691    {
692            clear();
693    
694            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
695            if (pMainForm == NULL)
696                    return;
697            if (pMainForm->client() == NULL)
698                    return;
699    
700            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
701    
702            // Load the whole bunch of instrument items...
703            qsamplerInstrumentItem *pItem = NULL;
704            lscp_midi_instrument_t *pInstrs
705                    = ::lscp_list_midi_instruments(pMainForm->client(), m_iMidiMap);
706            for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; ++iInstr) {
707                    int iMap  = pInstrs[iInstr].map;
708                    int iBank = pInstrs[iInstr].bank;
709                    int iProg = pInstrs[iInstr].prog;
710                    qsamplerInstrument *pInstrument
711                            = new qsamplerInstrument(iMap, iBank, iProg);
712                    if (pInstrument->getInstrument())
713                            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())) {
721                    pMainForm->appendMessagesClient("lscp_list_midi_instruments");
722                    pMainForm->appendMessagesError(tr("Could not get current list of MIDI instrument mappings.\n\nSorry."));
723            }
724    
725            selectionChangedSlot();
726    }
727    #endif
728    
729    MidiInstrumentsModel::MidiInstrumentsModel(QObject* parent) : QAbstractTableModel(parent) {
730        m_iMidiMap = LSCP_MIDI_MAP_ALL;
731    }
732    
733    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.969  
changed lines
  Added in v.1464

  ViewVC Help
Powered by ViewVC