# HG changeset patch # User Chris Cannam # Date 1564760552 -3600 # Node ID b402121d8f5f7cb36f17ac59f42437d95ed2f846 # Parent bd7fdc418f363089ca638cf693ab6b880164e95a Add direct method to get source model diff -r bd7fdc418f36 -r b402121d8f5f layer/Layer.cpp --- a/layer/Layer.cpp Fri Jul 19 16:10:19 2019 +0100 +++ b/layer/Layer.cpp Fri Aug 02 16:42:32 2019 +0100 @@ -64,6 +64,18 @@ this, SIGNAL(modelAlignmentCompletionChanged(ModelId))); } +ModelId +Layer::getSourceModel() const +{ + ModelId sourceId; + auto model = ModelById::get(getModel()); + while (model && !model->getSourceModel().isNone()) { + sourceId = model->getSourceModel(); + model = ModelById::get(sourceId); + } + return sourceId; +} + QString Layer::getPropertyContainerIconName() const { diff -r bd7fdc418f36 -r b402121d8f5f layer/Layer.h --- a/layer/Layer.h Fri Jul 19 16:10:19 2019 +0100 +++ b/layer/Layer.h Fri Aug 02 16:42:32 2019 +0100 @@ -64,6 +64,13 @@ * Return the ID of the model represented in this layer. */ virtual ModelId getModel() const = 0; + + /** + * Return the ID of the source model for the model represented in + * this layer. If the model has no other source, or there is no + * model here, return None. + */ + ModelId getSourceModel() const; /** * Return a zoom constraint object defining the supported zoom