Hello everybody! ... and thanks David for your recommendations!

I attached a patch with the modifications necessary to add Description to
networks. This version has corrected the details recommended by David.

Details arranged:

- when the ui file has no real modification, is better not to include it in
the patch. designer often just rewrites the formating from one version to
another. [solved]

> I deleted the file and download it again

- do not include in the patch the networks with dummy descriptions, copy the
networks and work with the copies or just edit the patch to delete them.
[solved]

- DescriptionDefinitionAdapter class is not needed at all, Text is already a
component, so remove the man in the middle and use the XMLComponentAdapter
with the Text. [solved]

> I deleted all traces of DescriptionDefinitionAdapter  :o)

- do not trigger an error if the description is not present, just take it as
empty. [solved]

- and, when storing it, if it is empty, do write it (you are currently
skiping) [solved]

- allow us to migrate silently old networks [solved]

> Every time you open a network and no description is added, it adds the
label <description/>

*Modified classes*:

BaseNetwork.hxx: added virtual method 'get' and 'set' for description.
FlattenedNetwork.cxx: reimplementation of StoreOn and LoadFrom (methods)...
this was necessary to support reading and writing
descriptionsFlattenedNetwork.hxx: added method 'get' and 'set' for
description ant attribute '_description'
MainWindows.hxx: added a _descriptionPanel and _textDescriptionEdit... this
was necessary to show the description

*See you*!! :o)

~ Angelo Scorza ~
"El que no posee el don de maravillarse ni de entusiasmarse más le valdría
estar muerto, porque sus ojos están cerrados." A. Einstein.
Index: NetworkEditor/src/MainWindow.hxx
===================================================================
--- NetworkEditor/src/MainWindow.hxx	(revision 13257)
+++ NetworkEditor/src/MainWindow.hxx	(working copy)
@@ -9,6 +9,7 @@
 #include <QtGui/QMessageBox>
 #include <QtCore/QSettings>
 #include <QtCore/QStringList>
+#include <QTextEdit>
 #include <QtCore/QTimer>
 #include "uic_About.hxx"
 #include <CLAM/Network.hxx>
@@ -108,6 +109,14 @@
 		_processingTreeDock->setWidget(_processingTree);
 		addDockWidget(Qt::LeftDockWidgetArea, _processingTreeDock);
 
+		// add a Description Panel for description of networks
+		_descriptionPanel = new QDockWidget(this);
+		_descriptionPanel->setObjectName("Description");
+		_descriptionPanel->setWindowTitle(tr("Description"));
+		_textDescriptionEdit = new QTextEdit(_descriptionPanel);
+		_descriptionPanel->setWidget(_textDescriptionEdit);
+		addDockWidget(Qt::LeftDockWidgetArea, _descriptionPanel);
+
 		_aboutDialog = new QDialog(this);
 		Ui::About aboutUi;
 		aboutUi.setupUi(_aboutDialog);
@@ -145,11 +154,11 @@
 		periodicPlayStatusUpdate(); // Should be directly called just once
 
 		connect(ui.action_Show_processing_toolbox, SIGNAL(toggled(bool)), _processingTreeDock, SLOT(setVisible(bool)));
-		connect(_processingTreeDock, SIGNAL(visibilityChanged(bool)), ui.action_Show_processing_toolbox, SLOT(setChecked(bool)));
 		connect(ui.action_Print, SIGNAL(triggered()), _canvas, SLOT(print()));
 		connect(_canvas, SIGNAL(changed()), this, SLOT(updateCaption()));
 		connect(_canvas, SIGNAL(openFileWithExternalApplicationRequest()), this, SLOT(openFileWithExternalApplicationFromProcessing()));
 		connect(_canvas, SIGNAL(browseUrlRequest()),this,SLOT(browseUrlInternalFromProcessing()));
+		connect(_textDescriptionEdit, SIGNAL(textChanged()), this, SLOT(updateNetworkDescription()));
 		updateCaption();
 
 	}
@@ -221,6 +230,8 @@
 			clear();
 			return;
 		}
+		_textDescriptionEdit->setText(tr((!_network.GetDescription().empty())?_network.GetDescription().c_str():""));
+
 		_playingLabel->setNetwork(&_network);
 		_canvas->loadNetwork(&_network);
 		_canvas->loadGeometriesFromXML();
@@ -347,6 +358,16 @@
 #endif
 	}
 
+	void updateNetworkDescription()
+	{
+		QString text(_textDescriptionEdit->toPlainText());
+		
+		if(!_canvas->isChanged())
+			_canvas->markAsChanged();
+		
+		_network.SetDescription(text.toStdString());
+	}
+
 	void on_action_Embed_SVG_Diagrams_Option_changed()
 	{
 		QAction *action = qobject_cast<QAction *>(sender());
@@ -541,7 +562,9 @@
 	QLabel * _backendLabel;
 	PlaybackIndicator * _playingLabel;
 	QStringList _recentFiles;
-	
+	QDockWidget * _descriptionPanel;
+	QTextEdit * _textDescriptionEdit; 
+
 	QDockWidget * _processingTreeDock;
 	NetworkGUI::ProcessingTree * _processingTree;
 };
Index: CLAM/src/Flow/Networks/FlattenedNetwork.cxx
===================================================================
--- CLAM/src/Flow/Networks/FlattenedNetwork.cxx	(revision 13257)
+++ CLAM/src/Flow/Networks/FlattenedNetwork.cxx	(working copy)
@@ -29,7 +29,7 @@
 #include "ProcessingFactory.hxx"
 #include "XmlStorageErr.hxx"
 #ifdef USE_LADSPA //TODO alway include it. move conditional code in LFactory.hxx
-#	include "ProcessingFactory.hxx"
+#include "ProcessingFactory.hxx"
 #endif
 #include "CLAMVersion.hxx"
 namespace CLAM
@@ -57,7 +57,10 @@
 		std::string version = CLAM::GetVersion();
 		XMLAdapter<std::string> versionAdapter( version, "clamVersion");
 		storage.Store(versionAdapter);
-
+		
+		XMLAdapter<std::string> descriptionAdapter(_description, "description", true);
+		storage.Store(descriptionAdapter);
+		
 		ProcessingsMap::const_iterator it;
 		for(it=BeginProcessings();it!=EndProcessings();it++)
 		{
@@ -154,6 +157,10 @@
 		storage.Load(strAdapter);
 		_processingsGeometries.clear();
 
+		Text text;
+		XMLAdapter<Text> descriptionAdapter(text, "description", true);
+		_description=(storage.Load(descriptionAdapter))?text:"";
+	
 		while(1)
 		{
 			ProcessingDefinitionAdapter procDefinition;
Index: CLAM/src/Flow/Networks/FlattenedNetwork.hxx
===================================================================
--- CLAM/src/Flow/Networks/FlattenedNetwork.hxx	(revision 13257)
+++ CLAM/src/Flow/Networks/FlattenedNetwork.hxx	(working copy)
@@ -52,6 +52,10 @@
 	// Methods related to network itself
 	const std::string& GetName() const { return _name; }
 	void SetName( const std::string& name ) { _name=name; }
+
+	const std::string& GetDescription() const {return _description;};
+	void SetDescription( const std::string& description ) {_description=description;};
+
 	virtual const char * GetClassName() const
 	{
 		return "FlattenedNetwork";
@@ -177,6 +181,7 @@
 private:
 	// fields
 	std::string _name;
+	std::string _description;
 	ProcessingsMap _processings;
 	FlowControl* _flowControl;
 	NetworkPlayer* _player;
Index: CLAM/src/Flow/Networks/BaseNetwork.hxx
===================================================================
--- CLAM/src/Flow/Networks/BaseNetwork.hxx	(revision 13257)
+++ CLAM/src/Flow/Networks/BaseNetwork.hxx	(working copy)
@@ -75,6 +75,10 @@
 	virtual void SetName( const std::string& name ) = 0;
 	virtual const std::string & GetNetworkId(const Processing * proc) const = 0;
 
+	// description
+	virtual const std::string& GetDescription() const = 0;
+	virtual void SetDescription( const std::string& description ) = 0;
+
 	// accessors to nodes and processing
 	virtual ProcessingsMap::iterator BeginProcessings() = 0; // { return _processings.begin(); }
 	virtual ProcessingsMap::iterator EndProcessings() = 0;// { return _processings.end(); }
_______________________________________________
Clam-devel mailing list
[email protected]
https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel

Reply via email to