changeset 1489:b402121d8f5f

Add direct method to get source model
author Chris Cannam
date Fri, 02 Aug 2019 16:42:32 +0100
parents bd7fdc418f36
children c83504eb2649
files layer/Layer.cpp layer/Layer.h
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
 {
--- 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