/[svn]/qsampler/trunk/src/qsamplerInstrumentList.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerInstrumentList.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1523 by capela, Sun Nov 25 11:40:47 2007 UTC revision 1558 by capela, Thu Dec 6 09:35:33 2007 UTC
# Line 53  using namespace QSampler; Line 53  using namespace QSampler;
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)
# Line 89  QVariant MidiInstrumentsModel::data ( co Line 89  QVariant MidiInstrumentsModel::data ( co
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
# Line 119  QVariant MidiInstrumentsModel::data ( co Line 121  QVariant MidiInstrumentsModel::data ( co
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());
# Line 129  QVariant MidiInstrumentsModel::data ( co Line 131  QVariant MidiInstrumentsModel::data ( co
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();
# Line 161  QVariant MidiInstrumentsModel::headerDat Line 162  QVariant MidiInstrumentsModel::headerDat
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
# Line 185  qsamplerInstrument* MidiInstrumentsModel Line 186  qsamplerInstrument* MidiInstrumentsModel
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    
# Line 195  qsamplerInstrument* MidiInstrumentsModel Line 196  qsamplerInstrument* MidiInstrumentsModel
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();
# Line 211  void MidiInstrumentsModel::removeInstrum Line 212  void MidiInstrumentsModel::removeInstrum
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();
# Line 275  void MidiInstrumentsModel::refresh (void Line 276  void MidiInstrumentsModel::refresh (void
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)

Legend:
Removed from v.1523  
changed lines
  Added in v.1558

  ViewVC Help
Powered by ViewVC