[qet] [3274] Diagram properties dialog: add button to open the conductor autonum ?\195?\169rotation editor.

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


Revision: 3274
Author:   blacksun
Date:     2014-08-15 15:16:58 +0200 (Fri, 15 Aug 2014)
Log Message:
-----------
Diagram properties dialog: add button to open the conductor autonum?\195?\169rotation editor.

Modified Paths:
--------------
    trunk/sources/configdialog.cpp
    trunk/sources/configdialog.h
    trunk/sources/projectview.cpp
    trunk/sources/ui/autonumselectorwidget.cpp
    trunk/sources/ui/autonumselectorwidget.h
    trunk/sources/ui/autonumselectorwidget.ui
    trunk/sources/ui/diagrampropertiesdialog.cpp
    trunk/sources/ui/diagrampropertiesdialog.h

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

Modified: trunk/sources/configdialog.cpp
===================================================================
--- trunk/sources/configdialog.cpp	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/configdialog.cpp	2014-08-15 13:16:58 UTC (rev 3274)
@@ -52,7 +52,7 @@
 	// connexion signaux / slots
 	connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf()));
 	connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
-	connect(pages_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
+	connect(pages_list, SIGNAL(currentRowChanged(int)), pages_widget, SLOT(setCurrentIndex(int)));
 	
 #ifdef Q_WS_MAC
 	if (parent) {
@@ -66,14 +66,6 @@
 }
 
 /**
-	Gere les changements de page dans le dialogue de configuration
-*/
-void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
-	if (!current) current = previous;
-	pages_widget -> setCurrentIndex(pages_list -> row(current));
-}
-
-/**
 	Construit la liste des pages sur la gauche
 */
 void ConfigDialog::buildPagesList() {
@@ -113,3 +105,12 @@
 	pages_widget -> addWidget(page);
 	addPageToList(page);
 }
+
+/**
+ * @brief ConfigDialog::setCurrentPage
+ * Set the current index to @index
+ * @param index
+ */
+void ConfigDialog::setCurrentPage(const int index) {
+	pages_list->setCurrentRow(index);
+}

Modified: trunk/sources/configdialog.h
===================================================================
--- trunk/sources/configdialog.h	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/configdialog.h	2014-08-15 13:16:58 UTC (rev 3274)
@@ -39,9 +39,9 @@
 	
 	// methods
 	public slots:
-	void changePage(QListWidgetItem *, QListWidgetItem *);
 	void applyConf();
 	void addPage(ConfigPage *);
+	void setCurrentPage(const int index);
 	
 	private:
 	void buildPagesList();

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/projectview.cpp	2014-08-15 13:16:58 UTC (rev 3274)
@@ -17,9 +17,7 @@
 */
 #include "projectview.h"
 #include "qetproject.h"
-#include "configdialog.h"
 #include "closediagramsdialog.h"
-#include "projectconfigpages.h"
 #include "diagramview.h"
 #include "diagram.h"
 #include "diagramprintdialog.h"
@@ -36,6 +34,7 @@
 #include "qettabbar.h"
 #include "qettemplateeditor.h"
 #include "diagramfoliolist.h"
+#include "projectpropertiesdialog.h"
 
 /**
 	Constructeur
@@ -444,13 +443,8 @@
 */
 void ProjectView::editProjectProperties() {
 	if (!project_) return;
-	
-	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 ProjectAutoNumConfigPage    (project_));
-	properties_dialog.exec();
+	ProjectPropertiesDialog dialog(project_, parentWidget());
+	dialog.exec();
 }
 
 /**

Modified: trunk/sources/ui/autonumselectorwidget.cpp
===================================================================
--- trunk/sources/ui/autonumselectorwidget.cpp	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/ui/autonumselectorwidget.cpp	2014-08-15 13:16:58 UTC (rev 3274)
@@ -20,38 +20,23 @@
 
 /**
  * @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 items, items for fill the combo box
  * @param parent, parent widget
  */
-AutonumSelectorWidget::AutonumSelectorWidget(const QList <QString> &text, QWidget *parent) :
+AutonumSelectorWidget::AutonumSelectorWidget(const QStringList &items, 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);
+	ui -> m_available_autonum_cb -> addItems(items);
 }
 
 /**
  * @brief AutonumSelectorWidget::~AutonumSelectorWidget
  * Destructor
  */
-AutonumSelectorWidget::~AutonumSelectorWidget()
-{
+AutonumSelectorWidget::~AutonumSelectorWidget() {
 	delete ui;
 }
 
@@ -59,16 +44,36 @@
  * @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
+ * @param item, item of index
  */
-void AutonumSelectorWidget::setCurrentItem(const QString &text) {
-	ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(text));
+void AutonumSelectorWidget::setCurrentItem(const QString &item) {
+	ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(item));
 }
 
 /**
+ * @brief AutonumSelectorWidget::setItems
+ * Populate this widget with the content of @items
+ * Previous items is clear.
+ * @param items
+ */
+void AutonumSelectorWidget::setItems(const QStringList &items) {
+	ui -> m_available_autonum_cb -> clear();
+	ui -> m_available_autonum_cb -> addItems(items);
+}
+
+/**
  * @brief AutonumSelectorWidget::text
  * @return the current displayed text
  */
 QString AutonumSelectorWidget::text() const {
 	return ui -> m_available_autonum_cb -> currentText();
 }
+
+/**
+ * @brief AutonumSelectorWidget::on_m_edit_autonum_pb_clicked
+ * Just emit the signal openAutonumEditor.
+ * The owner of AutonumSelectorWidget need to connect the signal.
+ */
+void AutonumSelectorWidget::on_m_edit_autonum_pb_clicked() {
+	emit openAutonumEditor();
+}

Modified: trunk/sources/ui/autonumselectorwidget.h
===================================================================
--- trunk/sources/ui/autonumselectorwidget.h	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/ui/autonumselectorwidget.h	2014-08-15 13:16:58 UTC (rev 3274)
@@ -35,13 +35,19 @@
 		Q_OBJECT
 
 	public:
-		explicit AutonumSelectorWidget(QWidget *parent = 0);
-		explicit AutonumSelectorWidget(const QList <QString> &text, QWidget *parent = 0);
+		explicit AutonumSelectorWidget(const QStringList &items, QWidget *parent = 0);
 		~AutonumSelectorWidget();
 
-		void setCurrentItem (const QString &text);
-		QString text() const;
+		void    setCurrentItem (const QString &item);
+		void    setItems       (const QStringList &items);
+		QString text           () const;
 
+	signals:
+		void openAutonumEditor ();
+
+	private slots:
+		void on_m_edit_autonum_pb_clicked();
+
 	private:
 		Ui::AutonumSelectorWidget *ui;
 };

Modified: trunk/sources/ui/autonumselectorwidget.ui
===================================================================
--- trunk/sources/ui/autonumselectorwidget.ui	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/ui/autonumselectorwidget.ui	2014-08-15 13:16:58 UTC (rev 3274)
@@ -42,6 +42,9 @@
    </item>
    <item>
     <widget class="QPushButton" name="m_edit_autonum_pb">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
      <property name="toolTip">
       <string>éditer les numérotations</string>
      </property>

Modified: trunk/sources/ui/diagrampropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/diagrampropertiesdialog.cpp	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/ui/diagrampropertiesdialog.cpp	2014-08-15 13:16:58 UTC (rev 3274)
@@ -21,6 +21,8 @@
 #include "conductorpropertieswidget.h"
 #include "diagramcommands.h"
 #include "autonumselectorwidget.h"
+#include "projectpropertiesdialog.h"
+#include "diagram.h"
 
 /**
  * @brief DiagramPropertiesDialog::DiagramPropertiesDialog
@@ -29,7 +31,8 @@
  * @param parent : parent widget
  */
 DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *parent) :
-	QDialog (parent)
+	QDialog (parent),
+	m_diagram (diagram)
 {
 	bool diagram_is_read_only = diagram -> isReadOnly();
 
@@ -64,9 +67,10 @@
 	cpw -> setReadOnly(diagram_is_read_only);
 
 	//Conductor autonum
-	AutonumSelectorWidget *asw = new AutonumSelectorWidget(diagram -> project() -> conductorAutoNum().keys(), this);
-	asw -> setCurrentItem(diagram -> conductorsAutonumName());
-	cpw->addAutonumWidget(asw);
+	m_asw = new AutonumSelectorWidget(diagram -> project() -> conductorAutoNum().keys(), this);
+	m_asw -> setCurrentItem(diagram -> conductorsAutonumName());
+	connect (m_asw, SIGNAL(openAutonumEditor()), this, SLOT(editAutonum()));
+	cpw->addAutonumWidget(m_asw);
 
 	// Buttons
 	QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -102,8 +106,8 @@
 		}
 
 		// Conductor autonum name
-		if (asw -> text() != diagram -> conductorsAutonumName()) {
-			diagram -> setConductorsAutonumName (asw -> text());
+		if (m_asw -> text() != diagram -> conductorsAutonumName()) {
+			diagram -> setConductorsAutonumName (m_asw -> text());
 		}
 	}
 }
@@ -117,3 +121,14 @@
 void DiagramPropertiesDialog::diagramPropertiesDialog(Diagram *diagram, QWidget *parent) {
 	DiagramPropertiesDialog dialog(diagram, parent);
 }
+
+/**
+ * @brief DiagramPropertiesDialog::editAutonum
+ * Open the autonum editor
+ */
+void DiagramPropertiesDialog::editAutonum() {
+	ProjectPropertiesDialog ppd (m_diagram->project(), this);
+	ppd.setCurrentPage(ProjectPropertiesDialog::Autonum);
+	ppd.exec();
+	m_asw -> setItems (m_diagram -> project() -> conductorAutoNum().keys());
+}

Modified: trunk/sources/ui/diagrampropertiesdialog.h
===================================================================
--- trunk/sources/ui/diagrampropertiesdialog.h	2014-08-14 20:31:22 UTC (rev 3273)
+++ trunk/sources/ui/diagrampropertiesdialog.h	2014-08-15 13:16:58 UTC (rev 3274)
@@ -18,18 +18,29 @@
 #ifndef DIAGRAMPROPERTIESDIALOG_H
 #define DIAGRAMPROPERTIESDIALOG_H
 
-#include "diagram.h"
+#include "qdialog.h"
 
+class Diagram;
+class AutonumSelectorWidget;
+
 /**
  * @brief The DiagramPropertiesDialog class
  * This dialog open a windows for edit properties of a diagram.
  */
-class DiagramPropertiesDialog : public QDialog
-{
+class DiagramPropertiesDialog : public QDialog {
+		Q_OBJECT
+
 	public:
 		DiagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
 
 		static void diagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
+
+	public slots:
+		void editAutonum ();
+
+	private:
+		Diagram               *m_diagram;
+		AutonumSelectorWidget *m_asw;
 };
 
 #endif // DIAGRAMPROPERTIESDIALOG_H

Added: trunk/sources/ui/projectpropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/projectpropertiesdialog.cpp	                        (rev 0)
+++ trunk/sources/ui/projectpropertiesdialog.cpp	2014-08-15 13:16:58 UTC (rev 3274)
@@ -0,0 +1,59 @@
+/*
+	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 "projectpropertiesdialog.h"
+#include "configdialog.h"
+#include "projectconfigpages.h"
+#include <QObject>
+
+/**
+ * @brief ProjectPropertiesDialog::ProjectPropertiesDialog
+ * Default constructor
+ * @param project : project to edit properties
+ * @param parent : parent widget of this dialog
+ */
+ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) {
+	m_properties_dialog = new ConfigDialog (parent);
+	m_properties_dialog -> setWindowTitle(QObject::tr("Propri\351t\351s du projet", "window title"));
+	m_properties_dialog -> addPage(new ProjectMainConfigPage       (project));
+	m_properties_dialog -> addPage(new ProjectNewDiagramConfigPage (project));
+	m_properties_dialog -> addPage(new ProjectAutoNumConfigPage    (project));
+}
+
+/**
+ * @brief ProjectPropertiesDialog::~ProjectPropertiesDialog
+ */
+ProjectPropertiesDialog::~ProjectPropertiesDialog () {
+	delete m_properties_dialog;
+}
+
+/**
+ * @brief ProjectPropertiesDialog::exec
+ * execute this dialog.
+ */
+void ProjectPropertiesDialog::exec() {
+	m_properties_dialog -> exec();
+}
+
+/**
+ * @brief ProjectPropertiesDialog::setCurrentPage
+ * Change the current displayed page by p.
+ * @param p : page to display
+ */
+void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
+	m_properties_dialog -> setCurrentPage(static_cast <int> (p));
+}

Added: trunk/sources/ui/projectpropertiesdialog.h
===================================================================
--- trunk/sources/ui/projectpropertiesdialog.h	                        (rev 0)
+++ trunk/sources/ui/projectpropertiesdialog.h	2014-08-15 13:16:58 UTC (rev 3274)
@@ -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 PROJECTPROPERTIESDIALOG_H
+#define PROJECTPROPERTIESDIALOG_H
+
+class QETProject;
+class QWidget;
+class ConfigDialog;
+
+/**
+ * @brief The ProjectPropertiesDialog class
+ * this class builds a dialog to edit whole properties of a project
+ */
+class ProjectPropertiesDialog
+{
+	public:
+		enum Page {
+			Main    = 0,
+			Diagram = 1,
+			Autonum = 2
+		};
+
+		ProjectPropertiesDialog(QETProject *project, QWidget *parent = 0);
+		~ProjectPropertiesDialog();
+		void exec();
+		void setCurrentPage(ProjectPropertiesDialog::Page);
+
+	private:
+		ConfigDialog *m_properties_dialog;
+};
+
+#endif // PROJECTPROPERTIESDIALOG_H


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