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. |
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 |
} |
} |
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: |
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()) { |
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; |
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 |
|
|
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |