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 |
} |
} |
331 |
m_pListModel = new InstrumentListModel(this); |
m_pListModel = new InstrumentListModel(this); |
332 |
|
|
333 |
QTreeView::setModel(m_pListModel); |
QTreeView::setModel(m_pListModel); |
334 |
|
|
335 |
|
QTreeView::setRootIsDecorated(false); |
336 |
|
QTreeView::setUniformRowHeights(true); |
337 |
|
QTreeView::setAlternatingRowColors(true); |
338 |
|
QTreeView::setSelectionBehavior(QAbstractItemView::SelectRows); |
339 |
|
QTreeView::setSelectionMode(QAbstractItemView::SingleSelection); |
340 |
|
|
341 |
|
QHeaderView *pHeader = QTreeView::header(); |
342 |
|
pHeader->setDefaultAlignment(Qt::AlignLeft); |
343 |
|
pHeader->setMovable(false); |
344 |
|
pHeader->setStretchLastSection(true); |
345 |
|
pHeader->resizeSection(0, 120); // Name |
346 |
|
QTreeView::resizeColumnToContents(1); // Map |
347 |
|
QTreeView::resizeColumnToContents(2); // Bank |
348 |
|
QTreeView::resizeColumnToContents(3); // Prog |
349 |
|
QTreeView::resizeColumnToContents(4); // Engine |
350 |
|
pHeader->resizeSection(5, 240); // File |
351 |
|
QTreeView::resizeColumnToContents(6); // Nr |
352 |
|
pHeader->resizeSection(7, 60); // Vol |
353 |
} |
} |
354 |
|
|
355 |
|
|
397 |
{ |
{ |
398 |
m_pListModel->beginReset(); |
m_pListModel->beginReset(); |
399 |
m_pListModel->updateInstrument(pInstrument); |
m_pListModel->updateInstrument(pInstrument); |
400 |
m_pListModel->endReset();} |
m_pListModel->endReset(); |
401 |
|
} |
402 |
|
|
403 |
|
|
404 |
// Refreshener. |
// Refreshener. |