[qet] [1794] Elements panel: also highlight integrated element when they are erased.

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


Revision: 1794
Author:   xavier
Date:     2012-05-10 19:48:38 +0200 (Thu, 10 May 2012)
Log Message:
-----------
Elements panel: also highlight integrated element when they are erased.

Modified Paths:
--------------
    trunk/sources/genericpanel.cpp
    trunk/sources/genericpanel.h

Modified: trunk/sources/genericpanel.cpp
===================================================================
--- trunk/sources/genericpanel.cpp	2012-05-10 17:48:33 UTC (rev 1793)
+++ trunk/sources/genericpanel.cpp	2012-05-10 17:48:38 UTC (rev 1794)
@@ -788,7 +788,28 @@
 }
 
 /**
+	Refresh element at \a location.
+	@return the refreshed tree item
+*/
+QTreeWidgetItem *GenericPanel::refreshElement(const ElementsLocation &location) {
+	QTreeWidgetItem *item = itemForElementsLocation(location);
+	if (!item) return(0);
+	if (item -> type() != QET::Element) return(0);
 	
+	QTreeWidgetItem *parent = item -> parent();
+	if (!parent) return(0);
+	
+	QTreeWidgetItem *result = updateElementItem(
+		item,
+		QETApp::collectionItem(location) -> toElement(),
+		PanelOptions(QFlag(parent -> data(0, GenericPanel::PanelFlags).toInt())),
+		false
+	);
+	return(result);
+}
+
+/**
+	
 */
 QTreeWidgetItem *GenericPanel::addElement(ElementDefinition *element, QTreeWidgetItem *parent_item, PanelOptions options) {
 	if (!element) return(0);
@@ -983,10 +1004,14 @@
 	}
 	if (added_locations.count()) {
 		refreshElementsCategory(loc);
+	} else {
+		if (refreshElement(location)) {
+			added_locations << location;
+		}
 	}
 	
 	// Since we have refreshed the panel before the element is actually used by
-	// the diagram, it will appear as unused; we force it as unused.
+	// the diagram, it will appear as unused; we force it as used.
 	// FIXME a better solution would be to get warned when an element gets used
 	// or unused.
 	if (QTreeWidgetItem *integrated_element_qtwi = itemForElementsLocation(location)) {

Modified: trunk/sources/genericpanel.h
===================================================================
--- trunk/sources/genericpanel.h	2012-05-10 17:48:33 UTC (rev 1793)
+++ trunk/sources/genericpanel.h	2012-05-10 17:48:38 UTC (rev 1794)
@@ -145,6 +145,7 @@
 	virtual QTreeWidgetItem *updateElementsCategoryItem(QTreeWidgetItem *, ElementsCategory *, PanelOptions = AddAllChild, bool = false);
 	virtual QTreeWidgetItem *fillElementsCategoryItem  (QTreeWidgetItem *, ElementsCategory *, PanelOptions = AddAllChild, bool = false);
 	virtual QTreeWidgetItem *refreshElementsCategory(const ElementsLocation &);
+	virtual QTreeWidgetItem *refreshElement(const ElementsLocation &);
 	
 	// elements methods
 	public:


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