# HG changeset patch # User Chris Cannam # Date 1562090745 -3600 # Node ID 0769eaacc6bf6d68235959c027ea10eea6af3406 # Parent c268fe2ad59736dcd7165146f83722974ede12da Further ModelId updates diff -r c268fe2ad597 -r 0769eaacc6bf widgets/LayerTree.cpp --- a/widgets/LayerTree.cpp Tue Jul 02 15:38:37 2019 +0100 +++ b/widgets/LayerTree.cpp Tue Jul 02 19:05:45 2019 +0100 @@ -77,7 +77,7 @@ void ModelMetadataModel::rebuildModelSet() { - std::set unfound = m_models; + std::set unfound = m_models; for (int i = 0; i < m_stack->getPaneCount(); ++i) { @@ -89,26 +89,23 @@ Layer *layer = pane->getLayer(j); if (!layer) continue; - Model *model = layer->getModel(); - if (!model) continue; + ModelId modelId = layer->getModel(); + if (modelId.isNone()) continue; if (m_waveModelsOnly) { - if (!dynamic_cast(model)) continue; + if (!ModelById::getAs(modelId)) continue; } - if (m_models.find(model) == m_models.end()) { - connect(model, SIGNAL(aboutToBeDeleted()), - this, SLOT(rebuildModelSet())); - m_models.insert(model); + if (m_models.find(modelId) == m_models.end()) { + m_models.insert(modelId); } else { - unfound.erase(model); + unfound.erase(modelId); } } } - for (std::set::iterator i = unfound.begin(); - i != unfound.end(); ++i) { - m_models.erase(*i); + for (ModelId m: unfound) { + m_models.erase(m); } SVDEBUG << "ModelMetadataModel::rebuildModelSet: " << m_models.size() << " models" << endl; @@ -173,11 +170,12 @@ int row = index.row(), col = index.column(); //!!! not exactly the ideal use of a std::set - std::set::iterator itr = m_models.begin(); + std::set::iterator itr = m_models.begin(); for (int i = 0; i < row && itr != m_models.end(); ++i, ++itr); if (itr == m_models.end()) return QVariant(); - Model *model = *itr; + auto model = ModelById::get(*itr); + if (!model) return QVariant(); if (role != Qt::DisplayRole) { if (m_waveModelsOnly && col == m_modelNameColumn && @@ -444,7 +442,7 @@ return QVariant(Qt::AlignHCenter); } } else if (col == m_modelNameColumn) { - Model *model = layer->getModel(); + auto model = ModelById::get(layer->getModel()); if (model && role == Qt::DisplayRole) { return QVariant(model->objectName()); } diff -r c268fe2ad597 -r 0769eaacc6bf widgets/LayerTree.h --- a/widgets/LayerTree.h Tue Jul 02 15:38:37 2019 +0100 +++ b/widgets/LayerTree.h Tue Jul 02 19:05:45 2019 +0100 @@ -19,6 +19,8 @@ #include +#include "data/model/Model.h" + #include class PaneStack; @@ -26,7 +28,6 @@ class Pane; class Layer; class PropertyContainer; -class Model; class ModelMetadataModel : public QAbstractItemModel { @@ -73,7 +74,7 @@ int m_modelSourceColumn; int m_columnCount; - std::set m_models; + std::set m_models; }; class LayerTreeModel : public QAbstractItemModel