El 05/30/2008 02:57 PM, Natanael Olaiz escribió:
El 05/30/2008 07:12 AM, Pau Arumí Albó escribió:
El dj 29 de 05 de 2008 a les 05:49 -0300, en/na Natanael Olaiz va
escriure:
Here I resend the patch of the "Connect to" function, with a little cleaner code, and a patch for a very cheating Copy&Paste processing(s) functionality. It uses QClipboard, but I send only the processings names of actual/selected processings on plain text :-) To do it seriously, I could define a new MIME format and use it in a similar way... or take the David advice to use his XML implementations on the Network (I unsuccessfully tried, I need to study further about all that stuff).


1-ProcesingContextConnectTo.cleanup.patch --> commit 11426
Very nice feature. Thanks!

For the second patch CheatCanvasCopyAndPasteProcessign.patch I got some
errors (rejected chunks) when applying it. So I'll wait for a new
version.

Please, notice me if there are pending patches.

Pau


Here is a little change: it doesn't need to get the icon every time of the loop, just one time by processing. Anyways, I asked before to put the secure get-attribute (or an exist-test) method on CLAM::Factory. What do you think?
...
Here is an example of an implementation of CLAM::Factory::AttributeExists(key,attribute), and its correspondent use getting the icons in NetworkCanvas.


Regards,
Natanael.
Index: NetworkEditor/src/NetworkCanvas.hxx
===================================================================
--- NetworkEditor/src/NetworkCanvas.hxx	(revision 11426)
+++ NetworkEditor/src/NetworkCanvas.hxx	(working copy)
@@ -1523,21 +1523,13 @@
 							QString PortName=(this->*targetPortName)(targetProcessing->model(),targetPort);
 							if (canConnectPorts(_processings[*outProcessing], *outPort, _processings[*inProcessing], *inPort))
 							{
-								//secure method to get icon (to avoid segm. fault when the attribute doesn't exist):
-								CLAM::ProcessingFactory::Pairs pairsFromKey=factory.GetPairsFromKey(targetClassName);
-								CLAM::ProcessingFactory::Pairs::const_iterator itPairs;
-								iconPath="";
-								for (itPairs=pairsFromKey.begin();itPairs!=pairsFromKey.end();itPairs++)
+								if (!submenu)
 								{
-									if(itPairs->attribute=="icon")
+									if (factory.AttributeExists(targetClassName,"icon"))
 									{
-										iconPath=itPairs->value;
+										iconPath=factory.GetValueFromAttribute(targetClassName,"icon");
 										processingIcon = QIcon( QString(":/icons/images/%1").arg(iconPath.c_str()));
-										break;
 									}
-								}
-								if (!submenu)
-								{
 									if (!menuUsedProcessings)
 									{
 										menu->addSeparator();
Index: CLAM/src/Base/Factory.hxx
===================================================================
--- CLAM/src/Base/Factory.hxx	(revision 11426)
+++ CLAM/src/Base/Factory.hxx	(working copy)
@@ -158,6 +158,11 @@
 		return _registry.ExistsKey(key);
 	}
 
+	bool AttributeExists (const std::string& key, const std::string& attribute)
+	{
+		return _registry.AttributeExists(key,attribute);
+	}
+
 	/// Get all keys that have attribute==value in its metadata.
 	Keys GetKeys(const std::string& attribute, const std::string& value)
 	{
@@ -313,6 +318,16 @@
 			}
 			return true;
 		}
+		bool AttributeExists(const std::string& key, const std::string& attribute)
+		{
+			Pairs pairsFromKey = GetPairsFromKey(key);
+			typename Pairs::const_iterator itPairs;
+			for (itPairs=pairsFromKey.begin();itPairs!=pairsFromKey.end();itPairs++)
+			{
+				if (itPairs->attribute==attribute) return true;
+			}
+			return false;
+		}
 
 		/// Get all keys that have attribute==value in its metadata.
 		Keys GetKeys(const std::string& attribute, const std::string& value)
_______________________________________________
Clam-devel mailing list
[email protected]
https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel

Reply via email to