mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Element panel widget : improve how an item is updated or added after editing an element with the Qet Element Editor.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4555 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -241,6 +241,54 @@ void ElementsCollectionModel::addCustomCollection(bool set_data)
|
||||
delete feci;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionModel::addLocation
|
||||
* Add the element or directory to this model.
|
||||
* If the location is already managed by this model, do nothing.
|
||||
* @param location
|
||||
*/
|
||||
void ElementsCollectionModel::addLocation(ElementsLocation location)
|
||||
{
|
||||
QModelIndex index = indexFromLocation(location);
|
||||
if (index.isValid())
|
||||
return;
|
||||
|
||||
ElementCollectionItem *last_item = nullptr;
|
||||
QString collection_name;
|
||||
|
||||
if (location.isProject()) {
|
||||
QETProject *project = location.project();
|
||||
|
||||
if (project) {
|
||||
XmlProjectElementCollectionItem *xpeci = m_project_hash.value(project);
|
||||
|
||||
last_item = xpeci->lastItemForPath(location.collectionPath(false), collection_name);
|
||||
}
|
||||
}
|
||||
else if (location.isCustomCollection()) {
|
||||
QList <ElementCollectionItem *> child_list;
|
||||
|
||||
for (int i=0 ; i<rowCount() ; i++)
|
||||
child_list.append(static_cast<ElementCollectionItem *>(item(i)));
|
||||
|
||||
foreach(ElementCollectionItem *eci, child_list) {
|
||||
|
||||
if (eci->type() == FileElementCollectionItem::Type) {
|
||||
FileElementCollectionItem *feci = static_cast<FileElementCollectionItem *>(eci);
|
||||
|
||||
if (feci->isCustomCollection()) {
|
||||
last_item = feci->lastItemForPath(location.collectionPath(false), collection_name);
|
||||
if(last_item)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (last_item)
|
||||
last_item->addChildAtPath(collection_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionModel::addProject
|
||||
* Add project to this model
|
||||
|
||||
Reference in New Issue
Block a user