# HG changeset patch # User Chris Cannam # Date 1552052250 0 # Node ID 62e908518c71c3a26b299f0241d1c69477880268 # Parent 6f51297a0250d22c320601c8e42d0860cde97d69 Update to Event api in place of Clipboard points diff -r 6f51297a0250 -r 62e908518c71 layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/FlexiNoteLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -1740,9 +1740,8 @@ for (FlexiNoteModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->value, i->duration, i->level, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -1752,7 +1751,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -1776,10 +1775,9 @@ FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand(m_model, tr("Paste")); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; sv_frame_t frame = 0; if (!realign) { @@ -1788,7 +1786,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -1798,17 +1796,16 @@ FlexiNoteModel::Point newPoint(frame); - if (i->haveLabel()) newPoint.label = i->getLabel(); - if (i->haveValue()) newPoint.value = i->getValue(); + if (i->hasLabel()) newPoint.label = i->getLabel(); + if (i->hasValue()) newPoint.value = i->getValue(); else newPoint.value = (m_model->getValueMinimum() + m_model->getValueMaximum()) / 2; - if (i->haveLevel()) newPoint.level = i->getLevel(); - if (i->haveDuration()) newPoint.duration = i->getDuration(); + if (i->hasLevel()) newPoint.level = i->getLevel(); + if (i->hasDuration()) newPoint.duration = i->getDuration(); else { sv_frame_t nextFrame = frame; - Clipboard::PointList::const_iterator j = i; + EventVector::const_iterator j = i; for (; j != points.end(); ++j) { - if (!j->haveFrame()) continue; if (j != i) break; } if (j != points.end()) { diff -r 6f51297a0250 -r 62e908518c71 layer/ImageLayer.cpp --- a/layer/ImageLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/ImageLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -811,9 +811,8 @@ for (ImageModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -823,7 +822,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -847,11 +846,9 @@ ImageModel::EditCommand *command = new ImageModel::EditCommand(m_model, tr("Paste")); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; - sv_frame_t frame = 0; if (!realign) { @@ -860,7 +857,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -872,9 +869,9 @@ //!!! inadequate - if (i->haveLabel()) { + if (i->hasLabel()) { newPoint.label = i->getLabel(); - } else if (i->haveValue()) { + } else if (i->hasValue()) { newPoint.label = QString("%1").arg(i->getValue()); } else { newPoint.label = tr("New Point"); diff -r 6f51297a0250 -r 62e908518c71 layer/Layer.cpp --- a/layer/Layer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/Layer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -232,7 +232,7 @@ // We either want to be literal all the way through, or aligned // all the way through. - for (Clipboard::PointList::const_iterator i = clip.getPoints().begin(); + for (EventVector::const_iterator i = clip.getPoints().begin(); i != clip.getPoints().end(); ++i) { // In principle, we want to know whether the aligned version @@ -252,12 +252,12 @@ sv_frame_t sourceFrame = i->getFrame(); sv_frame_t referenceFrame = sourceFrame; - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { referenceFrame = i->getReferenceFrame(); } sv_frame_t myMappedFrame = alignToReference(v, sourceFrame); -// cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->haveReferenceFrame() << "), myMappedFrame = " << myMappedFrame << endl; +// cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->hasReferenceFrame() << "), myMappedFrame = " << myMappedFrame << endl; if (myMappedFrame != referenceFrame) return true; } diff -r 6f51297a0250 -r 62e908518c71 layer/LayerFactory.cpp --- a/layer/LayerFactory.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/LayerFactory.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -544,24 +544,22 @@ LayerFactory::LayerType LayerFactory::getLayerTypeForClipboardContents(const Clipboard &clip) { - const Clipboard::PointList &contents = clip.getPoints(); + const EventVector &contents = clip.getPoints(); - bool haveFrame = false; bool haveValue = false; bool haveDuration = false; bool haveLevel = false; - for (Clipboard::PointList::const_iterator i = contents.begin(); + for (EventVector::const_iterator i = contents.begin(); i != contents.end(); ++i) { - if (i->haveFrame()) haveFrame = true; - if (i->haveValue()) haveValue = true; - if (i->haveDuration()) haveDuration = true; - if (i->haveLevel()) haveLevel = true; + if (i->hasValue()) haveValue = true; + if (i->hasDuration()) haveDuration = true; + if (i->hasLevel()) haveLevel = true; } - if (haveFrame && haveValue && haveDuration && haveLevel) return Notes; - if (haveFrame && haveValue && haveDuration) return Regions; - if (haveFrame && haveValue) return TimeValues; + if (haveValue && haveDuration && haveLevel) return Notes; + if (haveValue && haveDuration) return Regions; + if (haveValue) return TimeValues; return TimeInstants; } diff -r 6f51297a0250 -r 62e908518c71 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/NoteLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -1218,9 +1218,8 @@ for (NoteModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->value, i->duration, i->level, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -1230,7 +1229,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -1254,10 +1253,9 @@ NoteModel::EditCommand *command = new NoteModel::EditCommand(m_model, tr("Paste")); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; sv_frame_t frame = 0; if (!realign) { @@ -1266,7 +1264,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -1276,17 +1274,16 @@ NoteModel::Point newPoint(frame); - if (i->haveLabel()) newPoint.label = i->getLabel(); - if (i->haveValue()) newPoint.value = i->getValue(); + if (i->hasLabel()) newPoint.label = i->getLabel(); + if (i->hasValue()) newPoint.value = i->getValue(); else newPoint.value = (m_model->getValueMinimum() + m_model->getValueMaximum()) / 2; - if (i->haveLevel()) newPoint.level = i->getLevel(); - if (i->haveDuration()) newPoint.duration = i->getDuration(); + if (i->hasLevel()) newPoint.level = i->getLevel(); + if (i->hasDuration()) newPoint.duration = i->getDuration(); else { sv_frame_t nextFrame = frame; - Clipboard::PointList::const_iterator j = i; + EventVector::const_iterator j = i; for (; j != points.end(); ++j) { - if (!j->haveFrame()) continue; if (j != i) break; } if (j != points.end()) { diff -r 6f51297a0250 -r 62e908518c71 layer/RegionLayer.cpp --- a/layer/RegionLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/RegionLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -1478,9 +1478,8 @@ for (RegionModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->value, i->duration, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->value, i->duration, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -1490,7 +1489,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -1514,10 +1513,9 @@ RegionModel::EditCommand *command = new RegionModel::EditCommand(m_model, tr("Paste")); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; sv_frame_t frame = 0; if (!realign) { @@ -1526,7 +1524,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -1536,16 +1534,15 @@ RegionModel::Point newPoint(frame); - if (i->haveLabel()) newPoint.label = i->getLabel(); - if (i->haveValue()) newPoint.value = i->getValue(); + if (i->hasLabel()) newPoint.label = i->getLabel(); + if (i->hasValue()) newPoint.value = i->getValue(); else newPoint.value = (m_model->getValueMinimum() + m_model->getValueMaximum()) / 2; - if (i->haveDuration()) newPoint.duration = i->getDuration(); + if (i->hasDuration()) newPoint.duration = i->getDuration(); else { sv_frame_t nextFrame = frame; - Clipboard::PointList::const_iterator j = i; + EventVector::const_iterator j = i; for (; j != points.end(); ++j) { - if (!j->haveFrame()) continue; if (j != i) break; } if (j != points.end()) { diff -r 6f51297a0250 -r 62e908518c71 layer/TextLayer.cpp --- a/layer/TextLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/TextLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -709,9 +709,8 @@ for (TextModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->height, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->height, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -721,7 +720,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -746,19 +745,18 @@ new TextModel::EditCommand(m_model, tr("Paste")); double valueMin = 0.0, valueMax = 1.0; - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (i->haveValue()) { + if (i->hasValue()) { if (i->getValue() < valueMin) valueMin = i->getValue(); if (i->getValue() > valueMax) valueMax = i->getValue(); } } if (valueMax < valueMin + 1.0) valueMax = valueMin + 1.0; - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; sv_frame_t frame = 0; if (!realign) { @@ -767,7 +765,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -777,15 +775,15 @@ TextModel::Point newPoint(frame); - if (i->haveValue()) { + if (i->hasValue()) { newPoint.height = float((i->getValue() - valueMin) / (valueMax - valueMin)); } else { newPoint.height = 0.5f; } - if (i->haveLabel()) { + if (i->hasLabel()) { newPoint.label = i->getLabel(); - } else if (i->haveValue()) { + } else if (i->hasValue()) { newPoint.label = QString("%1").arg(i->getValue()); } else { newPoint.label = tr("New Point"); diff -r 6f51297a0250 -r 62e908518c71 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/TimeInstantLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -761,9 +761,8 @@ for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -773,7 +772,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -797,11 +796,9 @@ SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; - sv_frame_t frame = 0; if (!realign) { @@ -810,7 +807,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -825,9 +822,9 @@ } SparseOneDimensionalModel::Point newPoint(frame); - if (i->haveLabel()) { + if (i->hasLabel()) { newPoint.label = i->getLabel(); - } else if (i->haveValue()) { + } else if (i->hasValue()) { newPoint.label = QString("%1").arg(i->getValue()); } diff -r 6f51297a0250 -r 62e908518c71 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Mar 05 10:02:48 2019 +0000 +++ b/layer/TimeValueLayer.cpp Fri Mar 08 13:37:30 2019 +0000 @@ -1692,9 +1692,8 @@ for (SparseTimeValueModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->value, i->label); - point.setReferenceFrame(alignToReference(v, i->frame)); - to.addPoint(point); + Event point(i->frame, i->value, i->label); + to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); } } } @@ -1705,7 +1704,7 @@ { if (!m_model) return false; - const Clipboard::PointList &points = from.getPoints(); + const EventVector &points = from.getPoints(); bool realign = false; @@ -1746,18 +1745,16 @@ ValueAvailability availability = UnknownAvailability; - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; - if (availability == UnknownAvailability) { - if (i->haveValue()) availability = AllValues; + if (i->hasValue()) availability = AllValues; else availability = NoValues; continue; } - if (i->haveValue()) { + if (i->hasValue()) { if (availability == NoValues) { availability = SomeValues; } @@ -1768,7 +1765,7 @@ } if (!haveUsableLabels) { - if (i->haveLabel()) { + if (i->hasLabel()) { if (i->getLabel().contains(QRegExp("[0-9]"))) { haveUsableLabels = true; } @@ -1838,11 +1835,9 @@ SparseTimeValueModel::Point prevPoint(0); - for (Clipboard::PointList::const_iterator i = points.begin(); + for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { - if (!i->haveFrame()) continue; - sv_frame_t frame = 0; if (!realign) { @@ -1851,7 +1846,7 @@ } else { - if (i->haveReferenceFrame()) { + if (i->hasReferenceFrame()) { frame = i->getReferenceFrame(); frame = alignFromReference(v, frame); } else { @@ -1861,16 +1856,16 @@ SparseTimeValueModel::Point newPoint(frame); - if (i->haveLabel()) { + if (i->hasLabel()) { newPoint.label = i->getLabel(); - } else if (i->haveValue()) { + } else if (i->hasValue()) { newPoint.label = QString("%1").arg(i->getValue()); } bool usePrev = false; SparseTimeValueModel::Point formerPrevPoint = prevPoint; - if (i->haveValue()) { + if (i->hasValue()) { newPoint.value = i->getValue(); } else { #ifdef DEBUG_TIME_VALUE_LAYER