diff --git a/python/core/layertree/qgslayertreemodel.sip b/python/core/layertree/qgslayertreemodel.sip index 56f88034922..1b089ffdb7e 100644 --- a/python/core/layertree/qgslayertreemodel.sip +++ b/python/core/layertree/qgslayertreemodel.sip @@ -385,6 +385,8 @@ Filter nodes from QgsMapLayerLegend according to the current filtering rules QFlags operator|(QgsLayerTreeModel::Flag f1, QFlags f2); + + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/qgscodeeditorsql.sip b/python/gui/qgscodeeditorsql.sip index 88d78338cdf..4843596c37f 100644 --- a/python/gui/qgscodeeditorsql.sip +++ b/python/gui/qgscodeeditorsql.sip @@ -28,6 +28,7 @@ class QgsCodeEditorSQL : QgsCodeEditor }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/python/gui/symbology/qgsdatadefinedsizelegendwidget.sip b/python/gui/symbology/qgsdatadefinedsizelegendwidget.sip index 3dceef75760..b83e237f8fa 100644 --- a/python/gui/symbology/qgsdatadefinedsizelegendwidget.sip +++ b/python/gui/symbology/qgsdatadefinedsizelegendwidget.sip @@ -40,6 +40,7 @@ Returns configuration as set up in the dialog (may be null). Ownership is passed }; + /************************************************************************ * This file has been generated automatically from * * * diff --git a/src/app/qgsdiagramproperties.h b/src/app/qgsdiagramproperties.h index a1b479894f9..466f810b174 100644 --- a/src/app/qgsdiagramproperties.h +++ b/src/app/qgsdiagramproperties.h @@ -94,6 +94,8 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr class EditBlockerDelegate: public QStyledItemDelegate { + Q_OBJECT + public: EditBlockerDelegate( QObject *parent = nullptr ) : QStyledItemDelegate( parent ) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2be4e4354d1..c1c3e45863d 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -659,6 +659,7 @@ SET(QGIS_CORE_MOC_HDRS composer/qgslayoutmanager.h composer/qgspaperitem.h + processing/qgsnativealgorithms.h processing/qgsprocessingalgrunnertask.h processing/qgsprocessingfeedback.h processing/qgsprocessingprovider.h @@ -669,6 +670,8 @@ SET(QGIS_CORE_MOC_HDRS raster/qgsrasterfilewritertask.h raster/qgsrasterlayer.h raster/qgsrasterdataprovider.h + raster/qgsrasterinterface.h + raster/qgsrasterlayerrenderer.h geometry/qgspoint.h @@ -943,7 +946,6 @@ SET(QGIS_CORE_HDRS metadata/qgslayermetadata.h metadata/qgslayermetadatavalidator.h - processing/qgsnativealgorithms.h processing/qgsprocessing.h processing/qgsprocessingalgorithm.h processing/qgsprocessingcontext.h @@ -980,7 +982,6 @@ SET(QGIS_CORE_HDRS raster/qgsrasterfilewriter.h raster/qgsrasterhistogram.h raster/qgsrasteridentifyresult.h - raster/qgsrasterinterface.h raster/qgsrasteriterator.h raster/qgsrasterminmaxorigin.h raster/qgsrasternuller.h diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 70d385ed819..09fb4f8fe4c 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -33,36 +33,6 @@ #include "qgssymbollayerutils.h" #include "qgsvectorlayer.h" -///@cond PRIVATE - -/** In order to support embedded widgets in layer tree view, the model - * generates one placeholder legend node for each embedded widget. - * The placeholder will be replaced by an embedded widget in QgsLayerTreeView - */ -class EmbeddedWidgetLegendNode : public QgsLayerTreeModelLegendNode -{ - public: - EmbeddedWidgetLegendNode( QgsLayerTreeLayer *nodeL ) - : QgsLayerTreeModelLegendNode( nodeL ) - { - // we need a valid rule key to allow the model to build a tree out of legend nodes - // if that's possible (if there is a node without a rule key, building of tree is canceled) - mRuleKey = QStringLiteral( "embedded-widget-" ) + QUuid::createUuid().toString(); - } - - QVariant data( int role ) const override - { - if ( role == RuleKeyRole ) - return mRuleKey; - return QVariant(); - } - - private: - QString mRuleKey; -}; - -///@endcond - QgsLayerTreeModel::QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent ) : QAbstractItemModel( parent ) , mRootNode( rootNode ) diff --git a/src/core/layertree/qgslayertreemodel.h b/src/core/layertree/qgslayertreemodel.h index bb4d85791ee..2863a1ed5eb 100644 --- a/src/core/layertree/qgslayertreemodel.h +++ b/src/core/layertree/qgslayertreemodel.h @@ -25,11 +25,11 @@ #include "qgsgeometry.h" #include "qgsmaplayer.h" +#include "qgslayertreemodellegendnode.h" class QgsLayerTreeNode; class QgsLayerTreeGroup; class QgsLayerTreeLayer; -class QgsLayerTreeModelLegendNode; class QgsMapHitTest; class QgsMapLayer; class QgsMapSettings; @@ -385,4 +385,38 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags ) +///@cond PRIVATE +#ifndef SIP_RUN + +/** In order to support embedded widgets in layer tree view, the model + * generates one placeholder legend node for each embedded widget. + * The placeholder will be replaced by an embedded widget in QgsLayerTreeView + */ +class EmbeddedWidgetLegendNode : public QgsLayerTreeModelLegendNode +{ + Q_OBJECT + + public: + EmbeddedWidgetLegendNode( QgsLayerTreeLayer *nodeL ) + : QgsLayerTreeModelLegendNode( nodeL ) + { + // we need a valid rule key to allow the model to build a tree out of legend nodes + // if that's possible (if there is a node without a rule key, building of tree is canceled) + mRuleKey = QStringLiteral( "embedded-widget-" ) + QUuid::createUuid().toString(); + } + + QVariant data( int role ) const override + { + if ( role == RuleKeyRole ) + return mRuleKey; + return QVariant(); + } + + private: + QString mRuleKey; +}; +#endif + +///@endcond + #endif // QGSLAYERTREEMODEL_H diff --git a/src/core/layertree/qgslayertreemodellegendnode.h b/src/core/layertree/qgslayertreemodellegendnode.h index cfd4cf3a337..00843bbd2b7 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.h +++ b/src/core/layertree/qgslayertreemodellegendnode.h @@ -26,7 +26,7 @@ #include "qgis_core.h" #include "qgis.h" -#include "qgsrasterdataprovider.h" // for QgsImageFetcher dtor visibility +#include "raster/qgsrasterdataprovider.h" // for QgsImageFetcher dtor visibility class QgsLayerTreeLayer; class QgsLayerTreeModel; @@ -140,7 +140,7 @@ class CORE_EXPORT QgsLayerTreeModelLegendNode : public QObject QString mUserLabel; }; -#include "qgslegendsymbolitem.h" +#include "symbology/qgslegendsymbolitem.h" /** \ingroup core * Implementation of legend node interface for displaying preview of vector symbols and their labels @@ -388,6 +388,8 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode */ class CORE_EXPORT QgsDataDefinedSizeLegendNode : public QgsLayerTreeModelLegendNode { + Q_OBJECT + public: //! Construct the node using QgsDataDefinedSizeLegend as definition of the node's appearance QgsDataDefinedSizeLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsDataDefinedSizeLegend &settings, QObject *parent SIP_TRANSFERTHIS = nullptr ); diff --git a/src/core/layout/qgslayoutitemregistry.h b/src/core/layout/qgslayoutitemregistry.h index 788c837159c..1ae53579bfc 100644 --- a/src/core/layout/qgslayoutitemregistry.h +++ b/src/core/layout/qgslayoutitemregistry.h @@ -265,6 +265,8 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject //simple item for testing class TestLayoutItem : public QgsLayoutItem { + Q_OBJECT + public: TestLayoutItem( QgsLayout *layout ); diff --git a/src/core/processing/qgsnativealgorithms.h b/src/core/processing/qgsnativealgorithms.h index 7c599f7a57c..c23fbeb5140 100644 --- a/src/core/processing/qgsnativealgorithms.h +++ b/src/core/processing/qgsnativealgorithms.h @@ -29,6 +29,8 @@ class QgsNativeAlgorithms: public QgsProcessingProvider { + Q_OBJECT + public: QgsNativeAlgorithms( QObject *parent = nullptr ); diff --git a/src/core/qgsnetworkdiskcache.cpp b/src/core/qgsnetworkdiskcache.cpp index af1b5328bdd..c5f7a6ffc33 100644 --- a/src/core/qgsnetworkdiskcache.cpp +++ b/src/core/qgsnetworkdiskcache.cpp @@ -18,7 +18,9 @@ #include "qgsnetworkdiskcache.h" -QgsNetworkDiskCache::ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache; +///@cond PRIVATE +ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache; +///@endcond QMutex QgsNetworkDiskCache::sDiskCacheMutex; QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent ) diff --git a/src/core/qgsnetworkdiskcache.h b/src/core/qgsnetworkdiskcache.h index ac74b9a48f8..3f55398c79c 100644 --- a/src/core/qgsnetworkdiskcache.h +++ b/src/core/qgsnetworkdiskcache.h @@ -25,6 +25,19 @@ class QNetworkDiskCache; +///@cond PRIVATE + +class ExpirableNetworkDiskCache : public QNetworkDiskCache +{ + Q_OBJECT + + public: + explicit ExpirableNetworkDiskCache( QObject *parent = 0 ) : QNetworkDiskCache( parent ) {} + qint64 runExpire() { return QNetworkDiskCache::expire(); } +}; + +///@endcond + /** \ingroup core * Wrapper implementation of QNetworkDiskCache with all methods guarded by a * mutex soly for internal use of QgsNetworkAccessManagers @@ -83,14 +96,6 @@ class QgsNetworkDiskCache : public QNetworkDiskCache private: explicit QgsNetworkDiskCache( QObject *parent ); - Q_DISABLE_COPY( QgsNetworkDiskCache ) - - class ExpirableNetworkDiskCache : public QNetworkDiskCache - { - public: - explicit ExpirableNetworkDiskCache( QObject *parent = 0 ) : QNetworkDiskCache( parent ) {} - qint64 runExpire() { return QNetworkDiskCache::expire(); } - }; static ExpirableNetworkDiskCache sDiskCache; static QMutex sDiskCacheMutex; diff --git a/src/core/raster/qgsrasterinterface.h b/src/core/raster/qgsrasterinterface.h index 99842f27eaf..1b07f519d88 100644 --- a/src/core/raster/qgsrasterinterface.h +++ b/src/core/raster/qgsrasterinterface.h @@ -39,6 +39,8 @@ */ class CORE_EXPORT QgsRasterBlockFeedback : public QgsFeedback { + Q_OBJECT + public: //! Construct a new raster block feedback object QgsRasterBlockFeedback( QObject *parent = nullptr ) : QgsFeedback( parent ), mPreviewOnly( false ), mRenderPartialOutput( false ) {} diff --git a/src/core/raster/qgsrasterlayerrenderer.cpp b/src/core/raster/qgsrasterlayerrenderer.cpp index 837a6a55633..ac2f41ebc09 100644 --- a/src/core/raster/qgsrasterlayerrenderer.cpp +++ b/src/core/raster/qgsrasterlayerrenderer.cpp @@ -25,12 +25,50 @@ #include "qgsproject.h" #include "qgsexception.h" + +///@cond PRIVATE + +QgsRasterLayerRendererFeedback::QgsRasterLayerRendererFeedback( QgsRasterLayerRenderer *r ) + : QgsRasterBlockFeedback() + , mR( r ) + , mMinimalPreviewInterval( 250 ) +{ + setRenderPartialOutput( r->mContext.testFlag( QgsRenderContext::RenderPartialOutput ) ); +} + +void QgsRasterLayerRendererFeedback::onNewData() +{ + if ( !renderPartialOutput() ) + return; // we were not asked for partial renders and we may not have a temporary image for overwriting... + + // update only once upon a time + // (preview itself takes some time) + if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval ) + return; + + // TODO: update only the area that got new data + + QgsDebugMsg( QString( "new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ) ); + QTime t; + t.start(); + QgsRasterBlockFeedback feedback; + feedback.setPreviewOnly( true ); + feedback.setRenderPartialOutput( true ); + QgsRasterIterator iterator( mR->mPipe->last() ); + QgsRasterDrawer drawer( &iterator ); + drawer.draw( mR->mPainter, mR->mRasterViewPort, mR->mMapToPixel, &feedback ); + QgsDebugMsg( QString( "total raster preview time: %1 ms" ).arg( t.elapsed() ) ); + mLastPreview = QTime::currentTime(); +} + +///@endcond +/// QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRenderContext &rendererContext ) : QgsMapLayerRenderer( layer->id() ) , mRasterViewPort( nullptr ) , mPipe( nullptr ) , mContext( rendererContext ) - , mFeedback( new Feedback( this ) ) + , mFeedback( new QgsRasterLayerRendererFeedback( this ) ) { mPainter = rendererContext.painter(); const QgsMapToPixel &qgsMapToPixel = rendererContext.mapToPixel(); @@ -231,34 +269,3 @@ QgsFeedback *QgsRasterLayerRenderer::feedback() const return mFeedback; } -QgsRasterLayerRenderer::Feedback::Feedback( QgsRasterLayerRenderer *r ) - : mR( r ) - , mMinimalPreviewInterval( 250 ) -{ - setRenderPartialOutput( r->mContext.testFlag( QgsRenderContext::RenderPartialOutput ) ); -} - -void QgsRasterLayerRenderer::Feedback::onNewData() -{ - if ( !renderPartialOutput() ) - return; // we were not asked for partial renders and we may not have a temporary image for overwriting... - - // update only once upon a time - // (preview itself takes some time) - if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval ) - return; - - // TODO: update only the area that got new data - - QgsDebugMsg( QString( "new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ) ); - QTime t; - t.start(); - QgsRasterBlockFeedback feedback; - feedback.setPreviewOnly( true ); - feedback.setRenderPartialOutput( true ); - QgsRasterIterator iterator( mR->mPipe->last() ); - QgsRasterDrawer drawer( &iterator ); - drawer.draw( mR->mPainter, mR->mRasterViewPort, mR->mMapToPixel, &feedback ); - QgsDebugMsg( QString( "total raster preview time: %1 ms" ).arg( t.elapsed() ) ); - mLastPreview = QTime::currentTime(); -} diff --git a/src/core/raster/qgsrasterlayerrenderer.h b/src/core/raster/qgsrasterlayerrenderer.h index 7346791a626..8329904d750 100644 --- a/src/core/raster/qgsrasterlayerrenderer.h +++ b/src/core/raster/qgsrasterlayerrenderer.h @@ -23,7 +23,6 @@ class QPainter; class QgsMapToPixel; -class QgsRasterBlockFeedback; class QgsRasterLayer; class QgsRasterPipe; struct QgsRasterViewPort; @@ -33,6 +32,30 @@ class QgsRasterLayerRenderer; #include "qgsrasterinterface.h" +///@cond PRIVATE + +/** \ingroup core + * Specific internal feedback class to provide preview of raster layer rendering. + * \since QGIS 3.0 + * \note not available in Python bindings + */ +class CORE_EXPORT QgsRasterLayerRendererFeedback : public QgsRasterBlockFeedback +{ + Q_OBJECT + + public: + //! Create feedback object based on our layer renderer + explicit QgsRasterLayerRendererFeedback( QgsRasterLayerRenderer *r ); + + //! when notified of new data in data provider it launches a preview draw of the raster + virtual void onNewData() override; + private: + QgsRasterLayerRenderer *mR = nullptr; //!< Parent renderer instance + int mMinimalPreviewInterval; //!< In milliseconds + QTime mLastPreview; //!< When last preview has been generated +}; + +///@endcond /** \ingroup core * Implementation of threaded rendering for raster layers. @@ -40,7 +63,7 @@ class QgsRasterLayerRenderer; * \since QGIS 2.4 * \note not available in Python bindings */ -class QgsRasterLayerRenderer : public QgsMapLayerRenderer +class CORE_EXPORT QgsRasterLayerRenderer : public QgsMapLayerRenderer { public: QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRenderContext &rendererContext ); @@ -50,7 +73,7 @@ class QgsRasterLayerRenderer : public QgsMapLayerRenderer virtual QgsFeedback *feedback() const override; - protected: + private: QPainter *mPainter = nullptr; const QgsMapToPixel *mMapToPixel = nullptr; @@ -59,27 +82,10 @@ class QgsRasterLayerRenderer : public QgsMapLayerRenderer QgsRasterPipe *mPipe = nullptr; QgsRenderContext &mContext; - /** \ingroup core - * Specific internal feedback class to provide preview of raster layer rendering. - * \since QGIS 3.0 - * \note not available in Python bindings - */ - class Feedback : public QgsRasterBlockFeedback - { - public: - //! Create feedback object based on our layer renderer - explicit Feedback( QgsRasterLayerRenderer *r ); - - //! when notified of new data in data provider it launches a preview draw of the raster - virtual void onNewData() override; - private: - QgsRasterLayerRenderer *mR; //!< Parent renderer instance - int mMinimalPreviewInterval; //!< In milliseconds - QTime mLastPreview; //!< When last preview has been generated - }; - //! feedback class for cancelation and preview generation - Feedback *mFeedback = nullptr; + QgsRasterLayerRendererFeedback *mFeedback = nullptr; + + friend class QgsRasterLayerRendererFeedback; }; diff --git a/src/gui/locator/qgslocatorwidget.h b/src/gui/locator/qgslocatorwidget.h index 2aae612c450..6bb2931d1c2 100644 --- a/src/gui/locator/qgslocatorwidget.h +++ b/src/gui/locator/qgslocatorwidget.h @@ -130,6 +130,8 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget class QgsLocatorFilterFilter : public QgsLocatorFilter { + Q_OBJECT + public: QgsLocatorFilterFilter( QgsLocatorWidget *widget, QObject *parent = nullptr ); @@ -221,6 +223,8 @@ class QgsLocatorModel : public QAbstractTableModel class QgsLocatorProxyModel : public QSortFilterProxyModel { + Q_OBJECT + public: explicit QgsLocatorProxyModel( QObject *parent = nullptr ); diff --git a/src/gui/qgscodeeditorsql.cpp b/src/gui/qgscodeeditorsql.cpp index 66b2e0e1a9e..8131e8cc785 100644 --- a/src/gui/qgscodeeditorsql.cpp +++ b/src/gui/qgscodeeditorsql.cpp @@ -20,7 +20,6 @@ #include #include #include -#include QgsCodeEditorSQL::QgsCodeEditorSQL( QWidget *parent ) @@ -36,22 +35,6 @@ QgsCodeEditorSQL::QgsCodeEditorSQL( QWidget *parent ) setSciLexerSQL(); } -/** Internal use. - - setAutoCompletionCaseSensitivity( false ) is not sufficient when installing - a lexer, since its caseSensitive() method is actually used, and defaults - to true. - @note not available in Python bindings - @ingroup gui -*/ -class QgsCaseInsensitiveLexerSQL: public QsciLexerSQL -{ - public: - //! constructor - explicit QgsCaseInsensitiveLexerSQL( QObject *parent = 0 ) : QsciLexerSQL( parent ) {} - - bool caseSensitive() const override { return false; } -}; void QgsCodeEditorSQL::setSciLexerSQL() { diff --git a/src/gui/qgscodeeditorsql.h b/src/gui/qgscodeeditorsql.h index 8008669dffe..88de794aed0 100644 --- a/src/gui/qgscodeeditorsql.h +++ b/src/gui/qgscodeeditorsql.h @@ -19,6 +19,7 @@ #include "qgscodeeditor.h" #include "qgis_sip.h" #include "qgis_gui.h" +#include SIP_IF_MODULE( HAVE_QSCI_SIP ) @@ -41,4 +42,28 @@ class GUI_EXPORT QgsCodeEditorSQL : public QgsCodeEditor void setSciLexerSQL(); }; +#ifndef SIP_RUN +///@cond PRIVATE + +/** Internal use. + + setAutoCompletionCaseSensitivity( false ) is not sufficient when installing + a lexer, since its caseSensitive() method is actually used, and defaults + to true. + @note not available in Python bindings + @ingroup gui +*/ +class QgsCaseInsensitiveLexerSQL: public QsciLexerSQL +{ + Q_OBJECT + + public: + //! constructor + explicit QgsCaseInsensitiveLexerSQL( QObject *parent = 0 ) : QsciLexerSQL( parent ) {} + + bool caseSensitive() const override { return false; } +}; +///@endcond +#endif + #endif diff --git a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp index 3a452447d80..d3843398b88 100644 --- a/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp +++ b/src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp @@ -30,29 +30,6 @@ #include "qgsvectorlayer.h" -///@cond PRIVATE - -//! Simple delegate to allow only numeric values -class SizeClassDelegate : public QStyledItemDelegate -{ - public: - SizeClassDelegate( QObject *parent ) - : QStyledItemDelegate( parent ) - { - } - - QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const - { - QLineEdit *lineEdit = new QLineEdit( parent ); - QDoubleValidator *validator = new QDoubleValidator( 0, 1e6, 1, lineEdit ); - lineEdit->setValidator( validator ); - return lineEdit; - } -}; - -///@endcond - - QgsDataDefinedSizeLegendWidget::QgsDataDefinedSizeLegendWidget( const QgsDataDefinedSizeLegend *ddsLegend, const QgsProperty &ddSize, QgsMarkerSymbol *overrideSymbol, QgsMapCanvas *canvas, QWidget *parent ) : QgsPanelWidget( parent ) , mSizeProperty( ddSize ) diff --git a/src/gui/symbology/qgsdatadefinedsizelegendwidget.h b/src/gui/symbology/qgsdatadefinedsizelegendwidget.h index 5680a4daa93..a2fe6be93b2 100644 --- a/src/gui/symbology/qgsdatadefinedsizelegendwidget.h +++ b/src/gui/symbology/qgsdatadefinedsizelegendwidget.h @@ -24,6 +24,7 @@ #include "qgspanelwidget.h" #include "qgsproperty.h" +#include class QStandardItemModel; @@ -76,4 +77,30 @@ class GUI_EXPORT QgsDataDefinedSizeLegendWidget : public QgsPanelWidget, private QStandardItemModel *mSizeClassesModel; }; +#ifndef SIP_RUN +///@cond PRIVATE + +//! Simple delegate to allow only numeric values +class SizeClassDelegate : public QStyledItemDelegate +{ + Q_OBJECT + + public: + SizeClassDelegate( QObject *parent ) + : QStyledItemDelegate( parent ) + { + } + + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const + { + QLineEdit *lineEdit = new QLineEdit( parent ); + QDoubleValidator *validator = new QDoubleValidator( 0, 1e6, 1, lineEdit ); + lineEdit->setValidator( validator ); + return lineEdit; + } +}; + +///@endcond +#endif + #endif // QGSDATADEFINEDSIZELEGENDWIDGET_H diff --git a/src/plugins/grass/qgsgrassmoduleinput.h b/src/plugins/grass/qgsgrassmoduleinput.h index 101e6cd12ce..7ddb000ce7e 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.h +++ b/src/plugins/grass/qgsgrassmoduleinput.h @@ -152,6 +152,8 @@ class QgsGrassModuleInputCompleterProxy : public QAbstractProxyModel class QgsGrassModuleInputCompleter : public QCompleter { + Q_OBJECT + public: explicit QgsGrassModuleInputCompleter( QAbstractItemModel *model, QWidget *parent = 0 ); @@ -160,6 +162,8 @@ class QgsGrassModuleInputCompleter : public QCompleter class QgsGrassModuleInputComboBox : public QComboBox { + Q_OBJECT + public: explicit QgsGrassModuleInputComboBox( QgsGrassObject::Type type, QWidget *parent = 0 ); ~QgsGrassModuleInputComboBox(); @@ -340,7 +344,7 @@ class QgsGrassModuleInput : public QgsGrassModuleGroupBoxItem // List of vector layers matching mGeometryTypes for currently selected vector QList mLayers; - //! The imput map will be updated -> must be from current mapset + //! The input map will be updated -> must be from current mapset // TODO bool mUpdate; diff --git a/src/plugins/grass/qgsgrasstools.cpp b/src/plugins/grass/qgsgrasstools.cpp index 8b18c86e573..cd009010d26 100644 --- a/src/plugins/grass/qgsgrasstools.cpp +++ b/src/plugins/grass/qgsgrasstools.cpp @@ -41,114 +41,11 @@ #include "qgsdetaileditemdata.h" #include "qgsdetaileditemdelegate.h" -#include -#include #ifdef Q_OS_WIN #include "qgsgrassutils.h" #endif -// TODO: searching acros the tree is taken from QgsDockBrowserTreeView -> create common base class -class QgsGrassToolsTreeFilterProxyModel : public QSortFilterProxyModel -{ - public: - explicit QgsGrassToolsTreeFilterProxyModel( QObject *parent ) - : QSortFilterProxyModel( parent ) - , mModel( 0 ) - { - setDynamicSortFilter( true ); - mRegExp.setPatternSyntax( QRegExp::Wildcard ); - mRegExp.setCaseSensitivity( Qt::CaseInsensitive ); - } - - void setSourceModel( QAbstractItemModel *sourceModel ) override - { - mModel = sourceModel; - QSortFilterProxyModel::setSourceModel( sourceModel ); - } - - void setFilter( const QString &filter ) - { - QgsDebugMsg( QString( "filter = %1" ).arg( filter ) ); - if ( mFilter == filter ) - { - return; - } - mFilter = filter; - mRegExp.setPattern( mFilter ); - - invalidateFilter(); - } - - protected: - - QAbstractItemModel *mModel = nullptr; - QString mFilter; // filter string provided - QRegExp mRegExp; // regular expression constructed from filter string - - bool filterAcceptsString( const QString &value ) const - { - return value.contains( mRegExp ); - } - - // It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors - bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override - { - if ( mFilter.isEmpty() || !mModel ) - { - return true; - } - - QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent ); - return filterAcceptsItem( sourceIndex ) || filterAcceptsAncestor( sourceIndex ) || filterAcceptsDescendant( sourceIndex ); - } - - // returns true if at least one ancestor is accepted by filter - bool filterAcceptsAncestor( const QModelIndex &sourceIndex ) const - { - if ( !mModel ) - { - return true; - } - - QModelIndex sourceParentIndex = mModel->parent( sourceIndex ); - if ( !sourceParentIndex.isValid() ) - return false; - if ( filterAcceptsItem( sourceParentIndex ) ) - return true; - - return filterAcceptsAncestor( sourceParentIndex ); - } - - // returns true if at least one descendant s accepted by filter - bool filterAcceptsDescendant( const QModelIndex &sourceIndex ) const - { - if ( !mModel ) - { - return true; - } - - for ( int i = 0; i < mModel->rowCount( sourceIndex ); i++ ) - { - QModelIndex sourceChildIndex = mModel->index( i, 0, sourceIndex ); - if ( filterAcceptsItem( sourceChildIndex ) ) - return true; - if ( filterAcceptsDescendant( sourceChildIndex ) ) - return true; - } - return false; - } - - // filter accepts item name - bool filterAcceptsItem( const QModelIndex &sourceIndex ) const - { - if ( !mModel ) - { - return true; - } - return filterAcceptsString( mModel->data( sourceIndex, filterRole() ).toString() ); - } -}; QgsGrassTools::QgsGrassTools( QgisInterface *iface, QWidget *parent, const char *name, Qt::WindowFlags f ) : QgsDockWidget( parent, f ) @@ -792,3 +689,90 @@ void QgsGrassTools::on_mViewModeButton_clicked() mViewModeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconTreeView.png" ) ) ); } } + +QgsGrassToolsTreeFilterProxyModel::QgsGrassToolsTreeFilterProxyModel( QObject *parent ) + : QSortFilterProxyModel( parent ) + , mModel( 0 ) +{ + setDynamicSortFilter( true ); + mRegExp.setPatternSyntax( QRegExp::Wildcard ); + mRegExp.setCaseSensitivity( Qt::CaseInsensitive ); +} + +void QgsGrassToolsTreeFilterProxyModel::setSourceModel( QAbstractItemModel *sourceModel ) +{ + mModel = sourceModel; + QSortFilterProxyModel::setSourceModel( sourceModel ); +} + +void QgsGrassToolsTreeFilterProxyModel::setFilter( const QString &filter ) +{ + QgsDebugMsg( QString( "filter = %1" ).arg( filter ) ); + if ( mFilter == filter ) + { + return; + } + mFilter = filter; + mRegExp.setPattern( mFilter ); + + invalidateFilter(); +} + +bool QgsGrassToolsTreeFilterProxyModel::filterAcceptsString( const QString &value ) const +{ + return value.contains( mRegExp ); +} + +bool QgsGrassToolsTreeFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const +{ + if ( mFilter.isEmpty() || !mModel ) + { + return true; + } + + QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent ); + return filterAcceptsItem( sourceIndex ) || filterAcceptsAncestor( sourceIndex ) || filterAcceptsDescendant( sourceIndex ); +} + +bool QgsGrassToolsTreeFilterProxyModel::filterAcceptsAncestor( const QModelIndex &sourceIndex ) const +{ + if ( !mModel ) + { + return true; + } + + QModelIndex sourceParentIndex = mModel->parent( sourceIndex ); + if ( !sourceParentIndex.isValid() ) + return false; + if ( filterAcceptsItem( sourceParentIndex ) ) + return true; + + return filterAcceptsAncestor( sourceParentIndex ); +} + +bool QgsGrassToolsTreeFilterProxyModel::filterAcceptsDescendant( const QModelIndex &sourceIndex ) const +{ + if ( !mModel ) + { + return true; + } + + for ( int i = 0; i < mModel->rowCount( sourceIndex ); i++ ) + { + QModelIndex sourceChildIndex = mModel->index( i, 0, sourceIndex ); + if ( filterAcceptsItem( sourceChildIndex ) ) + return true; + if ( filterAcceptsDescendant( sourceChildIndex ) ) + return true; + } + return false; +} + +bool QgsGrassToolsTreeFilterProxyModel::filterAcceptsItem( const QModelIndex &sourceIndex ) const +{ + if ( !mModel ) + { + return true; + } + return filterAcceptsString( mModel->data( sourceIndex, filterRole() ).toString() ); +} diff --git a/src/plugins/grass/qgsgrasstools.h b/src/plugins/grass/qgsgrasstools.h index de0b43c3c12..777e38723e6 100644 --- a/src/plugins/grass/qgsgrasstools.h +++ b/src/plugins/grass/qgsgrasstools.h @@ -20,6 +20,9 @@ #include "ui_qgsgrasstoolsbase.h" +#include +#include + class QDomElement; class QSortFilterProxyModel; class QStandardItem; @@ -140,4 +143,38 @@ class QgsGrassTools: public QgsDockWidget, public Ui::QgsGrassToolsBase void showTabs(); }; + +// TODO: searching acros the tree is taken from QgsDockBrowserTreeView -> create common base class +class QgsGrassToolsTreeFilterProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + + public: + explicit QgsGrassToolsTreeFilterProxyModel( QObject *parent ); + + void setSourceModel( QAbstractItemModel *sourceModel ) override; + + void setFilter( const QString &filter ); + + protected: + + QAbstractItemModel *mModel = nullptr; + QString mFilter; // filter string provided + QRegExp mRegExp; // regular expression constructed from filter string + + bool filterAcceptsString( const QString &value ) const; + + // It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors + bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override; + + // returns true if at least one ancestor is accepted by filter + bool filterAcceptsAncestor( const QModelIndex &sourceIndex ) const; + + // returns true if at least one descendant s accepted by filter + bool filterAcceptsDescendant( const QModelIndex &sourceIndex ) const; + + // filter accepts item name + bool filterAcceptsItem( const QModelIndex &sourceIndex ) const; +}; + #endif // QGSGRASSTOOLS_H diff --git a/src/providers/arcgisrest/qgsafsdataitems.h b/src/providers/arcgisrest/qgsafsdataitems.h index e5f21a8f33e..d9c68b374ee 100644 --- a/src/providers/arcgisrest/qgsafsdataitems.h +++ b/src/providers/arcgisrest/qgsafsdataitems.h @@ -62,6 +62,8 @@ class QgsAfsConnectionItem : public QgsDataCollectionItem class QgsAfsLayerItem : public QgsLayerItem { + Q_OBJECT + public: QgsAfsLayerItem( QgsDataItem *parent, const QString &name, const QString &url, const QString &title, const QString &authid ); }; diff --git a/src/providers/arcgisrest/qgsamsdataitems.h b/src/providers/arcgisrest/qgsamsdataitems.h index 98647c8f524..f39c5f8890c 100644 --- a/src/providers/arcgisrest/qgsamsdataitems.h +++ b/src/providers/arcgisrest/qgsamsdataitems.h @@ -64,6 +64,8 @@ class QgsAmsConnectionItem : public QgsDataCollectionItem class QgsAmsLayerItem : public QgsLayerItem { + Q_OBJECT + public: QgsAmsLayerItem( QgsDataItem *parent, const QString &name, const QString &url, const QString &id, const QString &title, const QString &authid, const QString &format ); }; diff --git a/src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp b/src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp index e2d90605215..1567de730ec 100644 --- a/src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp +++ b/src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp @@ -29,7 +29,6 @@ #include "qgssettings.h" #include "qgsmapcanvas.h" -#include #include #include #include @@ -37,18 +36,6 @@ #include #include "qgshelp.h" -/** - * Item delegate with tweaked sizeHint. - */ -class QgsAbstractDataSourceWidgetItemDelegate : public QItemDelegate -{ - public: - //! Constructor - QgsAbstractDataSourceWidgetItemDelegate( QObject *parent = 0 ) : QItemDelegate( parent ) { } - QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override; -}; - - QgsArcGisServiceSourceSelect::QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ): QgsAbstractDataSourceWidget( parent, fl, widgetMode ), mServiceName( serviceName ), diff --git a/src/providers/arcgisrest/qgsarcgisservicesourceselect.h b/src/providers/arcgisrest/qgsarcgisservicesourceselect.h index c9ff04ff0d7..52ae2f092af 100644 --- a/src/providers/arcgisrest/qgsarcgisservicesourceselect.h +++ b/src/providers/arcgisrest/qgsarcgisservicesourceselect.h @@ -23,6 +23,8 @@ #include "qgscoordinatereferencesystem.h" #include "qgsabstractdatasourcewidget.h" +#include + class QStandardItemModel; class QSortFilterProxyModel; class QgsProjectionSelectionDialog; @@ -116,5 +118,17 @@ class QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidget, protect void treeWidgetCurrentRowChanged( const QModelIndex ¤t, const QModelIndex &previous ); }; +/** + * Item delegate with tweaked sizeHint. + */ +class QgsAbstractDataSourceWidgetItemDelegate : public QItemDelegate +{ + Q_OBJECT + + public: + //! Constructor + QgsAbstractDataSourceWidgetItemDelegate( QObject *parent = 0 ) : QItemDelegate( parent ) { } + QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override; +}; #endif // QGSARCGISSERVICESOURCESELECT_H diff --git a/src/providers/grass/CMakeLists.txt b/src/providers/grass/CMakeLists.txt index e7deea4ccb2..f25eede9409 100644 --- a/src/providers/grass/CMakeLists.txt +++ b/src/providers/grass/CMakeLists.txt @@ -33,6 +33,7 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION) SET(GRASS_LIBRARY_MOC_HDRS ../qgsgrass.h + ../qgsgrassdatafile.h ../qgsgrassfeatureiterator.h ../qgsgrassimport.h ../qgsgrassprovider.h diff --git a/src/providers/grass/qgsgrassdatafile.h b/src/providers/grass/qgsgrassdatafile.h index d6b33eba815..ead4f0d8227 100644 --- a/src/providers/grass/qgsgrassdatafile.h +++ b/src/providers/grass/qgsgrassdatafile.h @@ -34,6 +34,8 @@ */ class GRASS_LIB_EXPORT QgsGrassDataFile : public QFile { + Q_OBJECT + public: explicit QgsGrassDataFile( QObject *parent = 0 ); // We need FILE* to be able to test feof but QFile::open(FILE *, OpenMode) is not virtual diff --git a/src/providers/grass/qgsgrassprovidermodule.h b/src/providers/grass/qgsgrassprovidermodule.h index 0b8ba7a172a..e14c135e6f8 100644 --- a/src/providers/grass/qgsgrassprovidermodule.h +++ b/src/providers/grass/qgsgrassprovidermodule.h @@ -77,6 +77,8 @@ class QgsGrassObjectItemBase class QgsGrassLocationItem : public QgsDirectoryItem, public QgsGrassObjectItemBase { + Q_OBJECT + public: QgsGrassLocationItem( QgsDataItem *parent, QString dirPath, QString path ); diff --git a/src/providers/wfs/CMakeLists.txt b/src/providers/wfs/CMakeLists.txt index 328a118ffdb..b0807ab3607 100644 --- a/src/providers/wfs/CMakeLists.txt +++ b/src/providers/wfs/CMakeLists.txt @@ -19,6 +19,7 @@ SET(WFS_SRCS SET (WFS_MOC_HDRS qgswfscapabilities.h + qgswfsconnection.h qgswfsdataitems.h qgswfsprovider.h qgswfsfeatureiterator.h diff --git a/src/providers/wfs/qgswfsconnection.h b/src/providers/wfs/qgswfsconnection.h index e95b21d8dee..85e6b4f4428 100644 --- a/src/providers/wfs/qgswfsconnection.h +++ b/src/providers/wfs/qgswfsconnection.h @@ -20,6 +20,8 @@ class QgsWfsConnection : public QgsOwsConnection { + Q_OBJECT + public: /** diff --git a/src/providers/wfs/qgswfssourceselect.cpp b/src/providers/wfs/qgswfssourceselect.cpp index 11560917296..869e3775950 100644 --- a/src/providers/wfs/qgswfssourceselect.cpp +++ b/src/providers/wfs/qgswfssourceselect.cpp @@ -30,7 +30,6 @@ #include "qgslogger.h" #include "qgsmanageconnectionsdialog.h" #include "qgssqlstatement.h" -#include "qgssqlcomposerdialog.h" #include "qgssettings.h" #include @@ -406,19 +405,6 @@ void QgsWFSSourceSelect::addButtonClicked() } } -class QgsWFSValidatorCallback: public QObject, public QgsSQLComposerDialog::SQLValidatorCallback -{ - public: - QgsWFSValidatorCallback( QObject *parent, - const QgsWFSDataSourceURI &uri, const QString &allSql, - const QgsWfsCapabilities::Capabilities &caps ); - bool isValid( const QString &sql, QString &errorReason, QString &warningMsg ) override; - private: - QgsWFSDataSourceURI mURI; - QString mAllSql; - const QgsWfsCapabilities::Capabilities &mCaps; -}; - QgsWFSValidatorCallback::QgsWFSValidatorCallback( QObject *parent, const QgsWFSDataSourceURI &uri, const QString &allSql, @@ -449,20 +435,6 @@ bool QgsWFSValidatorCallback::isValid( const QString &sqlStr, QString &errorReas return true; } -class QgsWFSTableSelectedCallback: public QObject, public QgsSQLComposerDialog::TableSelectedCallback -{ - public: - QgsWFSTableSelectedCallback( QgsSQLComposerDialog *dialog, - const QgsWFSDataSourceURI &uri, - const QgsWfsCapabilities::Capabilities &caps ); - void tableSelected( const QString &name ) override; - - private: - QgsSQLComposerDialog *mDialog = nullptr; - QgsWFSDataSourceURI mURI; - const QgsWfsCapabilities::Capabilities &mCaps; -}; - QgsWFSTableSelectedCallback::QgsWFSTableSelectedCallback( QgsSQLComposerDialog *dialog, const QgsWFSDataSourceURI &uri, const QgsWfsCapabilities::Capabilities &caps ) @@ -796,4 +768,4 @@ QSize QgsWFSItemDelegate::sizeHint( const QStyleOptionViewItem &option, const QM void QgsWFSSourceSelect::showHelp() { QgsHelp::openHelp( QStringLiteral( "working_with_ogc/ogc_client_support.html" ) ); -} \ No newline at end of file +} diff --git a/src/providers/wfs/qgswfssourceselect.h b/src/providers/wfs/qgswfssourceselect.h index aa80b15f0bd..acdfe2d7188 100644 --- a/src/providers/wfs/qgswfssourceselect.h +++ b/src/providers/wfs/qgswfssourceselect.h @@ -23,6 +23,7 @@ #include "qgswfscapabilities.h" #include "qgsproviderregistry.h" #include "qgsabstractdatasourcewidget.h" +#include "qgssqlcomposerdialog.h" #include #include @@ -30,7 +31,6 @@ class QgsProjectionSelectionDialog; class QgsWfsCapabilities; -class QgsSQLComposerDialog; class QgsWFSItemDelegate : public QItemDelegate { @@ -43,6 +43,21 @@ class QgsWFSItemDelegate : public QItemDelegate }; +class QgsWFSValidatorCallback: public QObject, public QgsSQLComposerDialog::SQLValidatorCallback +{ + Q_OBJECT + + public: + QgsWFSValidatorCallback( QObject *parent, + const QgsWFSDataSourceURI &uri, const QString &allSql, + const QgsWfsCapabilities::Capabilities &caps ); + bool isValid( const QString &sql, QString &errorReason, QString &warningMsg ) override; + private: + QgsWFSDataSourceURI mURI; + QString mAllSql; + const QgsWfsCapabilities::Capabilities &mCaps; +}; + class QgsWFSSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsWFSSourceSelectBase { Q_OBJECT @@ -108,4 +123,20 @@ class QgsWFSSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsWFS }; +class QgsWFSTableSelectedCallback: public QObject, public QgsSQLComposerDialog::TableSelectedCallback +{ + Q_OBJECT + + public: + QgsWFSTableSelectedCallback( QgsSQLComposerDialog *dialog, + const QgsWFSDataSourceURI &uri, + const QgsWfsCapabilities::Capabilities &caps ); + void tableSelected( const QString &name ) override; + + private: + QgsSQLComposerDialog *mDialog = nullptr; + QgsWFSDataSourceURI mURI; + const QgsWfsCapabilities::Capabilities &mCaps; +}; + #endif diff --git a/src/providers/wms/qgswmssourceselect.cpp b/src/providers/wms/qgswmssourceselect.cpp index 0e2fe94719d..5508a82e732 100644 --- a/src/providers/wms/qgswmssourceselect.cpp +++ b/src/providers/wms/qgswmssourceselect.cpp @@ -1348,4 +1348,4 @@ void QgsWMSSourceSelect::updateLayerOrderTab( const QStringList &newLayerList, c void QgsWMSSourceSelect::showHelp() { QgsHelp::openHelp( QStringLiteral( "working_with_ogc/ogc_client_support.html" ) ); -} \ No newline at end of file +} diff --git a/tests/src/core/testqgslayoutitem.cpp b/tests/src/core/testqgslayoutitem.cpp index fcaf136ed24..8caa697ba91 100644 --- a/tests/src/core/testqgslayoutitem.cpp +++ b/tests/src/core/testqgslayoutitem.cpp @@ -28,6 +28,88 @@ #include #include + +//simple item for testing, since some methods in QgsLayoutItem are pure virtual +class TestItem : public QgsLayoutItem +{ + Q_OBJECT + + public: + + TestItem( QgsLayout *layout ) : QgsLayoutItem( layout ) {} + ~TestItem() {} + + //implement pure virtual methods + int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; } + QString stringType() const override { return QStringLiteral( "TestItemType" ); } + + protected: + void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * = nullptr ) override + { + QPainter *painter = context.painter(); + painter->save(); + painter->setRenderHint( QPainter::Antialiasing, false ); + painter->setPen( Qt::NoPen ); + painter->setBrush( QColor( 255, 100, 100, 200 ) ); + painter->drawRect( rect() ); + painter->restore(); + } +}; + +//item with minimum size +class MinSizedItem : public TestItem +{ + Q_OBJECT + + public: + MinSizedItem( QgsLayout *layout ) : TestItem( layout ) + { + setMinimumSize( QgsLayoutSize( 5.0, 10.0, QgsUnitTypes::LayoutCentimeters ) ); + } + + void updateMinSize( QgsLayoutSize size ) + { + setMinimumSize( size ); + } + + ~MinSizedItem() {} +}; + +//item with fixed size +class FixedSizedItem : public TestItem +{ + Q_OBJECT + + public: + + FixedSizedItem( QgsLayout *layout ) : TestItem( layout ) + { + setFixedSize( QgsLayoutSize( 2.0, 4.0, QgsUnitTypes::LayoutInches ) ); + } + + void updateFixedSize( QgsLayoutSize size ) + { + setFixedSize( size ); + } + ~FixedSizedItem() {} +}; + +//item with both conflicting fixed and minimum size +class FixedMinSizedItem : public TestItem +{ + Q_OBJECT + + public: + + FixedMinSizedItem( QgsLayout *layout ) : TestItem( layout ) + { + setFixedSize( QgsLayoutSize( 2.0, 4.0, QgsUnitTypes::LayoutCentimeters ) ); + setMinimumSize( QgsLayoutSize( 5.0, 9.0, QgsUnitTypes::LayoutCentimeters ) ); + } + ~FixedMinSizedItem() {} +}; + + class TestQgsLayoutItem: public QObject { Q_OBJECT @@ -66,78 +148,6 @@ class TestQgsLayoutItem: public QObject private: - //simple item for testing, since some methods in QgsLayoutItem are pure virtual - class TestItem : public QgsLayoutItem - { - public: - - TestItem( QgsLayout *layout ) : QgsLayoutItem( layout ) {} - ~TestItem() {} - - //implement pure virtual methods - int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; } - QString stringType() const override { return QStringLiteral( "TestItemType" ); } - - protected: - void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * = nullptr ) override - { - QPainter *painter = context.painter(); - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, false ); - painter->setPen( Qt::NoPen ); - painter->setBrush( QColor( 255, 100, 100, 200 ) ); - painter->drawRect( rect() ); - painter->restore(); - } - }; - - //item with minimum size - class MinSizedItem : public TestItem - { - public: - MinSizedItem( QgsLayout *layout ) : TestItem( layout ) - { - setMinimumSize( QgsLayoutSize( 5.0, 10.0, QgsUnitTypes::LayoutCentimeters ) ); - } - - void updateMinSize( QgsLayoutSize size ) - { - setMinimumSize( size ); - } - - ~MinSizedItem() {} - }; - - //item with fixed size - class FixedSizedItem : public TestItem - { - public: - - FixedSizedItem( QgsLayout *layout ) : TestItem( layout ) - { - setFixedSize( QgsLayoutSize( 2.0, 4.0, QgsUnitTypes::LayoutInches ) ); - } - - void updateFixedSize( QgsLayoutSize size ) - { - setFixedSize( size ); - } - ~FixedSizedItem() {} - }; - - //item with both conflicting fixed and minimum size - class FixedMinSizedItem : public TestItem - { - public: - - FixedMinSizedItem( QgsLayout *layout ) : TestItem( layout ) - { - setFixedSize( QgsLayoutSize( 2.0, 4.0, QgsUnitTypes::LayoutCentimeters ) ); - setMinimumSize( QgsLayoutSize( 5.0, 9.0, QgsUnitTypes::LayoutCentimeters ) ); - } - ~FixedMinSizedItem() {} - }; - QString mReport; bool renderCheck( QString testName, QImage &image, int mismatchCount );