diff --git a/sources/genericpanel.cpp b/sources/genericpanel.cpp index a0b473cf8..47e5b8737 100644 --- a/sources/genericpanel.cpp +++ b/sources/genericpanel.cpp @@ -787,6 +787,27 @@ QTreeWidgetItem *GenericPanel::refreshElementsCategory(const ElementsLocation &l return(result); } +/** + 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); +} + /** */ @@ -983,10 +1004,14 @@ QList GenericPanel::elementIntegrated(QETProject *project, con } 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)) { diff --git a/sources/genericpanel.h b/sources/genericpanel.h index 606c947b3..7cdcbf452 100644 --- a/sources/genericpanel.h +++ b/sources/genericpanel.h @@ -145,6 +145,7 @@ class GenericPanel : public QTreeWidget { 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: