diff transform/TransformFactory.cpp @ 80:f4f52566e451

* Fixes to presentation and organisation of plugins (especially duplicates)
author Chris Cannam
date Fri, 15 Dec 2006 16:34:17 +0000
parents bedc7517b6e8
children dd11619b73ba
line wrap: on
line diff
--- a/transform/TransformFactory.cpp	Fri Dec 08 18:17:29 2006 +0000
+++ b/transform/TransformFactory.cpp	Fri Dec 15 16:34:17 2006 +0000
@@ -149,17 +149,30 @@
     populateFeatureExtractionPlugins(transforms);
     populateRealTimePlugins(transforms);
 
-    // disambiguate plugins with similar descriptions
+    // disambiguate plugins with similar names
 
     std::map<QString, int> descriptions;
+    std::map<QString, QString> pluginSources;
+    std::map<QString, QString> pluginMakers;
 
     for (TransformDescriptionMap::iterator i = transforms.begin();
          i != transforms.end(); ++i) {
 
         TransformDesc desc = i->second;
 
-	++descriptions[desc.description];
-	++descriptions[QString("%1 [%2]").arg(desc.description).arg(desc.maker)];
+        QString td = desc.description;
+        QString tn = td.section(": ", 0, 0);
+        QString pn = desc.name.section(":", 1, 1);
+
+        if (pluginSources.find(tn) != pluginSources.end()) {
+            if (pluginSources[tn] != pn && pluginMakers[tn] != desc.maker) {
+                ++descriptions[tn];
+            }
+        } else {
+            ++descriptions[tn];
+            pluginSources[tn] = pn;
+            pluginMakers[tn] = desc.maker;
+        }
     }
 
     std::map<QString, int> counts;
@@ -170,18 +183,23 @@
 
         TransformDesc desc = i->second;
 	QString name = desc.name;
-        QString description = desc.description;
         QString maker = desc.maker;
 
-	if (descriptions[description] > 1) {
-	    description = QString("%1 [%2]").arg(description).arg(maker);
-	    if (descriptions[description] > 1) {
-		description = QString("%1 <%2>")
-		    .arg(description).arg(++counts[description]);
-	    }
+        QString td = desc.description;
+        QString tn = td.section(": ", 0, 0);
+        QString to = td.section(": ", 1);
+
+	if (descriptions[tn] > 1) {
+            maker.replace(QRegExp(tr(" [\\(<].*$")), "");
+	    tn = QString("%1 [%2]").arg(tn).arg(maker);
 	}
 
-        desc.description = description;
+        if (to != "") {
+            desc.description = QString("%1: %2").arg(tn).arg(to);
+        } else {
+            desc.description = tn;
+        }
+
 	m_transforms[name] = desc;
     }	    
 }