Mercurial > hg > svcore
comparison data/model/NoteModel.h @ 425:f5e8f12d2e58
* Add audio device selection to preferences
* Add (not yet functional) insert, delete, edit buttons to data edit window
* Add proper set methods for time fields in data edit window (using general
sparse model base class)
author | Chris Cannam |
---|---|
date | Fri, 13 Jun 2008 21:09:43 +0000 |
parents | eafef13bb0b3 |
children | 7226ebac8bd3 |
comparison
equal
deleted
inserted
replaced
424:eafef13bb0b3 | 425:f5e8f12d2e58 |
---|---|
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 virtual QVariant getData(int row, int column, int role) const | 187 virtual QVariant getData(int row, int column, int role) const |
188 { | 188 { |
189 if (column < 2) { | |
190 return SparseValueModel<Note>::getData | |
191 (row, column, role); | |
192 } | |
193 | |
189 PointListIterator i = getPointListIteratorForRow(row); | 194 PointListIterator i = getPointListIteratorForRow(row); |
190 if (i == m_points.end()) return QVariant(); | 195 if (i == m_points.end()) return QVariant(); |
191 | 196 |
192 switch (column) { | 197 switch (column) { |
193 case 0: { | |
194 if (role == SortRole) return int(i->frame); | |
195 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | |
196 return rt.toText().c_str(); | |
197 } | |
198 case 1: return int(i->frame); | |
199 case 2: | 198 case 2: |
200 if (role == Qt::EditRole || role == SortRole) return i->value; | 199 if (role == Qt::EditRole || role == SortRole) return i->value; |
201 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); | 200 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); |
202 case 3: return int(i->duration); | 201 case 3: return int(i->duration); |
203 case 4: return i->level; | 202 case 4: return i->level; |
206 } | 205 } |
207 } | 206 } |
208 | 207 |
209 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) | 208 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) |
210 { | 209 { |
210 if (column < 2) { | |
211 return SparseValueModel<Note>::getSetDataCommand | |
212 (row, column, value, role); | |
213 } | |
214 | |
211 if (role != Qt::EditRole) return false; | 215 if (role != Qt::EditRole) return false; |
212 PointListIterator i = getPointListIteratorForRow(row); | 216 PointListIterator i = getPointListIteratorForRow(row); |
213 if (i == m_points.end()) return false; | 217 if (i == m_points.end()) return false; |
214 EditCommand *command = new EditCommand(this, tr("Edit Data")); | 218 EditCommand *command = new EditCommand(this, tr("Edit Data")); |
215 | 219 |