Skip to content
Permalink
Browse files

Remove QgsInterruptionChecker and replace with QgsFeedback use

There's little need for two classes with similar goals here.
  • Loading branch information
nyalldawson committed Feb 19, 2018
1 parent 1014e5c commit d830821b133dfc78ef46f98bfa47d848442c7753
@@ -287,6 +287,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- HalfEdge.
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
- QgsInterruptionChecker. Use QgsFeedback instead.
- QgsGenericProjectionSelector. Use QgsProjectionSelectionTreeWidget instead.
- QgsGeometryCache. It got redundant after removal of old snapping classes (QgsSnapper + friends).
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngine.
@@ -1031,6 +1032,13 @@ None will need to be modified, as the method will return an empty geometry if th
- fields() no longer returns a pointer, but instead a QgsFields value.
- The duplicate method setFeatureId() was removed. Use setId() instead.


QgsFeatureIterator {#qgis_api_break_3_0_QgsFeatureIterator}
------------------

- setInterruptionChecker now accepts a QgsFeedback object instead of a QgsInterruptionChecker.


QgsFeatureListViewDelegate {#qgis_api_break_3_0_QgsFeatureListViewDelegate}
--------------------------

@@ -8,8 +8,6 @@





class QgsAbstractFeatureIterator
{
%Docstring
@@ -637,6 +637,7 @@ SET(QGIS_CORE_MOC_HDRS
qgsvectorlayerexporter.h
qgsvectorlayerfeaturecounter.h
qgsvectorlayerjoinbuffer.h
qgsvectorlayerrenderer.h
qgsvectorlayertools.h
qgsmapthemecollection.h
qgswebpage.h
@@ -920,7 +921,6 @@ SET(QGIS_CORE_HDRS
qgsvectorlayerjoininfo.h
qgsvectorlayerlabelprovider.h
qgsvectorlayerlabeling.h
qgsvectorlayerrenderer.h
qgsvectorlayerundocommand.h
qgsvectorlayerundopassthroughcommand.h
qgsvectorlayerutils.h
@@ -211,7 +211,7 @@ bool QgsAbstractFeatureIterator::prepareOrderBy( const QList<QgsFeatureRequest::
return false;
}

void QgsAbstractFeatureIterator::setInterruptionChecker( QgsInterruptionChecker * )
void QgsAbstractFeatureIterator::setInterruptionChecker( QgsFeedback * )
{
}

@@ -19,21 +19,7 @@
#include "qgsfeaturerequest.h"
#include "qgsindexedfeature.h"



/**
* \ingroup core
* Interface that can be optionally attached to an iterator so its
* nextFeature() implementaton can check if it must stop as soon as possible.
* \since QGIS 2.16
* \note not available in Python bindings
*/
class CORE_EXPORT QgsInterruptionChecker SIP_SKIP
{
public:
//! return true if the iterator must stop as soon as possible
virtual bool mustStop() const = 0;
};
class QgsFeedback;

/**
* \ingroup core
@@ -74,7 +60,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
* \since QGIS 2.16
* \note not available in Python bindings
*/
virtual void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker ) SIP_SKIP;
virtual void setInterruptionChecker( QgsFeedback *interruptionChecker ) SIP_SKIP;

/**
* Returns the status of expression compilation for filter expression requests.
@@ -329,7 +315,7 @@ class CORE_EXPORT QgsFeatureIterator
* \since QGIS 2.16
* \note not available in Python bindings
*/
void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker ) SIP_SKIP;
void setInterruptionChecker( QgsFeedback *interruptionChecker ) SIP_SKIP;

/**
* Returns the status of expression compilation for filter expression requests.
@@ -404,7 +390,7 @@ inline bool operator!= ( const QgsFeatureIterator &fi1, const QgsFeatureIterator
return !( fi1 == fi2 );
}

inline void QgsFeatureIterator::setInterruptionChecker( QgsInterruptionChecker *interruptionChecker )
inline void QgsFeatureIterator::setInterruptionChecker( QgsFeedback *interruptionChecker )
{
if ( mIter )
mIter->setInterruptionChecker( interruptionChecker );
@@ -402,7 +402,7 @@ bool QgsVectorLayerFeatureIterator::close()
return true;
}

void QgsVectorLayerFeatureIterator::setInterruptionChecker( QgsInterruptionChecker *interruptionChecker )
void QgsVectorLayerFeatureIterator::setInterruptionChecker( QgsFeedback *interruptionChecker )
{
mProviderIterator.setInterruptionChecker( interruptionChecker );
mInterruptionChecker = interruptionChecker;
@@ -119,7 +119,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
//! end of iterating: free the resources / lock
bool close() override;

void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker ) override SIP_SKIP;
void setInterruptionChecker( QgsFeedback *interruptionChecker ) override SIP_SKIP;

/**
* Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAttributes().
@@ -247,7 +247,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera

std::unique_ptr<QgsExpressionContext> mExpressionContext;

QgsInterruptionChecker *mInterruptionChecker = nullptr;
QgsFeedback *mInterruptionChecker = nullptr;

QList< int > mPreparedFields;
QList< int > mFieldsToPrepare;
@@ -549,10 +549,16 @@ void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer *layer, QSet<QStrin
QgsVectorLayerRendererInterruptionChecker::QgsVectorLayerRendererInterruptionChecker
( const QgsRenderContext &context )
: mContext( context )
, mTimer( new QTimer( this ) )
{
}
connect( mTimer, &QTimer::timeout, this, [ = ]
{
if ( mContext.renderingStopped() )
{
mTimer->stop();
cancel();
}
} );
mTimer->start( 50 );

bool QgsVectorLayerRendererInterruptionChecker::mustStop() const
{
return mContext.renderingStopped();
}
@@ -39,6 +39,7 @@ typedef QList<int> QgsAttributeList;
#include "qgsfeature.h" // QgsFeatureIds
#include "qgsfeatureiterator.h"
#include "qgsvectorsimplifymethod.h"
#include "qgsfeedback.h"

#include "qgsmaplayerrenderer.h"

@@ -50,14 +51,17 @@ class QgsVectorLayerDiagramProvider;
* Interruption checker used by QgsVectorLayerRenderer::render()
* \note not available in Python bindings
*/
class QgsVectorLayerRendererInterruptionChecker: public QgsInterruptionChecker
class QgsVectorLayerRendererInterruptionChecker: public QgsFeedback
{
Q_OBJECT

public:
//! Constructor
explicit QgsVectorLayerRendererInterruptionChecker( const QgsRenderContext &context );
bool mustStop() const override;

private:
const QgsRenderContext &mContext;
QTimer *mTimer = nullptr;
};

/**
@@ -27,6 +27,7 @@
#include "qgslogger.h"
#include "qgssettings.h"
#include "qgsexception.h"
#include "qgsfeedback.h"

#include <QDir>
#include <QProgressDialog>
@@ -965,7 +966,7 @@ void QgsWFSFeatureIterator::endOfDownload( bool )
mLoop->quit();
}

void QgsWFSFeatureIterator::setInterruptionChecker( QgsInterruptionChecker *interruptionChecker )
void QgsWFSFeatureIterator::setInterruptionChecker( QgsFeedback *interruptionChecker )
{
mInterruptionChecker = interruptionChecker;
}
@@ -1018,7 +1019,7 @@ void QgsWFSFeatureIterator::checkInterruption()
{
//QgsDebugMsg("QgsWFSFeatureIterator::checkInterruption()");

if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
if ( mInterruptionChecker && mInterruptionChecker->isCanceled() )
{
mDownloadFinished = true;
if ( mLoop )
@@ -1037,7 +1038,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature &f )
QgsFeature cachedFeature;
while ( mCacheIterator.nextFeature( cachedFeature ) )
{
if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
if ( mInterruptionChecker && mInterruptionChecker->isCanceled() )
return false;

//QgsDebugMsg(QString("QgsWFSSharedData::fetchFeature() : mCacheIterator.nextFeature(cachedFeature)") );
@@ -1134,7 +1135,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature &f )
{
while ( !mReaderStream->atEnd() )
{
if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
if ( mInterruptionChecker && mInterruptionChecker->isCanceled() )
return false;

QgsFeature feat;
@@ -1186,7 +1187,7 @@ bool QgsWFSFeatureIterator::fetchFeature( QgsFeature &f )

if ( mDownloadFinished )
return false;
if ( mInterruptionChecker && mInterruptionChecker->mustStop() )
if ( mInterruptionChecker && mInterruptionChecker->isCanceled() )
return false;

//QgsDebugMsg("fetchFeature before loop");
@@ -206,7 +206,7 @@ class QgsWFSFeatureIterator : public QObject,

bool close() override;

void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker ) override;
void setInterruptionChecker( QgsFeedback *interruptionChecker ) override;

//! Used by QgsWFSSharedData::registerToCache()
void connectSignals( QgsWFSFeatureDownloader *downloader );
@@ -232,7 +232,7 @@ class QgsWFSFeatureIterator : public QObject,
bool mDownloadFinished;
QEventLoop *mLoop = nullptr;
QgsFeatureIterator mCacheIterator;
QgsInterruptionChecker *mInterruptionChecker = nullptr;
QgsFeedback *mInterruptionChecker = nullptr;

//! this mutex synchronizes the mWriterXXXX variables between featureReceivedSynchronous() and fetchFeature()
QMutex mMutex;

0 comments on commit d830821

Please sign in to comment.
You can’t perform that action at this time.