Mercurial > hg > svcore
comparison data/model/SparseModel.h @ 1254:cbdd534f517a piper
Avoid assigning model resolution of 0 to models coming from plugins that report weirdly high output rates (symptom: data did not show up in edit layer data dialog, as the row/frame conversion failed)
author | Chris Cannam |
---|---|
date | Sat, 05 Nov 2016 10:40:22 +0000 |
parents | 771a17925576 |
children | 48e9f538e6e9 |
comparison
equal
deleted
inserted
replaced
1250:c2d66e3c83d0 | 1254:cbdd534f517a |
---|---|
330 | 330 |
331 virtual int getColumnCount() const { return 1; } | 331 virtual int getColumnCount() const { return 1; } |
332 virtual QVariant getData(int row, int column, int role) const | 332 virtual QVariant getData(int row, int column, int role) const |
333 { | 333 { |
334 PointListConstIterator i = getPointListIteratorForRow(row); | 334 PointListConstIterator i = getPointListIteratorForRow(row); |
335 if (i == m_points.end()) return QVariant(); | 335 if (i == m_points.end()) { |
336 | 336 // cerr << "no iterator for row " << row << " (have " << getRowCount() << " rows)" << endl; |
337 return QVariant(); | |
338 } | |
339 | |
340 // cerr << "returning data for row " << row << " col " << column << endl; | |
341 | |
337 switch (column) { | 342 switch (column) { |
338 case 0: { | 343 case 0: { |
339 if (role == SortRole) return int(i->frame); | 344 if (role == SortRole) return int(i->frame); |
340 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | 345 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); |
341 if (role == Qt::EditRole) return rt.toString().c_str(); | 346 if (role == Qt::EditRole) return rt.toString().c_str(); |
409 PointListConstIterator &endItr) const; | 414 PointListConstIterator &endItr) const; |
410 | 415 |
411 // This is only used if the model is called on to act in | 416 // This is only used if the model is called on to act in |
412 // TabularModel mode | 417 // TabularModel mode |
413 mutable std::vector<sv_frame_t> m_rows; // map from row number to frame | 418 mutable std::vector<sv_frame_t> m_rows; // map from row number to frame |
419 | |
414 void rebuildRowVector() const | 420 void rebuildRowVector() const |
415 { | 421 { |
416 m_rows.clear(); | 422 m_rows.clear(); |
417 for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { | 423 for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { |
418 // std::cerr << "rebuildRowVector: row " << m_rows.size() << " -> " << i->frame << std::endl; | 424 // std::cerr << "rebuildRowVector: row " << m_rows.size() << " -> " << i->frame << std::endl; |
456 int indexAtFrame = 0; | 462 int indexAtFrame = 0; |
457 int ri = row; | 463 int ri = row; |
458 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } | 464 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } |
459 int initialIndexAtFrame = indexAtFrame; | 465 int initialIndexAtFrame = indexAtFrame; |
460 | 466 |
461 // std::cerr << "getPointListIteratorForRow " << row << ": initialIndexAtFrame = " << initialIndexAtFrame << std::endl; | 467 // std::cerr << "getPointListIteratorForRow " << row << ": initialIndexAtFrame = " << initialIndexAtFrame << " for frame " << frame << std::endl; |
462 | 468 |
463 PointListConstIterator i0, i1; | 469 PointListConstIterator i0, i1; |
464 getPointIterators(frame, i0, i1); | 470 getPointIterators(frame, i0, i1); |
465 PointListConstIterator i = i0; | 471 PointListConstIterator i = i0; |
466 | 472 |
469 | 475 |
470 if (i->frame < (int)frame) { continue; } | 476 if (i->frame < (int)frame) { continue; } |
471 if (indexAtFrame > 0) { --indexAtFrame; continue; } | 477 if (indexAtFrame > 0) { --indexAtFrame; continue; } |
472 return i; | 478 return i; |
473 } | 479 } |
474 | 480 /* |
475 // std::cerr << "returning i with i->frame = " << i->frame << std::endl; | 481 if (i == m_points.end()) { |
476 | 482 std::cerr << "returning i at end" << std::endl; |
483 } else { | |
484 std::cerr << "returning i with i->frame = " << i->frame << std::endl; | |
485 } | |
486 */ | |
477 if (indexAtFrame > 0) { | 487 if (indexAtFrame > 0) { |
478 std::cerr << "WARNING: SparseModel::getPointListIteratorForRow: No iterator available for row " << row << " (frame = " << frame << ", index at frame = " << initialIndexAtFrame << ", leftover index " << indexAtFrame << ")" << std::endl; | 488 std::cerr << "WARNING: SparseModel::getPointListIteratorForRow: No iterator available for row " << row << " (frame = " << frame << ", index at frame = " << initialIndexAtFrame << ", leftover index " << indexAtFrame << ")" << std::endl; |
479 } | 489 } |
480 return i; | 490 return i; |
481 } | 491 } |