Mercurial > hg > svapp
changeset 710:3e930ea94db6
Rename time-frequency box to plain box - but also reload sessions if they have the "old" name (even though it was only used in 4.0-pre1 exports)
author | Chris Cannam |
---|---|
date | Wed, 25 Sep 2019 09:52:30 +0100 |
parents | dde6ff56a84b |
children | aee03ad6d3f6 |
files | framework/SVFileReader.cpp |
diffstat | 1 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/SVFileReader.cpp Fri Sep 20 14:19:49 2019 +0100 +++ b/framework/SVFileReader.cpp Wed Sep 25 09:52:30 2019 +0100 @@ -34,7 +34,7 @@ #include "data/model/RegionModel.h" #include "data/model/TextModel.h" #include "data/model/ImageModel.h" -#include "data/model/TimeFrequencyBoxModel.h" +#include "data/model/BoxModel.h" #include "data/model/AlignmentModel.h" #include "data/model/AggregateWaveModel.h" @@ -687,9 +687,11 @@ // Paths are no longer actually models Path *path = new Path(sampleRate, resolution); m_paths[id] = path; - } else if (attributes.value("subtype") == "timefrequencybox") { - auto model = std::make_shared<TimeFrequencyBoxModel> + } else if (attributes.value("subtype") == "box" || + attributes.value("subtype") == "timefrequencybox") { + auto model = std::make_shared<BoxModel> (sampleRate, resolution, notifyOnAdd); + model->setScaleUnits(units); model->setObjectName(name); m_models[id] = ModelById::add(model); } else { @@ -1063,7 +1065,7 @@ good = (ModelById::isa<SparseTimeValueModel>(modelId) || ModelById::isa<TextModel>(modelId) || - ModelById::isa<TimeFrequencyBoxModel>(modelId) || + ModelById::isa<BoxModel>(modelId) || path); break; @@ -1152,12 +1154,18 @@ return ok; } - if (auto bm = ModelById::getAs<TimeFrequencyBoxModel>(modelId)) { - float frequency = attributes.value("frequency").trimmed().toFloat(&ok); + if (auto bm = ModelById::getAs<BoxModel>(modelId)) { + float value = attributes.value("value").trimmed().toFloat(&ok); + if (!ok) { + value = attributes.value("frequency").trimmed().toFloat(&ok); + if (bm->getScaleUnits() == "") { + bm->setScaleUnits("Hz"); + } + } float extent = attributes.value("extent").trimmed().toFloat(&ok); int duration = attributes.value("duration").trimmed().toInt(&ok); QString label = attributes.value("label"); - bm->add(Event(frame, frequency, duration, extent, label)); + bm->add(Event(frame, value, duration, extent, label)); return ok; }