Elements panels now display and highlight elements newly-integrated into projects.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1697 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-04-28 16:45:16 +00:00
parent 1b52030484
commit fac1c5c2c4
10 changed files with 221 additions and 9 deletions

View File

@@ -10,6 +10,7 @@
#include "elementslocation.h"
#include "qeticons.h"
#include "elementscollectioncache.h"
#include "qetapp.h"
/**
Constructor
@@ -248,6 +249,10 @@ QTreeWidgetItem *GenericPanel::fillProjectItem(QTreeWidgetItem *project_qtwi, QE
project, SIGNAL(projectDiagramsOrderChanged(QETProject *, int, int)),
this, SLOT (projectDiagramsOrderChanged(QETProject *, int, int))
);
connect(
project, SIGNAL(elementIntegrated(QETProject *, const ElementsLocation &)),
this, SLOT(elementIntegrated(QETProject *, const ElementsLocation &))
);
} else {
// remove diagrams unknown to the project (presumably removed)
removeObsoleteItems(project -> diagrams(), project_qtwi, QET::Diagram, false);
@@ -729,6 +734,8 @@ QTreeWidgetItem *GenericPanel::fillElementsCategoryItem(QTreeWidgetItem *categor
int index = 0;
category_qtwi -> setData(0, GenericPanel::PanelFlags, (int)options);
if (options & AddChildElementsCategories) {
if (!freshly_created) {
QList<ElementsLocation> sub_categories;
@@ -761,6 +768,23 @@ QTreeWidgetItem *GenericPanel::fillElementsCategoryItem(QTreeWidgetItem *categor
return(fillItem(category_qtwi, options, freshly_created));
}
/**
Refresh elements category at \a location.
@return the refreshed tree item
*/
QTreeWidgetItem *GenericPanel::refreshElementsCategory(const ElementsLocation &location) {
QTreeWidgetItem *item = itemForElementsLocation(location);
if (!item) return(0);
if (item -> type() != QET::ElementsCategory && item -> type() != QET::ElementsCollection) return(0);
QTreeWidgetItem *result = fillElementsCategoryItem(
item,
QETApp::collectionItem(location) -> toCategory(),
PanelOptions(QFlag(item -> data(0, GenericPanel::PanelFlags).toInt())),
false
);
return(result);
}
/**
*/
@@ -940,6 +964,27 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, in
emit(panelContentChanged());
}
/**
Inform this panel the project \a project has integrated the element at \a location
*/
QList<ElementsLocation> GenericPanel::elementIntegrated(QETProject *project, const ElementsLocation &location) {
Q_UNUSED(project)
QList<ElementsLocation> added_locations;
int i = 0;
ElementsLocation loc = location;
// starting from the provided location, goes up into the tree until a displayed location is reached
while (i < 100 && !(itemForElementsLocation(loc))) {
added_locations << loc;
loc = loc.parent();
++ i;
}
if (added_locations.count()) {
refreshElementsCategory(loc);
}
return(added_locations);
}
/**
Inform this panel the diagram \a diagram has changed its title to \a title.
*/