comparison 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
comparison
equal deleted inserted replaced
414:6b1eddfedfab 415:aa8117d79702
20 20
21 #include "view/Pane.h" 21 #include "view/Pane.h"
22 #include "view/PaneStack.h" 22 #include "view/PaneStack.h"
23 #include "data/model/WaveFileModel.h" 23 #include "data/model/WaveFileModel.h"
24 #include "data/model/SparseOneDimensionalModel.h" 24 #include "data/model/SparseOneDimensionalModel.h"
25 #include "data/model/RangeSummarisableTimeValueModel.h"
25 #include "data/model/NoteModel.h" 26 #include "data/model/NoteModel.h"
26 #include "data/model/Labeller.h" 27 #include "data/model/Labeller.h"
27 #include "data/osc/OSCQueue.h" 28 #include "data/osc/OSCQueue.h"
28 #include "framework/Document.h" 29 #include "framework/Document.h"
29 #include "framework/TransformUserConfigurator.h" 30 #include "framework/TransformUserConfigurator.h"
1194 } 1195 }
1195 1196
1196 submenu->addAction(action); 1197 submenu->addAction(action);
1197 } 1198 }
1198 1199
1199 if (isDefault && menuType == layerMenuType) { 1200 if (isDefault && menuType == layerMenuType &&
1201 mi == candidateModels.begin()) {
1202 // only add for one model, one channel, one menu on
1203 // right button -- the action itself will discover
1204 // which model is the correct one (based on pane)
1200 action = new QAction(icon, mainText, this); 1205 action = new QAction(icon, mainText, this);
1201 action->setStatusTip(tipText); 1206 action->setStatusTip(tipText);
1202 connect(action, SIGNAL(triggered()), 1207 connect(action, SIGNAL(triggered()),
1203 this, SLOT(addLayer())); 1208 this, SLOT(addLayer()));
1204 connect(this, SIGNAL(canAddLayer(bool)), 1209 connect(this, SIGNAL(canAddLayer(bool)),
3211 3216
3212 } else { 3217 } else {
3213 3218
3214 Model *model = i->second.sourceModel; 3219 Model *model = i->second.sourceModel;
3215 3220
3221 cerr << "model = "<< model << endl;
3222
3216 if (!model) { 3223 if (!model) {
3217 if (type == LayerFactory::TimeRuler) { 3224 if (type == LayerFactory::TimeRuler) {
3218 newLayer = m_document->createMainModelLayer(type); 3225 newLayer = m_document->createMainModelLayer(type);
3219 } else { 3226 } else {
3220 // if model is unspecified and this is not a 3227 // if model is unspecified and this is not a
3221 // time-ruler layer, use the topmost plausible 3228 // time-ruler layer, use any plausible model from
3222 // model from the current pane (if any) -- this is 3229 // the current pane -- this is the case for
3223 // the case for right-button menu layer additions 3230 // right-button menu layer additions
3224 for (int i = pane->getLayerCount(); i > 0; --i) { 3231 Pane::ModelSet ms = pane->getModels();
3225 Layer *el = pane->getLayer(i-1); 3232 foreach (Model *m, ms) {
3226 if (el && 3233 RangeSummarisableTimeValueModel *r =
3227 el->getModel() && 3234 dynamic_cast<RangeSummarisableTimeValueModel *>(m);
3228 dynamic_cast<RangeSummarisableTimeValueModel *> 3235 if (r) model = m;
3229 (el->getModel())) {
3230 model = el->getModel();
3231 }
3232 } 3236 }
3233 if (!model) model = getMainModel(); 3237 if (!model) model = getMainModel();
3234 } 3238 }
3235 } 3239 }
3236 3240