Skip to content

Commit

Permalink
Ensure all classes derived from QObject include the Q_OBJECT macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 7, 2015
1 parent 6127851 commit 08ab4d4
Show file tree
Hide file tree
Showing 73 changed files with 1,190 additions and 851 deletions.
1 change: 1 addition & 0 deletions src/analysis/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(BEFORE raster)

SET(QGIS_NETWORK_ANALYSIS_MOC_HDRS
qgsgraphdirector.h
qgslinevectorlayerdirector.h
)

QT4_WRAP_CPP(QGIS_NETWORK_ANALYSIS_MOC_SRCS ${QGIS_NETWORK_ANALYSIS_MOC_HDRS})
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/network/qgslinevectorlayerdirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class QgsVectorLayer;
*/
class ANALYSIS_EXPORT QgsLineVectorLayerDirector : public QgsGraphDirector
{
Q_OBJECT

public:
/**
* @param myLayer source vector layer
Expand Down
10 changes: 10 additions & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ SET (QGIS_APP_MOC_HDRS
qgslabeldialog.h
qgslabelengineconfigdialog.h
qgslabelinggui.h
qgslabelpreview.h
qgslabelingwidget.h
qgslabelpropertydialog.h
qgsloadstylefromdbdialog.h
Expand All @@ -223,6 +224,7 @@ SET (QGIS_APP_MOC_HDRS
qgswelcomepage.h

qgsmaptooladdfeature.h
qgsmaptoolannotation.h
qgsmaptoolcircularstringradius.h
qgsmaptooladdpart.h
qgsmaptooladdring.h
Expand All @@ -231,12 +233,15 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptooldeletepart.h
qgsmaptooldeletering.h
qgsmaptoolfeatureaction.h
qgsmaptoolformannotation.h
qgsmaptoolhtmlannotation.h
qgsmaptoolpinlabels.h
qgsmaptoolshowhidelabels.h
qgsmaptoolidentifyaction.h
qgsmaptoolmeasureangle.h
qgsmaptoolmovefeature.h
qgsmaptoolmovelabel.h
qgsmaptoollabel.h
qgsmaptooloffsetcurve.h
qgsmaptoolreshape.h
qgsmaptoolrotatefeature.h
Expand All @@ -250,7 +255,10 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolsimplify.h
qgsmaptoolsplitfeatures.h
qgsmaptoolsplitparts.h
qgsmaptoolsvgannotation.h
qgsmaptooltextannotation.h
qgsmaptooladdcircularstring.h
qgsmaptoolcircularstringcurvepoint.h

nodetool/qgsmaptoolnodetool.h
nodetool/qgsselectedfeature.h
Expand Down Expand Up @@ -285,6 +293,8 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscomposeritemwidget.h
composer/qgscomposerlabelwidget.h
composer/qgscomposerlegendwidget.h
composer/qgscomposerlegenditemdialog.h
composer/qgscomposerlegendlayersdialog.h
composer/qgscomposermanager.h
composer/qgscomposermapwidget.h
composer/qgscomposerpicturewidget.h
Expand Down
5 changes: 4 additions & 1 deletion src/app/composer/qgscomposerlegenditemdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
#ifndef QGSCOMPOSERLEGENDITEMDIALOG_H
#define QGSCOMPOSERLEGENDITEMDIALOG_H

#include <QDialog>
#include "ui_qgscomposerlegenditemdialogbase.h"

class QStandardItem;

/** \ingroup MapComposer
* A dialog to enter properties of composer legend items (currently only item text)
* */
class QgsComposerLegendItemDialog: private Ui::QgsComposerLegendItemDialogBase, public QDialog
class QgsComposerLegendItemDialog: public QDialog, private Ui::QgsComposerLegendItemDialogBase
{
Q_OBJECT

public:
QgsComposerLegendItemDialog( const QStandardItem* item, QWidget* parent = 0 );
~QgsComposerLegendItemDialog();
Expand Down
4 changes: 3 additions & 1 deletion src/app/composer/qgscomposerlegendlayersdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
/** \ingroup MapComposer
* A dialog to add new layers to the legend.
* */
class QgsComposerLegendLayersDialog: private Ui::QgsComposerLegendLayersDialogBase, public QDialog
class QgsComposerLegendLayersDialog: public QDialog, private Ui::QgsComposerLegendLayersDialogBase
{
Q_OBJECT

public:
QgsComposerLegendLayersDialog( QList<QgsMapLayer*> layers, QWidget* parent = 0 );
~QgsComposerLegendLayersDialog();
Expand Down
85 changes: 41 additions & 44 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,6 @@
#include <QInputDialog>



class QgsComposerLegendMenuProvider : public QObject, public QgsLayerTreeViewMenuProvider
{
public:
QgsComposerLegendMenuProvider( QgsLayerTreeView* view, QgsComposerLegendWidget* w ) : mView( view ), mWidget( w ) {}

virtual QMenu* createContextMenu() override
{
if ( !mView->currentNode() )
return 0;

if ( mWidget->legend()->autoUpdateModel() )
return 0; // no editing allowed

QMenu* menu = new QMenu();

if ( QgsLayerTree::isLayer( mView->currentNode() ) )
{
menu->addAction( tr( "Reset to defaults" ), mWidget, SLOT( resetLayerNodeToDefaults() ) );
menu->addSeparator();
}

QgsComposerLegendStyle::Style currentStyle = QgsLegendRenderer::nodeLegendStyle( mView->currentNode(), mView->layerTreeModel() );

QList<QgsComposerLegendStyle::Style> lst;
lst << QgsComposerLegendStyle::Hidden << QgsComposerLegendStyle::Group << QgsComposerLegendStyle::Subgroup;
Q_FOREACH ( QgsComposerLegendStyle::Style style, lst )
{
QAction* action = menu->addAction( QgsComposerLegendStyle::styleLabel( style ), mWidget, SLOT( setCurrentNodeStyleFromAction() ) );
action->setCheckable( true );
action->setChecked( currentStyle == style );
action->setData(( int ) style );
}

return menu;
}

protected:
QgsLayerTreeView* mView;
QgsComposerLegendWidget* mWidget;
};



QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend )
: QgsComposerItemBaseWidget( 0, legend )
, mLegend( legend )
Expand Down Expand Up @@ -1096,3 +1052,44 @@ void QgsComposerLegendWidget::updateFilterLegendByAtlasButton()
const QgsAtlasComposition& atlas = mLegend->composition()->atlasComposition();
mFilterLegendByAtlasCheckBox->setEnabled( atlas.enabled() && atlas.coverageLayer() && atlas.coverageLayer()->geometryType() == QGis::Polygon );
}


//
// QgsComposerLegendMenuProvider
//

QgsComposerLegendMenuProvider::QgsComposerLegendMenuProvider( QgsLayerTreeView* view, QgsComposerLegendWidget* w )
: mView( view )
, mWidget( w )
{}

QMenu*QgsComposerLegendMenuProvider::createContextMenu()
{
if ( !mView->currentNode() )
return 0;

if ( mWidget->legend()->autoUpdateModel() )
return 0; // no editing allowed

QMenu* menu = new QMenu();

if ( QgsLayerTree::isLayer( mView->currentNode() ) )
{
menu->addAction( tr( "Reset to defaults" ), mWidget, SLOT( resetLayerNodeToDefaults() ) );
menu->addSeparator();
}

QgsComposerLegendStyle::Style currentStyle = QgsLegendRenderer::nodeLegendStyle( mView->currentNode(), mView->layerTreeModel() );

QList<QgsComposerLegendStyle::Style> lst;
lst << QgsComposerLegendStyle::Hidden << QgsComposerLegendStyle::Group << QgsComposerLegendStyle::Subgroup;
Q_FOREACH ( QgsComposerLegendStyle::Style style, lst )
{
QAction* action = menu->addAction( QgsComposerLegendStyle::styleLabel( style ), mWidget, SLOT( setCurrentNodeStyleFromAction() ) );
action->setCheckable( true );
action->setChecked( currentStyle == style );
action->setData(( int ) style );
}

return menu;
}
16 changes: 16 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,21 @@ class QgsComposerLegendWidget: public QgsComposerItemBaseWidget, private Ui::Qgs
QgsComposerLegend* mLegend;
};


class QgsComposerLegendMenuProvider : public QObject, public QgsLayerTreeViewMenuProvider
{
Q_OBJECT

public:
QgsComposerLegendMenuProvider( QgsLayerTreeView* view, QgsComposerLegendWidget* w );

virtual QMenu* createContextMenu() override;

protected:
QgsLayerTreeView* mView;
QgsComposerLegendWidget* mWidget;
};


#endif

56 changes: 27 additions & 29 deletions src/app/nodetool/qgsnodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,6 @@
static const int MinRadiusRole = Qt::UserRole + 1;


class CoordinateItemDelegate : public QStyledItemDelegate
{
public:
QString displayText( const QVariant & value, const QLocale & locale ) const override
{
return locale.toString( value.toDouble(), 'f', 4 );
}

protected:
QWidget* createEditor( QWidget * parent, const QStyleOptionViewItem & /*option*/, const QModelIndex & index ) const override
{
QLineEdit* lineEdit = new QLineEdit( parent );
QDoubleValidator* validator = new QDoubleValidator();
if ( !index.data( MinRadiusRole ).isNull() )
validator->setBottom( index.data( MinRadiusRole ).toDouble() );
lineEdit->setValidator( validator );
return lineEdit;
}
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override
{
QLineEdit* lineEdit = qobject_cast<QLineEdit*>( editor );
if ( lineEdit->hasAcceptableInput() )
{
QStyledItemDelegate::setModelData( editor, model, index );
}
}
};


QgsNodeEditorModel::QgsNodeEditorModel( QgsVectorLayer* layer, QgsSelectedFeature* selectedFeature, QgsMapCanvas* canvas, QObject* parent )
: QAbstractTableModel( parent )
, mLayer( layer )
Expand Down Expand Up @@ -410,3 +381,30 @@ void QgsNodeEditor::zoomToNode( int idx )
}


//
// CoordinateItemDelegate
//

QString CoordinateItemDelegate::displayText( const QVariant& value, const QLocale& locale ) const
{
return locale.toString( value.toDouble(), 'f', 4 );
}

QWidget*CoordinateItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index ) const
{
QLineEdit* lineEdit = new QLineEdit( parent );
QDoubleValidator* validator = new QDoubleValidator();
if ( !index.data( MinRadiusRole ).isNull() )
validator->setBottom( index.data( MinRadiusRole ).toDouble() );
lineEdit->setValidator( validator );
return lineEdit;
}

void CoordinateItemDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const
{
QLineEdit* lineEdit = qobject_cast<QLineEdit*>( editor );
if ( lineEdit->hasAcceptableInput() )
{
QStyledItemDelegate::setModelData( editor, model, index );
}
}
14 changes: 14 additions & 0 deletions src/app/nodetool/qgsnodeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QDockWidget>
#include <QAbstractTableModel>
#include <QItemSelection>
#include <QStyledItemDelegate>

class QgsMapCanvas;
class QgsRubberBand;
Expand Down Expand Up @@ -94,4 +95,17 @@ class QgsNodeEditor : public QDockWidget
bool mUpdatingNodeSelection;
};


class CoordinateItemDelegate : public QStyledItemDelegate
{
Q_OBJECT

public:
QString displayText( const QVariant & value, const QLocale & locale ) const override;

protected:
QWidget* createEditor( QWidget * parent, const QStyleOptionViewItem & /*option*/, const QModelIndex & index ) const override;
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
};

#endif // QGSNODEEDITOR_H
33 changes: 17 additions & 16 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@
#include "qgsfield.h"
#include "qgseditorwidgetregistry.h"

class QgsAttributeTableDock : public QDockWidget
{
public:
QgsAttributeTableDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )
: QDockWidget( title, parent, flags )
{
setObjectName( "AttributeTable" ); // set object name so the position can be saved
}

virtual void closeEvent( QCloseEvent * ev ) override
{
Q_UNUSED( ev );
deleteLater();
}
};

static QgsExpressionContext _getExpressionContext( const void* context )
{
QgsExpressionContext expContext;
Expand Down Expand Up @@ -857,3 +841,20 @@ void QgsAttributeTableDialog::setFilterExpression( const QString& filterString )
}
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowFilteredList );
}


//
// QgsAttributeTableDock
//

QgsAttributeTableDock::QgsAttributeTableDock( const QString& title, QWidget* parent, Qt::WindowFlags flags )
: QDockWidget( title, parent, flags )
{
setObjectName( "AttributeTable" ); // set object name so the position can be saved
}

void QgsAttributeTableDock::closeEvent( QCloseEvent* ev )
{
Q_UNUSED( ev );
deleteLater();
}
15 changes: 13 additions & 2 deletions src/app/qgsattributetabledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
#include "qgsvectorlayer.h" //QgsFeatureIds
#include "qgsfieldmodel.h"
#include "qgssearchwidgetwrapper.h"
#include <QDockWidget>

class QDialogButtonBox;
class QPushButton;
class QLineEdit;
class QComboBox;
class QMenu;
class QDockWidget;
class QSignalMapper;

class QgsAttributeTableModel;
class QgsAttributeTableFilterModel;
class QgsRubberBand;
Expand Down Expand Up @@ -222,4 +221,16 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
QgsSearchWidgetWrapper* mCurrentSearchWidgetWrapper;
};


class QgsAttributeTableDock : public QDockWidget
{
Q_OBJECT

public:
QgsAttributeTableDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );

virtual void closeEvent( QCloseEvent * ev ) override;
};


#endif
Loading

0 comments on commit 08ab4d4

Please sign in to comment.