[qet] [3239] Conductor autonumerotation: Remove one autonum per diagram and add global autonums for the project.

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


Revision: 3239
Author:   blacksun
Date:     2014-07-31 12:02:33 +0200 (Thu, 31 Jul 2014)
Log Message:
-----------
Conductor autonumerotation: Remove one autonum per diagram and add global autonums for the project.
several diagram can share the same autonumerotation.
This is first step, need to be improved and readd some feature (disabled for first step).

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/diagramcommands.h
    trunk/sources/diagramview.cpp
    trunk/sources/projectconfigpages.cpp
    trunk/sources/projectconfigpages.h
    trunk/sources/projectview.cpp
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetproject.cpp
    trunk/sources/qetproject.h
    trunk/sources/ui/conductorpropertieswidget.cpp
    trunk/sources/ui/conductorpropertieswidget.h
    trunk/sources/ui/conductorpropertieswidget.ui
    trunk/sources/ui/diagrampropertiesdialog.cpp
    trunk/sources/ui/dialogautonum.cpp
    trunk/sources/ui/selectautonumw.cpp
    trunk/sources/ui/selectautonumw.h
    trunk/sources/ui/selectautonumw.ui

Added Paths:
-----------
    trunk/sources/ui/autonumselectorwidget.cpp
    trunk/sources/ui/autonumselectorwidget.h
    trunk/sources/ui/autonumselectorwidget.ui

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/diagram.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -47,13 +47,13 @@
 */
 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),
-	project_(0),
-	read_only_(false),
-	diagram_qet_version_(-1)
+	read_only_(false)
 {
 	qgi_manager_ = new QGIManager(this);
 	setBackgroundBrush(Qt::white);
@@ -205,6 +205,22 @@
 }
 
 /**
+ * @brief Diagram::conductorsAutonumName
+ * @return the name of autonum to use.
+ */
+QString Diagram::conductorsAutonumName() const {
+	return m_conductors_autonum_name;
+}
+
+/**
+ * @brief Diagram::setConductorsAutonumName
+ * @param name, name of autonum to use.
+ */
+void Diagram::setConductorsAutonumName(const QString &name) {
+	m_conductors_autonum_name= name;
+}
+
+/**
 	Exporte le schema vers une image
 	@return Une QImage representant le schema
 */
@@ -327,13 +343,6 @@
 		QDomElement default_conductor = document.createElement("defaultconductor");
 		defaultConductorProperties.toXml(default_conductor);
 		racine.appendChild(default_conductor);
-
-		//autonumerotation of conductor
-		if (!getNumerotation(Diagram::Conductors).isEmpty()) {
-			QDomElement autonum = document.createElement("autonum");
-			autonum.appendChild(getNumerotation(Diagram::Conductors).toXml(document, "conductor"));
-			racine.appendChild(autonum);
-		}
 	}
 	document.appendChild(racine);
 	
@@ -504,16 +513,6 @@
 		if (!default_conductor_elmt.isNull()) {
 			defaultConductorProperties.fromXml(default_conductor_elmt);
 		}
-		// find the first element autonum
-		QDomElement num_auto = root.firstChildElement("autonum");
-		if (!num_auto.isNull()) {
-			QDomElement num_conductor = num_auto.firstChildElement("conductor");
-			//set the auto-numerotation of conductor
-			if (!num_conductor.isNull()) {
-				NumerotationContext nc(num_conductor);
-				setNumerotation(Diagram::Conductors, nc);
-			}
-		}
 	}
 	
 	// si la racine n'a pas d'enfant : le chargement est fini (schema vide)

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/diagram.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -58,63 +58,72 @@
 	private:
 	Diagram(const Diagram &diagram);
 	
-	// attributes
+	// ATTRIBUTES
 	public:
-	/**
-		Represents available options when rendering a particular diagram:
-		 * EmptyBorder: display border only
-		 * TitleBlock: display title block
-		 * Columns: display columns
-	*/
-	enum BorderOptions { EmptyBorder, TitleBlock, Columns };
-	/// Represents available option of Numerotation type.
-	enum NumerotationType { Conductors };
-	/// Default properties for new conductors
-	ConductorProperties defaultConductorProperties;
-	/// Diagram dimensions and title block
-	BorderTitleBlock border_and_titleblock;
-	/// abscissa grid step size
-	static const int xGrid;
-	/// ordinate grid step size
-	static const int yGrid;
-	/// margin around the diagram
-	static const qreal margin;
-	/// background color of diagram
-	static QColor background_color;
+		/**
+			Represents available options when rendering a particular diagram:
+			 * EmptyBorder: display border only
+			 * TitleBlock: display title block
+			 * Columns: display columns
+		*/
+		enum BorderOptions { EmptyBorder, TitleBlock, Columns };
+		/// Represents available option of Numerotation type.
+		enum NumerotationType { Conductors };
+		/// Default properties for new conductors
+		ConductorProperties defaultConductorProperties;
+		/// Diagram dimensions and title block
+		BorderTitleBlock border_and_titleblock;
+		/// abscissa grid step size
+		static const int xGrid;
+		/// ordinate grid step size
+		static const int yGrid;
+		/// margin around the diagram
+		static const qreal margin;
+		/// background color of diagram
+		static QColor background_color;
+
 	private:
-	QGraphicsLineItem *conductor_setter_;
-	ElementsMover *elements_mover_;
-	ElementTextsMover *element_texts_mover_;
-	bool draw_grid_;
-	bool use_border_;
-	QGIManager *qgi_manager_;
-	bool draw_terminals_;
-	bool draw_colored_conductors_;
-	QDomDocument xml_document_;
-	QETProject *project_;
-	bool read_only_;
-	qreal diagram_qet_version_;
-	QHash <NumerotationType, NumerotationContext > numerotation_;
+		QGraphicsLineItem *conductor_setter_;
+		ElementsMover     *elements_mover_;
+		ElementTextsMover *element_texts_mover_;
+		QGIManager        *qgi_manager_;
+		QETProject        *project_;
+
+		QDomDocument xml_document_;
+
+		qreal diagram_qet_version_;
+
+		bool draw_grid_;
+		bool use_border_;
+		bool draw_terminals_;
+		bool draw_colored_conductors_;
+		bool read_only_;
+
+		QString m_conductors_autonum_name;
 	
-	// methods
+	// METHODS
 	protected:
-	virtual void drawBackground(QPainter *, const QRectF &);
-	virtual void keyPressEvent(QKeyEvent *);
-	virtual void keyReleaseEvent(QKeyEvent *);
+		virtual void drawBackground(QPainter *, const QRectF &);
+		virtual void keyPressEvent(QKeyEvent *);
+		virtual void keyReleaseEvent(QKeyEvent *);
 	
 	public:
-	QString		   defaultReportProperties () const {return project_ -> defaultReportProperties();}
-	XRefProperties defaultXRefProperties   (const QString &str) const {return project_ -> defaultXRefProperties(str);}
-	static bool clipboardMayContainDiagram();
-	bool setNumerotation (NumerotationType, NumerotationContext);
-	NumerotationContext getNumerotation (NumerotationType) const;
+		//methods related to xref properties
+		QString		   defaultReportProperties () const {return project_ -> defaultReportProperties();}
+		XRefProperties defaultXRefProperties   (const QString &str) const {return project_ -> defaultXRefProperties(str);}
+
+		//methods related to autonum
+		QString conductorsAutonumName() const;
+		void setConductorsAutonumName(const QString &name);
+
+		static bool clipboardMayContainDiagram();
 	
-	// methods related to parent project
-	QETProject *project() const;
-	void setProject(QETProject *);
-	int folioIndex() const;
-	qreal declaredQElectroTechVersion(bool = true) const;
-	void showMe() {emit showDiagram(this);}
+		// methods related to parent project
+		QETProject *project() const;
+		void setProject(QETProject *);
+		int folioIndex() const;
+		qreal declaredQElectroTechVersion(bool = true) const;
+		void showMe() {emit showDiagram(this);}
 	
 	// methods related to read only mode
 	bool isReadOnly() const;
@@ -218,31 +227,6 @@
 Q_DECLARE_METATYPE(Diagram *)
 
 /**
- * @brief Diagram::setNumerotation, store a numerotation type
- * @return true if storage is available
- */
-inline bool Diagram::setNumerotation(Diagram::NumerotationType type, NumerotationContext context) {
-	switch (type) {
-		case Conductors:
-			numerotation_.insert(type, context);
-			return true;
-			break;
-		default:
-			return false;
-			break;
-	}
-}
-
-/**
- * @brief Diagram::getNumerotation
- * @return the NumerotationContext associated with the key.
- * If numerotation_ contains no item with the key, the function returns a default-constructed NumerotationContext
- */
-inline NumerotationContext Diagram::getNumerotation(Diagram::NumerotationType type) const {
-	return numerotation_.value(type);
-}
-
-/**
 	Display or hide the conductor setter, i.e. a dashed conductor stub which appears when creating a conductor between two terminals.
 	@param pf true pour ajouter le poseur de conducteur, false pour l'enlever
 */

Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/diagramcommands.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -147,22 +147,22 @@
 class AddConductorCommand : public QUndoCommand {
 	// constructors, destructor
 	public:
-	AddConductorCommand(Diagram *, Conductor *, QUndoCommand * = 0);
-	virtual ~AddConductorCommand();
+		AddConductorCommand(Diagram *, Conductor *, QUndoCommand * = 0);
+		virtual ~AddConductorCommand();
 	private:
-	AddConductorCommand(const AddConductorCommand &);
+		AddConductorCommand(const AddConductorCommand &);
 	
 	// methods
 	public:
-	virtual void undo();
-	virtual void redo();
+		virtual void undo();
+		virtual void redo();
 	
 	// attributes
 	private:
-	/// added conductor
-	Conductor *conductor;
-	/// diagram the conductor is added to
-	Diagram *diagram;
+		/// added conductor
+		Conductor *conductor;
+		/// diagram the conductor is added to
+		Diagram *diagram;
 };
 
 /**

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/diagramview.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -1289,7 +1289,6 @@
 			context_menu -> addAction(paste_here);
 			context_menu -> addSeparator();
 			context_menu -> addAction(qde -> infos_diagram);
-			context_menu -> addAction(qde -> prj_diagramNum);
 			context_menu -> addActions(qde -> m_row_column_actions_group.actions());
 		} else {
 			context_menu -> addAction(qde -> cut);

Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/projectconfigpages.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -25,6 +25,8 @@
 #include <QtGui>
 #include "ui/reportpropertiewidget.h"
 #include "ui/xrefpropertieswidget.h"
+#include "selectautonumw.h"
+#include "numerotationcontext.h"
 
 /**
 	Constructor
@@ -89,6 +91,8 @@
 	}
 }
 
+//######################################################################################//
+
 /**
 	Constructor
 	@param project Project this page is editing.
@@ -201,6 +205,8 @@
 	title_value_ -> setReadOnly(is_read_only);
 }
 
+//######################################################################################//
+
 /**
 	Constructor
 	@param project Project this page is editing.
@@ -335,3 +341,134 @@
 	conductor_  -> setReadOnly(is_read_only);
 	xref_		-> setReadOnly(is_read_only);
 }
+
+//######################################################################################//
+
+/**
+ * @brief ProjectAutoNumConfigPage::ProjectAutoNumConfigPage
+ * Default constructor
+ * @param project, project to edit
+ * @param parent, parent widget
+ */
+ProjectAutoNumConfigPage::ProjectAutoNumConfigPage (QETProject *project, QWidget *parent) :
+	ProjectConfigPage(project, parent)
+{
+	initWidgets();
+	initLayout();
+	buildConnections();
+	readValuesFromProject();
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::title
+ * Title of this config page
+ * @return
+ */
+QString ProjectAutoNumConfigPage::title() const {
+	return tr("Auto numerotation");
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::icon
+ * Icon of this config pafe
+ * @return
+ */
+QIcon ProjectAutoNumConfigPage::icon() const {
+	return QIcon ();
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::applyProjectConf
+ */
+void ProjectAutoNumConfigPage::applyProjectConf() {}
+
+/**
+ * @brief ProjectAutoNumConfigPage::initWidgets
+ * Init some widget of this page
+ */
+void ProjectAutoNumConfigPage::initWidgets() {
+	m_label = new QLabel(tr("Num\351rotations disponibles :", "availables numerotations"), this);
+	m_context_cb = new QComboBox(this);
+	m_context_cb->addItem(tr("Nouveau"));
+	m_name_le = new QLineEdit(this);
+	m_name_le->setPlaceholderText(tr("Nom de la nouvelle num\351rotation"));
+
+	m_saw = new SelectAutonumW(this);
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::initLayout
+ * Init the layout of this page
+ */
+void ProjectAutoNumConfigPage::initLayout() {
+	QHBoxLayout *context_layout = new QHBoxLayout();
+	context_layout -> addWidget (m_label);
+	context_layout -> addWidget (m_context_cb);
+	context_layout -> addWidget (m_name_le);
+
+	QVBoxLayout *main_layout = new QVBoxLayout(this);
+	this        -> setLayout (main_layout);
+	main_layout -> addLayout (context_layout);
+	main_layout -> addWidget (m_saw);
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::readValuesFromProject
+ * Read value stored on project, and update display
+ */
+void ProjectAutoNumConfigPage::readValuesFromProject() {
+	QList <QString> keys = project_->conductorAutoNum().keys();
+	if (keys.isEmpty()) return;
+	foreach (QString str, keys) { m_context_cb -> addItem(str); }
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::adjustReadOnly
+ * set this config page disable if project is read only
+ */
+void ProjectAutoNumConfigPage::adjustReadOnly() {
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::buildConnections
+ * setup some connections
+ */
+void ProjectAutoNumConfigPage::buildConnections() {
+	connect(m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString)));
+	connect(m_saw,        SIGNAL (applyPressed()),               this, SLOT (saveContext()));
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::updateContext
+ * Display the current selected context
+ * @param str, key of context stored in project
+ */
+void ProjectAutoNumConfigPage::updateContext(QString str) {
+	if (str == tr("Nouveau")) {
+		m_saw -> setContext(NumerotationContext());
+		m_name_le -> setText(QString());
+		m_name_le ->setEnabled(true);
+	}
+	else {
+		m_saw ->setContext(project_->conductorAutoNum(str));
+		m_name_le -> setText(str);
+		m_name_le -> setDisabled(true);
+	}
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::saveContext
+ * Save the current displayed context in project
+ */
+void ProjectAutoNumConfigPage::saveContext() {
+	if (m_context_cb->currentText() == tr("Nouveau")) {
+		if (m_name_le->text().isEmpty()) {
+			m_name_le->setText(tr("Nouvel num\351rotation"));
+		}
+		project_->addConductorAutoNum(m_name_le -> text(), m_saw -> toNumContext());
+		m_context_cb -> addItem(m_name_le -> text());
+	}
+	else {
+		project_->addConductorAutoNum (m_context_cb -> currentText(), m_saw -> toNumContext());
+	}
+}

Modified: trunk/sources/projectconfigpages.h
===================================================================
--- trunk/sources/projectconfigpages.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/projectconfigpages.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -1,3 +1,5 @@
+
+
 /*
 	Copyright 2006-2014 The QElectroTech Team
 	This file is part of QElectroTech.
@@ -27,6 +29,8 @@
 class DiagramContextWidget;
 class ReportPropertieWidget;
 class XRefPropertiesWidget;
+class SelectAutonumW;
+class QComboBox;
 
 /**
 	This class, derived from ConfigPage, aims at providing the basic skeleton
@@ -148,4 +152,37 @@
 	XRefPropertiesWidget *xref_;
 };
 
+class ProjectAutoNumConfigPage : public ProjectConfigPage {
+		Q_OBJECT
+
+	//Methods
+	public:
+		ProjectAutoNumConfigPage (QETProject *project, QWidget *parent = 0);
+
+		virtual QString title() const;
+		virtual QIcon   icon() const;
+		virtual void    applyProjectConf();
+
+	protected:
+		virtual void initWidgets();
+		virtual void initLayout();
+		virtual void readValuesFromProject();
+		virtual void adjustReadOnly();
+
+	private:
+		void buildConnections();
+
+	private slots:
+		void updateContext(QString);
+		void saveContext();
+
+	//Attributes
+	private:
+		QLabel         *m_label;
+		QLineEdit      *m_name_le;
+		QComboBox      *m_context_cb;
+		SelectAutonumW *m_saw;
+
+};
+
 #endif

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/projectview.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -447,8 +447,9 @@
 	
 	ConfigDialog properties_dialog(parentWidget());
 	properties_dialog.setWindowTitle(tr("Propri\351t\351s du projet", "window title"));
-	properties_dialog.addPage(new ProjectMainConfigPage(project_));
-	properties_dialog.addPage(new ProjectNewDiagramConfigPage(project_));
+	properties_dialog.addPage(new ProjectMainConfigPage       (project_));
+	properties_dialog.addPage(new ProjectNewDiagramConfigPage (project_));
+	properties_dialog.addPage(new ProjectAutoNumConfigPage    (project_));
 	properties_dialog.exec();
 }
 

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/qetdiagrameditor.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -208,7 +208,6 @@
 	prj_add_diagram   = new QAction(QET::Icons::DiagramAdd,            tr("Ajouter un sch\351ma"),                 this);
 	prj_del_diagram   = new QAction(QET::Icons::DiagramDelete,         tr("Supprimer le sch\351ma"),               this);
 	prj_clean         = new QAction(QET::Icons::EditClear,             tr("Nettoyer le projet"),                   this);
-	prj_diagramNum    = new QAction(QET::Icons::ConductorSettings,     tr("Annoter les sch\351mas"),               this);
 	prj_diagramList   = new QAction(QET::Icons::listDrawings,          tr("Ajouter un sommaire"),                  this);
 	prj_nomenclature  = new QAction(QET::Icons::DocumentExport,        tr("Exporter une nomenclature (beta)"),     this);
 	tabbed_view_mode  = new QAction(                                   tr("en utilisant des onglets"),             this);
@@ -424,7 +423,6 @@
 	connect(prj_add_diagram,    SIGNAL(triggered()), this,       SLOT(addDiagramToProject())       );
 	connect(prj_del_diagram,    SIGNAL(triggered()), this,       SLOT(removeDiagramFromProject())  );
 	connect(prj_clean,          SIGNAL(triggered()), this,       SLOT(cleanCurrentProject())       );
-	connect(prj_diagramNum,     SIGNAL(triggered()), this,       SLOT(diagramNumProject())         );
 	connect(prj_diagramList,    SIGNAL(triggered()), this,       SLOT(addDiagramFolioListToProject()));
 	connect(prj_nomenclature,   SIGNAL(triggered()), this,       SLOT(nomenclatureProject())       );
 	connect(print,              SIGNAL(triggered()), this,       SLOT(printDialog())               );
@@ -512,7 +510,6 @@
 	menu_project -> addAction(prj_del_diagram);
 	menu_project -> addAction(prj_clean);
 	menu_project -> addSeparator();
-	menu_project -> addAction(prj_diagramNum);
 	menu_project -> addAction(prj_diagramList);
 	menu_project -> addAction(prj_nomenclature);
 	
@@ -1152,7 +1149,6 @@
 	//prj_add_diagram_foliolist   -> setEnabled(editable_project);
 	prj_del_diagram   -> setEnabled(editable_project);
 	prj_clean         -> setEnabled(editable_project);
-	prj_diagramNum    -> setEnabled(editable_project);
 	prj_diagramList   -> setEnabled(opened_project);
 	prj_nomenclature  -> setEnabled(editable_project);
 	export_diagram    -> setEnabled(opened_diagram);
@@ -1207,7 +1203,6 @@
 	delete_selection -> setEnabled(editable_diagram && deletable_items);
 	rotate_selection -> setEnabled(editable_diagram && dv -> diagram() -> canRotateSelection());
 	selection_prop   -> setEnabled(deletable_items);
-	prj_diagramNum   -> setEnabled(editable_diagram);
 
 	// actions ayant besoin de textes selectionnes
 	int selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
@@ -1811,17 +1806,6 @@
 }
 
 /**
- * @brief launch dialog for numerate diagram
- */
-void QETDiagramEditor::diagramNumProject() {
-	DialogAutoNum *dg = new DialogAutoNum(currentDiagram()->diagram(), this);
-	dg->setModal(true);
-	dg->exec();
-	
-	delete dg;
-}
-
-/**
  * @brief export nomemclature of schema
  */
 void QETDiagramEditor::nomenclatureProject() {

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/qetdiagrameditor.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -157,7 +157,6 @@
 	void moveDiagramUp(Diagram *);
 	void moveDiagramDown(Diagram *);
 	void cleanCurrentProject();
-	void diagramNumProject();
 	void nomenclatureProject();
 	void diagramWasAdded(DiagramView *);
 	void diagramIsAboutToBeRemoved(DiagramView *);
@@ -194,7 +193,6 @@
 	QAction *prj_add_diagram;    ///< Add a diagram to the current project.
 	QAction *prj_del_diagram;    ///< Delete a diagram from the current project
 	QAction *prj_clean;          ///< Clean the content of the curent project by removing useless items
-	QAction *prj_diagramNum;     ///< Numerotation des schemas
 	QAction *prj_diagramList;    ///< Sommaire des schemas
 	QAction *prj_nomenclature;   ///< generate nomenclature
 	QAction *tile_window;        ///< Show MDI subwindows as tile

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -23,9 +23,9 @@
 #include "element.h"
 #include "diagram.h"
 #include "diagramcommands.h"
-#include "conductorautonumerotation.h"
 #include "qetdiagrameditor.h"
 #include "terminal.h"
+#include "conductorautonumerotation.h"
 #define PR(x) qDebug() << #x " = " << x;
 
 bool Conductor::pen_and_brush_initialized = false;
@@ -984,7 +984,7 @@
 			segments_y << segment_length;
 		}
 	}
-	
+
 	// s'il n'y a pas de segments, on renvoie true
 	if (!segments_x.size()) return(true);
 	// les longueurs recueillies doivent etre coherentes avec les positions des bornes
@@ -1321,11 +1321,6 @@
 }
 
 /**
- * @param t_list terminaux a ne pas inclure dans la recherche
- * @return les conducteurs avec lesquels ce conducteur partage
- *  le meme potentiel electrique a l'exception de lui même
- */
-/**
  * @brief Conductor::relatedPotentialConductors
  * Return all conductors at the same potential of this conductor, this conductor isn't
  * part of the returned QSet.
@@ -1340,9 +1335,8 @@
 	}
 
 	QSet <Conductor *> other_conductors;
-	// QList <Terminal *> this_terminal{terminal1, terminal2};
 	QList <Terminal *> this_terminal;
-    this_terminal << terminal1 << terminal2;
+	this_terminal << terminal1 << terminal2;
 
 	// Return all conductor of terminal 1 and 2
 	foreach (Terminal *terminal, this_terminal) {

Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/qetproject.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -30,6 +30,7 @@
 #include "qetmessagebox.h"
 #include "titleblocktemplate.h"
 #include "ui/dialogwaiting.h"
+#include "numerotationcontext.h"
 
 QString QETProject::integration_category_name = "import";
 
@@ -462,6 +463,36 @@
 }
 
 /**
+ * @brief QETProject::conductorAutoNum
+ * @return All value of conductor autonum stored in project
+ */
+QHash <QString, NumerotationContext> QETProject::conductorAutoNum() const {
+	return m_conductor_autonum;
+}
+
+/**
+ * @brief QETProject::addConductorAutoNum
+ * Add a new numerotation context. If key already exist,
+ * replace old context by the new context
+ * @param key
+ * @param context
+ */
+void QETProject::addConductorAutoNum(QString key, NumerotationContext context) {
+	m_conductor_autonum.insert(key, context);
+}
+
+/**
+ * @brief QETProject::conductorAutoNum
+ * Return the numerotation context stored with @key.
+ * If key is not found, return an empty numerotation context
+ * @param key
+ */
+NumerotationContext QETProject::conductorAutoNum (const QString &key) const {
+	if (m_conductor_autonum.contains(key)) return m_conductor_autonum[key];
+	else return NumerotationContext();
+}
+
+/**
 	@return un document XML representant le projet 
 */
 QDomDocument QETProject::toXml() {
@@ -1167,7 +1198,7 @@
 	m_default_xref_properties	   = QETDiagramEditor::defaultXRefProperties();
 	
 	//Read values indicate in project
-	QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt;
+	QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums;
 	
 	for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) {
 		QDomElement child_elmt = child.toElement();
@@ -1182,10 +1213,12 @@
 			report_elmt = child_elmt;
 		} else if (child_elmt.tagName() == "xrefs") {
 			xref_elmt = child_elmt;
+		} else if (child_elmt.tagName() == "conductors_autonums") {
+			conds_autonums = child_elmt;
 		}
 	}
 	
-	// size, titleblock, conductor, report
+	// size, titleblock, conductor, report, conductor autonum
 	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);
@@ -1197,6 +1230,13 @@
 			m_default_xref_properties.insert(elmt.attribute("type"), xrp);
 		}
 	}
+	if (!conds_autonums.isNull()) {
+		foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum")) {
+			NumerotationContext nc;
+			nc.fromXml(elmt);
+			m_conductor_autonum.insert(elmt.attribute("title"), nc);
+		}
+	}
 }
 
 
@@ -1241,8 +1281,16 @@
 		defaultXRefProperties()[key].toXml(xref_elmt);
 		xrefs_elmt.appendChild(xref_elmt);
 	}
+	xml_element.appendChild(xrefs_elmt);
 
-	xml_element.appendChild(xrefs_elmt);
+	//Export conductors autonums
+	QDomElement conds_autonums = xml_document.createElement("conductors_autonums");
+	foreach (QString key, conductorAutoNum().keys()) {
+		QDomElement cond_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum");
+		cond_autonum.setAttribute("title", key);
+		conds_autonums.appendChild(cond_autonum);
+	}
+	xml_element.appendChild(conds_autonums);
 }
 
 /**

Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/qetproject.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -37,6 +37,7 @@
 class XmlElementsCollection;
 class MoveElementsHandler;
 class MoveTitleBlockTemplatesHandler;
+class NumerotationContext;
 
 /**
 	This class represents a QET project. Typically saved as a .qet file, it
@@ -96,17 +97,25 @@
 	///DEFAULT PROPERTIES
 	BorderProperties defaultBorderProperties() const;
 	void setDefaultBorderProperties(const BorderProperties &);
+
 	TitleBlockProperties defaultTitleBlockProperties() const;
 	void setDefaultTitleBlockProperties(const TitleBlockProperties &);
+
 	ConductorProperties defaultConductorProperties() const;
 	void setDefaultConductorProperties(const ConductorProperties &);
+
 	QString defaultReportProperties() const;
 	void setDefaultReportProperties (const QString &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);
 
+	QHash <QString, NumerotationContext> conductorAutoNum() const;
+	void addConductorAutoNum (QString key, NumerotationContext context);
+	NumerotationContext conductorAutoNum(const QString &key) const;
+
 	QDomDocument toXml();
 	bool close();
 	QETResult write();
@@ -218,6 +227,8 @@
 	DiagramContext project_properties_;
 	/// undo stack for this project
 	QUndoStack *undo_stack_;
+	/// Conductor auto numerotation
+	QHash <QString, NumerotationContext> m_conductor_autonum;
 };
 Q_DECLARE_METATYPE(QETProject *)
 #endif

Added: trunk/sources/ui/autonumselectorwidget.cpp
===================================================================
--- trunk/sources/ui/autonumselectorwidget.cpp	                        (rev 0)
+++ trunk/sources/ui/autonumselectorwidget.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -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 "autonumselectorwidget.h"
+#include "ui_autonumselectorwidget.h"
+
+/**
+ * @brief AutonumSelectorWidget::AutonumSelectorWidget
+ * default constructor
+ * @param parent, parent widget
+ */
+AutonumSelectorWidget::AutonumSelectorWidget(QWidget *parent) :
+	QWidget(parent),
+	ui(new Ui::AutonumSelectorWidget)
+{
+	ui->setupUi(this);
+	ui->m_edit_autonum_pb->setDisabled(true);
+}
+
+/**
+ * @brief AutonumSelectorWidget::AutonumSelectorWidget
+ * Constructor with texts to fill the combo box
+ * @param text, texts for fill the combo box
+ * @param parent, parent widget
+ */
+AutonumSelectorWidget::AutonumSelectorWidget(const QList <QString> &text, QWidget *parent) :
+	QWidget(parent),
+	ui(new Ui::AutonumSelectorWidget)
+{
+	ui->setupUi(this);
+	ui -> m_available_autonum_cb -> addItems(text);
+	ui->m_edit_autonum_pb->setDisabled(true);
+}
+
+/**
+ * @brief AutonumSelectorWidget::~AutonumSelectorWidget
+ * Destructor
+ */
+AutonumSelectorWidget::~AutonumSelectorWidget()
+{
+	delete ui;
+}
+
+/**
+ * @brief AutonumSelectorWidget::setCurrentItem
+ * Set the combo box current index by text.
+ * If text doesn't exist, set current index -1
+ * @param text, text of index
+ */
+void AutonumSelectorWidget::setCurrentItem(const QString &text) {
+	ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(text));
+}
+
+/**
+ * @brief AutonumSelectorWidget::text
+ * @return the current displayed text
+ */
+QString AutonumSelectorWidget::text() const {
+	return ui -> m_available_autonum_cb -> currentText();
+}

Added: trunk/sources/ui/autonumselectorwidget.h
===================================================================
--- trunk/sources/ui/autonumselectorwidget.h	                        (rev 0)
+++ trunk/sources/ui/autonumselectorwidget.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -0,0 +1,49 @@
+/*
+	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 AUTONUMSELECTORWIDGET_H
+#define AUTONUMSELECTORWIDGET_H
+
+#include <QWidget>
+
+namespace Ui {
+	class AutonumSelectorWidget;
+}
+
+/**
+ * @brief The AutonumSelectorWidget class
+ * This widget show a combobox to select an autonum and a button to edit the autonum
+ * The combo box is empty and the button isn't linked with anything, it's the role of caller
+ * of this class to fill the combo box and edit the connection with the button.
+ */
+class AutonumSelectorWidget : public QWidget
+{
+		Q_OBJECT
+
+	public:
+		explicit AutonumSelectorWidget(QWidget *parent = 0);
+		explicit AutonumSelectorWidget(const QList <QString> &text, QWidget *parent = 0);
+		~AutonumSelectorWidget();
+
+		void setCurrentItem (const QString &text);
+		QString text() const;
+
+	private:
+		Ui::AutonumSelectorWidget *ui;
+};
+
+#endif // AUTONUMSELECTORWIDGET_H

Added: trunk/sources/ui/autonumselectorwidget.ui
===================================================================
--- trunk/sources/ui/autonumselectorwidget.ui	                        (rev 0)
+++ trunk/sources/ui/autonumselectorwidget.ui	2014-07-31 10:02:33 UTC (rev 3239)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AutonumSelectorWidget</class>
+ <widget class="QWidget" name="AutonumSelectorWidget">
+  <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="QHBoxLayout" name="horizontalLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Autonumérotation :</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QComboBox" name="m_available_autonum_cb"/>
+   </item>
+   <item>
+    <spacer name="horizontalSpacer">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QPushButton" name="m_edit_autonum_pb">
+     <property name="toolTip">
+      <string>éditer les numérotations</string>
+     </property>
+     <property name="text">
+      <string/>
+     </property>
+     <property name="icon">
+      <iconset resource="../../qelectrotech.qrc">
+       <normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../../qelectrotech.qrc"/>
+ </resources>
+ <connections/>
+</ui>

Modified: trunk/sources/ui/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/conductorpropertieswidget.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -115,6 +115,10 @@
 	this->setDisabled(ro);
 }
 
+void ConductorPropertiesWidget::addAutonumWidget(QWidget *widget) {
+	ui->m_autonum_layout->addWidget(widget);
+}
+
 /**
  * @brief ConductorPropertiesWidget::initWidget
  */

Modified: trunk/sources/ui/conductorpropertieswidget.h
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/conductorpropertieswidget.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -40,6 +40,8 @@
 		ConductorProperties properties() const;
 		void setReadOnly(const bool &ro);
 
+		void addAutonumWidget (QWidget *widget);
+
 	private:
 		void initWidget();
 		void setConductorType(ConductorProperties::ConductorType type);

Modified: trunk/sources/ui/conductorpropertieswidget.ui
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.ui	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/conductorpropertieswidget.ui	2014-07-31 10:02:33 UTC (rev 3239)
@@ -57,7 +57,7 @@
            <item>
             <widget class="QLabel" name="label">
              <property name="text">
-              <string>Texte :</string>
+              <string>Texte par defaut :</string>
              </property>
             </widget>
            </item>
@@ -84,6 +84,9 @@
           </layout>
          </item>
          <item>
+          <layout class="QHBoxLayout" name="m_autonum_layout"/>
+         </item>
+         <item>
           <widget class="QLabel" name="label_3">
            <property name="text">
             <string>Rotation du texte de conducteur :</string>

Modified: trunk/sources/ui/diagrampropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/diagrampropertiesdialog.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/diagrampropertiesdialog.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -20,6 +20,7 @@
 #include "titleblockpropertieswidget.h"
 #include "conductorpropertieswidget.h"
 #include "diagramcommands.h"
+#include "autonumselectorwidget.h"
 
 /**
  * @brief DiagramPropertiesDialog::DiagramPropertiesDialog
@@ -62,6 +63,11 @@
 	ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this);
 	cpw -> setReadOnly(diagram_is_read_only);
 
+	//Conductor autonum
+	AutonumSelectorWidget *asw = new AutonumSelectorWidget(diagram -> project() -> conductorAutoNum().keys(), this);
+	asw -> setCurrentItem(diagram -> conductorsAutonumName());
+	cpw->addAutonumWidget(asw);
+
 	// Buttons
 	QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
 	connect(&boutons, SIGNAL(accepted()), this, SLOT(accept()));
@@ -70,7 +76,7 @@
 	QGridLayout glayout(this);
 	glayout.addWidget(border_infos,0,0);
 	glayout.addWidget(titleblock_infos, 1, 0);
-	glayout.addWidget(cpw, 0, 1, 0 ,1, Qt::AlignTop);
+	glayout.addWidget(cpw, 0, 1, 0, 1, Qt::AlignTop);
 	glayout.addWidget(&boutons, 2, 1);
 
 	// if dialog is accepted
@@ -94,6 +100,11 @@
 			/// TODO implement an undo command to allow the user to undo/redo this action
 			diagram -> defaultConductorProperties = new_conductors;
 		}
+
+		// Conductor autonum name
+		if (asw -> text() != diagram -> conductorsAutonumName()) {
+			diagram -> setConductorsAutonumName (asw -> text());
+		}
 	}
 }
 

Modified: trunk/sources/ui/dialogautonum.cpp
===================================================================
--- trunk/sources/ui/dialogautonum.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/dialogautonum.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -18,7 +18,7 @@
 #include "dialogautonum.h"
 #include "ui_dialogautonum.h"
 
-#include "conductorautonumerotation.h"
+//#include "conductorautonumerotation.h"
 #include "qetmessagebox.h"
 #include "ui/selectautonumw.h"
 
@@ -34,7 +34,7 @@
 {
 	ui -> setupUi(this);
 	
-	ui -> configuration_layout -> addWidget (new SelectAutonumW(dg_ -> project() -> diagrams(), dg, ui -> configuration_tab));
+	ui -> configuration_layout -> addWidget (new SelectAutonumW());
 
 	dgselect_ = new diagramselection( dg_ -> project(), ui -> annotation_tab);
 	ui -> verticalLayout_Selection -> addWidget(dgselect_);
@@ -74,8 +74,8 @@
 	// if yes remove all
 	if( answer ==  QMessageBox::Yes) {
 		for(int i=0; i<listDiag.count(); i++){
-			ConductorAutoNumerotation can(listDiag.at(i));
-			can.removeNumOfDiagram();
+			/*ConductorAutoNumerotation can(listDiag.at(i));
+			can.removeNumOfDiagram();*/
 		}
 	}
 }
@@ -107,8 +107,8 @@
 	// if yes numerate all
 	if( answer ==  QMessageBox::Yes) {
 		foreach (Diagram *d, listDiag) {
-			ConductorAutoNumerotation can(d);
-			can.numerateDiagram();
+			/*ConductorAutoNumerotation can(d);
+			can.numerateDiagram();*/
 		}
 	}
 }

Modified: trunk/sources/ui/selectautonumw.cpp
===================================================================
--- trunk/sources/ui/selectautonumw.cpp	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/selectautonumw.cpp	2014-07-31 10:02:33 UTC (rev 3239)
@@ -17,21 +17,27 @@
 */
 #include "selectautonumw.h"
 #include "ui_selectautonumw.h"
-#include "diagram.h"
+#include "numparteditorw.h"
+#include <QMessageBox>
+#include "qdebug.h"
 
 /**
  * Constructor
  */
-SelectAutonumW::SelectAutonumW(const QList <Diagram *> &diagrams, Diagram *current_diagram ,QWidget *parent) :
+SelectAutonumW::SelectAutonumW(QWidget *parent) :
 	QWidget(parent),
-	ui(new Ui::SelectAutonumW),
-	diagram_list(diagrams)
+	ui(new Ui::SelectAutonumW)
 {
 	ui->setupUi(this);
+	setContext(NumerotationContext());
+}
 
-	initDiagramChooser();
-	if (current_diagram) ui -> diagram_chooser -> setCurrentIndex (diagram_list.indexOf(current_diagram));
-	setCurrentContext();
+SelectAutonumW::SelectAutonumW(const NumerotationContext &context, QWidget *parent) :
+	QWidget(parent),
+	ui(new Ui::SelectAutonumW)
+{
+	ui->setupUi(this);
+	setContext(context);
 }
 
 /**
@@ -43,35 +49,31 @@
 }
 
 /**
- * @brief SelectAutonumW::setDiagramChooser
- * build the content of QComboBox @diagram_chooser.
- */
-void SelectAutonumW::initDiagramChooser() {
-	for (int i=0; i<diagram_list.size(); ++i) {
-		QString diagram_title = diagram_list.at(i) -> title();
-		if (diagram_title.isEmpty()) diagram_title = (tr("Sch\351ma sans titre"));
-		ui -> diagram_chooser -> addItem(diagram_title);
-	}
-}
-
-/**
  * @brief SelectAutonumW::setCurrentContext
  * build the context of current diagram selected in the @diagram_chooser QcomboBox
  */
-void SelectAutonumW::setCurrentContext() {
-	NumerotationContext nc = diagram_list.at(ui->diagram_chooser->currentIndex()) -> getNumerotation(Diagram::Conductors);
+void SelectAutonumW::setContext(const NumerotationContext &context) {
+	m_context = context;
 
-	if (nc.size() == 0) { //@nc contain nothing, build a default numPartEditor
+	qDeleteAll(num_part_list_);
+	num_part_list_.clear();
+
+	if (m_context.size() == 0) { //@context contain nothing, build a default numPartEditor
 		on_add_button_clicked();
-		applyEnable(false);
-		return;
 	}
-	for (int i=0; i<nc.size(); ++i) { //build with the content of @nc
-		NumPartEditorW *part= new NumPartEditorW(nc, i, this);
-		connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
-		num_part_list_ << part;
-		ui -> editor_layout -> addWidget(part);
+	else {
+		for (int i=0; i<m_context.size(); ++i) { //build with the content of @context
+			NumPartEditorW *part= new NumPartEditorW(m_context, i, this);
+			connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
+			num_part_list_ << part;
+			ui -> editor_layout -> addWidget(part);
+		}
 	}
+
+	num_part_list_.size() == 1 ?
+				ui -> remove_button -> setDisabled(true):
+				ui -> remove_button -> setEnabled (true);
+
 	applyEnable(false);
 }
 
@@ -95,6 +97,7 @@
 	connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
 	num_part_list_ << part;
 	ui -> editor_layout -> addWidget(part);
+	ui -> remove_button -> setEnabled(true);
 }
 
 /**
@@ -107,21 +110,14 @@
 		NumPartEditorW *part = num_part_list_.takeLast();
 		disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable()));
 		delete part;
+		if (num_part_list_.size() == 1) {
+			ui -> remove_button -> setDisabled(true);
+		}
 	}
 	applyEnable();
 }
 
 /**
- * @brief SelectAutonumW::on_diagram_chooser_activated
- * Action on diagram_chooser
- */
-void SelectAutonumW::on_diagram_chooser_activated() {
-	foreach(NumPartEditorW *npew, num_part_list_) delete npew;
-	num_part_list_.clear();
-	setCurrentContext();
-}
-
-/**
  * @brief SelectAutonumW::on_buttonBox_clicked
  * Action on @buttonBox clicked
  */
@@ -130,10 +126,9 @@
 	int answer = ui -> buttonBox -> buttonRole(button);
 
 	switch (answer) {
-			//reset the displayed context to default context of @diagram_chooser.
+			//Reset the curent context
 		case QDialogButtonBox::ResetRole:
-			on_diagram_chooser_activated();
-			applyEnable(false);
+			setContext(m_context);
 			break;
 			//help dialog
 		case QDialogButtonBox::HelpRole:
@@ -157,9 +152,8 @@
 
 			//apply the context in the diagram displayed by @diagram_chooser.
 		case QDialogButtonBox::ApplyRole:
-			NumerotationContext nc = toNumContext();
-			diagram_list.at(ui -> diagram_chooser -> currentIndex()) -> setNumerotation(Diagram::Conductors, nc);
 			applyEnable(false);
+			emit applyPressed();
 			break;
 	};
 }

Modified: trunk/sources/ui/selectautonumw.h
===================================================================
--- trunk/sources/ui/selectautonumw.h	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/selectautonumw.h	2014-07-31 10:02:33 UTC (rev 3239)
@@ -19,9 +19,11 @@
 #define SELECTAUTONUMW_H
 
 #include <QWidget>
-#include "diagram.h"
-#include "ui/numparteditorw.h"
+#include "numerotationcontext.h"
 
+class NumPartEditorW;
+class QAbstractButton;
+
 namespace Ui {
 	class SelectAutonumW;
 }
@@ -32,27 +34,28 @@
 	
 	//METHODS
 	public:
-	explicit SelectAutonumW(const QList <Diagram *> &, Diagram * = 0, QWidget *parent = 0);
-	~SelectAutonumW();
-	
-	private:
-	void initDiagramChooser();
-	void setCurrentContext ();
-	NumerotationContext toNumContext() const;
+		explicit SelectAutonumW(QWidget *parent = 0);
+		explicit SelectAutonumW(const NumerotationContext &context, QWidget *parent = 0);
+		~SelectAutonumW();
 
+		void setContext (const NumerotationContext &context);
+		NumerotationContext toNumContext() const;
+
+	signals:
+		void applyPressed();
+
 	//SLOT
 	private slots:
-	void on_add_button_clicked();
-	void on_remove_button_clicked();
-	void on_diagram_chooser_activated();
-	void on_buttonBox_clicked(QAbstractButton *);
-	void applyEnable (bool = true);
+		void on_add_button_clicked();
+		void on_remove_button_clicked();
+		void on_buttonBox_clicked(QAbstractButton *);
+		void applyEnable (bool = true);
 
 	//ATTRIBUTS
 	private:
-	Ui::SelectAutonumW *ui;
-	const QList <Diagram *> diagram_list;
-	QList <NumPartEditorW *> num_part_list_;
+		Ui::SelectAutonumW *ui;
+		QList <NumPartEditorW *> num_part_list_;
+		NumerotationContext m_context;
 };
 
 #endif // SELECTAUTONUMW_H

Modified: trunk/sources/ui/selectautonumw.ui
===================================================================
--- trunk/sources/ui/selectautonumw.ui	2014-07-30 20:14:39 UTC (rev 3238)
+++ trunk/sources/ui/selectautonumw.ui	2014-07-31 10:02:33 UTC (rev 3239)
@@ -13,85 +13,55 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <property name="spacing">
-      <number>0</number>
-     </property>
-     <item>
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>Folio:  </string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QComboBox" name="diagram_chooser">
-       <property name="toolTip">
-        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choisir le folio&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-       </property>
-       <property name="maxVisibleItems">
-        <number>5</number>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="remove_button">
-       <property name="toolTip">
-        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimer une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-       <property name="icon">
-        <iconset resource="../../qelectrotech.qrc">
-         <normaloff>:/ico/22x22/list-remove.png</normaloff>:/ico/22x22/list-remove.png</iconset>
-       </property>
-       <property name="flat">
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="add_button">
-       <property name="toolTip">
-        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ajouter une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-       <property name="icon">
-        <iconset resource="../../qelectrotech.qrc">
-         <normaloff>:/ico/22x22/list-add.png</normaloff>:/ico/22x22/list-add.png</iconset>
-       </property>
-       <property name="flat">
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
     <widget class="QGroupBox" name="definition_groupe">
      <property name="title">
       <string>Définition</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout_3">
       <item>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QPushButton" name="remove_button">
+          <property name="toolTip">
+           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimer une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+          <property name="icon">
+           <iconset resource="../../qelectrotech.qrc">
+            <normaloff>:/ico/22x22/list-remove.png</normaloff>:/ico/22x22/list-remove.png</iconset>
+          </property>
+          <property name="flat">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="add_button">
+          <property name="toolTip">
+           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ajouter une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+          <property name="icon">
+           <iconset resource="../../qelectrotech.qrc">
+            <normaloff>:/ico/22x22/list-add.png</normaloff>:/ico/22x22/list-add.png</iconset>
+          </property>
+          <property name="flat">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
        <layout class="QVBoxLayout" name="editor_layout">
         <property name="spacing">
          <number>0</number>


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