Mercurial > hg > svcore
comparison transform/TransformFactory.cpp @ 487:c45e6c6722e0
* Use enum for transform type instead of trying to do dumb things like
compare translated strings
author | Chris Cannam |
---|---|
date | Fri, 21 Nov 2008 13:37:35 +0000 |
parents | 9eb7ef610d7f |
children | 82ab61fa9223 |
comparison
equal
deleted
inserted
replaced
486:4c000e196bf1 | 487:c45e6c6722e0 |
---|---|
210 m_uninstalledTransformsMutex.unlock(); | 210 m_uninstalledTransformsMutex.unlock(); |
211 return TransformUnknown; | 211 return TransformUnknown; |
212 } | 212 } |
213 | 213 |
214 | 214 |
215 std::vector<QString> | 215 std::vector<TransformDescription::Type> |
216 TransformFactory::getAllTransformTypes() | 216 TransformFactory::getAllTransformTypes() |
217 { | 217 { |
218 populateTransforms(); | 218 populateTransforms(); |
219 | 219 |
220 std::set<QString> types; | 220 std::set<TransformDescription::Type> types; |
221 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); | 221 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); |
222 i != m_transforms.end(); ++i) { | 222 i != m_transforms.end(); ++i) { |
223 types.insert(i->second.type); | 223 types.insert(i->second.type); |
224 } | 224 } |
225 | 225 |
226 std::vector<QString> rv; | 226 std::vector<TransformDescription::Type> rv; |
227 for (std::set<QString>::iterator i = types.begin(); i != types.end(); ++i) { | 227 for (std::set<TransformDescription::Type>::iterator i = types.begin(); i != types.end(); ++i) { |
228 rv.push_back(*i); | 228 rv.push_back(*i); |
229 } | 229 } |
230 | 230 |
231 return rv; | 231 return rv; |
232 } | 232 } |
233 | 233 |
234 std::vector<QString> | 234 std::vector<QString> |
235 TransformFactory::getTransformCategories(QString transformType) | 235 TransformFactory::getTransformCategories(TransformDescription::Type transformType) |
236 { | 236 { |
237 populateTransforms(); | 237 populateTransforms(); |
238 | 238 |
239 std::set<QString> categories; | 239 std::set<QString> categories; |
240 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); | 240 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); |
257 | 257 |
258 return rv; | 258 return rv; |
259 } | 259 } |
260 | 260 |
261 std::vector<QString> | 261 std::vector<QString> |
262 TransformFactory::getTransformMakers(QString transformType) | 262 TransformFactory::getTransformMakers(TransformDescription::Type transformType) |
263 { | 263 { |
264 populateTransforms(); | 264 populateTransforms(); |
265 | 265 |
266 std::set<QString> makers; | 266 std::set<QString> makers; |
267 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); | 267 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); |
281 } | 281 } |
282 | 282 |
283 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last | 283 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last |
284 | 284 |
285 return rv; | 285 return rv; |
286 } | |
287 | |
288 QString | |
289 TransformFactory::getTransformTypeName(TransformDescription::Type type) const | |
290 { | |
291 switch (type) { | |
292 case TransformDescription::Analysis: return tr("Analysis"); | |
293 case TransformDescription::Effects: return tr("Effects"); | |
294 case TransformDescription::EffectsData: return tr("Effects Data"); | |
295 case TransformDescription::Generator: return tr("Generator"); | |
296 case TransformDescription::UnknownType: return tr("Other"); | |
297 } | |
286 } | 298 } |
287 | 299 |
288 void | 300 void |
289 TransformFactory::populateTransforms() | 301 TransformFactory::populateTransforms() |
290 { | 302 { |
434 !plugin->getParameterDescriptors().empty()); | 446 !plugin->getParameterDescriptors().empty()); |
435 | 447 |
436 // cerr << "Feature extraction plugin transform: " << transformId.toStdString() << " friendly name: " << friendlyName.toStdString() << endl; | 448 // cerr << "Feature extraction plugin transform: " << transformId.toStdString() << " friendly name: " << friendlyName.toStdString() << endl; |
437 | 449 |
438 transforms[transformId] = | 450 transforms[transformId] = |
439 TransformDescription(tr("Analysis"), | 451 TransformDescription(TransformDescription::Analysis, |
440 category, | 452 category, |
441 transformId, | 453 transformId, |
442 userName, | 454 userName, |
443 friendlyName, | 455 friendlyName, |
444 description, | 456 description, |
537 .arg(pluginName) | 549 .arg(pluginName) |
538 .arg(maker); | 550 .arg(maker); |
539 } | 551 } |
540 | 552 |
541 transforms[transformId] = | 553 transforms[transformId] = |
542 TransformDescription(tr("Effects Data"), | 554 TransformDescription(TransformDescription::EffectsData, |
543 category, | 555 category, |
544 transformId, | 556 transformId, |
545 userName, | 557 userName, |
546 userName, | 558 userName, |
547 "", | 559 "", |
555 if (!descriptor->isSynth || descriptor->audioInputPortCount > 0) { | 567 if (!descriptor->isSynth || descriptor->audioInputPortCount > 0) { |
556 | 568 |
557 if (descriptor->audioOutputPortCount > 0) { | 569 if (descriptor->audioOutputPortCount > 0) { |
558 | 570 |
559 QString transformId = QString("%1:A").arg(pluginId); | 571 QString transformId = QString("%1:A").arg(pluginId); |
560 QString type = tr("Effects"); | 572 TransformDescription::Type type = TransformDescription::Effects; |
561 | 573 |
562 QString description = tr("Transform audio signal with \"%1\" effect plugin (from %2)") | 574 QString description = tr("Transform audio signal with \"%1\" effect plugin (from %2)") |
563 .arg(pluginName) | 575 .arg(pluginName) |
564 .arg(maker); | 576 .arg(maker); |
565 | 577 |
566 if (descriptor->audioInputPortCount == 0) { | 578 if (descriptor->audioInputPortCount == 0) { |
567 type = tr("Generators"); | 579 type = TransformDescription::Generator; |
568 QString description = tr("Generate audio signal using \"%1\" plugin (from %2)") | 580 QString description = tr("Generate audio signal using \"%1\" plugin (from %2)") |
569 .arg(pluginName) | 581 .arg(pluginName) |
570 .arg(maker); | 582 .arg(maker); |
571 } | 583 } |
572 | 584 |
639 | 651 |
640 QString oname = desc.getOutputName(*j); | 652 QString oname = desc.getOutputName(*j); |
641 if (oname == "") oname = *j; | 653 if (oname == "") oname = *j; |
642 | 654 |
643 TransformDescription td; | 655 TransformDescription td; |
644 td.type = tr("Analysis"); //!!! should be enum or something | 656 td.type = TransformDescription::Analysis; |
645 td.category = ""; | 657 td.category = ""; |
646 td.identifier = tid; | 658 td.identifier = tid; |
647 | 659 |
648 if (oids.size() == 1) { | 660 if (oids.size() == 1) { |
649 td.name = name; | 661 td.name = name; |
1061 | 1073 |
1062 TextMatcher::Match match; | 1074 TextMatcher::Match match; |
1063 | 1075 |
1064 match.key = i->first; | 1076 match.key = i->first; |
1065 | 1077 |
1066 matcher.test(match, keywords, i->second.type, tr("Plugin type"), 5); | 1078 matcher.test(match, keywords, |
1079 getTransformTypeName(i->second.type), | |
1080 tr("Plugin type"), 5); | |
1081 | |
1067 matcher.test(match, keywords, i->second.category, tr("Category"), 20); | 1082 matcher.test(match, keywords, i->second.category, tr("Category"), 20); |
1068 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 6); | 1083 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 6); |
1069 matcher.test(match, keywords, i->second.name, tr("Name"), 30); | 1084 matcher.test(match, keywords, i->second.name, tr("Name"), 30); |
1070 matcher.test(match, keywords, i->second.description, tr("Description"), 20); | 1085 matcher.test(match, keywords, i->second.description, tr("Description"), 20); |
1071 matcher.test(match, keywords, i->second.maker, tr("Maker"), 10); | 1086 matcher.test(match, keywords, i->second.maker, tr("Maker"), 10); |
1096 | 1111 |
1097 TextMatcher::Match match; | 1112 TextMatcher::Match match; |
1098 | 1113 |
1099 match.key = i->first; | 1114 match.key = i->first; |
1100 | 1115 |
1101 matcher.test(match, keywords, i->second.type, tr("Plugin type"), 2); | 1116 matcher.test(match, keywords, |
1117 getTransformTypeName(i->second.type), | |
1118 tr("Plugin type"), 2); | |
1119 | |
1102 matcher.test(match, keywords, i->second.category, tr("Category"), 10); | 1120 matcher.test(match, keywords, i->second.category, tr("Category"), 10); |
1103 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 3); | 1121 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 3); |
1104 matcher.test(match, keywords, i->second.name, tr("Name"), 15); | 1122 matcher.test(match, keywords, i->second.name, tr("Name"), 15); |
1105 matcher.test(match, keywords, i->second.description, tr("Description"), 10); | 1123 matcher.test(match, keywords, i->second.description, tr("Description"), 10); |
1106 matcher.test(match, keywords, i->second.maker, tr("Maker"), 5); | 1124 matcher.test(match, keywords, i->second.maker, tr("Maker"), 5); |