Mercurial > hg > svgui
diff layer/TimeRulerLayer.cpp @ 1486:ac0a8addabcf
Merge from branch by-id
author | Chris Cannam |
---|---|
date | Wed, 17 Jul 2019 14:25:16 +0100 |
parents | 36ad3cdabf55 |
children | e6362cf5ff1d |
line wrap: on
line diff
--- a/layer/TimeRulerLayer.cpp Thu Jun 13 15:35:01 2019 +0100 +++ b/layer/TimeRulerLayer.cpp Wed Jul 17 14:25:16 2019 +0100 @@ -36,14 +36,13 @@ TimeRulerLayer::TimeRulerLayer() : SingleColourLayer(), - m_model(nullptr), m_labelHeight(LabelTop) { } void -TimeRulerLayer::setModel(Model *model) +TimeRulerLayer::setModel(ModelId model) { if (m_model == model) return; m_model = model; @@ -54,7 +53,8 @@ TimeRulerLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const { - if (!m_model) { + auto model = ModelById::get(m_model); + if (!model) { resolution = 1; return false; } @@ -62,7 +62,7 @@ bool q; int64_t tickUSec = getMajorTickUSec(v, q); RealTime rtick = RealTime::fromMicroseconds(tickUSec); - sv_samplerate_t rate = m_model->getSampleRate(); + sv_samplerate_t rate = model->getSampleRate(); RealTime rt = RealTime::frame2RealTime(frame, rate); double ratio = rt / rtick; @@ -137,9 +137,10 @@ bool &quarterTicks) const { // return value is in microseconds - if (!m_model || !v) return 1000 * 1000; + auto model = ModelById::get(m_model); + if (!model || !v) return 1000 * 1000; - sv_samplerate_t sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = model->getSampleRate(); if (!sampleRate) return 1000 * 1000; sv_frame_t startFrame = v->getStartFrame(); @@ -148,6 +149,11 @@ endFrame = startFrame + 1; } + // Qt 5.13 deprecates QFontMetrics::width(), but its suggested + // replacement (horizontalAdvance) was only added in Qt 5.11 + // which is too new for us +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + int exampleWidth = QFontMetrics(QFont()).width("10:42.987654"); int minPixelSpacing = v->getXForViewX(exampleWidth); @@ -210,7 +216,8 @@ int TimeRulerLayer::getXForUSec(LayerGeometryProvider *v, double us) const { - sv_samplerate_t sampleRate = m_model->getSampleRate(); + auto model = ModelById::get(m_model); + sv_samplerate_t sampleRate = model->getSampleRate(); double dframe = (us * sampleRate) / 1000000.0; double eps = 1e-7; sv_frame_t frame = sv_frame_t(floor(dframe + eps)); @@ -249,9 +256,10 @@ << ") [" << rect.width() << "x" << rect.height() << "]" << endl; #endif - if (!m_model || !m_model->isOK()) return; + auto model = ModelById::get(m_model); + if (!model || !model->isOK()) return; - sv_samplerate_t sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = model->getSampleRate(); if (!sampleRate) return; sv_frame_t startFrame = v->getFrameForX(rect.x() - 50);