diff data/model/Model.h @ 923:defbe5bc47b7 tonioni

Add an experimental cancel button to view progress bars
author Chris Cannam
date Fri, 13 Jun 2014 17:39:01 +0100
parents d81c16e47e22
children d03b3d956358
line wrap: on
line diff
--- a/data/model/Model.h	Fri Jun 13 16:35:15 2014 +0100
+++ b/data/model/Model.h	Fri Jun 13 17:39:01 2014 +0100
@@ -105,7 +105,27 @@
      * Caller owns the returned value.
      */
     virtual Model *clone() const = 0;
-    
+
+    /**
+     * Mark the model as abandoning. This means that the application
+     * no longer needs it, so it can stop doing any background
+     * calculations it may be involved in. Note that as far as the
+     * model API is concerned, this does nothing more than tell the
+     * model to return true from isAbandoning().  The actual response
+     * to this will depend on the model's context -- it's possible
+     * nothing at all will change.
+     */
+    virtual void abandon() {
+        m_abandoning = true;
+    }
+
+    /**
+     * Query whether the model has been marked as abandoning.
+     */
+    virtual bool isAbandoning() const { 
+        return m_abandoning;
+    }
+
     /**
      * Return true if the model has finished loading or calculating
      * all its data, for a model that is capable of calculating in a
@@ -268,7 +288,11 @@
     void aboutToBeDeleted();
 
 protected:
-    Model() : m_sourceModel(0), m_alignment(0), m_aboutToDelete(false) { }
+    Model() : 
+        m_sourceModel(0), 
+        m_alignment(0), 
+        m_abandoning(false), 
+        m_aboutToDelete(false) { }
 
     // Not provided.
     Model(const Model &);
@@ -277,6 +301,7 @@
     Model *m_sourceModel;
     AlignmentModel *m_alignment;
     QString m_typeUri;
+    bool m_abandoning;
     bool m_aboutToDelete;
 };