Fix missing Q_OBJECT macros

Thanks to Clazy
This commit is contained in:
Nyall Dawson 2017-08-29 16:27:19 +10:00
parent 972a1fe459
commit 78b834c5b0
36 changed files with 465 additions and 359 deletions

View File

@ -385,6 +385,8 @@ Filter nodes from QgsMapLayerLegend according to the current filtering rules
QFlags<QgsLayerTreeModel::Flag> operator|(QgsLayerTreeModel::Flag f1, QFlags<QgsLayerTreeModel::Flag> f2);
/************************************************************************
* This file has been generated automatically from *
* *

View File

@ -28,6 +28,7 @@ class QgsCodeEditorSQL : QgsCodeEditor
};
/************************************************************************
* This file has been generated automatically from *
* *

View File

@ -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 *
* *

View File

@ -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 )

View File

@ -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

View File

@ -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 )

View File

@ -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

View File

@ -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 );

View File

@ -265,6 +265,8 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
//simple item for testing
class TestLayoutItem : public QgsLayoutItem
{
Q_OBJECT
public:
TestLayoutItem( QgsLayout *layout );

View File

@ -29,6 +29,8 @@
class QgsNativeAlgorithms: public QgsProcessingProvider
{
Q_OBJECT
public:
QgsNativeAlgorithms( QObject *parent = nullptr );

View File

@ -18,7 +18,9 @@
#include "qgsnetworkdiskcache.h"
QgsNetworkDiskCache::ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache;
///@cond PRIVATE
ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache;
///@endcond
QMutex QgsNetworkDiskCache::sDiskCacheMutex;
QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent )

View File

@ -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;

View File

@ -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 ) {}

View File

@ -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();
}

View File

@ -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;
};

View File

@ -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 );

View File

@ -20,7 +20,6 @@
#include <QString>
#include <QFont>
#include <QLabel>
#include <Qsci/qscilexersql.h>
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()
{

View File

@ -19,6 +19,7 @@
#include "qgscodeeditor.h"
#include "qgis_sip.h"
#include "qgis_gui.h"
#include <Qsci/qscilexersql.h>
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

View File

@ -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 )

View File

@ -24,6 +24,7 @@
#include "qgspanelwidget.h"
#include "qgsproperty.h"
#include <QStyledItemDelegate>
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

View File

@ -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<QgsGrassVectorLayer *> 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;

View File

@ -41,114 +41,11 @@
#include "qgsdetaileditemdata.h"
#include "qgsdetaileditemdelegate.h"
#include <QSortFilterProxyModel>
#include <QStandardItem>
#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() );
}

View File

@ -20,6 +20,9 @@
#include "ui_qgsgrasstoolsbase.h"
#include <QSortFilterProxyModel>
#include <QStandardItem>
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

View File

@ -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 );
};

View File

@ -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 );
};

View File

@ -29,7 +29,6 @@
#include "qgssettings.h"
#include "qgsmapcanvas.h"
#include <QItemDelegate>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QFileDialog>
@ -37,18 +36,6 @@
#include <QImageReader>
#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 ),

View File

@ -23,6 +23,8 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsabstractdatasourcewidget.h"
#include <QItemDelegate>
class QStandardItemModel;
class QSortFilterProxyModel;
class QgsProjectionSelectionDialog;
@ -116,5 +118,17 @@ class QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidget, protect
void treeWidgetCurrentRowChanged( const QModelIndex &current, 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

View File

@ -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

View File

@ -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

View File

@ -77,6 +77,8 @@ class QgsGrassObjectItemBase
class QgsGrassLocationItem : public QgsDirectoryItem, public QgsGrassObjectItemBase
{
Q_OBJECT
public:
QgsGrassLocationItem( QgsDataItem *parent, QString dirPath, QString path );

View File

@ -19,6 +19,7 @@ SET(WFS_SRCS
SET (WFS_MOC_HDRS
qgswfscapabilities.h
qgswfsconnection.h
qgswfsdataitems.h
qgswfsprovider.h
qgswfsfeatureiterator.h

View File

@ -20,6 +20,8 @@
class QgsWfsConnection : public QgsOwsConnection
{
Q_OBJECT
public:
/**

View File

@ -30,7 +30,6 @@
#include "qgslogger.h"
#include "qgsmanageconnectionsdialog.h"
#include "qgssqlstatement.h"
#include "qgssqlcomposerdialog.h"
#include "qgssettings.h"
#include <QDomDocument>
@ -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" ) );
}
}

View File

@ -23,6 +23,7 @@
#include "qgswfscapabilities.h"
#include "qgsproviderregistry.h"
#include "qgsabstractdatasourcewidget.h"
#include "qgssqlcomposerdialog.h"
#include <QItemDelegate>
#include <QStandardItemModel>
@ -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

View File

@ -1348,4 +1348,4 @@ void QgsWMSSourceSelect::updateLayerOrderTab( const QStringList &newLayerList, c
void QgsWMSSourceSelect::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_ogc/ogc_client_support.html" ) );
}
}

View File

@ -28,6 +28,88 @@
#include <QImage>
#include <QtTest/QSignalSpy>
//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 );