comparison data/model/SparseModel.h @ 427:72ec275e458b

* Basic implementation of add and remove point in data editor * Improve resilience of frame - real-time - frame round-trip conversions
author Chris Cannam
date Mon, 16 Jun 2008 14:48:42 +0000
parents f5e8f12d2e58
children 113cf8781bd1
comparison
equal deleted inserted replaced
426:2386582f67cd 427:72ec275e458b
305 case 1: return int(i->frame); 305 case 1: return int(i->frame);
306 } 306 }
307 307
308 return QVariant(); 308 return QVariant();
309 } 309 }
310
310 virtual Command *getSetDataCommand(int row, int column, 311 virtual Command *getSetDataCommand(int row, int column,
311 const QVariant &value, int role) 312 const QVariant &value, int role)
312 { 313 {
313 if (role != Qt::EditRole) return false; 314 if (role != Qt::EditRole) return false;
314 PointListIterator i = getPointListIteratorForRow(row); 315 PointListIterator i = getPointListIteratorForRow(row);
325 326
326 command->addPoint(point); 327 command->addPoint(point);
327 return command->finish(); 328 return command->finish();
328 } 329 }
329 330
331 virtual Command *getInsertRowCommand(int row)
332 {
333 EditCommand *command = new EditCommand(this, tr("Insert Data Point"));
334 Point point(0);
335 PointListIterator i = getPointListIteratorForRow(row);
336 if (i == m_points.end() && i != m_points.begin()) --i;
337 if (i != m_points.end()) point = *i;
338 command->addPoint(point);
339 return command->finish();
340 }
341
342 virtual Command *getRemoveRowCommand(int row)
343 {
344 EditCommand *command = new EditCommand(this, tr("Delete Data Point"));
345 PointListIterator i = getPointListIteratorForRow(row);
346 if (i == m_points.end()) return 0;
347 command->deletePoint(*i);
348 return command->finish();
349 }
350
330 protected: 351 protected:
331 size_t m_sampleRate; 352 size_t m_sampleRate;
332 size_t m_resolution; 353 size_t m_resolution;
333 bool m_notifyOnAdd; 354 bool m_notifyOnAdd;
334 long m_sinceLastNotifyMin; 355 long m_sinceLastNotifyMin;