Skip to content
Permalink
Browse files
Add a minimal data provider for annotation layers
Required for some nice things, like avoiding rendering slower
annotation layers in canvas preview jobs
  • Loading branch information
nyalldawson committed Aug 31, 2021
1 parent 47bcf09 commit b09994abcc975da390f8d2502b990c1837816372
@@ -132,9 +132,12 @@ The optional ``feedback`` argument can be used to cancel the search early.

virtual bool supportsEditing() const;

virtual QgsDataProvider *dataProvider();


};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -103,12 +103,14 @@ QgsAnnotationLayer::QgsAnnotationLayer( const QString &name, const LayerOptions
{
mShouldValidateCrs = false;
mValid = true;
mDataProvider = new QgsAnnotationLayerDataProvider( QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
}

QgsAnnotationLayer::~QgsAnnotationLayer()
{
emit willBeDeleted();
qDeleteAll( mItems );
delete mDataProvider;
}

void QgsAnnotationLayer::reset()
@@ -385,3 +387,50 @@ bool QgsAnnotationLayer::supportsEditing() const
{
return true;
}

QgsDataProvider *QgsAnnotationLayer::dataProvider()
{
return mDataProvider;
}

const QgsDataProvider *QgsAnnotationLayer::dataProvider() const
{
return mDataProvider;
}


//
// QgsAnnotationLayerDataProvider
//
///@cond PRIVATE
QgsAnnotationLayerDataProvider::QgsAnnotationLayerDataProvider(
const ProviderOptions &options,
QgsDataProvider::ReadFlags flags )
: QgsDataProvider( QString(), options, flags )
{}

QgsCoordinateReferenceSystem QgsAnnotationLayerDataProvider::crs() const
{
return QgsCoordinateReferenceSystem();
}

QString QgsAnnotationLayerDataProvider::name() const
{
return QStringLiteral( "annotation" );
}

QString QgsAnnotationLayerDataProvider::description() const
{
return QString();
}

QgsRectangle QgsAnnotationLayerDataProvider::extent() const
{
return QgsRectangle();
}

bool QgsAnnotationLayerDataProvider::isValid() const
{
return true;
}
///@endcond
@@ -148,6 +148,8 @@ class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
bool isEditable() const override;
bool supportsEditing() const override;
QgsDataProvider *dataProvider() override;
const QgsDataProvider *dataProvider() const override SIP_SKIP;

private:
QMap<QString, QgsAnnotationItem *> mItems;
@@ -156,10 +158,37 @@ class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
std::unique_ptr< QgsAnnotationLayerSpatialIndex > mSpatialIndex;
QSet< QString > mNonIndexedItems;

QgsDataProvider *mDataProvider = nullptr;

QStringList queryIndex( const QgsRectangle &bounds, QgsFeedback *feedback = nullptr ) const;

friend class QgsAnnotationLayerRenderer;

};

#ifndef SIP_RUN
///@cond PRIVATE

/**
* A minimal data provider for annotation layers.
*
* \since QGIS 3.22
*/
class QgsAnnotationLayerDataProvider : public QgsDataProvider
{
Q_OBJECT

public:
QgsAnnotationLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
QgsDataProvider::ReadFlags flags );
QgsCoordinateReferenceSystem crs() const override;
QString name() const override;
QString description() const override;
QgsRectangle extent() const override;
bool isValid() const override;

};
///@endcond
#endif

#endif // QGSANNOTATIONLAYER_H

0 comments on commit b09994a

Please sign in to comment.