[qet] [3943] Diagram editor : add dock widget for edit the current selection.

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


Revision: 3943
Author:   blacksun
Date:     2015-05-08 00:15:00 +0200 (Fri, 08 May 2015)
Log Message:
-----------
Diagram editor : add dock widget for edit the current selection.
For the moment only work with element

Modified Paths:
--------------
    trunk/qelectrotech.pro
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h
    trunk/sources/ui/elementinfowidget.h
    trunk/sources/ui/elementpropertieswidget.h
    trunk/sources/ui/elementselectorwidget.cpp
    trunk/sources/ui/elementselectorwidget.h
    trunk/sources/ui/linksingleelementwidget.h
    trunk/sources/ui/masterpropertieswidget.cpp
    trunk/sources/ui/masterpropertieswidget.h

Added Paths:
-----------
    trunk/sources/PropertiesEditor/
    trunk/sources/PropertiesEditor/PropertiesEditor.pri
    trunk/sources/PropertiesEditor/propertieseditordockwidget.cpp
    trunk/sources/PropertiesEditor/propertieseditordockwidget.h
    trunk/sources/PropertiesEditor/propertieseditordockwidget.ui
    trunk/sources/PropertiesEditor/propertieseditorwidget.cpp
    trunk/sources/PropertiesEditor/propertieseditorwidget.h
    trunk/sources/ui/diagrampropertieseditordockwidget.cpp
    trunk/sources/ui/diagrampropertieseditordockwidget.h

Removed Paths:
-------------
    trunk/sources/ui/propertieseditorwidget.cpp
    trunk/sources/ui/propertieseditorwidget.h

Modified: trunk/qelectrotech.pro
===================================================================
--- trunk/qelectrotech.pro	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/qelectrotech.pro	2015-05-07 22:15:00 UTC (rev 3943)
@@ -61,6 +61,8 @@
 
 ######################################################################
 
+include(sources/PropertiesEditor/PropertiesEditor.pri)
+
 TEMPLATE = app
 DEPENDPATH += .
 INCLUDEPATH += sources \

Added: trunk/sources/PropertiesEditor/PropertiesEditor.pri
===================================================================
--- trunk/sources/PropertiesEditor/PropertiesEditor.pri	                        (rev 0)
+++ trunk/sources/PropertiesEditor/PropertiesEditor.pri	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,10 @@
+FORMS += \
+    $$PWD/propertieseditordockwidget.ui
+
+HEADERS += \
+    $$PWD/propertieseditordockwidget.h \
+    $$PWD/propertieseditorwidget.h
+
+SOURCES += \
+    $$PWD/propertieseditordockwidget.cpp \
+    $$PWD/propertieseditorwidget.cpp


Property changes on: trunk/sources/PropertiesEditor/PropertiesEditor.pri
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/sources/PropertiesEditor/propertieseditordockwidget.cpp
===================================================================
--- trunk/sources/PropertiesEditor/propertieseditordockwidget.cpp	                        (rev 0)
+++ trunk/sources/PropertiesEditor/propertieseditordockwidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,160 @@
+/*
+	Copyright 2006-2015 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 "propertieseditordockwidget.h"
+#include "ui_propertieseditordockwidget.h"
+#include "propertieseditorwidget.h"
+
+#include <QAbstractButton>
+
+/**
+ * @brief PropertiesEditorDockWidget::PropertiesEditorDockWidget
+ * Constructor
+ * @param parent : parent widget
+ */
+PropertiesEditorDockWidget::PropertiesEditorDockWidget(QWidget *parent) :
+	QDockWidget(parent),
+	ui(new Ui::PropertiesEditorDockWidget)
+{
+	ui->setupUi(this);
+	ui->m_main_vlayout->setAlignment(ui->buttonBox, Qt::AlignBottom);
+	ui->buttonBox->setDisabled(true);
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::~PropertiesEditorDockWidget
+ * Destructor
+ */
+PropertiesEditorDockWidget::~PropertiesEditorDockWidget()
+{
+	clear();
+	delete ui;
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::clear
+ * Remove all editor present in this dock and delete it.
+ * They also disabled the button box at the bottom of this dock
+ */
+void PropertiesEditorDockWidget::clear()
+{
+	foreach (PropertiesEditorWidget *editor, m_editor_list)
+	{
+		m_editor_list.removeOne(editor);
+		ui->m_main_vlayout->removeWidget(editor);
+		editor->deleteLater();
+	}
+
+	m_editor_list.clear();
+
+	ui->buttonBox->setDisabled(true);
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::apply
+ * Call the apply method for each editor present in this dock
+ */
+void PropertiesEditorDockWidget::apply()
+{
+	foreach(PropertiesEditorWidget *editor, m_editor_list)
+		editor->apply();
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::reset
+ * Call the reset method for each editor present in this widget
+ */
+void PropertiesEditorDockWidget::reset()
+{
+	foreach(PropertiesEditorWidget *editor, m_editor_list)
+		editor->reset();
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::addEditor
+ * Add an @editor in this dock at @index in the main vertical layout (note the button box
+ * are displayed at bottom of this layout by default)
+ * When an editor is added, we enable the button box
+ * @param editor : editor to add;
+ * @param index : index of editor in the layout
+ * @return true if was added (or already add) or false if can't be add (editor = nullptr)
+ */
+bool PropertiesEditorDockWidget::addEditor(PropertiesEditorWidget *editor, int index)
+{
+	if (!editor) return false;
+	if (m_editor_list.contains(editor)) return true;
+
+	ui -> m_main_vlayout -> insertWidget(index, editor);
+	m_editor_list << editor;
+	setEnabledButtonBox(true);
+	return true;
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::removeEditor
+ * Remove @editor from this dock. The editor wasn't delete a the end of this method
+ * If the editor was the last on this widget, we disabled the button box
+ * @param editor : editor to remove
+ * @return true on success, else false
+ */
+bool PropertiesEditorDockWidget::removeEditor(PropertiesEditorWidget *editor)
+{
+	bool result = m_editor_list.removeOne(editor);
+	if (result)
+		ui -> m_main_vlayout -> removeWidget(editor);
+
+	if (m_editor_list.isEmpty())
+		setDisabledButtonBox(true);
+	return result;
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::setDisabledButtonBox
+ * Disabled the button box at bottom of dock
+ * @param b
+ */
+void PropertiesEditorDockWidget::setDisabledButtonBox(bool b) {
+	ui -> buttonBox -> setDisabled(b);
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::setEnabledButtonBox
+ * Enabled button box at bottom of dock
+ * @param b
+ */
+void PropertiesEditorDockWidget::setEnabledButtonBox(bool b) {
+	ui -> buttonBox -> setEnabled(b);
+}
+
+/**
+ * @brief PropertiesEditorDockWidget::on_buttonBox_clicked
+ * Action when button box button is clciked.
+ * If button is ApplyRole : call the apply() method
+ * If button is ResetRole : call the reset() method
+ * @param button
+ */
+void PropertiesEditorDockWidget::on_buttonBox_clicked(QAbstractButton *button)
+{
+	int answer = ui->buttonBox->buttonRole(button);
+
+	switch (answer)
+	{
+		case QDialogButtonBox::ApplyRole: apply(); break;
+		case QDialogButtonBox::ResetRole: reset(); break;
+		default: break;
+	}
+}

Added: trunk/sources/PropertiesEditor/propertieseditordockwidget.h
===================================================================
--- trunk/sources/PropertiesEditor/propertieseditordockwidget.h	                        (rev 0)
+++ trunk/sources/PropertiesEditor/propertieseditordockwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,57 @@
+/*
+	Copyright 2006-2015 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 SELECTIONPROPERTIESDOCKWIDGET_H
+#define SELECTIONPROPERTIESDOCKWIDGET_H
+
+#include <QDockWidget>
+
+class PropertiesEditorWidget;
+class QAbstractButton;
+
+namespace Ui {
+	class PropertiesEditorDockWidget;
+}
+
+class PropertiesEditorDockWidget : public QDockWidget
+{
+		Q_OBJECT
+
+	public:
+		explicit PropertiesEditorDockWidget(QWidget *parent = 0);
+		~PropertiesEditorDockWidget();
+
+		virtual void clear();
+		virtual void apply();
+		virtual void reset();
+		bool addEditor (PropertiesEditorWidget *editor, int index = 0);
+		bool removeEditor (PropertiesEditorWidget *editor);
+		void setDisabledButtonBox(bool b = true);
+		void setEnabledButtonBox (bool b = true);
+
+
+	private slots:
+		void on_buttonBox_clicked(QAbstractButton *button);
+
+	protected:
+		QList <PropertiesEditorWidget *> m_editor_list;
+
+	private:
+		Ui::PropertiesEditorDockWidget *ui;
+};
+
+#endif // SELECTIONPROPERTIESDOCKWIDGET_H

Added: trunk/sources/PropertiesEditor/propertieseditordockwidget.ui
===================================================================
--- trunk/sources/PropertiesEditor/propertieseditordockwidget.ui	                        (rev 0)
+++ trunk/sources/PropertiesEditor/propertieseditordockwidget.ui	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PropertiesEditorDockWidget</class>
+ <widget class="QDockWidget" name="PropertiesEditorDockWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Propriété de la séléction</string>
+  </property>
+  <widget class="QWidget" name="dockWidgetContents">
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <property name="sizeConstraint">
+     <enum>QLayout::SetMaximumSize</enum>
+    </property>
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
+     <number>0</number>
+    </property>
+    <item>
+     <layout class="QVBoxLayout" name="m_main_vlayout">
+      <item>
+       <widget class="QDialogButtonBox" name="buttonBox">
+        <property name="standardButtons">
+         <set>QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults</set>
+        </property>
+        <property name="centerButtons">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Added: trunk/sources/PropertiesEditor/propertieseditorwidget.cpp
===================================================================
--- trunk/sources/PropertiesEditor/propertieseditorwidget.cpp	                        (rev 0)
+++ trunk/sources/PropertiesEditor/propertieseditorwidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,46 @@
+/*
+	Copyright 2006-2015 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 "propertieseditorwidget.h"
+#include <QUndoCommand>
+
+/**
+ * @brief PropertiesEditorWidget::PropertiesEditorWidget
+ * Constructor
+ * @param parent : parent widget
+ */
+PropertiesEditorWidget::PropertiesEditorWidget(QWidget *parent) :
+	QWidget(parent)
+{}
+
+/**
+ * @brief PropertiesEditorWidget::associatedUndo
+ * By default, return a nullptr
+ * @return nullptr
+ */
+QUndoCommand *PropertiesEditorWidget::associatedUndo() const{
+	return nullptr;
+}
+
+/**
+ * @brief PropertiesEditorWidget::title
+ * @return the title of this editor
+ */
+QString PropertiesEditorWidget::title() const
+{
+	return QString();
+}

Added: trunk/sources/PropertiesEditor/propertieseditorwidget.h
===================================================================
--- trunk/sources/PropertiesEditor/propertieseditorwidget.h	                        (rev 0)
+++ trunk/sources/PropertiesEditor/propertieseditorwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,42 @@
+/*
+	Copyright 2006-2015 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 PROPERTIESEDITORWIDGET_H
+#define PROPERTIESEDITORWIDGET_H
+
+#include <QWidget>
+
+class QUndoCommand;
+
+/**
+ * @brief The PropertiesEditorWidget class
+ * This class extend QWidget method for have common way
+ * to edit propertie.
+ */
+class PropertiesEditorWidget : public QWidget
+{
+		Q_OBJECT
+	public:
+		explicit PropertiesEditorWidget(QWidget *parent = 0);
+
+		virtual void apply() {}
+		virtual void reset() {}
+		virtual QUndoCommand *associatedUndo () const;
+		virtual QString title() const;
+};
+
+#endif // PROPERTIESEDITORWIDGET_H

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/qetdiagrameditor.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -39,6 +39,7 @@
 #include "dveventaddshape.h"
 #include "dveventaddtext.h"
 #include "reportproperties.h"
+#include "diagrampropertieseditordockwidget.h"
 
 #include "ui/dialogautonum.h"
 
@@ -82,6 +83,7 @@
 	
 	setUpElementsPanel();
 	setUpUndoStack();
+	setUpSelectionPropertiesEditor();
 	setUpActions();
 	setUpToolBar();
 	setUpMenu();
@@ -173,6 +175,17 @@
 }
 
 /**
+ * @brief QETDiagramEditor::setUpSelectionPropertiesEditor
+ * Setup the dock for edit the current selection
+ */
+void QETDiagramEditor::setUpSelectionPropertiesEditor()
+{
+	m_selection_properties_editor = new DiagramPropertiesEditorDockWidget(this);
+	m_selection_properties_editor -> setObjectName("diagram_properties_editor_dock_widget");
+	addDockWidget(Qt::RightDockWidgetArea, m_selection_properties_editor);
+}
+
+/**
  * @brief QETDiagramEditor::setUpActions
  * Set up all Qaction
  */
@@ -727,7 +740,7 @@
 bool QETDiagramEditor::closeProject(ProjectView *project_view) {
 	if (project_view) {
 		activateProject(project_view);
-		if (QMdiSubWindow *sub_window = subWindowForWidget(project_view)) {
+		if (QMdiSubWindow *sub_window = subWindowForWidget(project_view)){
 			return(sub_window -> close());
 		}
 	}
@@ -1217,7 +1230,7 @@
 void QETDiagramEditor::slot_updateComplexActions() {
 	DiagramView *dv = currentDiagram();
 	bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
-	
+
 		//Number of selected conductors
 	int selected_conductors_count = dv ? dv -> diagram() -> selectedConductors().count() : 0;
 	conductor_reset  -> setEnabled(editable_diagram && selected_conductors_count);
@@ -1961,7 +1974,7 @@
  */
 void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
 {
-	connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
+	connect(dv, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
 	connect(dv, SIGNAL(modeChanged()),      this, SLOT(slot_updateModeActions()));
 	connect(dv, SIGNAL(itemAdded()),		this, SLOT(addItemFinish()));
 }
@@ -2072,6 +2085,19 @@
 }
 
 /**
+ * @brief QETDiagramEditor::selectionChanged
+ * This slot is called when a diagram selection was changed.
+ */
+void QETDiagramEditor::selectionChanged()
+{
+	slot_updateComplexActions();
+
+	DiagramView *dv = currentDiagram();
+	if (dv && dv->diagram())
+		m_selection_properties_editor->setDiagram(dv->diagram());
+}
+
+/**
  * @brief QETDiagramEditor::activeUndoStackCleanChanged
  * Enable the QAction save_file when @clean is set to false
  * @clean at true do nothing;

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/qetdiagrameditor.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -30,6 +30,7 @@
 class ElementsPanelWidget;
 class ElementsLocation;
 class RecentFiles;
+class DiagramPropertiesEditorDockWidget;
 /**
 	This class represents the main window of the QElectroTech diagram editor and,
 	ipso facto, the most important part of the QElectroTech user interface.
@@ -48,6 +49,7 @@
 	private:
 		void setUpElementsPanel ();
 		void setUpUndoStack     ();
+		void setUpSelectionPropertiesEditor();
 		void setUpActions       ();
 		void setUpToolBar       ();
 		void setUpMenu          ();
@@ -161,6 +163,7 @@
 		void subWindowActivated(QMdiSubWindow *subWindows);
 
 	private slots:
+		void selectionChanged();
 		void activeUndoStackCleanChanged (bool clean);
 	
 		// attributes
@@ -225,6 +228,7 @@
 		QDockWidget *qdw_pa;
 		/// Dock for the undo list
 		QDockWidget *qdw_undo;
+		DiagramPropertiesEditorDockWidget *m_selection_properties_editor;
 		/// Elements panel
 		ElementsPanelWidget *pa;
 		QMenu *windows_menu;

Added: trunk/sources/ui/diagrampropertieseditordockwidget.cpp
===================================================================
--- trunk/sources/ui/diagrampropertieseditordockwidget.cpp	                        (rev 0)
+++ trunk/sources/ui/diagrampropertieseditordockwidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,88 @@
+/*
+	Copyright 2006-2015 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 "diagrampropertieseditordockwidget.h"
+#include "elementpropertieswidget.h"
+#include "diagram.h"
+#include "element.h"
+
+/**
+ * @brief DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget
+ * Constructor
+ * @param parent : parent widget
+ */
+DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget(QWidget *parent) :
+	PropertiesEditorDockWidget(parent),
+	m_diagram(nullptr)
+{}
+
+/**
+ * @brief DiagramPropertiesEditorDockWidget::setDiagram
+ * Set the diagram to edit the selection.
+ * Connect the diagram signal selectionChanged() to this slot selectionChanged();
+ * If diagram = nullptr, we just disconnect all signal and remove editor.
+ * @param diagram
+ * @param diagram
+ */
+void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
+{
+	if (m_diagram == diagram) return;
+	clear();
+
+	if (m_diagram)
+	{
+		disconnect(m_diagram, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
+		disconnect(m_diagram, SIGNAL(destroyed()),        this, SLOT(diagramWasDeleted()));
+	}
+
+	if (diagram)
+	{
+		m_diagram = diagram;
+		connect(m_diagram, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
+		connect(m_diagram, SIGNAL(destroyed()),        this, SLOT(diagramWasDeleted()));
+		selectionChanged();
+	}
+	else
+		m_diagram = nullptr;
+}
+
+/**
+ * @brief DiagramPropertiesEditorDockWidget::selectionChanged
+ * The current selection of diagram was changed.
+ * We fill the dock with the appropriate ElementPropertiesWidget of the current selection.
+ */
+void DiagramPropertiesEditorDockWidget::selectionChanged()
+{
+	if (!m_diagram) return;
+	clear();
+	if (m_diagram->selectedItems().size() == 1)
+	{
+		QGraphicsItem *item = m_diagram->selectedItems().first();
+		if (Element *elmt = dynamic_cast<Element*>(item))
+			addEditor(new ElementPropertiesWidget(elmt, this));
+	}
+}
+
+/**
+ * @brief DiagramPropertiesEditorDockWidget::diagramWasDeleted
+ * Remove current editor and set m_diagram to nullptr.
+ */
+void DiagramPropertiesEditorDockWidget::diagramWasDeleted()
+{
+	m_diagram = nullptr;
+	clear();
+}

Added: trunk/sources/ui/diagrampropertieseditordockwidget.h
===================================================================
--- trunk/sources/ui/diagrampropertieseditordockwidget.h	                        (rev 0)
+++ trunk/sources/ui/diagrampropertieseditordockwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -0,0 +1,42 @@
+/*
+	Copyright 2006-2015 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 DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
+#define DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
+
+#include "PropertiesEditor/propertieseditordockwidget.h"
+
+class Diagram;
+
+class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
+{
+		Q_OBJECT
+
+	public:
+		DiagramPropertiesEditorDockWidget(QWidget *parent = nullptr);
+
+		void setDiagram(Diagram *diagram);
+
+	private slots:
+		void selectionChanged();
+		void diagramWasDeleted();
+
+	private:
+		Diagram *m_diagram;
+};
+
+#endif // DIAGRAMPROPERTIESEDITORDOCKWIDGET_H

Modified: trunk/sources/ui/elementinfowidget.h
===================================================================
--- trunk/sources/ui/elementinfowidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/elementinfowidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -20,7 +20,7 @@
 
 #include <QWidget>
 #include "diagramcontext.h"
-#include "propertieseditorwidget.h"
+#include "PropertiesEditor/propertieseditorwidget.h"
 
 class Element;
 class QUndoCommand;

Modified: trunk/sources/ui/elementpropertieswidget.h
===================================================================
--- trunk/sources/ui/elementpropertieswidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/elementpropertieswidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -18,7 +18,7 @@
 #ifndef ELEMENTPROPERTIESWIDGET_H
 #define ELEMENTPROPERTIESWIDGET_H
 
-#include "propertieseditorwidget.h"
+#include "PropertiesEditor/propertieseditorwidget.h"
 
 class Element;
 class Diagram;

Modified: trunk/sources/ui/elementselectorwidget.cpp
===================================================================
--- trunk/sources/ui/elementselectorwidget.cpp	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/elementselectorwidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -62,10 +62,15 @@
  * @param elmt
  */
 void ElementSelectorWidget::showElement(Element *elmt) {
-	if (showed_element) showed_element->setHighlighted(false);
+	if (showed_element)
+	{
+		disconnect(showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
+		showed_element->setHighlighted(false);
+	}
 	elmt->diagram()->showMe();
 	elmt->setHighlighted(true);
 	showed_element = elmt;
+	connect(showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
 }
 
 /**
@@ -225,6 +230,14 @@
 }
 
 /**
+ * @brief ElementSelectorWidget::showedElementWasDeleted
+ * Set to nullptr the current showed element when he was deleted
+ */
+void ElementSelectorWidget::showedElementWasDeleted() {
+	showed_element = nullptr;
+}
+
+/**
  * @brief ElementSelectorWidget::filter
  * @return A stringlist with all available value
  * to filter the content of this widget;

Modified: trunk/sources/ui/elementselectorwidget.h
===================================================================
--- trunk/sources/ui/elementselectorwidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/elementselectorwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -55,8 +55,9 @@
 	void buildInterface();
 
 	private slots:
-	void setSelectedElement  (const int i) {selected_element = elements_list.at(i);}
-	void showElementFromList (const int i);
+		void setSelectedElement  (const int i) {selected_element = elements_list.at(i);}
+		void showElementFromList (const int i);
+		void showedElementWasDeleted ();
 
 
 	///Attributes

Modified: trunk/sources/ui/linksingleelementwidget.h
===================================================================
--- trunk/sources/ui/linksingleelementwidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/linksingleelementwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -18,7 +18,7 @@
 #ifndef LINKSINGLEELEMENTWIDGET_H
 #define LINKSINGLEELEMENTWIDGET_H
 
-#include "propertieseditorwidget.h"
+#include "PropertiesEditor/propertieseditorwidget.h"
 #include "element.h"
 
 class Diagram;

Modified: trunk/sources/ui/masterpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/masterpropertieswidget.cpp	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/masterpropertieswidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -33,7 +33,8 @@
 MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
 	PropertiesEditorWidget(parent),
 	ui(new Ui::MasterPropertiesWidget),
-	element_(elmt)
+	element_(elmt),
+	m_showed_element (nullptr)
 {
 	ui->setupUi(this);
 	buildInterface();
@@ -47,7 +48,8 @@
  */
 MasterPropertiesWidget::~MasterPropertiesWidget()
 {
-	foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
+	if (m_showed_element) m_showed_element->setHighlighted(false);
+	//foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
 	delete ui;
 }
 
@@ -184,9 +186,24 @@
  * Show the element corresponding to the given QListWidgetItem
  * @param lwi
  */
-void MasterPropertiesWidget::showElementFromLWI(QListWidgetItem *lwi) {
-	foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
-	Element *elmt = lwi_hash[lwi];
-	elmt->diagram()->showMe();
-	elmt->setHighlighted(true);
+void MasterPropertiesWidget::showElementFromLWI(QListWidgetItem *lwi)
+{
+	if (m_showed_element)
+	{
+		disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
+		m_showed_element -> setHighlighted(false);
+	}
+
+	m_showed_element = lwi_hash[lwi];
+	m_showed_element->diagram()->showMe();
+	m_showed_element->setHighlighted(true);
+	connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
 }
+
+/**
+ * @brief MasterPropertiesWidget::showedElementWasDeleted
+ * Set to nullptr the current showed element when he was deleted
+ */
+void MasterPropertiesWidget::showedElementWasDeleted() {
+	m_showed_element = nullptr;
+}

Modified: trunk/sources/ui/masterpropertieswidget.h
===================================================================
--- trunk/sources/ui/masterpropertieswidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/masterpropertieswidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -20,7 +20,7 @@
 
 #include <QWidget>
 #include <QHash>
-#include <propertieseditorwidget.h>
+#include "PropertiesEditor/propertieseditorwidget.h"
 
 class QListWidgetItem;
 class Element;
@@ -53,14 +53,16 @@
 	void buildInterface();
 
 	private slots:
-	void on_link_button_clicked();
-	void on_unlink_button_clicked();
-	void showElementFromLWI(QListWidgetItem *lwi);
+		void on_link_button_clicked();
+		void on_unlink_button_clicked();
+		void showElementFromLWI(QListWidgetItem *lwi);
+		void showedElementWasDeleted ();
 
 	private:
 	Ui::MasterPropertiesWidget *ui;
 	Element *element_;
 	QHash <QListWidgetItem *, Element *> lwi_hash;
+	Element *m_showed_element;
 };
 
 #endif // MASTERPROPERTIESWIDGET_H

Deleted: trunk/sources/ui/propertieseditorwidget.cpp
===================================================================
--- trunk/sources/ui/propertieseditorwidget.cpp	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/propertieseditorwidget.cpp	2015-05-07 22:15:00 UTC (rev 3943)
@@ -1,46 +0,0 @@
-/*
-	Copyright 2006-2015 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 "propertieseditorwidget.h"
-#include <QUndoCommand>
-
-/**
- * @brief PropertiesEditorWidget::PropertiesEditorWidget
- * Constructor
- * @param parent : parent widget
- */
-PropertiesEditorWidget::PropertiesEditorWidget(QWidget *parent) :
-	QWidget(parent)
-{}
-
-/**
- * @brief PropertiesEditorWidget::associatedUndo
- * By default, return a nullptr
- * @return nullptr
- */
-QUndoCommand *PropertiesEditorWidget::associatedUndo() const{
-	return nullptr;
-}
-
-/**
- * @brief PropertiesEditorWidget::title
- * @return the title of this editor
- */
-QString PropertiesEditorWidget::title() const
-{
-	return QString();
-}

Deleted: trunk/sources/ui/propertieseditorwidget.h
===================================================================
--- trunk/sources/ui/propertieseditorwidget.h	2015-05-07 18:30:49 UTC (rev 3942)
+++ trunk/sources/ui/propertieseditorwidget.h	2015-05-07 22:15:00 UTC (rev 3943)
@@ -1,42 +0,0 @@
-/*
-	Copyright 2006-2015 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 PROPERTIESEDITORWIDGET_H
-#define PROPERTIESEDITORWIDGET_H
-
-#include <QWidget>
-
-class QUndoCommand;
-
-/**
- * @brief The PropertiesEditorWidget class
- * This class extend QWidget method for have common way
- * to edit propertie.
- */
-class PropertiesEditorWidget : public QWidget
-{
-		Q_OBJECT
-	public:
-		explicit PropertiesEditorWidget(QWidget *parent = 0);
-
-		virtual void apply() {}
-		virtual void reset() {}
-		virtual QUndoCommand *associatedUndo () const;
-		virtual QString title() const;
-};
-
-#endif // PROPERTIESEDITORWIDGET_H


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