[qet] [3564] Diagram : Constructor need a QETProject

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3564
Author:   blacksun
Date:     2014-12-21 13:50:26 +0100 (Sun, 21 Dec 2014)
Log Message:
-----------
Diagram : Constructor need a QETProject

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/diagramfoliolist.cpp
    trunk/sources/diagramfoliolist.h
    trunk/sources/qetproject.cpp

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-12-21 12:15:45 UTC (rev 3563)
+++ trunk/sources/diagram.cpp	2014-12-21 12:50:26 UTC (rev 3564)
@@ -41,20 +41,23 @@
 
 // static variable to keep track of present background color of the diagram.
 QColor		Diagram::background_color = Qt::white;
+
 /**
-	Constructeur
-	@param parent Le QObject parent du schema
-*/
-Diagram::Diagram(QObject *parent) :
-	QGraphicsScene(parent),
-	project_(0),
-	diagram_qet_version_(-1),
-	draw_grid_(true),
-	use_border_(true),
-	draw_terminals_(true),
-	draw_colored_conductors_(true),
-	read_only_(false)
+ * @brief Diagram::Diagram
+ * Constructor
+ * @param project : The project of this diagram and also parent QObject
+ */
+Diagram::Diagram(QETProject *project) :
+	QGraphicsScene           (project),
+	project_                 (nullptr),
+	diagram_qet_version_     (-1),
+	draw_grid_               (true),
+	use_border_              (true),
+	draw_terminals_          (true),
+	draw_colored_conductors_ (true),
+	read_only_               (false)
 {
+	setProject(project);
 	qgi_manager_ = new QGIManager(this);
 	setBackgroundBrush(Qt::white);
 	conductor_setter_ = new QGraphicsLineItem(0, 0);
@@ -66,18 +69,12 @@
 	conductor_setter_ -> setPen(t);
 	conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
 	
-	// initialise les objets gerant les deplacements
-	elements_mover_ = new ElementsMover();           // deplacements d'elements/conducteurs/textes
-	element_texts_mover_ = new ElementTextsMover();  // deplacements d'ElementTextItem
+		//Init object for manage movement
+	elements_mover_      = new ElementsMover();
+	element_texts_mover_ = new ElementTextsMover();
 
-	connect(
-		&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)),
-		this, SLOT(setTitleBlockTemplate(const QString &))
-	);
-	connect(
-		&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
-		this, SLOT(titleChanged(const QString &))
-	);
+	connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
+	connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),    this, SLOT(titleChanged(const QString &)));
 }
 
 /**
@@ -1203,18 +1200,24 @@
 
 /**
  * @brief Diagram::setProject
- * @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project
+ * Set parent project of this diagram, project also become the parent QObject of this diagram
+ * @param project new project
  */
-void Diagram::setProject(QETProject *project) {
-	if (project_) {
-		disconnect (project_, SIGNAL(reportPropertiesChanged(QString)),	  this, SIGNAL(reportPropertiesChanged(QString)));
-		disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
+void Diagram::setProject(QETProject *project)
+{
+	if (project_ == project) return;
+
+	if (project_)
+	{
+		disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
+		disconnect (project_, SIGNAL(XRefPropertiesChanged()),          this, SIGNAL(XRefPropertiesChanged()));
 	}
+
 	project_ = project;
-	if (project_) {
-		connect (project_, SIGNAL(reportPropertiesChanged(QString)),	  this, SIGNAL(reportPropertiesChanged(QString)));
-		connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
-	}
+	setParent (project);
+
+	connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
+	connect (project_, SIGNAL(XRefPropertiesChanged()),          this, SIGNAL(XRefPropertiesChanged()));
 }
 
 /**

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2014-12-21 12:15:45 UTC (rev 3563)
+++ trunk/sources/diagram.h	2014-12-21 12:50:26 UTC (rev 3564)
@@ -47,16 +47,16 @@
 	This class represents an electric diagram. It manages its various child
 	elements, conductors and texts and handles their graphic rendering.
 */
-class Diagram : public QGraphicsScene {
+class Diagram : public QGraphicsScene
+{
 	Q_OBJECT
 	
-	// constructors, destructor
+		// constructors, destructor
 	public:
-	Diagram(QObject * = 0);
-	virtual ~Diagram();
-	
+		Diagram(QETProject *project);
+		virtual ~Diagram();
 	private:
-	Diagram(const Diagram &diagram);
+		Diagram(const Diagram &diagram);
 	
 	// ATTRIBUTES
 	public:

Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp	2014-12-21 12:15:45 UTC (rev 3563)
+++ trunk/sources/diagramfoliolist.cpp	2014-12-21 12:50:26 UTC (rev 3564)
@@ -24,16 +24,12 @@
 /**
  * @brief DiagramFolioList::DiagramFolioList
  * Constructor
- * @param project QETproject *: The project from which this constructor was called. Important to setProject().
- * @param parent parent QObject
+ * @param project : The project of this diagram and also parent QObject
  */
-DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
-	if (project) {
-		setProject(project);
-		id = project -> getFolioSheetsQuantity();
-	}
-	else
-		id = 0;
+DiagramFolioList::DiagramFolioList( QETProject *project) :
+	Diagram(project)
+{
+	id = project -> getFolioSheetsQuantity();
 }
 
 /**

Modified: trunk/sources/diagramfoliolist.h
===================================================================
--- trunk/sources/diagramfoliolist.h	2014-12-21 12:15:45 UTC (rev 3563)
+++ trunk/sources/diagramfoliolist.h	2014-12-21 12:50:26 UTC (rev 3564)
@@ -24,7 +24,7 @@
 class DiagramFolioList : public Diagram
 {
 	public:
-	DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
+	DiagramFolioList(QETProject *project);
 	virtual ~DiagramFolioList();
 	virtual QList<QLineF *> lines() const		{return list_lines_;}
 	virtual QList<QRectF *> rectangles() const	{return list_rectangles_;}

Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp	2014-12-21 12:15:45 UTC (rev 3563)
+++ trunk/sources/qetproject.cpp	2014-12-21 12:50:26 UTC (rev 3564)
@@ -902,7 +902,7 @@
 	if (isReadOnly()) return(0);
 	
 	// cree un nouveau schema
-	Diagram *diagram = new Diagram();
+	Diagram *diagram = new Diagram(this);
 	
 	// lui transmet les parametres par defaut
 	diagram -> border_and_titleblock.importBorder(defaultBorderProperties());
@@ -1120,8 +1120,7 @@
 		dlgWaiting->setProgressBar(i+1);
 		if (diagram_nodes.at(i).isElement()) {
 			QDomElement diagram_xml_element = diagram_nodes.at(i).toElement();
-			Diagram *diagram = new Diagram();
-			diagram -> setProject(this);
+			Diagram *diagram = new Diagram(this);
 			bool diagram_loading = diagram -> initFromXml(diagram_xml_element);
 			if (diagram_loading) {
 				dlgWaiting->setDetail( diagram->title() );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/