Skip to content

Commit

Permalink
Add missing Q_OBJECT macros and enable clazy check missing-qobject-macro
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed Jul 12, 2022
1 parent ea13e0c commit d5505e3
Show file tree
Hide file tree
Showing 76 changed files with 388 additions and 258 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -887,7 +887,7 @@ if (WITH_CORE)
if (WITH_CLAZY)
set(CMAKE_CXX_BASE_FLAGS "${CMAKE_CXX_FLAGS}")
# qcolor-from-literal crashes clang with clazy 1.11
set(CLAZY_BASE_CHECKS "connect-3arg-lambda,lambda-unique-connection,empty-qstringliteral,fully-qualified-moc-types,lowercase-qml-type-name,qfileinfo-exists,qmap-with-pointer-key,unused-non-trivial-variable,overridden-signal,qdeleteall,qstring-left,skipped-base-method,isempty-vs-count")
set(CLAZY_BASE_CHECKS "connect-3arg-lambda,lambda-unique-connection,empty-qstringliteral,fully-qualified-moc-types,lowercase-qml-type-name,qfileinfo-exists,qmap-with-pointer-key,unused-non-trivial-variable,overridden-signal,qdeleteall,qstring-left,skipped-base-method,isempty-vs-count,missing-qobject-macro")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_BASE_FLAGS} -Xclang -plugin-arg-clazy -Xclang ${CLAZY_BASE_CHECKS}")

if (WERROR AND NOT ${QGISDEBUG})
Expand Down
Expand Up @@ -224,10 +224,11 @@ Moves up currently selected field
Moves down currently selected field
%End

public:
};




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
4 changes: 2 additions & 2 deletions python/gui/auto_generated/qgsfieldmappingwidget.sip.in
Expand Up @@ -146,11 +146,11 @@ Moves up currently selected field
Moves down the currently selected field
%End

public:
public:
};




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
1 change: 1 addition & 0 deletions src/app/devtools/networklogger/qgsnetworklogger.h
Expand Up @@ -131,6 +131,7 @@ class QgsNetworkLogger : public QAbstractItemModel
*/
class QgsNetworkLoggerProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:

/**
Expand Down
1 change: 1 addition & 0 deletions src/app/devtools/querylogger/qgsappquerylogger.h
Expand Up @@ -112,6 +112,7 @@ class QgsAppQueryLogger : public QAbstractItemModel
*/
class QgsDatabaseQueryLoggerProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:

/**
Expand Down
1 change: 1 addition & 0 deletions src/app/maptools/qgsmaptoolshapecircle2points.h
Expand Up @@ -40,6 +40,7 @@ class APP_EXPORT QgsMapToolShapeCircle2PointsMetadata : public QgsMapToolShapeMe

class APP_EXPORT QgsMapToolShapeCircle2Points : public QgsMapToolShapeCircleAbstract
{
Q_OBJECT
public:
QgsMapToolShapeCircle2Points( QgsMapToolCapture *parentTool )
: QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle2PointsMetadata::TOOL_ID, parentTool )
Expand Down
21 changes: 0 additions & 21 deletions src/app/qgsrelationmanagerdialog.cpp
Expand Up @@ -22,27 +22,6 @@
#include "qgsvectorlayer.h"


#ifndef SIP_RUN
class RelationNameEditorDelegate: public QStyledItemDelegate
{
public:
RelationNameEditorDelegate( const QList<int> &editableColumns, QObject *parent = nullptr )
: QStyledItemDelegate( parent )
, mEditableColumns( editableColumns )
{}

virtual QWidget *createEditor( QWidget *parentWidget, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( mEditableColumns.contains( index.column() ) )
return QStyledItemDelegate::createEditor( parentWidget, option, index );

return nullptr;
}
private:
QList<int> mEditableColumns;
};
#endif

QgsRelationManagerDialog::QgsRelationManagerDialog( QgsRelationManager *relationMgr, QWidget *parent )
: QWidget( parent )
, Ui::QgsRelationManagerDialogBase()
Expand Down
20 changes: 20 additions & 0 deletions src/app/qgsrelationmanagerdialog.h
Expand Up @@ -56,4 +56,24 @@ class APP_EXPORT QgsRelationManagerDialog : public QWidget, private Ui::QgsRelat
QString getUniqueId( const QString &idTmpl, const QString &ids ) const;
};

class RelationNameEditorDelegate: public QStyledItemDelegate
{
Q_OBJECT
public:
RelationNameEditorDelegate( const QList<int> &editableColumns, QObject *parent = nullptr )
: QStyledItemDelegate( parent )
, mEditableColumns( editableColumns )
{}

virtual QWidget *createEditor( QWidget *parentWidget, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( mEditableColumns.contains( index.column() ) )
return QStyledItemDelegate::createEditor( parentWidget, option, index );

return nullptr;
}
private:
QList<int> mEditableColumns;
};

#endif // QGSRELATIONMANAGERDIALOG_H
26 changes: 1 addition & 25 deletions src/app/qgssnappinglayertreemodel.cpp
Expand Up @@ -29,30 +29,6 @@
#include "qgsapplication.h"
#include "qgsscalewidget.h"

class SnapTypeMenu: public QMenu
{
public:
SnapTypeMenu( const QString &title, QWidget *parent = nullptr )
: QMenu( title, parent ) {}

void mouseReleaseEvent( QMouseEvent *e )
{
QAction *action = activeAction();
if ( action )
action->trigger();
else
QMenu::mouseReleaseEvent( e );
}

// set focus to parent so that mTypeButton is not displayed
void hideEvent( QHideEvent *e )
{
qobject_cast<QWidget *>( parent() )->setFocus();
QMenu::hideEvent( e );
}
};


QgsSnappingLayerDelegate::QgsSnappingLayerDelegate( QgsMapCanvas *canvas, QObject *parent )
: QItemDelegate( parent )
, mCanvas( canvas )
Expand All @@ -70,7 +46,7 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
QToolButton *mTypeButton = new QToolButton( parent );
mTypeButton->setToolTip( tr( "Snapping Type" ) );
mTypeButton->setPopupMode( QToolButton::InstantPopup );
SnapTypeMenu *typeMenu = new SnapTypeMenu( tr( "Set Snapping Mode" ), parent );
SnappingLayerDelegateTypeMenu *typeMenu = new SnappingLayerDelegateTypeMenu( tr( "Set Snapping Mode" ), parent );

for ( Qgis::SnappingType type : qgsEnumList<Qgis::SnappingType>() )
{
Expand Down
25 changes: 25 additions & 0 deletions src/app/qgssnappinglayertreemodel.h
Expand Up @@ -102,4 +102,29 @@ class APP_EXPORT QgsSnappingLayerTreeModel : public QSortFilterProxyModel
void hasRowchanged( QgsLayerTreeNode *node, const QHash<QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettings> &oldSettings );
};

class SnappingLayerDelegateTypeMenu: public QMenu
{
Q_OBJECT

public:
SnappingLayerDelegateTypeMenu( const QString &title, QWidget *parent = nullptr )
: QMenu( title, parent ) {}

void mouseReleaseEvent( QMouseEvent *e )
{
QAction *action = activeAction();
if ( action )
action->trigger();
else
QMenu::mouseReleaseEvent( e );
}

// set focus to parent so that mTypeButton is not displayed
void hideEvent( QHideEvent *e )
{
qobject_cast<QWidget *>( parent() )->setFocus();
QMenu::hideEvent( e );
}
};

#endif // QGSSNAPPINGLAYERTREEVIEW_H
16 changes: 0 additions & 16 deletions src/app/qgssnappingwidget.cpp
Expand Up @@ -47,22 +47,6 @@
#include "modeltest.h"
#endif

class SnapTypeMenu: public QMenu
{
public:
SnapTypeMenu( const QString &title, QWidget *parent = nullptr )
: QMenu( title, parent ) {}

void mouseReleaseEvent( QMouseEvent *e )
{
QAction *action = activeAction();
if ( action )
action->trigger();
else
QMenu::mouseReleaseEvent( e );
}
};

QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas, QWidget *parent )
: QWidget( parent )
, mProject( project )
Expand Down
17 changes: 17 additions & 0 deletions src/app/qgssnappingwidget.h
Expand Up @@ -182,4 +182,21 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
void cleanGroup( QgsLayerTreeNode *node );
};

class SnapTypeMenu: public QMenu
{
Q_OBJECT
public:
SnapTypeMenu( const QString &title, QWidget *parent = nullptr )
: QMenu( title, parent ) {}

void mouseReleaseEvent( QMouseEvent *e )
{
QAction *action = activeAction();
if ( action )
action->trigger();
else
QMenu::mouseReleaseEvent( e );
}
};

#endif
1 change: 1 addition & 0 deletions src/core/layertree/qgslayertreemodellegendnode.h
Expand Up @@ -730,6 +730,7 @@ class CORE_EXPORT QgsDataDefinedSizeLegendNode : public QgsLayerTreeModelLegendN
*/
class CORE_EXPORT QgsVectorLabelLegendNode : public QgsLayerTreeModelLegendNode
{
Q_OBJECT
public:

/**
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/copc/qgscopcprovider.h
Expand Up @@ -66,6 +66,7 @@ class QgsCopcProvider: public QgsPointCloudDataProvider

class QgsCopcProviderMetadata : public QgsProviderMetadata
{
Q_OBJECT
public:
QgsCopcProviderMetadata();
QIcon icon() const override;
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/ept/qgseptprovider.h
Expand Up @@ -62,6 +62,7 @@ class QgsEptProvider: public QgsPointCloudDataProvider

class QgsEptProviderMetadata : public QgsProviderMetadata
{
Q_OBJECT
public:
QgsEptProviderMetadata();
QIcon icon() const override;
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/gdal/qgsgdalprovider.h
Expand Up @@ -370,6 +370,7 @@ class QgsGdalProvider final: public QgsRasterDataProvider, QgsGdalProviderBase
*/
class QgsGdalProviderMetadata final: public QgsProviderMetadata
{
Q_OBJECT
public:
QgsGdalProviderMetadata();
QIcon icon() const override;
Expand Down
2 changes: 2 additions & 0 deletions src/core/providers/memory/qgsmemoryprovider.h
Expand Up @@ -101,6 +101,8 @@ class QgsMemoryProvider final: public QgsVectorDataProvider

class QgsMemoryProviderMetadata final: public QgsProviderMetadata
{
Q_OBJECT

public:
QgsMemoryProviderMetadata();
QIcon icon() const override;
Expand Down
2 changes: 2 additions & 0 deletions src/core/providers/meshmemory/qgsmeshmemorydataprovider.h
Expand Up @@ -189,6 +189,8 @@ class CORE_EXPORT QgsMeshMemoryDataProvider final: public QgsMeshDataProvider

class QgsMeshMemoryProviderMetadata final: public QgsProviderMetadata
{
Q_OBJECT

public:
QgsMeshMemoryProviderMetadata();
QIcon icon() const override;
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/ogr/qgsogrprovidermetadata.h
Expand Up @@ -28,6 +28,7 @@ email : nyall dot dawson at gmail dot com
*/
class QgsOgrProviderMetadata final: public QgsProviderMetadata
{
Q_OBJECT
public:

QgsOgrProviderMetadata();
Expand Down
1 change: 1 addition & 0 deletions src/core/vectortile/qgsvectortileprovidermetadata.h
Expand Up @@ -29,6 +29,7 @@
*/
class QgsVectorTileProviderMetadata : public QgsProviderMetadata
{
Q_OBJECT
public:
QgsVectorTileProviderMetadata();
QIcon icon() const override;
Expand Down
1 change: 1 addition & 0 deletions src/gui/layout/qgsgeopdflayertreemodel.h
Expand Up @@ -75,6 +75,7 @@ class GUI_EXPORT QgsGeoPdfLayerTreeModel : public QgsMapLayerModel
///@cond PRIVATE
class GUI_EXPORT QgsGeoPdfLayerFilteredTreeModel : public QSortFilterProxyModel
{
Q_OBJECT
public:

QgsGeoPdfLayerFilteredTreeModel( QgsGeoPdfLayerTreeModel *sourceModel, QObject *parent = nullptr );
Expand Down
1 change: 1 addition & 0 deletions src/gui/maptools/qgsmaptoolcapturelayergeometry.h
Expand Up @@ -29,6 +29,7 @@ class QgsMapCanvas;
*/
class GUI_EXPORT QgsMapToolCaptureLayerGeometry : public QgsMapToolCapture
{
Q_OBJECT
public:
//! Constructor
QgsMapToolCaptureLayerGeometry( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/mesh/qgsmeshdatasetgrouptreeview.h
Expand Up @@ -126,6 +126,7 @@ class QgsMeshDatasetGroupTreeModel : public QAbstractItemModel
*/
class QgsMeshAvailableDatasetGroupTreeModel: public QgsMeshDatasetGroupTreeModel
{
Q_OBJECT
public:
QgsMeshAvailableDatasetGroupTreeModel( QObject *parent = nullptr );

Expand All @@ -146,6 +147,7 @@ class QgsMeshAvailableDatasetGroupTreeModel: public QgsMeshDatasetGroupTreeModel
*/
class QgsMeshDatasetGroupProxyModel: public QSortFilterProxyModel
{
Q_OBJECT
public:
QgsMeshDatasetGroupProxyModel( QAbstractItemModel *sourceModel );

Expand Down Expand Up @@ -301,6 +303,7 @@ class GUI_EXPORT QgsMeshActiveDatasetGroupTreeView : public QTreeView
*/
class GUI_EXPORT QgsMeshDatasetGroupListModel: public QAbstractListModel
{
Q_OBJECT
public:
explicit QgsMeshDatasetGroupListModel( QObject *parent );

Expand Down
1 change: 1 addition & 0 deletions src/gui/mesh/qgsmeshstaticdatasetwidget.h
Expand Up @@ -35,6 +35,7 @@ class QgsMeshDataProvider;
*/
class QgsMeshDatasetListModel: public QAbstractListModel
{
Q_OBJECT
public:
//! Constructor
QgsMeshDatasetListModel( QObject *parent );
Expand Down
Expand Up @@ -34,6 +34,7 @@ class QMimeData;
*/
class QgsModelDesignerInputsTreeWidget : public QTreeWidget
{
Q_OBJECT
public:

/**
Expand Down
1 change: 1 addition & 0 deletions src/gui/processing/models/qgsmodelinputreorderwidget.h
Expand Up @@ -72,6 +72,7 @@ class GUI_EXPORT QgsModelInputReorderWidget : public QWidget, private Ui::QgsMod
*/
class GUI_EXPORT QgsModelInputReorderDialog : public QDialog
{
Q_OBJECT

public:

Expand Down

0 comments on commit d5505e3

Please sign in to comment.