changeset 1862:3072aa267248

Permit setting completion directly on the alignment model, if we aren't using a transform to populate the path source but are instead going to set the path directly after completion
author Chris Cannam
date Fri, 22 May 2020 16:23:25 +0100
parents 9219834e39a4
children 14bf9bf5ac28
files data/model/AlignmentModel.cpp data/model/AlignmentModel.h
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/AlignmentModel.cpp	Thu May 21 16:09:46 2020 +0100
+++ b/data/model/AlignmentModel.cpp	Fri May 22 16:23:25 2020 +0100
@@ -29,7 +29,8 @@
     m_reversePath(nullptr),
     m_pathBegun(false),
     m_pathComplete(false),
-    m_relativePitch(0)
+    m_relativePitch(0),
+    m_explicitlySetCompletion(-1)
 {
     setPathFrom(pathSource);
 
@@ -105,6 +106,10 @@
 bool
 AlignmentModel::isReady(int *completion) const
 {
+    if (m_explicitlySetCompletion != -1) {
+        if (completion) *completion = m_explicitlySetCompletion;
+        return (m_explicitlySetCompletion == 100);
+    }
     if (!m_pathBegun && !m_pathSource.isNone()) {
         if (completion) *completion = 0;
 #ifdef DEBUG_ALIGNMENT_MODEL
@@ -156,6 +161,13 @@
     return m_aligned;
 }
 
+void
+AlignmentModel::setCompletion(int completion)
+{
+    m_explicitlySetCompletion = completion;
+    emit completionChanged(getId());
+}
+
 sv_frame_t
 AlignmentModel::toReference(sv_frame_t frame) const
 {
--- a/data/model/AlignmentModel.h	Thu May 21 16:09:46 2020 +0100
+++ b/data/model/AlignmentModel.h	Fri May 22 16:23:25 2020 +0100
@@ -56,6 +56,8 @@
     ModelId getReferenceModel() const;
     ModelId getAlignedModel() const;
 
+    void setCompletion(int completion);
+
     sv_frame_t toReference(sv_frame_t frame) const;
     sv_frame_t fromReference(sv_frame_t frame) const;
 
@@ -107,6 +109,7 @@
     bool m_pathComplete;
     QString m_error;
     int m_relativePitch;
+    int m_explicitlySetCompletion;
 
     void constructPath() const;
     void constructReversePath() const;