# HG changeset patch # User Chris Cannam # Date 1429521026 -3600 # Node ID e53a87a5efb2fcf90ca9d97cfe0592b53226d002 # Parent 78c152e4db958ac5a36e0fba3102cb6fdc52dd62 Allow layers to be loaded without models if their layer class explicitly says it's OK (otherwise default template won't load, as it has an empty waveform layer) diff -r 78c152e4db95 -r e53a87a5efb2 layer/Layer.h --- a/layer/Layer.h Mon Apr 20 09:12:17 2015 +0100 +++ b/layer/Layer.h Mon Apr 20 10:10:26 2015 +0100 @@ -62,7 +62,7 @@ Model *getModel() { return const_cast(const_cast(this)->getModel()); } - + /** * Return a zoom constraint object defining the supported zoom * levels for this layer. If this returns zero, the layer will @@ -518,6 +518,13 @@ */ virtual RangeMapper *getNewVerticalZoomRangeMapper() const { return 0; } + /** + * Return true if this layer type can function without a model + * being set. If false (the default), the layer will not be loaded + * from a session if its model cannot be found. + */ + virtual bool canExistWithoutModel() const { return false; } + public slots: void showLayer(View *, bool show); diff -r 78c152e4db95 -r e53a87a5efb2 layer/TimeRulerLayer.h --- a/layer/TimeRulerLayer.h Mon Apr 20 09:12:17 2015 +0100 +++ b/layer/TimeRulerLayer.h Mon Apr 20 10:10:26 2015 +0100 @@ -60,6 +60,8 @@ void setProperties(const QXmlAttributes &attributes); + virtual bool canExistWithoutModel() const { return true; } + protected: Model *m_model; LabelHeight m_labelHeight; diff -r 78c152e4db95 -r e53a87a5efb2 layer/WaveformLayer.h --- a/layer/WaveformLayer.h Mon Apr 20 09:12:17 2015 +0100 +++ b/layer/WaveformLayer.h Mon Apr 20 10:10:26 2015 +0100 @@ -202,6 +202,8 @@ virtual int getCurrentVerticalZoomStep() const; virtual void setVerticalZoomStep(int); + virtual bool canExistWithoutModel() const { return true; } + protected: int dBscale(double sample, int m) const;