29 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
30 |
|
|
31 |
#include <QApplication> |
#include <QApplication> |
32 |
|
#include <QHeaderView> |
33 |
#include <QCursor> |
#include <QCursor> |
34 |
|
|
35 |
|
|
191 |
// with the very same key (bank, program); |
// with the very same key (bank, program); |
192 |
// if yes, just remove it without prejudice... |
// if yes, just remove it without prejudice... |
193 |
InstrumentList& list = m_instruments[iMap]; |
InstrumentList& list = m_instruments[iMap]; |
194 |
for (int i = 0; i < list.size(); ++i) { |
|
195 |
|
int i = 0; |
196 |
|
for ( ; i < list.size(); ++i) { |
197 |
const Instrument *pInstr = list.at(i); |
const Instrument *pInstr = list.at(i); |
198 |
if (pInstr->bank() == iBank && pInstr->prog() == iProg) { |
if (pInstr->bank() == iBank && pInstr->prog() == iProg) { |
199 |
delete pInstr; |
delete pInstr; |
203 |
} |
} |
204 |
|
|
205 |
// Resolve the appropriate place, we keep the list sorted that way... |
// Resolve the appropriate place, we keep the list sorted that way... |
206 |
int i = 0; |
for (i = 0; i < list.size(); ++i) { |
|
for ( ; i < list.size(); ++i) { |
|
207 |
const Instrument *pInstr = list.at(i); |
const Instrument *pInstr = list.at(i); |
208 |
if (iBank < pInstr->bank() |
if (iBank < pInstr->bank() |
209 |
|| (iBank == pInstr->bank() && iProg < pInstr->prog())) { |
|| (iBank == pInstr->bank() && iProg < pInstr->prog())) { |
223 |
} |
} |
224 |
|
|
225 |
|
|
226 |
void InstrumentListModel::removeInstrument ( const Instrument *pInstrument ) |
void InstrumentListModel::removeInstrument ( Instrument *pInstrument ) |
227 |
{ |
{ |
228 |
const int iMap = pInstrument->map(); |
const int iMap = pInstrument->map(); |
|
const int iBank = pInstrument->bank(); |
|
|
const int iProg = pInstrument->prog(); |
|
229 |
|
|
230 |
if (m_instruments.contains(iMap)) { |
if (m_instruments.contains(iMap)) { |
231 |
InstrumentList& list = m_instruments[iMap]; |
InstrumentList& list = m_instruments[iMap]; |
232 |
for (int i = 0; i < list.size(); ++i) { |
for (int i = 0; i < list.size(); ++i) { |
233 |
const Instrument *pInstr = list.at(i); |
if (pInstrument == list.at(i)) { |
234 |
if (pInstr->bank() == iBank && pInstr->prog() == iProg) { |
delete pInstrument; |
|
delete pInstr; |
|
235 |
list.removeAt(i); |
list.removeAt(i); |
236 |
break; |
break; |
237 |
} |
} |
240 |
} |
} |
241 |
|
|
242 |
|
|
243 |
|
void InstrumentListModel::updateInstrument ( Instrument *pInstrument ) |
244 |
|
{ |
245 |
|
pInstrument->getInstrument(); |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
// Reposition the instrument in the model (called when map/bank/prg changed) |
// Reposition the instrument in the model (called when map/bank/prg changed) |
250 |
void InstrumentListModel::updateInstrument ( const Instrument *pInstrument ) |
void InstrumentListModel::resortInstrument ( Instrument *pInstrument ) |
251 |
{ |
{ |
252 |
const int iMap = pInstrument->map(); |
const int iMap = pInstrument->map(); |
253 |
const int iBank = pInstrument->bank(); |
const int iBank = pInstrument->bank(); |
390 |
} |
} |
391 |
|
|
392 |
|
|
393 |
void InstrumentListView::removeInstrument ( const Instrument *pInstrument ) |
void InstrumentListView::removeInstrument ( Instrument *pInstrument ) |
394 |
{ |
{ |
395 |
m_pListModel->beginReset(); |
m_pListModel->beginReset(); |
396 |
m_pListModel->removeInstrument(pInstrument); |
m_pListModel->removeInstrument(pInstrument); |
398 |
} |
} |
399 |
|
|
400 |
|
|
401 |
// Reposition the instrument in the model (called when map/bank/prg changed) |
void InstrumentListView::updateInstrument ( Instrument *pInstrument ) |
|
void InstrumentListView::updateInstrument ( const Instrument *pInstrument ) |
|
402 |
{ |
{ |
403 |
m_pListModel->beginReset(); |
m_pListModel->beginReset(); |
404 |
m_pListModel->updateInstrument(pInstrument); |
m_pListModel->updateInstrument(pInstrument); |
405 |
m_pListModel->endReset(); |
m_pListModel->endReset(); |
406 |
} |
} |
407 |
|
|
408 |
|
|
409 |
|
// Reposition the instrument in the model (called when map/bank/prg changed) |
410 |
|
void InstrumentListView::resortInstrument ( Instrument *pInstrument ) |
411 |
|
{ |
412 |
|
m_pListModel->beginReset(); |
413 |
|
m_pListModel->resortInstrument(pInstrument); |
414 |
|
m_pListModel->endReset(); |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
// Refreshener. |
// Refreshener. |
419 |
void InstrumentListView::refresh (void) |
void InstrumentListView::refresh (void) |