[qet] [2983] -add class for store Xref properties

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


Revision: 2983
Author:   blacksun
Date:     2014-04-11 11:51:21 +0200 (Fri, 11 Apr 2014)
Log Message:
-----------
-add class for store Xref properties
-add widget for edit it
-make link betwen QET -> QETproject -> Diagram, for transmit the xrefproperties
-xrefpropertie can save/load to xml and setting.
-XRefItem don't use the properties yet

Modified Paths:
--------------
    trunk/qelectrotech.pro
    trunk/sources/configpages.cpp
    trunk/sources/configpages.h
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/projectconfigpages.cpp
    trunk/sources/projectconfigpages.h
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h
    trunk/sources/qetproject.cpp
    trunk/sources/qetproject.h

Added Paths:
-----------
    trunk/sources/properties/
    trunk/sources/properties/propertiesinterface.cpp
    trunk/sources/properties/propertiesinterface.h
    trunk/sources/properties/xrefproperties.cpp
    trunk/sources/properties/xrefproperties.h
    trunk/sources/ui/xrefpropertieswidget.cpp
    trunk/sources/ui/xrefpropertieswidget.h
    trunk/sources/ui/xrefpropertieswidget.ui

Modified: trunk/qelectrotech.pro
===================================================================
--- trunk/qelectrotech.pro	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/qelectrotech.pro	2014-04-11 09:51:21 UTC (rev 2983)
@@ -61,12 +61,16 @@
 
 TEMPLATE = app
 DEPENDPATH += .
-INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory
+INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory sources/properties
 
 # Fichiers sources
-HEADERS += sources/*.h   sources/ui/*.h   sources/editor/*.h   sources/titleblock/*.h  sources/richtext/*.h sources/qetgraphicsitem/*.h sources/factory/*.cpp
+HEADERS += sources/*.h   sources/ui/*.h   sources/editor/*.h   sources/titleblock/*.h  sources/richtext/*.h sources/qetgraphicsitem/*.h sources/factory/*.cpp \
+    sources/properties/propertiesinterface.h \
+    sources/properties/xrefproperties.h
 
-SOURCES += sources/*.cpp sources/editor/*.cpp sources/titleblock/*.cpp sources/richtext/*.cpp sources/ui/*.cpp sources/qetgraphicsitem/*.cpp sources/factory/*.cpp
+SOURCES += sources/*.cpp sources/editor/*.cpp sources/titleblock/*.cpp sources/richtext/*.cpp sources/ui/*.cpp sources/qetgraphicsitem/*.cpp sources/factory/*.cpp \
+    sources/properties/propertiesinterface.cpp \
+    sources/properties/xrefproperties.cpp
 
 # Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
 RESOURCES += qelectrotech.qrc
@@ -82,7 +86,8 @@
 
 # UI DESIGNER FILES AND GENERATION SOURCES FILES
 FORMS += sources/richtext/addlinkdialog.ui  sources/ui/*.ui \
-    sources/ui/linksingleelementwidget.ui
+    sources/ui/linksingleelementwidget.ui \
+    sources/ui/xrefpropertieswidget.ui
 UI_SOURCES_DIR = sources/ui/
 UI_HEADERS_DIR = sources/ui/
 

Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/configpages.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -25,6 +25,7 @@
 #include "qeticons.h"
 #include "exportpropertieswidget.h"
 #include "ui/reportpropertiewidget.h"
+#include "ui/xrefpropertieswidget.h"
 
 /**
 	Constructeur
@@ -52,6 +53,10 @@
 	// default propertie of report label
 	rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
 	tab_widget->addTab(rpw, tr("Report de folio"));
+
+	// default properties of xref
+	xrefpw = new XRefPropertiesWidget(QETDiagramEditor::defaultXRefProperties(), this);
+	tab_widget->addTab(xrefpw, tr("R\351f\351rence crois\351es"));
 	
 	QVBoxLayout *vlayout1 = new QVBoxLayout();
 	vlayout1->addWidget(tab_widget);
@@ -80,6 +85,9 @@
 
 	// default report propertie
 	rpw->toSettings(settings, "diagrameditor/defaultreport");
+
+	// default xref properties
+	xrefpw -> properties().toSettings(settings, "diagrameditor/defaultxref");
 }
 
 /// @return l'icone de cette page

Modified: trunk/sources/configpages.h
===================================================================
--- trunk/sources/configpages.h	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/configpages.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -24,6 +24,7 @@
 class TitleBlockPropertiesWidget;
 class ExportPropertiesWidget;
 class ReportPropertieWidget;
+class XRefPropertiesWidget;
 
 /**
 	This configuration page enables users to define the properties of new
@@ -49,7 +50,9 @@
 	BorderPropertiesWidget *bpw;     ///< Widget to edit default diagram dimensions
 	TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties
 	ConductorPropertiesWidget *cpw;  ///< Widget to edit default conductor properties
-	ReportPropertieWidget *rpw;///< Widget to edit default report label
+	ReportPropertieWidget *rpw;		 ///< Widget to edit default report label
+	XRefPropertiesWidget *xrefpw;	 ///< Widget to edit default xref properties
+
 };
 
 /**

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/diagram.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -1187,12 +1187,19 @@
 }
 
 /**
-	@param project le nouveau projet auquel ce schema appartient ou 0 s'il
-	s'agit d'un schema independant. Indiquer 0 pour rendre ce schema independant.
-*/
+ * @brief Diagram::setProject
+ * @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project
+ */
 void Diagram::setProject(QETProject *project) {
+	if (project_) {
+		disconnect (project_, SIGNAL(reportPropertiesChanged(QString)),	  this, SIGNAL(reportPropertiesChanged(QString)));
+		disconnect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties)));
+	}
 	project_ = project;
-	connect(project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
+	if (project_) {
+		connect (project_, SIGNAL(reportPropertiesChanged(QString)),	  this, SIGNAL(reportPropertiesChanged(QString)));
+		connect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties)));
+	}
 }
 
 /**

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/diagram.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -26,6 +26,7 @@
 #include "qgimanager.h"
 #include "numerotationcontext.h"
 #include "qetproject.h"
+#include "properties/xrefproperties.h"
 
 class Conductor;
 class CustomElement;
@@ -102,7 +103,8 @@
 	virtual void keyReleaseEvent(QKeyEvent *);
 	
 	public:
-	QString defaultReportProperties () const {return project_->defaultReportProperties();}
+	QString		   defaultReportProperties () const {return project_ -> defaultReportProperties();}
+	XRefProperties defaultXRefProperties   () const {return project_ -> defaultXrefProperties();}
 	static bool clipboardMayContainDiagram();
 	bool setNumerotation (NumerotationType, NumerotationContext);
 	NumerotationContext getNumerotation (NumerotationType) const;
@@ -210,6 +212,7 @@
 	/// Signal emitted when users wish to edit an element from the diagram
 	void editElementRequired(const ElementsLocation &);
 	void reportPropertiesChanged(QString);
+	void XRefPropertiesChanged(XRefProperties);
 };
 Q_DECLARE_METATYPE(Diagram *)
 

Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/projectconfigpages.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -24,6 +24,7 @@
 #include "titleblockpropertieswidget.h"
 #include <QtGui>
 #include "ui/reportpropertiewidget.h"
+#include "ui/xrefpropertieswidget.h"
 
 /**
 	Constructor
@@ -260,6 +261,12 @@
 		project_->setDefaultReportProperties(new_report_prop);
 		modified_project = true;
 	}
+
+	XRefProperties new_xref_properties = xref_ -> properties();
+	if (project_ -> defaultXrefProperties() != new_xref_properties) {
+		project_ -> setDefaultXRefProperties(new_xref_properties);
+		modified_project = true;
+	}
 	
 	if (modified_project) {
 		project_ -> setModified(modified_project);
@@ -276,11 +283,12 @@
 			"explicative label"
 		)
 	);
-	border_ = new BorderPropertiesWidget(BorderProperties()); 
+	border_		= new BorderPropertiesWidget(BorderProperties());
 	titleblock_ = new TitleBlockPropertiesWidget(TitleBlockProperties(), true);
-	conductor_ = new ConductorPropertiesWidget();
-	conductor_ -> setContentsMargins(0, 0, 0, 0);
-	report_ = new ReportPropertieWidget("_");
+	conductor_  = new ConductorPropertiesWidget();
+	conductor_  -> setContentsMargins(0, 0, 0, 0);
+	report_		= new ReportPropertieWidget("_");
+	xref_		= new XRefPropertiesWidget();
 }
 
 /**
@@ -294,12 +302,12 @@
 	QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
 	diagram_layout -> addWidget(border_);
 	diagram_layout -> addWidget(titleblock_);
-	tab_widget->addTab(diagram_widget, tr("Sch\351ma"));
 
-	tab_widget->addTab(conductor_, tr("Conducteur"));
+	tab_widget -> addTab (diagram_widget, tr("Sch\351ma"));
+	tab_widget -> addTab (conductor_,	  tr("Conducteur"));
+	tab_widget -> addTab (report_,		  tr("Report de folio"));
+	tab_widget -> addTab (xref_,		  tr("R\351f\351rence crois\351es"));
 
-	tab_widget->addTab(report_, tr("Report de folio"));
-
 	QVBoxLayout *vlayout1 = new QVBoxLayout();
 	vlayout1->addWidget(tab_widget);
 
@@ -310,19 +318,20 @@
 	Read properties from the edited project then fill widgets with them.
 */
 void ProjectNewDiagramConfigPage::readValuesFromProject() {
-	border_ -> setEditedBorder(project_ -> defaultBorderProperties());
-	conductor_ -> setConductorProperties(project_ -> defaultConductorProperties());
-	titleblock_ -> setTitleBlockProperties(project_ -> defaultTitleBlockProperties());
-	report_->setReportProperties(project_->defaultReportProperties());
+	border_		-> setEditedBorder		   (project_ -> defaultBorderProperties());
+	conductor_	-> setConductorProperties  (project_ -> defaultConductorProperties());
+	titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
+	report_		-> setReportProperties	   (project_ -> defaultReportProperties());
+	xref_		-> setProperties		   (project_ -> defaultXrefProperties());
 }
 
 /**
-	Set the content of this page read only if the project is read only,
 	editable if the project is editable.
  */
 void ProjectNewDiagramConfigPage::adjustReadOnly() {
 	bool is_read_only = project_ -> isReadOnly();
-	border_ -> setReadOnly(is_read_only);
+	border_		-> setReadOnly(is_read_only);
 	titleblock_ -> setReadOnly(is_read_only);
-	conductor_ -> setReadOnly(is_read_only);
+	conductor_  -> setReadOnly(is_read_only);
+	xref_		-> setReadOnly(is_read_only);
 }

Modified: trunk/sources/projectconfigpages.h
===================================================================
--- trunk/sources/projectconfigpages.h	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/projectconfigpages.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -26,6 +26,7 @@
 class ConductorPropertiesWidget;
 class DiagramContextWidget;
 class ReportPropertieWidget;
+class XRefPropertiesWidget;
 
 /**
 	This class, derived from ConfigPage, aims at providing the basic skeleton
@@ -144,6 +145,7 @@
 	TitleBlockPropertiesWidget *titleblock_;
 	ConductorPropertiesWidget *conductor_;
 	ReportPropertieWidget *report_;
+	XRefPropertiesWidget *xref_;
 };
 
 #endif

Added: trunk/sources/properties/propertiesinterface.cpp
===================================================================
--- trunk/sources/properties/propertiesinterface.cpp	                        (rev 0)
+++ trunk/sources/properties/propertiesinterface.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,22 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "propertiesinterface.h"
+
+PropertiesInterface::PropertiesInterface()
+{
+}

Added: trunk/sources/properties/propertiesinterface.h
===================================================================
--- trunk/sources/properties/propertiesinterface.h	                        (rev 0)
+++ trunk/sources/properties/propertiesinterface.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,41 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef PROPERTIESINTERFACE_H
+#define PROPERTIESINTERFACE_H
+
+#include <QString>
+#include <QSettings>
+#include <QDomElement>
+
+/**
+ * @brief The PropertiesInterface class
+ * This class is an interface for have common way to use properties in QElectroTech
+ */
+class PropertiesInterface
+{
+	public:
+	PropertiesInterface();
+	// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
+	virtual void toSettings	  (QSettings &settings, const QString = QString()) const =0;
+	virtual void fromSettings (const QSettings &settings, const QString = QString()) =0;
+	// Save/load properties to xml element
+	virtual void toXml		  (QDomElement &xml_element) const =0;
+	virtual void fromXml	  (const QDomElement &xml_element) =0;
+};
+
+#endif // PROPERTIESINTERFACE_H

Added: trunk/sources/properties/xrefproperties.cpp
===================================================================
--- trunk/sources/properties/xrefproperties.cpp	                        (rev 0)
+++ trunk/sources/properties/xrefproperties.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,74 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "xrefproperties.h"
+
+/**
+ * @brief XRefProperties::XRefProperties
+ * Default Constructor
+ */
+XRefProperties::XRefProperties()
+{
+}
+
+/**
+ * @brief XRefProperties::toSettings
+ * Save to settings
+ * @param settings: QSettings to use
+ * @param prefix: prefix before properties name
+ */
+void XRefProperties::toSettings(QSettings &settings, const QString prefix) const {
+	settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
+}
+
+/**
+ * @brief XRefProperties::fromSettings
+ * load from settings
+ * @param settings: QSettings to use
+ * @param prefix: prefix before properties name
+ */
+void XRefProperties::fromSettings(const QSettings &settings, const QString prefix) {
+	m_show_power_ctc = settings.value(prefix + "showpowerctc", false).toBool();
+}
+
+/**
+ * @brief XRefProperties::toXml
+ * Save to xml
+ * @param xml_element: QDomElement to use for saving
+ */
+void XRefProperties::toXml(QDomElement &xml_element) const {
+	xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "fasle");
+}
+
+/**
+ * @brief XRefProperties::fromXml
+ * Load from xml
+ * @param xml_element: QDomElement to use for load
+ */
+void XRefProperties::fromXml(const QDomElement &xml_element) {
+	m_show_power_ctc = xml_element.attribute("showpowerctc")  == "true";
+}
+
+bool XRefProperties::operator ==(const XRefProperties &xrp) const{
+	return (m_show_power_ctc == xrp.m_show_power_ctc);
+}
+
+bool XRefProperties::operator !=(const XRefProperties &xrp) const {
+	return (! (*this == xrp));
+}
+
+

Added: trunk/sources/properties/xrefproperties.h
===================================================================
--- trunk/sources/properties/xrefproperties.h	                        (rev 0)
+++ trunk/sources/properties/xrefproperties.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,47 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef XREFPROPERTIES_H
+#define XREFPROPERTIES_H
+
+#include "propertiesinterface.h"
+
+/**
+ * @brief The XRefProperties class
+ * this class store properties used by XrefItem
+ */
+class XRefProperties : public PropertiesInterface
+{
+	public:
+	XRefProperties();
+
+	virtual void toSettings	  (QSettings &settings, const QString = QString()) const;
+	virtual void fromSettings (const QSettings &settings, const QString = QString());
+	virtual void toXml		  (QDomElement &xml_element) const;
+	virtual void fromXml	  (const QDomElement &xml_element);
+
+	bool operator == (const XRefProperties &xrp) const;
+	bool operator != (const XRefProperties &xrp) const;
+
+	void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
+	bool showPowerContact	() const	   {return m_show_power_ctc;}
+
+	private:
+	bool m_show_power_ctc;
+};
+
+#endif // XREFPROPERTIES_H

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/qetdiagrameditor.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -651,17 +651,20 @@
 }
 
 /**
-	Cree un nouveau projet vide
-*/
+ * @brief QETDiagramEditor::newProject
+ * Create an empty project
+ * @return
+ */
 bool QETDiagramEditor::newProject() {
-	// cree un nouveau projet sans schema
+	// create new project without diagram
 	QETProject *new_project = new QETProject(0);
 	
-	// transmet les proprietes par defaut des nouveaux schemas
-	new_project -> setDefaultBorderProperties(defaultBorderProperties());
-	new_project -> setDefaultConductorProperties(defaultConductorProperties());
-	new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties());
-	new_project -> setDefaultReportProperties(defaultReportProperties());
+	// Set default properties for new diagram
+	new_project -> setDefaultBorderProperties	  (defaultBorderProperties());
+	new_project -> setDefaultConductorProperties  (defaultConductorProperties());
+	new_project -> setDefaultTitleBlockProperties (defaultTitleBlockProperties());
+	new_project -> setDefaultReportProperties	  (defaultReportProperties());
+	new_project -> setDefaultXRefProperties		  (defaultXRefProperties());
 	
 	// add new diagram
 	new_project -> addNewDiagram();
@@ -2084,3 +2087,13 @@
 	QSettings &settings= QETApp::settings();
 	return(settings.value("diagrameditor/defaultreportlabel", "%f-%l%c").toString());
 }
+
+/**
+ * @brief QETDiagramEditor::defaultXRefProperties
+ * @return the default setting for Xref
+ */
+XRefProperties QETDiagramEditor::defaultXRefProperties() {
+	XRefProperties properties;
+	properties.fromSettings(QETApp::settings(), "diagrameditor/defaultxref");
+	return properties;
+}

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/qetdiagrameditor.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -23,6 +23,8 @@
 #include "conductorproperties.h"
 #include "titleblockproperties.h"
 #include "exportproperties.h"
+#include "properties/xrefproperties.h"
+
 class QETProject;
 class QETResult;
 class ProjectView;
@@ -62,7 +64,8 @@
 	static ConductorProperties defaultConductorProperties();
 	static ExportProperties    defaultExportProperties();
 	static ExportProperties    defaultPrintProperties();
-	static QString defaultReportProperties();
+	static QString			   defaultReportProperties();
+	static XRefProperties	   defaultXRefProperties();
 	
 	protected:
 	void actions();

Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/qetproject.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -29,7 +29,6 @@
 #include "basicmoveelementshandler.h"
 #include "qetmessagebox.h"
 #include "titleblocktemplate.h"
-
 #include "ui/dialogwaiting.h"
 
 QString QETProject::integration_category_name = "import";
@@ -452,6 +451,15 @@
 	emit reportPropertiesChanged(properties);
 }
 
+XRefProperties QETProject::defaultXrefProperties() const{
+	return m_default_xref_properties;
+}
+
+void QETProject::setDefaultXRefProperties(const XRefProperties &properties) {
+	m_default_xref_properties = properties;
+	emit XRefPropertiesChanged(properties);
+}
+
 /**
 	@return un document XML representant le projet 
 */
@@ -481,7 +489,7 @@
 	writeProjectPropertiesXml(project_properties);
 	project_root.appendChild(project_properties);
 	
-	// proprietes pour les nouveaux schemas
+	// Properties for news diagrams
 	QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
 	writeDefaultPropertiesXml(new_diagrams_properties);
 	project_root.appendChild(new_diagrams_properties);
@@ -1139,29 +1147,27 @@
 }
 
 /**
-	Charge les proprietes par defaut des nouveaux schemas depuis la description
-	XML du projet :
-	  * dimensions
-	  * contenu du cartouche
-	  * conducteurs par defaut
-*/
+ * @brief QETProject::readDefaultPropertiesXml
+ * load default properties for new diagram, found in the xml of this project
+ * or by default find in the QElectroTech global conf
+ */
 void QETProject::readDefaultPropertiesXml() {
-	// repere l'element XML decrivant les proprietes des nouveaux schemas
+	// Find xml element where is stored properties for new diagram
 	QDomNodeList newdiagrams_nodes = document_root_.elementsByTagName("newdiagrams");
 	if (newdiagrams_nodes.isEmpty()) return;
 	
 	QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
 	
-	// par defaut, les valeurs sont celles de la configuration QElectroTech
-	default_border_properties_    = QETDiagramEditor::defaultBorderProperties();
-	default_titleblock_properties_     = QETDiagramEditor::defaultTitleBlockProperties();
-	default_conductor_properties_ = QETDiagramEditor::defaultConductorProperties();
-	default_report_properties_ = QETDiagramEditor::defaultReportProperties();
+	// By default, use value find in the global conf of QElectroTech
+	default_border_properties_	   = QETDiagramEditor::defaultBorderProperties();
+	default_titleblock_properties_ = QETDiagramEditor::defaultTitleBlockProperties();
+	default_conductor_properties_  = QETDiagramEditor::defaultConductorProperties();
+	default_report_properties_	   = QETDiagramEditor::defaultReportProperties();
+	m_default_xref_properties	   = QETDiagramEditor::defaultXRefProperties();
 	
-	// lecture des valeurs indiquees dans le projet
-	QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt;
+	//Read values indicate in project
+	QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt;
 	
-	// recherche des elements XML concernant les dimensions, le cartouche et les conducteurs
 	for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) {
 		QDomElement child_elmt = child.toElement();
 		if (child_elmt.isNull()) continue;
@@ -1173,38 +1179,44 @@
 			conductors_elmt = child_elmt;
 		} else if (child_elmt.tagName() == "report") {
 			report_elmt = child_elmt;
+		} else if (child_elmt.tagName() == "xref") {
+			xref_elmt = child_elmt;
 		}
 	}
 	
 	// size, titleblock, conductor, report
-	if (!border_elmt.isNull())     default_border_properties_.fromXml(border_elmt);
-	if (!titleblock_elmt.isNull())      default_titleblock_properties_.fromXml(titleblock_elmt);
+	if (!border_elmt.isNull())	   default_border_properties_.fromXml(border_elmt);
+	if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
 	if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
-	if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label"));
+	if (!report_elmt.isNull())	   setDefaultReportProperties(report_elmt.attribute("label"));
+	if (!xref_elmt.isNull())	   m_default_xref_properties.fromXml(xref_elmt);
 }
 
+
 /**
-	Exporte les proprietes par defaut des nouveaux schemas dans l'element XML :
-	  * dimensions
-	  * contenu du cartouche
-	  * conducteurs par defaut
-	@param xml_element Element XML sous lequel seront exportes les proprietes
-	par defaut des nouveaux schemas 
-*/
+ * @brief QETProject::writeDefaultPropertiesXml
+ * Export all defaults properties used by a new diagram and his content
+ * #size of border
+ * #content of titleblock
+ * #default conductor
+ * #defaut folio report
+ * #default Xref
+ * @param xml_element xml element to use for store default propertie.
+ */
 void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
 	QDomDocument xml_document = xml_element.ownerDocument();
 	
-	// exporte les dimensions
+	// export size of border
 	QDomElement border_elmt = xml_document.createElement("border");
 	default_border_properties_.toXml(border_elmt);
 	xml_element.appendChild(border_elmt);
 	
-	// exporte le contenu du cartouche
+	// export content of titleblock
 	QDomElement titleblock_elmt = xml_document.createElement("inset");
 	default_titleblock_properties_.toXml(titleblock_elmt);
 	xml_element.appendChild(titleblock_elmt);
 	
-	// exporte le type de conducteur par defaut
+	// exporte default conductor
 	QDomElement conductor_elmt = xml_document.createElement("conductors");
 	default_conductor_properties_.toXml(conductor_elmt);
 	xml_element.appendChild(conductor_elmt);
@@ -1213,6 +1225,11 @@
 	QDomElement report_elmt = xml_document.createElement("report");
 	report_elmt.setAttribute("label", defaultReportProperties());
 	xml_element.appendChild(report_elmt);
+
+	// export default XRef properties
+	QDomElement xref_elmt = xml_document.createElement("xref");
+	defaultXrefProperties().toXml(xref_elmt);
+	xml_element.appendChild(xref_elmt);
 }
 
 /**

Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h	2014-04-11 08:06:55 UTC (rev 2982)
+++ trunk/sources/qetproject.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -25,6 +25,7 @@
 #include "conductorproperties.h"
 #include "titleblockproperties.h"
 #include "templatescollection.h"
+#include "properties/xrefproperties.h"
 
 class Diagram;
 class ElementsCollection;
@@ -99,6 +100,8 @@
 	void setDefaultConductorProperties(const ConductorProperties &);
 	QString defaultReportProperties() const;
 	void setDefaultReportProperties (const QString &properties);
+	XRefProperties defaultXrefProperties () const;
+	void setDefaultXRefProperties(const XRefProperties &properties);
 	QDomDocument toXml();
 	bool close();
 	QETResult write();
@@ -144,6 +147,7 @@
 	void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
 	void readOnlyChanged(QETProject *, bool);
 	void reportPropertiesChanged(QString);
+	void XRefPropertiesChanged (XRefProperties);
 	
 	private slots:
 	void updateDiagramsFolioData();
@@ -201,6 +205,8 @@
 	TitleBlockProperties default_titleblock_properties_;
 	/// Default report properties
 	QString default_report_properties_;
+	/// Default xref properties
+	XRefProperties m_default_xref_properties;
 	/// Embedded title block templates collection
 	TitleBlockTemplatesProjectCollection titleblocks_;
 	/// project-wide variables that will be made available to child diagrams

Added: trunk/sources/ui/xrefpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.cpp	                        (rev 0)
+++ trunk/sources/ui/xrefpropertieswidget.cpp	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,80 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "xrefpropertieswidget.h"
+#include "ui_xrefpropertieswidget.h"
+#include "qdebug.h"
+
+/**
+ * @brief XRefPropertiesWidget::XRefPropertiesWidget
+ * Default constructor
+ * @param properties: properties to use
+ * @param parent: parent widget
+ */
+XRefPropertiesWidget::XRefPropertiesWidget(XRefProperties properties, QWidget *parent) :
+	QWidget(parent),
+	ui(new Ui::XRefPropertiesWidget),
+	m_properties(properties)
+{
+	ui->setupUi(this);
+	updateDisplay();
+}
+
+/**
+ * @brief XRefPropertiesWidget::~XRefPropertiesWidget
+ * Default destructor
+ */
+XRefPropertiesWidget::~XRefPropertiesWidget()
+{
+	delete ui;
+}
+
+/**
+ * @brief XRefPropertiesWidget::setProperties
+ * set new properties for this widget
+ * @param properties
+ */
+void XRefPropertiesWidget::setProperties(const XRefProperties &properties) {
+	m_properties = properties;
+	updateDisplay();
+}
+
+/**
+ * @brief XRefPropertiesWidget::properties
+ * @return the propertie edited by this widget
+ */
+XRefProperties XRefPropertiesWidget::properties() {
+	m_properties.setShowPowerContac(ui->cb_show_power->isChecked());
+	return m_properties;
+}
+
+/**
+ * @brief XRefPropertiesWidget::setReadOnly
+ * Set all of this widget disable if true
+ * @param ro
+ */
+void XRefPropertiesWidget::setReadOnly(bool ro) {
+	ui->cb_show_power->setDisabled(ro);
+}
+
+/**
+ * @brief XRefPropertiesWidget::updateDisplay
+ * Update display with the content of the properties
+ */
+void XRefPropertiesWidget::updateDisplay() {
+	ui->cb_show_power->setChecked(m_properties.showPowerContact());
+}

Added: trunk/sources/ui/xrefpropertieswidget.h
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.h	                        (rev 0)
+++ trunk/sources/ui/xrefpropertieswidget.h	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,53 @@
+/*
+	Copyright 2006-2014 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef XREFPROPERTIESWIDGET_H
+#define XREFPROPERTIESWIDGET_H
+
+#include <QWidget>
+#include "properties/xrefproperties.h"
+
+namespace Ui {
+	class XRefPropertiesWidget;
+}
+
+/**
+ * @brief The XRefPropertiesWidget class
+ * This class provide a widget to edit the XRefProperties
+ */
+class XRefPropertiesWidget : public QWidget
+{
+	Q_OBJECT
+
+	public:
+	XRefPropertiesWidget(XRefProperties properties = XRefProperties(), QWidget *parent = 0);
+	~XRefPropertiesWidget();
+
+	void setProperties (const XRefProperties &properties);
+	XRefProperties properties();
+
+	void setReadOnly (bool = true);
+
+	private:
+	void updateDisplay();
+
+	private:
+	Ui::XRefPropertiesWidget *ui;
+	XRefProperties m_properties;
+};
+
+#endif // XREFPROPERTIESWIDGET_H

Added: trunk/sources/ui/xrefpropertieswidget.ui
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.ui	                        (rev 0)
+++ trunk/sources/ui/xrefpropertieswidget.ui	2014-04-11 09:51:21 UTC (rev 2983)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>XRefPropertiesWidget</class>
+ <widget class="QWidget" name="XRefPropertiesWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QCheckBox" name="cb_show_power">
+     <property name="text">
+      <string>Afficher les contacts de puissance dans la croix</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>253</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>


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