This commit is contained in:
Miodrag Milanovic 2018-10-20 17:04:49 +02:00
parent ba0ab7cb30
commit f43ee265e8
3 changed files with 15 additions and 30 deletions

View File

@ -306,8 +306,6 @@ void DesignWidget::newContext(Context *ctx)
#endif
getTreeByElementType(ElementType::CELL)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL)));
getTreeByElementType(ElementType::NET)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET)));
getTreeByElementType(ElementType::CELL)->updateCells(ctx);
getTreeByElementType(ElementType::NET)->updateNets(ctx);
}
updateTree();
}
@ -331,8 +329,18 @@ void DesignWidget::updateTree()
{
std::lock_guard<std::mutex> lock_ui(ctx->ui_mutex);
std::lock_guard<std::mutex> lock(ctx->mutex);
getTreeByElementType(ElementType::CELL)->updateCells(ctx);
getTreeByElementType(ElementType::NET)->updateNets(ctx);
std::vector<IdString> cells;
for (auto &pair : ctx->cells) {
cells.push_back(pair.first);
}
std::vector<IdString> nets;
for (auto &pair : ctx->nets) {
nets.push_back(pair.first);
}
getTreeByElementType(ElementType::CELL)->updateElements(ctx, cells);
getTreeByElementType(ElementType::NET)->updateElements(ctx, nets);
}
}
QtProperty *DesignWidget::addTopLevelProperty(const QString &id)

View File

@ -161,35 +161,13 @@ void Model::loadData(std::unique_ptr<Item> data)
endResetModel();
}
void Model::updateCells(Context *ctx)
void Model::updateElements(Context *ctx, std::vector<IdString> elements)
{
if (!ctx)
return;
beginResetModel();
std::vector<IdString> cells;
for (auto &pair : ctx->cells) {
cells.push_back(pair.first);
}
root_->updateElements(ctx, cells);
endResetModel();
}
void Model::updateNets(Context *ctx)
{
if (!ctx)
return;
beginResetModel();
std::vector<IdString> nets;
for (auto &pair : ctx->nets) {
nets.push_back(pair.first);
}
root_->updateElements(ctx, nets);
root_->updateElements(ctx, elements);
endResetModel();
}

View File

@ -353,8 +353,7 @@ class Model : public QAbstractItemModel
~Model();
void loadData(std::unique_ptr<Item> data);
void updateCells(Context *ctx);
void updateNets(Context *ctx);
void updateElements(Context *ctx, std::vector<IdString> elements);
Item *nodeFromIndex(const QModelIndex &idx) const;
QModelIndex indexFromNode(Item *node)
{