53 |
|
|
54 |
|
|
55 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
56 |
// MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView) |
// QSampler::MidiInstrumentsModel - data model for MIDI prog mappings |
57 |
// |
// (used for QTableView) |
58 |
|
|
59 |
MidiInstrumentsModel::MidiInstrumentsModel ( QObject* pParent) |
MidiInstrumentsModel::MidiInstrumentsModel ( QObject* pParent) |
60 |
: QAbstractTableModel(pParent) |
: QAbstractTableModel(pParent) |
89 |
if (!index.isValid()) |
if (!index.isValid()) |
90 |
return QVariant(); |
return QVariant(); |
91 |
|
|
92 |
const qsamplerInstrument* pInstr = NULL; |
const Instrument* pInstr = NULL; |
93 |
|
|
94 |
if (m_iMidiMap == LSCP_MIDI_MAP_ALL) { |
if (m_iMidiMap == LSCP_MIDI_MAP_ALL) { |
95 |
int n = 0; |
int n = 0; |
96 |
for (InstrumentsMap::const_iterator itMap = m_instruments.begin(); |
for (InstrumentsMap::const_iterator itMap = m_instruments.begin(); |
97 |
itMap != m_instruments.end(); ++itMap) { |
itMap != m_instruments.end(); ++itMap) { |
98 |
n += (*itMap).size(); |
n += (*itMap).size(); |
99 |
if (index.row() < n) |
if (index.row() < n) { |
100 |
pInstr = &(*itMap)[index.row() + (*itMap).size() - n]; |
pInstr = &(*itMap)[index.row() + (*itMap).size() - n]; |
101 |
|
break; |
102 |
|
} |
103 |
} |
} |
104 |
} else { |
} else { |
105 |
// resolve MIDI instrument map |
// resolve MIDI instrument map |
121 |
case 0: return pInstr->name(); |
case 0: return pInstr->name(); |
122 |
case 1: return QVariant::fromValue(pInstr->map()); |
case 1: return QVariant::fromValue(pInstr->map()); |
123 |
case 2: return QVariant::fromValue(pInstr->bank()); |
case 2: return QVariant::fromValue(pInstr->bank()); |
124 |
case 3: return QVariant::fromValue(pInstr->prog()); |
case 3: return QVariant::fromValue(pInstr->prog() + 1); |
125 |
case 4: return pInstr->engineName(); |
case 4: return pInstr->engineName(); |
126 |
case 5: return pInstr->instrumentFile(); |
case 5: return pInstr->instrumentFile(); |
127 |
case 6: return QVariant::fromValue(pInstr->instrumentNr()); |
case 6: return QVariant::fromValue(pInstr->instrumentNr()); |
131 |
case 3: return QObject::tr("Persistent"); |
case 3: return QObject::tr("Persistent"); |
132 |
case 2: return QObject::tr("On Demand Hold"); |
case 2: return QObject::tr("On Demand Hold"); |
133 |
case 1: return QObject::tr("On Demand"); |
case 1: return QObject::tr("On Demand"); |
|
default: return QVariant(); |
|
134 |
} |
} |
135 |
} |
} |
136 |
default: return QVariant(); |
default: return QVariant(); |
162 |
} |
} |
163 |
|
|
164 |
|
|
165 |
qsamplerInstrument* MidiInstrumentsModel::addInstrument ( |
Instrument* MidiInstrumentsModel::addInstrument ( |
166 |
int iMap, int iBank, int iProg ) |
int iMap, int iBank, int iProg ) |
167 |
{ |
{ |
168 |
// Check it there's already one instrument item |
// Check it there's already one instrument item |
186 |
} |
} |
187 |
} |
} |
188 |
|
|
189 |
m_instruments[iMap].insert(i, qsamplerInstrument(iMap, iBank, iProg)); |
m_instruments[iMap].insert(i, Instrument(iMap, iBank, iProg)); |
190 |
qsamplerInstrument& instr = m_instruments[iMap][i]; |
Instrument& instr = m_instruments[iMap][i]; |
191 |
if (!instr.getInstrument()) |
if (!instr.getInstrument()) |
192 |
m_instruments[iMap].removeAt(i); |
m_instruments[iMap].removeAt(i); |
193 |
|
|
196 |
|
|
197 |
|
|
198 |
void MidiInstrumentsModel::removeInstrument ( |
void MidiInstrumentsModel::removeInstrument ( |
199 |
const qsamplerInstrument& instrument ) |
const Instrument& instrument ) |
200 |
{ |
{ |
201 |
const int iMap = instrument.map(); |
const int iMap = instrument.map(); |
202 |
const int iBank = instrument.bank(); |
const int iBank = instrument.bank(); |
212 |
|
|
213 |
|
|
214 |
// Reposition the instrument in the model (called when map/bank/prg changed) |
// Reposition the instrument in the model (called when map/bank/prg changed) |
215 |
void MidiInstrumentsModel::resort ( const qsamplerInstrument& instrument ) |
void MidiInstrumentsModel::resort ( const Instrument& instrument ) |
216 |
{ |
{ |
217 |
const int iMap = instrument.map(); |
const int iMap = instrument.map(); |
218 |
const int iBank = instrument.bank(); |
const int iBank = instrument.bank(); |
276 |
|
|
277 |
|
|
278 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
279 |
// MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings |
// QSampler::MidiInstrumentsDelegate - table cell renderer for MIDI prog |
280 |
// (doesn't actually do anything ATM, but is already there for a future |
// mappings (doesn't actually do anything ATM, but is already there for a |
281 |
// cell editor widget implementation) |
// future cell editor widget implementation) |
282 |
|
|
283 |
MidiInstrumentsDelegate::MidiInstrumentsDelegate ( QObject* pParent ) |
MidiInstrumentsDelegate::MidiInstrumentsDelegate ( QObject* pParent ) |
284 |
: QItemDelegate(pParent) |
: QItemDelegate(pParent) |