mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +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:
@@ -263,10 +263,7 @@ void ElementsCollectionWidget::editElement()
|
||||
app->openElementLocations(QList<ElementsLocation>() << location);
|
||||
|
||||
foreach (QETElementEditor *element_editor, app->elementEditors())
|
||||
{
|
||||
if (element_editor->isEditing(location))
|
||||
connect(element_editor, &QETElementEditor::destroyed, [eci](){ eci->clearData(); eci->setUpData();});
|
||||
}
|
||||
connect(element_editor, &QETElementEditor::saveToLocation, this, &ElementsCollectionWidget::locationWasSaved);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,6 +478,33 @@ void ElementsCollectionWidget::reload()
|
||||
m_progress_bar->hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionWidget::locationWasSaved
|
||||
* This method is connected with the signal savedToLocation of Element editor (see ElementsCollectionWidget::editElement())
|
||||
* Update or add the item represented by location to m_model
|
||||
* @param location
|
||||
*/
|
||||
void ElementsCollectionWidget::locationWasSaved(ElementsLocation location)
|
||||
{
|
||||
//Because this method update an item in the model, location must
|
||||
//represente an existing element (in file system of project)
|
||||
if (!location.exist())
|
||||
return;
|
||||
|
||||
QModelIndex index = m_model->indexFromLocation(location);
|
||||
|
||||
if (index.isValid()) {
|
||||
QStandardItem *item = m_model->itemFromIndex(index);
|
||||
if (item) {
|
||||
static_cast<ElementCollectionItem *>(item)->clearData();
|
||||
static_cast<ElementCollectionItem *>(item)->setUpData();
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_model->addLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionWidget::search
|
||||
* Search every item (directory or element) that match the text of m_search_field
|
||||
|
||||
Reference in New Issue
Block a user