[qet] [4002] Element info widget : fix wrong behavior with cursor when use the live edit mode

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


Revision: 4002
Author:   blacksun
Date:     2015-06-09 18:28:54 +0200 (Tue, 09 Jun 2015)
Log Message:
-----------
Element info widget : fix wrong behavior with cursor when use the live edit mode

Modified Paths:
--------------
    trunk/sources/ui/elementinfowidget.cpp
    trunk/sources/ui/elementinfowidget.h

Modified: trunk/sources/ui/elementinfowidget.cpp
===================================================================
--- trunk/sources/ui/elementinfowidget.cpp	2015-06-08 18:18:35 UTC (rev 4001)
+++ trunk/sources/ui/elementinfowidget.cpp	2015-06-09 16:28:54 UTC (rev 4002)
@@ -59,12 +59,12 @@
 	if (m_element == element) return;
 
 	if (m_element)
-		disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::updateUi);
+		disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
 
 	m_element = element;
 	updateUi();
 
-	connect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::updateUi);
+	connect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
 }
 
 /**
@@ -87,18 +87,9 @@
  */
 QUndoCommand* ElementInfoWidget::associatedUndo() const
 {
-	DiagramContext new_info;
+	DiagramContext new_info = currentInfo();
 	DiagramContext old_info = m_element -> elementInformations();
 
-	foreach (ElementInfoPartWidget *eipw, m_eipw_list)
-	{
-			//add value only if they're something to store
-		if (!eipw->text().isEmpty())
-			new_info.addValue(eipw->key(),
-						eipw->text(),
-						eipw->mustShow());
-	}
-
 	if (old_info != new_info)
 		return (new ChangeElementInformationCommand(m_element, old_info, new_info));
 
@@ -215,6 +206,21 @@
 }
 
 /**
+ * @brief ElementInfoWidget::currentInfo
+ * @return the info currently edited
+ */
+DiagramContext ElementInfoWidget::currentInfo() const
+{
+	DiagramContext info_;
+
+	foreach (ElementInfoPartWidget *eipw, m_eipw_list)
+		if (!eipw->text().isEmpty()) //add value only if they're something to store
+			info_.addValue(eipw->key(), eipw->text(), eipw->mustShow());
+
+	return info_;
+}
+
+/**
  * @brief ElementInfoWidget::firstActivated
  * Slot activated when this widget is show.
  * Set the focus to the first line edit provided by this widget
@@ -222,3 +228,13 @@
 void ElementInfoWidget::firstActivated() {
 	m_eipw_list.first() -> setFocusTolineEdit();
 }
+
+/**
+ * @brief ElementInfoWidget::elementInfoChange
+ * This slot is called when m_element::elementInformation change.
+ */
+void ElementInfoWidget::elementInfoChange()
+{
+	if(currentInfo() != m_element->elementInformations())
+		updateUi();
+}

Modified: trunk/sources/ui/elementinfowidget.h
===================================================================
--- trunk/sources/ui/elementinfowidget.h	2015-06-08 18:18:35 UTC (rev 4001)
+++ trunk/sources/ui/elementinfowidget.h	2015-06-09 16:28:54 UTC (rev 4002)
@@ -20,6 +20,7 @@
 
 #include <QWidget>
 #include "abstractelementpropertieseditorwidget.h"
+#include "diagramcontext.h"
 
 class Element;
 class QUndoCommand;
@@ -49,7 +50,9 @@
 		QString title() const {return tr("Informations");}
 		bool setLiveEdit(bool live_edit);
 		virtual void updateUi();
+		DiagramContext currentInfo() const;
 
+
 	protected:
 		virtual bool event(QEvent *event);
 		virtual void enableLiveEdit();
@@ -60,6 +63,7 @@
 
 	private slots:
 		void firstActivated();
+		void elementInfoChange();
 
 		//ATTRIBUTES
 	private:


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