[qet] [3185] xref properties widget: user can define the behavior of xref for coil and protection.

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


Revision: 3185
Author:   blacksun
Date:     2014-07-03 10:52:14 +0200 (Thu, 03 Jul 2014)
Log Message:
-----------
xref properties widget: user can define the behavior of xref for coil and protection.
They don't work now with official collection, because we must to update the information of element (type coil or protection).
You can test it by creating new master element (dont forget to define the master type, coil or protection).

Modified Paths:
--------------
    trunk/sources/configpages.cpp
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/projectconfigpages.cpp
    trunk/sources/properties/xrefproperties.cpp
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h
    trunk/sources/qetgraphicsitem/crossrefitem.cpp
    trunk/sources/qetgraphicsitem/crossrefitem.h
    trunk/sources/qetproject.cpp
    trunk/sources/qetproject.h
    trunk/sources/ui/xrefpropertieswidget.cpp
    trunk/sources/ui/xrefpropertieswidget.h
    trunk/sources/ui/xrefpropertieswidget.ui

Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/configpages.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -87,7 +87,12 @@
 	rpw->toSettings(settings, "diagrameditor/defaultreport");
 
 	// default xref properties
-	xrefpw -> properties().toSettings(settings, "diagrameditor/defaultxref");
+	QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
+	foreach (QString key, hash_xrp.keys()) {
+		XRefProperties xrp = hash_xrp[key];
+		QString str("diagrameditor/defaultxref");
+		xrp.toSettings(settings, str += key);
+	}
 }
 
 /// @return l'icone de cette page

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/diagram.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -1203,12 +1203,12 @@
 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)));
+		disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
 	}
 	project_ = project;
 	if (project_) {
 		connect (project_, SIGNAL(reportPropertiesChanged(QString)),	  this, SIGNAL(reportPropertiesChanged(QString)));
-		connect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties)));
+		connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
 	}
 }
 

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/diagram.h	2014-07-03 08:52:14 UTC (rev 3185)
@@ -104,7 +104,7 @@
 	
 	public:
 	QString		   defaultReportProperties () const {return project_ -> defaultReportProperties();}
-	XRefProperties defaultXRefProperties   () const {return project_ -> defaultXrefProperties();}
+	XRefProperties defaultXRefProperties   (const QString &str) const {return project_ -> defaultXRefProperties(str);}
 	static bool clipboardMayContainDiagram();
 	bool setNumerotation (NumerotationType, NumerotationContext);
 	NumerotationContext getNumerotation (NumerotationType) const;
@@ -213,7 +213,7 @@
 	/// Signal emitted when users wish to edit an element from the diagram
 	void editElementRequired(const ElementsLocation &);
 	void reportPropertiesChanged(QString);
-	void XRefPropertiesChanged(XRefProperties);
+	void XRefPropertiesChanged();
 };
 Q_DECLARE_METATYPE(Diagram *)
 

Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/projectconfigpages.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -262,8 +262,8 @@
 		modified_project = true;
 	}
 
-	XRefProperties new_xref_properties = xref_ -> properties();
-	if (project_ -> defaultXrefProperties() != new_xref_properties) {
+	QHash<QString, XRefProperties> new_xref_properties = xref_ -> properties();
+	if (project_ -> defaultXRefProperties() != new_xref_properties) {
 		project_ -> setDefaultXRefProperties(new_xref_properties);
 		modified_project = true;
 	}
@@ -288,7 +288,7 @@
 	conductor_  = new ConductorPropertiesWidget();
 	conductor_  -> setContentsMargins(0, 0, 0, 0);
 	report_		= new ReportPropertieWidget("_");
-	xref_		= new XRefPropertiesWidget(XRefProperties());
+	xref_		= new XRefPropertiesWidget();
 }
 
 /**
@@ -322,7 +322,7 @@
 	conductor_	-> setConductorProperties  (project_ -> defaultConductorProperties());
 	titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
 	report_		-> setReportProperties	   (project_ -> defaultReportProperties());
-	xref_		-> setProperties		   (project_ -> defaultXrefProperties());
+	xref_		-> setProperties		   (project_ -> defaultXRefProperties());
 }
 
 /**

Modified: trunk/sources/properties/xrefproperties.cpp
===================================================================
--- trunk/sources/properties/xrefproperties.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/properties/xrefproperties.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -22,7 +22,11 @@
  * Default Constructor
  */
 XRefProperties::XRefProperties()
-{}
+{
+	m_show_power_ctc = true;
+	m_display = Cross;
+	m_snap_to = Bottom;
+}
 
 /**
  * @brief XRefProperties::toSettings

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetdiagrameditor.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -2076,8 +2076,15 @@
  * @brief QETDiagramEditor::defaultXRefProperties
  * @return the default setting for Xref
  */
-XRefProperties QETDiagramEditor::defaultXRefProperties() {
-	XRefProperties properties;
-	properties.fromSettings(QETApp::settings(), "diagrameditor/defaultxref");
-	return properties;
+QHash <QString, XRefProperties> QETDiagramEditor::defaultXRefProperties() {
+	QHash <QString, XRefProperties> hash;
+	QStringList keys;
+	keys << "coil" << "protection";
+	foreach (QString key, keys) {
+		XRefProperties properties;
+		QString str("diagrameditor/defaultxref");
+		properties.fromSettings(QETApp::settings(), str += key);
+		hash.insert(key, properties);
+	}
+	return hash;
 }

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetdiagrameditor.h	2014-07-03 08:52:14 UTC (rev 3185)
@@ -59,13 +59,13 @@
 	QList<DiagramView *> projectViews() const;
 	QList<QString> editedFiles() const;
 	ProjectView *viewForFile(const QString &) const;
-	static TitleBlockProperties     defaultTitleBlockProperties();
-	static BorderProperties    defaultBorderProperties();
-	static ConductorProperties defaultConductorProperties();
-	static ExportProperties    defaultExportProperties();
-	static ExportProperties    defaultPrintProperties();
-	static QString			   defaultReportProperties();
-	static XRefProperties	   defaultXRefProperties();
+	static TitleBlockProperties			  defaultTitleBlockProperties();
+	static BorderProperties				  defaultBorderProperties();
+	static ConductorProperties			  defaultConductorProperties();
+	static ExportProperties				  defaultExportProperties();
+	static ExportProperties				  defaultPrintProperties();
+	static QString						  defaultReportProperties();
+	static QHash<QString, XRefProperties> defaultXRefProperties();
 	
 	protected:
 	void actions();

Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -35,10 +35,10 @@
 	QGraphicsObject(elmt),
 	m_element (elmt)
 {
-	m_properties = elmt->diagram()->defaultXRefProperties();
+	m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
 	connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 	connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
-	connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
+	connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
 
 	//set specific behavior related to the parent item.
 	if(m_properties.snapTo() == XRefProperties::Bottom) {
@@ -61,7 +61,7 @@
 	}
 	disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
 	disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
-	disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
+	disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
 }
 
 /**
@@ -119,7 +119,13 @@
 	}
 }
 
-void CrossRefItem::setProperties(const XRefProperties &xrp) {
+/**
+ * @brief CrossRefItem::updateProperties
+ * update the curent properties
+ */
+void CrossRefItem::updateProperties() {
+	XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
+
 	if (m_properties != xrp) {
 		if (m_properties.snapTo() != xrp.snapTo()) {
 			if (xrp.snapTo() == XRefProperties::Bottom) {

Modified: trunk/sources/qetgraphicsitem/crossrefitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.h	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetgraphicsitem/crossrefitem.h	2014-07-03 08:52:14 UTC (rev 3185)
@@ -61,7 +61,7 @@
 	signals:
 
 	public slots:
-	void setProperties (const XRefProperties &xrp);
+	void updateProperties ();
 	void updateLabel   ();
 	void autoPos	   ();
 

Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetproject.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -451,13 +451,14 @@
 	emit reportPropertiesChanged(properties);
 }
 
-XRefProperties QETProject::defaultXrefProperties() const{
-	return m_default_xref_properties;
+void QETProject::setDefaultXRefProperties(const QString type, const XRefProperties &properties) {
+	m_default_xref_properties.insert(type, properties);
+	emit XRefPropertiesChanged();
 }
 
-void QETProject::setDefaultXRefProperties(const XRefProperties &properties) {
-	m_default_xref_properties = properties;
-	emit XRefPropertiesChanged(properties);
+void QETProject::setDefaultXRefProperties(QHash<QString, XRefProperties> hash) {
+	m_default_xref_properties.swap(hash);
+	emit XRefPropertiesChanged();
 }
 
 /**
@@ -1179,7 +1180,7 @@
 			conductors_elmt = child_elmt;
 		} else if (child_elmt.tagName() == "report") {
 			report_elmt = child_elmt;
-		} else if (child_elmt.tagName() == "xref") {
+		} else if (child_elmt.tagName() == "xrefs") {
 			xref_elmt = child_elmt;
 		}
 	}
@@ -1189,7 +1190,13 @@
 	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 (!xref_elmt.isNull())	   m_default_xref_properties.fromXml(xref_elmt);
+	if (!xref_elmt.isNull()) {
+		foreach(QDomElement elmt, QET::findInDomElement(xref_elmt, "xref")) {
+			XRefProperties xrp;
+			xrp.fromXml(elmt);
+			m_default_xref_properties.insert(elmt.attribute("type"), xrp);
+		}
+	}
 }
 
 
@@ -1227,9 +1234,15 @@
 	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);
+	QDomElement xrefs_elmt = xml_document.createElement("xrefs");
+	foreach (QString key, defaultXRefProperties().keys()) {
+		QDomElement xref_elmt = xml_document.createElement("xref");
+		xref_elmt.setAttribute("type", key);
+		defaultXRefProperties()[key].toXml(xref_elmt);
+		xrefs_elmt.appendChild(xref_elmt);
+	}
+
+	xml_element.appendChild(xrefs_elmt);
 }
 
 /**

Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/qetproject.h	2014-07-03 08:52:14 UTC (rev 3185)
@@ -92,6 +92,8 @@
 	QDomElement getTemplateXmlDescriptionByName(const QString &);
 	bool setTemplateXmlDescription(const QString &, const QDomElement &);
 	void removeTemplateByName(const QString &);
+
+	///DEFAULT PROPERTIES
 	BorderProperties defaultBorderProperties() const;
 	void setDefaultBorderProperties(const BorderProperties &);
 	TitleBlockProperties defaultTitleBlockProperties() const;
@@ -100,8 +102,11 @@
 	void setDefaultConductorProperties(const ConductorProperties &);
 	QString defaultReportProperties() const;
 	void setDefaultReportProperties (const QString &properties);
-	XRefProperties defaultXrefProperties () const;
-	void setDefaultXRefProperties(const XRefProperties &properties);
+	XRefProperties					defaultXRefProperties (const QString &type) const {return m_default_xref_properties[type];}
+	QHash <QString, XRefProperties> defaultXRefProperties() const					  {return m_default_xref_properties;}
+	void setDefaultXRefProperties(const QString type, const XRefProperties &properties);
+	void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
+
 	QDomDocument toXml();
 	bool close();
 	QETResult write();
@@ -147,7 +152,7 @@
 	void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
 	void readOnlyChanged(QETProject *, bool);
 	void reportPropertiesChanged(QString);
-	void XRefPropertiesChanged (XRefProperties);
+	void XRefPropertiesChanged ();
 	
 	private slots:
 	void updateDiagramsFolioData();
@@ -206,7 +211,7 @@
 	/// Default report properties
 	QString default_report_properties_;
 	/// Default xref properties
-	XRefProperties m_default_xref_properties;
+	QHash <QString, XRefProperties> m_default_xref_properties;
 	/// Embedded title block templates collection
 	TitleBlockTemplatesProjectCollection titleblocks_;
 	/// project-wide variables that will be made available to child diagrams

Modified: trunk/sources/ui/xrefpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.cpp	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/ui/xrefpropertieswidget.cpp	2014-07-03 08:52:14 UTC (rev 3185)
@@ -25,16 +25,15 @@
  * @param properties: properties to use
  * @param parent: parent widget
  */
-XRefPropertiesWidget::XRefPropertiesWidget(XRefProperties properties, QWidget *parent) :
+XRefPropertiesWidget::XRefPropertiesWidget(QHash <QString, XRefProperties> properties, QWidget *parent) :
 	QWidget(parent),
 	ui(new Ui::XRefPropertiesWidget),
 	m_properties(properties)
 {
 	ui->setupUi(this);
-
-	ui->m_snap_to_cb->addItem(tr("En bas de page"),					  "bottom");
-	ui->m_snap_to_cb->addItem(tr("Sous le label de l'\351l\351ment"), "label");
-	connect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
+	buildUi();
+	connect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)),            ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
+	connect(ui->m_type_cb,              SIGNAL(currentIndexChanged(int)), this,                      SLOT(typeChanged()));
 	updateDisplay();
 }
 
@@ -44,7 +43,8 @@
  */
 XRefPropertiesWidget::~XRefPropertiesWidget()
 {
-	disconnect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
+	disconnect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)),            ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
+	disconnect(ui->m_type_cb,              SIGNAL(currentIndexChanged(int)), this,                      SLOT(typeChanged()));
 	delete ui;
 }
 
@@ -53,25 +53,18 @@
  * set new properties for this widget
  * @param properties
  */
-void XRefPropertiesWidget::setProperties(const XRefProperties &properties) {
+void XRefPropertiesWidget::setProperties(const QHash <QString, XRefProperties> &properties) {
 	m_properties = properties;
 	updateDisplay();
+	m_previous_type_index = ui->m_type_cb->currentIndex();
 }
 
 /**
  * @brief XRefPropertiesWidget::properties
- * @return the propertie edited by this widget
+ * @return the properties edited by this widget
  */
-XRefProperties XRefPropertiesWidget::properties() {
-	if		(ui->m_display_has_cross_rb->isChecked())	 m_properties.setDisplayHas(XRefProperties::Cross);
-	else if (ui->m_display_has_contacts_rb->isChecked()) m_properties.setDisplayHas(XRefProperties::Contacts);
-	if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
-		 m_properties.setSnapTo(XRefProperties::Bottom);
-	else m_properties.setSnapTo(XRefProperties::Label);
-	m_properties.setShowPowerContac(ui->m_show_power_cb->isChecked());
-	m_properties.setPrefix("power", ui->m_power_prefix_le->text());
-	m_properties.setPrefix("delay", ui->m_delay_prefix_le->text());
-
+QHash <QString, XRefProperties> XRefPropertiesWidget::properties(){
+	saveProperties(ui->m_type_cb->currentIndex());
 	return m_properties;
 }
 
@@ -81,21 +74,57 @@
  * @param ro
  */
 void XRefPropertiesWidget::setReadOnly(bool ro) {
-	ui->m_display_has_cross_rb->setDisabled(ro);
-	ui->m_display_has_contacts_rb->setDisabled(ro);
+	ui->m_type_cb->setDisabled(ro);
+	ui->m_display_gb->setDisabled(ro);
+	ui->m_cross_properties_gb->setDisabled(ro);
 
-	if (m_properties.displayHas() != XRefProperties::Cross)
+	if (!ro && ui->m_display_has_contacts_rb->isChecked()) {
 		ui->m_cross_properties_gb->setDisabled(true);
-	else
-		ui->m_cross_properties_gb->setDisabled(ro);
+	}
 }
 
 /**
+ * @brief XRefPropertiesWidget::buildUi
+ * Build some widget of this ui.
+ */
+void XRefPropertiesWidget::buildUi() {
+	ui -> m_type_cb -> addItem(tr("Bobine"),			   "coil");
+	ui -> m_type_cb -> addItem(tr("Organe de protection"), "protection");
+	ui -> m_snap_to_cb -> addItem(tr("En bas de page"),					  "bottom");
+	ui -> m_snap_to_cb -> addItem(tr("Sous le label de l'\351l\351ment"), "label");
+	m_previous_type_index = ui -> m_type_cb -> currentIndex();
+}
+
+/**
+ * @brief XRefPropertiesWidget::saveProperties
+ * Save the properties of the type define at @index of the combo box m_type_cb
+ * @param index
+ */
+void XRefPropertiesWidget::saveProperties(int index) {
+	QString type = ui->m_type_cb->itemData(index).toString();
+	XRefProperties xrp = m_properties[type];
+
+	if		(ui->m_display_has_cross_rb->isChecked())	 xrp.setDisplayHas(XRefProperties::Cross);
+	else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts);
+	if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
+		 xrp.setSnapTo(XRefProperties::Bottom);
+	else xrp.setSnapTo(XRefProperties::Label);
+	xrp.setShowPowerContac(ui->m_show_power_cb->isChecked());
+	xrp.setPrefix("power", ui->m_power_prefix_le->text());
+	xrp.setPrefix("delay", ui->m_delay_prefix_le->text());
+
+	m_properties.insert(type, xrp);
+}
+
+/**
  * @brief XRefPropertiesWidget::updateDisplay
- * Update display with the content of the properties
+ * Update display with the curent displayed type.
  */
 void XRefPropertiesWidget::updateDisplay() {
-	XRefProperties::DisplayHas dh = m_properties.displayHas();
+	QString type = ui->m_type_cb->itemData(ui->m_type_cb->currentIndex()).toString();
+	XRefProperties xrp = m_properties[type];
+
+	XRefProperties::DisplayHas dh = xrp.displayHas();
 	if		(dh == XRefProperties::Cross)	 {
 		ui->m_display_has_cross_rb->setChecked(true);
 	}
@@ -103,11 +132,26 @@
 		ui->m_display_has_contacts_rb->setChecked(true);
 	}
 
-	if (m_properties.snapTo() == XRefProperties::Bottom)
+	if (xrp.snapTo() == XRefProperties::Bottom)
 		 ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));
 	else ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("label"));
-	ui->m_show_power_cb->setChecked(m_properties.showPowerContact());
-	ui->m_power_prefix_le->setText(m_properties.prefix("power"));
-	ui->m_delay_prefix_le->setText(m_properties.prefix("delay"));
+	ui->m_show_power_cb->setChecked(xrp.showPowerContact());
+	ui->m_power_prefix_le->setText(xrp.prefix("power"));
+	ui->m_delay_prefix_le->setText(xrp.prefix("delay"));
 	ui->m_cross_properties_gb->setDisabled(!ui->m_display_has_cross_rb->isChecked());
 }
+
+/**
+ * @brief XRefPropertiesWidget::typeChanged
+ * manage the save of the current properties,
+ * when the combo box of type change.
+ */
+void XRefPropertiesWidget::typeChanged() {
+	//save the properties of the previous xref type
+	saveProperties(m_previous_type_index);
+	//update display with the current xref type
+	updateDisplay();
+	//everything is done
+	//previous index is now the current index
+	m_previous_type_index = ui->m_type_cb->currentIndex();
+}

Modified: trunk/sources/ui/xrefpropertieswidget.h
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.h	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/ui/xrefpropertieswidget.h	2014-07-03 08:52:14 UTC (rev 3185)
@@ -34,20 +34,27 @@
 	Q_OBJECT
 
 	public:
-	XRefPropertiesWidget(XRefProperties properties = XRefProperties(), QWidget *parent = 0);
+	XRefPropertiesWidget(QHash <QString, XRefProperties> properties = QHash <QString, XRefProperties>(), QWidget *parent = 0);
 	~XRefPropertiesWidget();
 
-	void setProperties (const XRefProperties &properties);
-	XRefProperties properties();
+	void setProperties (const QHash <QString, XRefProperties> &properties);
+	QHash <QString, XRefProperties> properties();
 
 	void setReadOnly (bool = true);
 
 	private:
+	void buildUi();
+	void saveProperties(int index);
+
+	private slots:
 	void updateDisplay();
+	void typeChanged();
 
+
 	private:
 	Ui::XRefPropertiesWidget *ui;
-	XRefProperties m_properties;
+	QHash <QString, XRefProperties> m_properties;
+	int m_previous_type_index;
 };
 
 #endif // XREFPROPERTIESWIDGET_H

Modified: trunk/sources/ui/xrefpropertieswidget.ui
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.ui	2014-06-28 15:13:37 UTC (rev 3184)
+++ trunk/sources/ui/xrefpropertieswidget.ui	2014-07-03 08:52:14 UTC (rev 3185)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>484</width>
+    <height>470</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -15,6 +15,20 @@
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>Type :</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="m_type_cb"/>
+     </item>
+    </layout>
+   </item>
+   <item>
     <widget class="QGroupBox" name="m_display_gb">
      <property name="title">
       <string>Représentation:</string>


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