Mercurial > hg > sonic-visualiser
diff main/MainWindow.cpp @ 415:aa8117d79702
Once again, avoid multiple entries in right-button Layer menu when more than one audio file loaded; fix to ensure correct model is picked up for Add Layer on this menu
author | Chris Cannam |
---|---|
date | Thu, 14 Apr 2011 12:13:06 +0100 |
parents | 94bb597df464 |
children | a0d162a3f3a7 af775c7b929b 5f22e0bbe4ba e1bde903c65c |
line wrap: on
line diff
--- a/main/MainWindow.cpp Tue Apr 12 10:54:25 2011 +0100 +++ b/main/MainWindow.cpp Thu Apr 14 12:13:06 2011 +0100 @@ -22,6 +22,7 @@ #include "view/PaneStack.h" #include "data/model/WaveFileModel.h" #include "data/model/SparseOneDimensionalModel.h" +#include "data/model/RangeSummarisableTimeValueModel.h" #include "data/model/NoteModel.h" #include "data/model/Labeller.h" #include "data/osc/OSCQueue.h" @@ -1196,7 +1197,11 @@ submenu->addAction(action); } - if (isDefault && menuType == layerMenuType) { + if (isDefault && menuType == layerMenuType && + mi == candidateModels.begin()) { + // only add for one model, one channel, one menu on + // right button -- the action itself will discover + // which model is the correct one (based on pane) action = new QAction(icon, mainText, this); action->setStatusTip(tipText); connect(action, SIGNAL(triggered()), @@ -3213,22 +3218,21 @@ Model *model = i->second.sourceModel; + cerr << "model = "<< model << endl; + if (!model) { if (type == LayerFactory::TimeRuler) { newLayer = m_document->createMainModelLayer(type); } else { // if model is unspecified and this is not a - // time-ruler layer, use the topmost plausible - // model from the current pane (if any) -- this is - // the case for right-button menu layer additions - for (int i = pane->getLayerCount(); i > 0; --i) { - Layer *el = pane->getLayer(i-1); - if (el && - el->getModel() && - dynamic_cast<RangeSummarisableTimeValueModel *> - (el->getModel())) { - model = el->getModel(); - } + // time-ruler layer, use any plausible model from + // the current pane -- this is the case for + // right-button menu layer additions + Pane::ModelSet ms = pane->getModels(); + foreach (Model *m, ms) { + RangeSummarisableTimeValueModel *r = + dynamic_cast<RangeSummarisableTimeValueModel *>(m); + if (r) model = m; } if (!model) model = getMainModel(); }