Mercurial > hg > svgui
changeset 1481:e540aa5d89cd by-id
Update for removal of (public) getId from Model
author | Chris Cannam |
---|---|
date | Fri, 05 Jul 2019 15:34:50 +0100 |
parents | 232262e38051 |
children | c1cae369979d |
files | layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/FlexiNoteLayer.cpp layer/ImageLayer.cpp layer/Layer.cpp layer/Layer.h layer/NoteLayer.cpp layer/RegionLayer.cpp layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/SpectrumLayer.cpp layer/TimeValueLayer.cpp view/Overview.cpp view/Overview.h view/Pane.cpp view/Pane.h view/View.cpp view/View.h |
diffstat | 18 files changed, 159 insertions(+), 164 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/Colour3DPlotLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -155,10 +155,10 @@ if (newModel) { connectSignals(m_model); - connect(newModel.get(), SIGNAL(modelChanged()), - this, SLOT(handleModelChanged())); - connect(newModel.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(handleModelChangedWithin(sv_frame_t, sv_frame_t))); + connect(newModel.get(), SIGNAL(modelChanged(ModelId)), + this, SLOT(handleModelChanged(ModelId))); + connect(newModel.get(), SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), + this, SLOT(handleModelChangedWithin(ModelId, sv_frame_t, sv_frame_t))); m_peakResolution = 256; if (newModel->getResolution() > 512) { @@ -214,14 +214,13 @@ if (m_peakCache.isNone()) { auto peakCache = std::make_shared<Dense3DModelPeakCache> (m_model, m_peakCacheDivisor); - ModelById::add(peakCache); - m_peakCache = peakCache->getId(); + m_peakCache = ModelById::add(peakCache); } return m_peakCache; } void -Colour3DPlotLayer::handleModelChanged() +Colour3DPlotLayer::handleModelChanged(ModelId modelId) { if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_model); @@ -234,11 +233,13 @@ } } invalidatePeakCache(); - emit modelChanged(); + emit modelChanged(modelId); } void -Colour3DPlotLayer::handleModelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) +Colour3DPlotLayer::handleModelChangedWithin(ModelId modelId, + sv_frame_t startFrame, + sv_frame_t endFrame) { if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_model); @@ -250,7 +251,7 @@ } } } - emit modelChangedWithin(startFrame, endFrame); + emit modelChangedWithin(modelId, startFrame, endFrame); } Layer::PropertyList
--- a/layer/Colour3DPlotLayer.h Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/Colour3DPlotLayer.h Fri Jul 05 15:34:50 2019 +0100 @@ -156,8 +156,8 @@ QString extraAttributes = "") const override; protected slots: - void handleModelChanged(); - void handleModelChangedWithin(sv_frame_t, sv_frame_t); + void handleModelChanged(ModelId); + void handleModelChangedWithin(ModelId, sv_frame_t, sv_frame_t); protected: ModelId m_model; // A DenseThreeDimensionalModel
--- a/layer/FlexiNoteLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/FlexiNoteLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -189,7 +189,7 @@ if (model) { model->setScaleUnits (UnitDatabase::getInstance()->getUnitById(value)); - emit modelChanged(); + emit modelChanged(m_model); } } else { return SingleColourLayer::setProperty(name, value);
--- a/layer/ImageLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/ImageLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -930,7 +930,7 @@ m_images.erase(img); for (ViewImageMap::iterator i = m_scaled.begin(); i != m_scaled.end(); ++i) { i->second.erase(img); - emit modelChanged(); + emit modelChanged(getModel()); } }
--- a/layer/Layer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/Layer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -51,17 +51,17 @@ auto model = ModelById::get(modelId); if (!model) return; - connect(model.get(), SIGNAL(modelChanged()), - this, SIGNAL(modelChanged())); + connect(model.get(), SIGNAL(modelChanged(ModelId)), + this, SIGNAL(modelChanged(ModelId))); - connect(model.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); + connect(model.get(), SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), + this, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t))); - connect(model.get(), SIGNAL(completionChanged()), - this, SIGNAL(modelCompletionChanged())); + connect(model.get(), SIGNAL(completionChanged(ModelId)), + this, SIGNAL(modelCompletionChanged(ModelId))); - connect(model.get(), SIGNAL(alignmentCompletionChanged()), - this, SIGNAL(modelAlignmentCompletionChanged())); + connect(model.get(), SIGNAL(alignmentCompletionChanged(ModelId)), + this, SIGNAL(modelAlignmentCompletionChanged(ModelId))); } QString
--- a/layer/Layer.h Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/Layer.h Fri Jul 05 15:34:50 2019 +0100 @@ -562,10 +562,10 @@ void showLayer(LayerGeometryProvider *, bool show); signals: - void modelChanged(); - void modelCompletionChanged(); - void modelAlignmentCompletionChanged(); - void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); + void modelChanged(ModelId); + void modelCompletionChanged(ModelId); + void modelAlignmentCompletionChanged(ModelId); + void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame); void modelReplaced(); void layerParametersChanged();
--- a/layer/NoteLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/NoteLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -193,7 +193,7 @@ if (model) { model->setScaleUnits (UnitDatabase::getInstance()->getUnitById(value)); - emit modelChanged(); + emit modelChanged(m_model); } } else { return SingleColourLayer::setProperty(name, value);
--- a/layer/RegionLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/RegionLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -228,7 +228,7 @@ if (model) { model->setScaleUnits (UnitDatabase::getInstance()->getUnitById(value)); - emit modelChanged(); + emit modelChanged(m_model); } } else { return SingleColourLayer::setProperty(name, value);
--- a/layer/SpectrogramLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/SpectrogramLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -215,10 +215,12 @@ connectSignals(m_model); - connect(newModel.get(), SIGNAL(modelChanged()), - this, SLOT(cacheInvalid())); - connect(newModel.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t))); + connect(newModel.get(), + SIGNAL(modelChanged(ModelId)), + this, SLOT(cacheInvalid(ModelId))); + connect(newModel.get(), + SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), + this, SLOT(cacheInvalid(ModelId, sv_frame_t, sv_frame_t))); } emit modelReplaced(); @@ -1058,7 +1060,7 @@ } void -SpectrogramLayer::cacheInvalid() +SpectrogramLayer::cacheInvalid(ModelId) { #ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "SpectrogramLayer::cacheInvalid()" << endl; @@ -1070,6 +1072,7 @@ void SpectrogramLayer::cacheInvalid( + ModelId, #ifdef DEBUG_SPECTROGRAM_REPAINT sv_frame_t from, sv_frame_t to #else @@ -1417,8 +1420,7 @@ return; } - ModelById::add(newFFTModel); - m_fftModel = newFFTModel->getId(); + m_fftModel = ModelById::add(newFFTModel); bool createWholeCache = false; checkCacheSpace(&m_peakCacheDivisor, &createWholeCache); @@ -1426,20 +1428,17 @@ if (createWholeCache) { auto whole = std::make_shared<Dense3DModelPeakCache>(m_fftModel, 1); - ModelById::add(whole); - m_wholeCache = whole->getId(); + m_wholeCache = ModelById::add(whole); auto peaks = std::make_shared<Dense3DModelPeakCache>(m_wholeCache, m_peakCacheDivisor); - ModelById::add(peaks); - m_peakCache = peaks->getId(); + m_peakCache = ModelById::add(peaks); } else { auto peaks = std::make_shared<Dense3DModelPeakCache>(m_fftModel, m_peakCacheDivisor); - ModelById::add(peaks); - m_peakCache = peaks->getId(); + m_peakCache = ModelById::add(peaks); } }
--- a/layer/SpectrogramLayer.h Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/SpectrogramLayer.h Fri Jul 05 15:34:50 2019 +0100 @@ -237,8 +237,8 @@ ModelId getSliceableModel() const override; protected slots: - void cacheInvalid(); - void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); + void cacheInvalid(ModelId); + void cacheInvalid(ModelId, sv_frame_t startFrame, sv_frame_t endFrame); void preferenceChanged(PropertyContainer::PropertyName name);
--- a/layer/SpectrumLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/SpectrumLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -116,8 +116,7 @@ m_maxbin = newFFT->getHeight(); } - ModelById::add(newFFT); - setSliceableModel(newFFT->getId()); + setSliceableModel(ModelById::add(newFFT)); m_biasCurve.clear(); for (int i = 0; i < fftSize; ++i) {
--- a/layer/TimeValueLayer.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/layer/TimeValueLayer.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -284,7 +284,7 @@ if (model) { model->setScaleUnits (UnitDatabase::getInstance()->getUnitById(value)); - emit modelChanged(); + emit modelChanged(m_model); } } else if (name == "Draw Segment Division Lines") { setDrawSegmentDivisions(value > 0.5);
--- a/view/Overview.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/view/Overview.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -42,7 +42,7 @@ } void -Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) +Overview::modelChangedWithin(ModelId modelId, sv_frame_t startFrame, sv_frame_t endFrame) { using namespace std::rel_ops; @@ -70,7 +70,7 @@ } } - View::modelChangedWithin(startFrame, endFrame); + View::modelChangedWithin(modelId, startFrame, endFrame); } void
--- a/view/Overview.h Thu Jul 04 18:04:44 2019 +0100 +++ b/view/Overview.h Fri Jul 05 15:34:50 2019 +0100 @@ -41,7 +41,7 @@ QString getPropertyContainerIconName() const override { return "panner"; } public slots: - void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) override; + void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame) override; void modelReplaced() override; void globalCentreFrameChanged(sv_frame_t) override;
--- a/view/Pane.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/view/Pane.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -367,37 +367,49 @@ Layer *topLayer = getTopLayer(); bool haveSomeTimeXAxis = false; - std::shared_ptr<const Model> waveformModel; // just for reporting purposes - std::shared_ptr<const Model> workModel; - - for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { + ModelId waveformModelId; // just for reporting purposes + ModelId workModelId; + + for (LayerList::iterator vi = m_layerStack.end(); + vi != m_layerStack.begin(); ) { + --vi; + if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) { haveSomeTimeXAxis = true; } - auto model = ModelById::get((*vi)->getModel()); - - if (model) { + + ModelId modelId = (*vi)->getModel(); + if (!modelId.isNone()) { if (dynamic_cast<WaveformLayer *>(*vi)) { - waveformModel = model; - workModel = waveformModel; + waveformModelId = modelId; + workModelId = modelId; } else { - if (std::dynamic_pointer_cast<WaveFileModel>(model)) { - workModel = model; - } else if (auto wm = ModelById::getAs<WaveFileModel> - (model->getSourceModel())) { - workModel = wm; + if (ModelById::isa<WaveFileModel>(modelId)) { + workModelId = modelId; + } else { + auto model = ModelById::get(modelId); + if (model) { + ModelId sourceId = model->getSourceModel(); + if (ModelById::isa<WaveFileModel>(sourceId)) { + workModelId = sourceId; + } + } } } } - if (waveformModel && workModel && haveSomeTimeXAxis) break; + if (!waveformModelId.isNone() && + !workModelId.isNone() && + haveSomeTimeXAxis) { + break; + } } // Block off left and right extents so we can see where the main model ends - if (workModel && hasTopLayerTimeXAxis()) { - drawModelTimeExtents(r, paint, *workModel); + if (!workModelId.isNone() && hasTopLayerTimeXAxis()) { + drawModelTimeExtents(r, paint, workModelId); } // Crosshairs for mouse movement in measure mode @@ -448,26 +460,26 @@ paint.setPen(QColor(50, 50, 50)); - if (waveformModel && + if (!waveformModelId.isNone() && sampleRate && m_manager && m_manager->shouldShowDuration()) { - drawDurationAndRate(r, *waveformModel, sampleRate, paint); + drawDurationAndRate(r, waveformModelId, sampleRate, paint); } bool haveWorkTitle = false; - if (workModel && + if (!workModelId.isNone() && m_manager && m_manager->shouldShowWorkTitle()) { - drawWorkTitle(r, paint, *workModel); + drawWorkTitle(r, paint, workModelId); haveWorkTitle = true; } - if (workModel && + if (!workModelId.isNone() && m_manager && m_manager->getAlignMode()) { - drawAlignmentStatus(r, paint, *workModel, haveWorkTitle); + drawAlignmentStatus(r, paint, workModelId, haveWorkTitle); } if (m_manager && @@ -759,8 +771,11 @@ } void -Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model &model) +Pane::drawModelTimeExtents(QRect r, QPainter &paint, ModelId modelId) { + auto model = ModelById::get(modelId); + if (!model) return; + paint.save(); QBrush brush; @@ -773,7 +788,7 @@ paint.setPen(Qt::white); } - sv_frame_t f0 = model.getStartFrame(); + sv_frame_t f0 = model->getStartFrame(); if (f0 > getStartFrame() && f0 < getEndFrame()) { int x0 = getXForFrame(f0); @@ -783,7 +798,7 @@ } } - sv_frame_t f1 = model.getEndFrame(); + sv_frame_t f1 = model->getEndFrame(); if (f1 > getStartFrame() && f1 < getEndFrame()) { int x1 = getXForFrame(f1); @@ -797,14 +812,17 @@ } void -Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model &model, +Pane::drawAlignmentStatus(QRect r, QPainter &paint, ModelId modelId, bool down) { - ModelId reference = model.getAlignmentReference(); + auto model = ModelById::get(modelId); + if (!model) return; + + ModelId reference = model->getAlignmentReference(); /* if (!reference) { cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << endl; - } else if (reference == model.getId()) { + } else if (reference == model->getId()) { cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << endl; } else { cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << endl; @@ -813,12 +831,12 @@ QString text; int completion = 100; - if (reference == model.getId()) { + if (reference == modelId) { text = tr("Reference"); } else if (reference.isNone()) { text = tr("Unaligned"); } else { - completion = model.getAlignmentCompletion(); + completion = model->getAlignmentCompletion(); if (completion == 0) { text = tr("Unaligned"); } else if (completion < 100) { @@ -850,17 +868,20 @@ } void -Pane::modelAlignmentCompletionChanged() +Pane::modelAlignmentCompletionChanged(ModelId modelId) { - View::modelAlignmentCompletionChanged(); + View::modelAlignmentCompletionChanged(modelId); update(QRect(0, 0, 300, 100)); } void -Pane::drawWorkTitle(QRect r, QPainter &paint, const Model &model) +Pane::drawWorkTitle(QRect r, QPainter &paint, ModelId modelId) { - QString title = model.getTitle(); - QString maker = model.getMaker(); + auto model = ModelById::get(modelId); + if (!model) return; + + QString title = model->getTitle(); + QString maker = model->getMaker(); //SVDEBUG << "Pane::drawWorkTitle: title=\"" << title//<< "\", maker=\"" << maker << "\"" << endl; if (title == "") return; @@ -1034,16 +1055,19 @@ } void -Pane::drawDurationAndRate(QRect r, const Model &waveformModel, +Pane::drawDurationAndRate(QRect r, ModelId waveformModelId, sv_samplerate_t sampleRate, QPainter &paint) { + auto waveformModel = ModelById::get(waveformModelId); + if (!waveformModel) return; + int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); if (r.y() + r.height() < height() - fontHeight - 6) return; - sv_samplerate_t modelRate = waveformModel.getSampleRate(); - sv_samplerate_t nativeRate = waveformModel.getNativeRate(); + sv_samplerate_t modelRate = waveformModel->getSampleRate(); + sv_samplerate_t nativeRate = waveformModel->getNativeRate(); sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); QString srNote = ""; @@ -1062,7 +1086,7 @@ } QString desc = tr("%1 / %2Hz%3") - .arg(RealTime::frame2RealTime(waveformModel.getEndFrame(), + .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(), sampleRate) .toText(false).c_str()) .arg(nativeRate)
--- a/view/Pane.h Thu Jul 04 18:04:44 2019 +0100 +++ b/view/Pane.h Fri Jul 05 15:34:50 2019 +0100 @@ -88,7 +88,7 @@ virtual void toolModeChanged() override; virtual void zoomWheelsEnabledChanged() override; virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override; - virtual void modelAlignmentCompletionChanged() override; + virtual void modelAlignmentCompletionChanged(ModelId) override; // local slots, not overrides virtual void horizontalThumbwheelMoved(int value); @@ -129,12 +129,12 @@ void drawVerticalScale(QRect r, Layer *, QPainter &); void drawFeatureDescription(Layer *, QPainter &); void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine); - void drawModelTimeExtents(QRect, QPainter &, const Model &); - void drawDurationAndRate(QRect, const Model &, sv_samplerate_t, QPainter &); - void drawWorkTitle(QRect, QPainter &, const Model &); + void drawModelTimeExtents(QRect, QPainter &, ModelId); + void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &); + void drawWorkTitle(QRect, QPainter &, ModelId); void drawLayerNames(QRect, QPainter &); void drawEditingSelection(QPainter &); - void drawAlignmentStatus(QRect, QPainter &, const Model &, bool down); + void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down); virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override;
--- a/view/View.cpp Thu Jul 04 18:04:44 2019 +0100 +++ b/view/View.cpp Fri Jul 05 15:34:50 2019 +0100 @@ -706,14 +706,14 @@ this, SLOT(layerMeasurementRectsChanged())); connect(layer, SIGNAL(layerNameChanged()), this, SLOT(layerNameChanged())); - connect(layer, SIGNAL(modelChanged()), - this, SLOT(modelChanged())); - connect(layer, SIGNAL(modelCompletionChanged()), - this, SLOT(modelCompletionChanged())); - connect(layer, SIGNAL(modelAlignmentCompletionChanged()), - this, SLOT(modelAlignmentCompletionChanged())); - connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); + connect(layer, SIGNAL(modelChanged(ModelId)), + this, SLOT(modelChanged(ModelId))); + connect(layer, SIGNAL(modelCompletionChanged(ModelId)), + this, SLOT(modelCompletionChanged(ModelId))); + connect(layer, SIGNAL(modelAlignmentCompletionChanged(ModelId)), + this, SLOT(modelAlignmentCompletionChanged(ModelId))); + connect(layer, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t))); connect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -761,14 +761,14 @@ this, SLOT(layerParameterRangesChanged())); disconnect(layer, SIGNAL(layerNameChanged()), this, SLOT(layerNameChanged())); - disconnect(layer, SIGNAL(modelChanged()), - this, SLOT(modelChanged())); - disconnect(layer, SIGNAL(modelCompletionChanged()), - this, SLOT(modelCompletionChanged())); - disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()), - this, SLOT(modelAlignmentCompletionChanged())); - disconnect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); + disconnect(layer, SIGNAL(modelChanged(ModelId)), + this, SLOT(modelChanged(ModelId))); + disconnect(layer, SIGNAL(modelCompletionChanged(ModelId)), + this, SLOT(modelCompletionChanged(ModelId))); + disconnect(layer, SIGNAL(modelAlignmentCompletionChanged(ModelId)), + this, SLOT(modelAlignmentCompletionChanged(ModelId))); + disconnect(layer, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t))); disconnect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -922,23 +922,12 @@ } void -View::modelChanged() +View::modelChanged(ModelId modelId) { #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "View(" << this << ")::modelChanged()" << endl; #endif - QObject *obj = sender(); - - ModelId model; - if (Model *modelPtr = qobject_cast<Model *>(obj)) { - model = modelPtr->getId(); - } else if (Layer *layerPtr = qobject_cast<Layer *>(obj)) { - model = layerPtr->getModel(); - } else { - return; - } - // If the model that has changed is not used by any of the cached // layers, we won't need to recreate the cache @@ -948,7 +937,7 @@ LayerList scrollables = getScrollableBackLayers(false, discard); for (LayerList::const_iterator i = scrollables.begin(); i != scrollables.end(); ++i) { - if ((*i)->getModel() == model) { + if ((*i)->getModel() == modelId) { recreate = true; break; } @@ -960,25 +949,15 @@ emit layerModelChanged(); - checkProgress(obj); + checkProgress(modelId); update(); } void -View::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) +View::modelChangedWithin(ModelId modelId, + sv_frame_t startFrame, sv_frame_t endFrame) { - QObject *obj = sender(); - - ModelId model; - if (Model *modelPtr = qobject_cast<Model *>(obj)) { - model = modelPtr->getId(); - } else if (Layer *layerPtr = qobject_cast<Layer *>(obj)) { - model = layerPtr->getModel(); - } else { - return; - } - sv_frame_t myStartFrame = getStartFrame(); sv_frame_t myEndFrame = getEndFrame(); @@ -987,11 +966,11 @@ #endif if (myStartFrame > 0 && endFrame < myStartFrame) { - checkProgress(obj); + checkProgress(modelId); return; } if (startFrame > myEndFrame) { - checkProgress(obj); + checkProgress(modelId); return; } @@ -1004,7 +983,7 @@ LayerList scrollables = getScrollableBackLayers(false, discard); for (LayerList::const_iterator i = scrollables.begin(); i != scrollables.end(); ++i) { - if ((*i)->getModel() == model) { + if ((*i)->getModel() == modelId) { recreate = true; break; } @@ -1017,27 +996,21 @@ if (startFrame < myStartFrame) startFrame = myStartFrame; if (endFrame > myEndFrame) endFrame = myEndFrame; - checkProgress(obj); + checkProgress(modelId); update(); } void -View::modelCompletionChanged() +View::modelCompletionChanged(ModelId modelId) { -// cerr << "View(" << this << ")::modelCompletionChanged()" << endl; - - QObject *obj = sender(); - checkProgress(obj); + checkProgress(modelId); } void -View::modelAlignmentCompletionChanged() +View::modelAlignmentCompletionChanged(ModelId modelId) { -// cerr << "View(" << this << ")::modelAlignmentCompletionChanged()" << endl; - - QObject *obj = sender(); - checkProgress(obj); + checkProgress(modelId); } void @@ -1391,17 +1364,18 @@ if (!layer) continue; if (dynamic_cast<TimeRulerLayer *>(layer)) continue; - auto model = ModelById::get(layer->getModel()); + ModelId thisId = layer->getModel(); + auto model = ModelById::get(thisId); if (!model) continue; - anyModel = model->getId(); + anyModel = thisId; if (!model->getAlignmentReference().isNone()) { - alignedModel = model->getId(); + alignedModel = thisId; if (layer->isLayerOpaque() || std::dynamic_pointer_cast <RangeSummarisableTimeValueModel>(model)) { - goodModel = model->getId(); + goodModel = thisId; } } } @@ -1762,11 +1736,11 @@ } void -View::checkProgress(void *object) +View::checkProgress(ModelId modelId) { if (!m_showProgress) { #ifdef DEBUG_PROGRESS_STUFF - SVCERR << "View[" << this << "]::checkProgress(" << object << "): " + SVCERR << "View[" << this << "]::checkProgress(" << modelId << "): " << "m_showProgress is off" << endl; #endif return; @@ -1786,7 +1760,7 @@ QProgressBar *pb = i->second.bar; QPushButton *cancel = i->second.cancel; - if (i->first == object) { + if (i->first && i->first->getModel() == modelId) { found = true; @@ -1820,8 +1794,6 @@ m_lastError = error; } - ModelId modelId = i->first->getModel(); - auto model = ModelById::get(modelId); auto wfm = std::dynamic_pointer_cast <RangeSummarisableTimeValueModel>(model);
--- a/view/View.h Thu Jul 04 18:04:44 2019 +0100 +++ b/view/View.h Fri Jul 05 15:34:50 2019 +0100 @@ -417,10 +417,10 @@ void contextHelpChanged(const QString &); public slots: - virtual void modelChanged(); - virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); - virtual void modelCompletionChanged(); - virtual void modelAlignmentCompletionChanged(); + virtual void modelChanged(ModelId); + virtual void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame); + virtual void modelCompletionChanged(ModelId); + virtual void modelAlignmentCompletionChanged(ModelId); virtual void modelReplaced(); virtual void layerParametersChanged(); virtual void layerParameterRangesChanged(); @@ -504,7 +504,7 @@ void movePlayPointer(sv_frame_t f); - void checkProgress(void *object); + void checkProgress(ModelId); int getProgressBarWidth() const; // if visible int effectiveDevicePixelRatio() const;