39 |
// |
// |
40 |
|
|
41 |
InstrumentListModel::InstrumentListModel ( QObject *pParent ) |
InstrumentListModel::InstrumentListModel ( QObject *pParent ) |
42 |
: QAbstractItemModel(pParent) |
: QAbstractItemModel(pParent), m_iMidiMap(LSCP_MIDI_MAP_ALL) |
43 |
{ |
{ |
44 |
m_iMidiMap = LSCP_MIDI_MAP_ALL; |
// QAbstractItemModel::reset(); |
|
|
|
|
QAbstractItemModel::reset(); |
|
45 |
} |
} |
46 |
|
|
47 |
InstrumentListModel::~InstrumentListModel (void) |
InstrumentListModel::~InstrumentListModel (void) |
79 |
{ |
{ |
80 |
if (!index.isValid()) |
if (!index.isValid()) |
81 |
return QVariant(); |
return QVariant(); |
|
|
|
82 |
const Instrument *pInstr |
const Instrument *pInstr |
83 |
= static_cast<Instrument *> (index.internalPointer()); |
= static_cast<Instrument *> (index.internalPointer()); |
84 |
|
|
129 |
InstrumentMap::const_iterator itMap = m_instruments.find(m_iMidiMap); |
InstrumentMap::const_iterator itMap = m_instruments.find(m_iMidiMap); |
130 |
if (itMap != m_instruments.constEnd()) { |
if (itMap != m_instruments.constEnd()) { |
131 |
const InstrumentList& list = *itMap; |
const InstrumentList& list = *itMap; |
|
// resolve instrument in that map |
|
132 |
if (row < list.size()) |
if (row < list.size()) |
133 |
pInstr = list.at(row); |
pInstr = list.at(row); |
134 |
} |
} |
141 |
} |
} |
142 |
|
|
143 |
|
|
144 |
QModelIndex InstrumentListModel::parent ( const QModelIndex& child ) const |
QModelIndex InstrumentListModel::parent ( const QModelIndex& /*child*/ ) const |
145 |
{ |
{ |
146 |
return QModelIndex(); |
return QModelIndex(); |
147 |
} |
} |
221 |
} |
} |
222 |
|
|
223 |
|
|
224 |
void InstrumentListModel::removeInstrument ( const Instrument *pInstrument ) |
void InstrumentListModel::removeInstrument ( Instrument *pInstrument ) |
225 |
{ |
{ |
226 |
const int iMap = pInstrument->map(); |
const int iMap = pInstrument->map(); |
227 |
const int iBank = pInstrument->bank(); |
const int iBank = pInstrument->bank(); |
241 |
} |
} |
242 |
|
|
243 |
|
|
244 |
|
void InstrumentListModel::updateInstrument ( Instrument *pInstrument ) |
245 |
|
{ |
246 |
|
pInstrument->getInstrument(); |
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
// Reposition the instrument in the model (called when map/bank/prg changed) |
// Reposition the instrument in the model (called when map/bank/prg changed) |
251 |
void InstrumentListModel::updateInstrument ( const Instrument *pInstrument ) |
void InstrumentListModel::resortInstrument ( Instrument *pInstrument ) |
252 |
{ |
{ |
253 |
const int iMap = pInstrument->map(); |
const int iMap = pInstrument->map(); |
254 |
const int iBank = pInstrument->bank(); |
const int iBank = pInstrument->bank(); |
337 |
m_pListModel = new InstrumentListModel(this); |
m_pListModel = new InstrumentListModel(this); |
338 |
|
|
339 |
QTreeView::setModel(m_pListModel); |
QTreeView::setModel(m_pListModel); |
340 |
|
|
341 |
|
QTreeView::setRootIsDecorated(false); |
342 |
|
QTreeView::setUniformRowHeights(true); |
343 |
|
QTreeView::setAlternatingRowColors(true); |
344 |
|
QTreeView::setSelectionBehavior(QAbstractItemView::SelectRows); |
345 |
|
QTreeView::setSelectionMode(QAbstractItemView::SingleSelection); |
346 |
|
QTreeView::setItemsExpandable(false); |
347 |
|
|
348 |
|
QHeaderView *pHeader = QTreeView::header(); |
349 |
|
pHeader->setDefaultAlignment(Qt::AlignLeft); |
350 |
|
pHeader->setMovable(false); |
351 |
|
pHeader->setStretchLastSection(true); |
352 |
|
pHeader->resizeSection(0, 120); // Name |
353 |
|
QTreeView::resizeColumnToContents(1); // Map |
354 |
|
QTreeView::resizeColumnToContents(2); // Bank |
355 |
|
QTreeView::resizeColumnToContents(3); // Prog |
356 |
|
QTreeView::resizeColumnToContents(4); // Engine |
357 |
|
pHeader->resizeSection(5, 240); // File |
358 |
|
QTreeView::resizeColumnToContents(6); // Nr |
359 |
|
pHeader->resizeSection(7, 60); // Vol |
360 |
} |
} |
361 |
|
|
362 |
|
|
391 |
} |
} |
392 |
|
|
393 |
|
|
394 |
void InstrumentListView::removeInstrument ( const Instrument *pInstrument ) |
void InstrumentListView::removeInstrument ( Instrument *pInstrument ) |
395 |
{ |
{ |
396 |
m_pListModel->beginReset(); |
m_pListModel->beginReset(); |
397 |
m_pListModel->removeInstrument(pInstrument); |
m_pListModel->removeInstrument(pInstrument); |
399 |
} |
} |
400 |
|
|
401 |
|
|
402 |
// Reposition the instrument in the model (called when map/bank/prg changed) |
void InstrumentListView::updateInstrument ( Instrument *pInstrument ) |
|
void InstrumentListView::updateInstrument ( const Instrument *pInstrument ) |
|
403 |
{ |
{ |
404 |
m_pListModel->beginReset(); |
m_pListModel->beginReset(); |
405 |
m_pListModel->updateInstrument(pInstrument); |
m_pListModel->updateInstrument(pInstrument); |
406 |
m_pListModel->endReset();} |
m_pListModel->endReset(); |
407 |
|
} |
408 |
|
|
409 |
|
|
410 |
|
// Reposition the instrument in the model (called when map/bank/prg changed) |
411 |
|
void InstrumentListView::resortInstrument ( Instrument *pInstrument ) |
412 |
|
{ |
413 |
|
m_pListModel->beginReset(); |
414 |
|
m_pListModel->resortInstrument(pInstrument); |
415 |
|
m_pListModel->endReset(); |
416 |
|
} |
417 |
|
|
418 |
|
|
419 |
// Refreshener. |
// Refreshener. |