28 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
29 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
30 |
|
|
31 |
|
#include <qapplication.h> |
32 |
#include <qmessagebox.h> |
#include <qmessagebox.h> |
33 |
|
#include <qeventloop.h> |
34 |
#include <qaction.h> |
#include <qaction.h> |
35 |
|
#include <qcursor.h> |
36 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
37 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
38 |
|
|
339 |
// with the very same key (bank, program); |
// with the very same key (bank, program); |
340 |
// if yes, just remove it without prejudice... |
// if yes, just remove it without prejudice... |
341 |
qsamplerInstrumentItem *pItem = findItem(pInstrument); |
qsamplerInstrumentItem *pItem = findItem(pInstrument); |
342 |
if (pItem) |
if (pItem) { |
343 |
|
// If exactly the same, just update view and bail out... |
344 |
|
if (pItem->instrument() == pInstrument) { |
345 |
|
pItem->update(); |
346 |
|
return pItem; |
347 |
|
} |
348 |
|
// Remove it, as instrument keys must be unique. |
349 |
delete pItem; |
delete pItem; |
350 |
|
} |
351 |
|
|
352 |
// Add the new item under proper group one, if any... |
// Add the new item under proper group one, if any... |
353 |
if (pParentGroup) { |
if (pParentGroup) { |
532 |
pInstrument = pItem->instrument(); |
pInstrument = pItem->instrument(); |
533 |
if (pInstrument) { |
if (pInstrument) { |
534 |
// Save current key values... |
// Save current key values... |
535 |
int iMap = pInstrument->map(); |
qsamplerInstrument oldInstrument(*pInstrument); |
|
int iBank = pInstrument->bank(); |
|
|
int iProg = pInstrument->prog(); |
|
536 |
// Do the edit dance... |
// Do the edit dance... |
537 |
qsamplerInstrumentForm form(this); |
qsamplerInstrumentForm form(this); |
538 |
form.setup(pInstrument); |
form.setup(pInstrument); |
540 |
// Commit... |
// Commit... |
541 |
pInstrument->mapInstrument(); |
pInstrument->mapInstrument(); |
542 |
// Check whether we changed instrument key... |
// Check whether we changed instrument key... |
543 |
if (iMap == pInstrument->map() && |
if (oldInstrument.map() == pInstrument->map() && |
544 |
iBank == pInstrument->bank() && |
oldInstrument.bank() == pInstrument->bank() && |
545 |
iProg == pInstrument->prog()) { |
oldInstrument.prog() == pInstrument->prog()) { |
546 |
// just update tree item... |
// just update tree item... |
547 |
pItem->update(); |
pItem->update(); |
548 |
} else { |
} else { |
549 |
|
// Unmap old instance... |
550 |
|
oldInstrument.unmapInstrument(); |
551 |
// Change item tree, whether applicable... |
// Change item tree, whether applicable... |
552 |
if (m_iMidiMap < 0 || m_iMidiMap == pInstrument->map()) { |
if (m_iMidiMap < 0 || m_iMidiMap == pInstrument->map()) { |
553 |
// Add new brand item into view... |
// Add new brand item into view... |
693 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
694 |
return; |
return; |
695 |
|
|
696 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
697 |
|
|
698 |
|
// Load the whole bunch of instrument items... |
699 |
qsamplerInstrumentItem *pItem = NULL; |
qsamplerInstrumentItem *pItem = NULL; |
700 |
lscp_midi_instrument_t *pInstrs |
lscp_midi_instrument_t *pInstrs |
701 |
= ::lscp_list_midi_instruments(pMainForm->client(), m_iMidiMap); |
= ::lscp_list_midi_instruments(pMainForm->client(), m_iMidiMap); |
707 |
= new qsamplerInstrument(iMap, iBank, iProg); |
= new qsamplerInstrument(iMap, iBank, iProg); |
708 |
if (pInstrument->getInstrument()) |
if (pInstrument->getInstrument()) |
709 |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
710 |
|
// Try to keep it snappy :) |
711 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
712 |
} |
} |
713 |
|
|
714 |
|
QApplication::restoreOverrideCursor(); |
715 |
|
|
716 |
if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) { |
if (pInstrs == NULL && ::lscp_client_get_errno(pMainForm->client())) { |
717 |
pMainForm->appendMessagesClient("lscp_list_midi_instruments"); |
pMainForm->appendMessagesClient("lscp_list_midi_instruments"); |
718 |
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.")); |