# HG changeset patch # User Chris Cannam # Date 1402677541 -3600 # Node ID defbe5bc47b78b19914b4091aa724f9e5d39e055 # Parent 9911b8cb53bc8e61f4da5e9de8a5ec675506bd0f Add an experimental cancel button to view progress bars diff -r 9911b8cb53bc -r defbe5bc47b7 data/model/Model.h --- 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; }; diff -r 9911b8cb53bc -r defbe5bc47b7 transform/FeatureExtractionModelTransformer.cpp --- a/transform/FeatureExtractionModelTransformer.cpp Fri Jun 13 16:35:15 2014 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Fri Jun 13 17:39:01 2014 +0100 @@ -1018,6 +1018,7 @@ SparseOneDimensionalModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { @@ -1025,24 +1026,28 @@ SparseTimeValueModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { NoteModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); - } else if (isOutput(n)) { + } else if (isOutput(n)) { FlexiNoteModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { RegionModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { @@ -1050,6 +1055,7 @@ EditableDenseThreeDimensionalModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); //!!!m_context.updates); } }