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(); |
176 |
} |
} |
177 |
} |
} |
178 |
|
|
179 |
// resolve the appropriate place, we keep the list sorted that way ... |
// Resolve the appropriate place, we keep the list sorted that way ... |
180 |
int i = 0; |
int i = 0; |
181 |
for (; i < m_instruments[iMap].size(); i++) |
for (; i < m_instruments[iMap].size(); ++i) { |
182 |
if (iBank > m_instruments[iMap][i].bank() |
if (iBank < m_instruments[iMap][i].bank() |
183 |
|| (iBank == m_instruments[iMap][i].bank() && |
|| (iBank == m_instruments[iMap][i].bank() && |
184 |
iProg > m_instruments[iMap][i].prog())) |
iProg < m_instruments[iMap][i].prog())) { |
185 |
break; |
break; |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
m_instruments[iMap].insert(i, qsamplerInstrument(iMap, iBank, iProg)); |
m_instruments[iMap].insert(i, qsamplerInstrument(iMap, iBank, iProg)); |
190 |
qsamplerInstrument& instr = m_instruments[iMap][i]; |
qsamplerInstrument& instr = m_instruments[iMap][i]; |
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 qsamplerInstrument& instrument ) |
216 |
{ |
{ |
217 |
const int iMap = instrument.map(); |
const int iMap = instrument.map(); |
218 |
const int iBank = instrument.bank(); |
const int iBank = instrument.bank(); |
219 |
const int iProg = instrument.prog(); |
const int iProg = instrument.prog(); |
220 |
// remove given instrument from its current list |
// Remove given instrument from its current list |
221 |
removeInstrument(instrument); |
removeInstrument(instrument); |
222 |
// re-add the instrument |
// Re-add the instrument |
223 |
addInstrument(iMap, iBank, iProg); |
addInstrument(iMap, iBank, iProg); |
224 |
} |
} |
225 |
|
|