[qet] qet/qet: [4839] Minor : Element info widget : when editing the field formula, the field label must be disable.

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


Revision: 4839
Author:   blacksun
Date:     2017-01-10 10:09:30 +0100 (Tue, 10 Jan 2017)
Log Message:
-----------
Minor : Element info widget : when editing the field formula, the field label must be disable.
Only work when element info widget is in the dock, but not with the dialog : fix it.

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

Modified: trunk/sources/ui/elementinfowidget.cpp
===================================================================
--- trunk/sources/ui/elementinfowidget.cpp	2017-01-10 01:35:44 UTC (rev 4838)
+++ trunk/sources/ui/elementinfowidget.cpp	2017-01-10 09:09:30 UTC (rev 4839)
@@ -64,6 +64,22 @@
 	m_element = element;
 	updateUi();
 
+	ElementInfoPartWidget *f = infoPartWidgetForKey("formula");
+	ElementInfoPartWidget *l = infoPartWidgetForKey("label");
+
+	if (f && l)
+	{
+		if (f->text().isEmpty())
+			l->setEnabled(true);
+		else
+			l->setDisabled(true);
+
+		connect(f, &ElementInfoPartWidget::textChanged, [l](const QString text)
+		{
+			l->setEnabled(text.isEmpty()? true : false);
+		});
+	}
+
 	connect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
 }
 
@@ -75,20 +91,7 @@
 void ElementInfoWidget::apply()
 {
 	if (QUndoCommand *undo = associatedUndo())
-	{
 		m_element -> diagram() -> undoStack().push(undo);
-
-		ElementInfoPartWidget *f = infoPartWidgetForKey("formula");
-		ElementInfoPartWidget *l = infoPartWidgetForKey("label");
-
-		if (f && l)
-		{
-			if (f->text().isEmpty())
-				l->setEnabled(true);
-			else
-				l->setDisabled(true);
-		}
-	}
 }
 
 /**
@@ -232,17 +235,6 @@
 			eipw->setHideShow(true);
 	}
 
-	ElementInfoPartWidget *f = infoPartWidgetForKey("formula");
-	ElementInfoPartWidget *l = infoPartWidgetForKey("label");
-
-	if (f && l)
-	{
-		if (f->text().isEmpty())
-			l->setEnabled(true);
-		else
-			l->setDisabled(true);
-	}
-
 	if (m_live_edit) enableLiveEdit();
 }
 


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