comparison main/MainWindow.cpp @ 272:ffc0acc10ffc

* Add beginnings of transform-search-by-text function
author Chris Cannam
date Mon, 22 Sep 2008 15:44:03 +0000
parents c452d8a7b770
children 9070db6244a2
comparison
equal deleted inserted replaced
271:3c4aaa8f8418 272:ffc0acc10ffc
1215 m_transformActionsReverse.clear(); 1215 m_transformActionsReverse.clear();
1216 m_transformsMenu->clear(); 1216 m_transformsMenu->clear();
1217 } else { 1217 } else {
1218 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); 1218 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
1219 m_transformsMenu->setTearOffEnabled(true); 1219 m_transformsMenu->setTearOffEnabled(true);
1220 } 1220 }
1221 1221
1222 TransformList transforms = 1222 TransformList transforms =
1223 TransformFactory::getInstance()->getAllTransformDescriptions(); 1223 TransformFactory::getInstance()->getAllTransformDescriptions();
1224 1224 /*!!!
1225 std::cerr << "Testing transform search..." << std::endl;
1226 QStringList terms;
1227 terms << "onset";
1228 terms << "detector";
1229 TransformFactory::SearchResults results = TransformFactory::getInstance()->
1230 search(terms);
1231 std::cerr << results.size() << " result(s)..." << std::endl;
1232 int i = 0;
1233 std::set<TransformFactory::Match> sortedResults;
1234 for (TransformFactory::SearchResults::const_iterator j =
1235 results.begin();
1236 j != results.end(); ++j) {
1237 sortedResults.insert(j->second);
1238 }
1239 for (std::set<TransformFactory::Match>::const_iterator j =
1240 sortedResults.begin();
1241 j != sortedResults.end(); ++j) {
1242 std::cerr << i << ": " << j->transform.toStdString()
1243 << ": ";
1244 for (int k = 0; k < j->fragments.size(); ++k) {
1245 std::cerr << j->fragments[k].toStdString() << " ";
1246 }
1247 std::cerr << "(" << j->score << ")" << std::endl;
1248 ++i;
1249 }
1250 */
1225 vector<QString> types = 1251 vector<QString> types =
1226 TransformFactory::getInstance()->getAllTransformTypes(); 1252 TransformFactory::getInstance()->getAllTransformTypes();
1227 1253
1228 map<QString, map<QString, SubdividingMenu *> > categoryMenus; 1254 map<QString, map<QString, SubdividingMenu *> > categoryMenus;
1229 map<QString, map<QString, SubdividingMenu *> > makerMenus; 1255 map<QString, map<QString, SubdividingMenu *> > makerMenus;
1236 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms")); 1262 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms"));
1237 m_recentTransformsMenu->setTearOffEnabled(true); 1263 m_recentTransformsMenu->setTearOffEnabled(true);
1238 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu); 1264 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu);
1239 connect(&m_recentTransforms, SIGNAL(recentChanged()), 1265 connect(&m_recentTransforms, SIGNAL(recentChanged()),
1240 this, SLOT(setupRecentTransformsMenu())); 1266 this, SLOT(setupRecentTransformsMenu()));
1267
1268 QAction *action = new QAction(tr("Find Transform..."), this);
1269 action->setStatusTip(tr("Search for a transform by name or description"));
1270 connect(action, SIGNAL(triggered()), this, SLOT(findTransform()));
1271 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1272 m_transformsMenu->addAction(action);
1273 m_rightButtonTransformsMenu->addAction(action);
1241 1274
1242 m_transformsMenu->addSeparator(); 1275 m_transformsMenu->addSeparator();
1243 m_rightButtonTransformsMenu->addSeparator(); 1276 m_rightButtonTransformsMenu->addSeparator();
1244 1277
1245 for (vector<QString>::iterator i = types.begin(); i != types.end(); ++i) { 1278 for (vector<QString>::iterator i = types.begin(); i != types.end(); ++i) {
1373 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); 1406 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
1374 m_transformActions[action] = transforms[i].identifier; 1407 m_transformActions[action] = transforms[i].identifier;
1375 m_transformActionsReverse[transforms[i].identifier] = action; 1408 m_transformActionsReverse[transforms[i].identifier] = action;
1376 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); 1409 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1377 1410
1378 action->setStatusTip(transforms[i].description); 1411 action->setStatusTip(transforms[i].longDescription);
1379 1412
1380 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { 1413 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
1381 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1414 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1382 << "No category menu for transform \"" 1415 << "No category menu for transform \""
1383 << name.toStdString() << "\" (category = \"" 1416 << name.toStdString() << "\" (category = \""
1397 1430
1398 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this); 1431 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
1399 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); 1432 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
1400 m_transformActions[action] = transforms[i].identifier; 1433 m_transformActions[action] = transforms[i].identifier;
1401 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); 1434 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1402 action->setStatusTip(transforms[i].description); 1435 action->setStatusTip(transforms[i].longDescription);
1403 1436
1404 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl; 1437 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl;
1405 1438
1406 if (pluginNameMenus[type].find(pluginName) == 1439 if (pluginNameMenus[type].find(pluginName) ==
1407 pluginNameMenus[type].end()) { 1440 pluginNameMenus[type].end()) {
3057 layer->setPresentationName(newName); 3090 layer->setPresentationName(newName);
3058 setupExistingLayersMenus(); 3091 setupExistingLayersMenus();
3059 } 3092 }
3060 } 3093 }
3061 } 3094 }
3095 }
3096
3097 void
3098 MainWindow::findTransform()
3099 {
3100 //!!! implement me!
3062 } 3101 }
3063 3102
3064 void 3103 void
3065 MainWindow::playSoloToggled() 3104 MainWindow::playSoloToggled()
3066 { 3105 {