Skip to content

Commit

Permalink
Declutter header files
Browse files Browse the repository at this point in the history
Implementations of virtual methods will never be inlined, there's no
reason to keep them in headers. It just makes code less readable and
potentially slows down compilation.
  • Loading branch information
m-kuhn committed May 19, 2017
1 parent 95ac7d0 commit ac50214
Show file tree
Hide file tree
Showing 19 changed files with 329 additions and 28 deletions.
10 changes: 10 additions & 0 deletions src/core/annotations/qgsannotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ void QgsAnnotation::setMapLayer( QgsMapLayer *layer )
emit mapLayerChanged();
}

void QgsAnnotation::setAssociatedFeature( const QgsFeature &feature )
{
mFeature = feature;
}

QSizeF QgsAnnotation::minimumFrameSize() const
{
return QSizeF( 0, 0 );
}

void QgsAnnotation::updateBalloon()
{
//first test if the point is in the frame. In that case we don't need a balloon.
Expand Down
4 changes: 2 additions & 2 deletions src/core/annotations/qgsannotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class CORE_EXPORT QgsAnnotation : public QObject
* Sets the feature associated with the annotation.
* \see associatedFeature()
*/
virtual void setAssociatedFeature( const QgsFeature &feature ) { mFeature = feature; }
virtual void setAssociatedFeature( const QgsFeature &feature );

signals:

Expand Down Expand Up @@ -282,7 +282,7 @@ class CORE_EXPORT QgsAnnotation : public QObject
* Returns the minimum frame size for the annotation. Subclasses should implement this if they
* cannot be resized smaller than a certain minimum size.
*/
virtual QSizeF minimumFrameSize() const { return QSizeF( 0, 0 ); }
virtual QSizeF minimumFrameSize() const;

/**
* Writes common annotation properties to a DOM element.
Expand Down
30 changes: 30 additions & 0 deletions src/core/composer/qgscomposermapitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@ void QgsComposerMapItem::setComposerMap( QgsComposerMap *map )
mComposerMap = map;
}

const QgsComposerMap *QgsComposerMapItem::composerMap() const
{
return mComposerMap;
}

void QgsComposerMapItem::setName( const QString &name )
{
mName = name;
}

QString QgsComposerMapItem::name() const
{
return mName;
}

void QgsComposerMapItem::setEnabled( const bool enabled )
{
mEnabled = enabled;
}

bool QgsComposerMapItem::enabled() const
{
return mEnabled;
}

bool QgsComposerMapItem::usesAdvancedEffects() const
{
return false;
}

//
// QgsComposerMapItemStack
//
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposermapitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject
* \returns composer map
* \see setComposerMap
*/
virtual const QgsComposerMap *composerMap() const { return mComposerMap; }
virtual const QgsComposerMap *composerMap() const;

/** Get the unique id for the map item
* \returns unique id
Expand All @@ -79,13 +79,13 @@ class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject
* \param name display name
* \see name
*/
virtual void setName( const QString &name ) { mName = name; }
virtual void setName( const QString &name );

/** Get friendly display name for the item
* \returns display name
* \see setName
*/
virtual QString name() const { return mName; }
virtual QString name() const;

/** Controls whether the item will be drawn
* \param enabled set to true to enable drawing of the item
Expand Down
15 changes: 15 additions & 0 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ QgsComposerMultiFrame::~QgsComposerMultiFrame()
deleteFrames();
}

QSizeF QgsComposerMultiFrame::fixedFrameSize( const int frameIndex ) const
{
Q_UNUSED( frameIndex ); return QSizeF( 0, 0 );
}

QSizeF QgsComposerMultiFrame::minFrameSize( const int frameIndex ) const
{
Q_UNUSED( frameIndex ); return QSizeF( 0, 0 );
}

double QgsComposerMultiFrame::findNearbyPageBreak( double yPos )
{
return yPos;
}

void QgsComposerMultiFrame::setResizeMode( ResizeMode mode )
{
if ( mode != mResizeMode )
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposermultiframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
* \see minFrameSize
* \see recalculateFrameRects
*/
virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const;

/** Returns the minimum size for a frames, if desired. If the minimum
* size changes, the sizes of all frames can be recalculated by calling
Expand All @@ -90,7 +90,7 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
* \see fixedFrameSize
* \see recalculateFrameRects
*/
virtual QSizeF minFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
virtual QSizeF minFrameSize( const int frameIndex = -1 ) const;

/** Renders a portion of the multiframe's content into a painter.
* \param painter destination painter
Expand All @@ -113,7 +113,7 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
* to and before the specified yPos
* \since QGIS 2.3
*/
virtual double findNearbyPageBreak( double yPos ) { return yPos; }
virtual double findNearbyPageBreak( double yPos );

/** Removes a frame from the multiframe. This method automatically removes the frame from the
* composition.
Expand Down
20 changes: 20 additions & 0 deletions src/core/effects/qgsshadoweffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,21 @@ QgsDropShadowEffect::QgsDropShadowEffect()

}

QString QgsDropShadowEffect::type() const
{
return QStringLiteral( "dropShadow" );
}

QgsDropShadowEffect *QgsDropShadowEffect::clone() const
{
return new QgsDropShadowEffect( *this );
}

bool QgsDropShadowEffect::exteriorShadow() const
{
return true;
}


//
// QgsInnerShadowEffect
Expand All @@ -191,7 +201,17 @@ QgsInnerShadowEffect::QgsInnerShadowEffect()

}

QString QgsInnerShadowEffect::type() const
{
return QStringLiteral( "innerShadow" );
}

QgsInnerShadowEffect *QgsInnerShadowEffect::clone() const
{
return new QgsInnerShadowEffect( *this );
}

bool QgsInnerShadowEffect::exteriorShadow() const
{
return false;
}
8 changes: 4 additions & 4 deletions src/core/effects/qgsshadoweffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ class CORE_EXPORT QgsDropShadowEffect : public QgsShadowEffect

QgsDropShadowEffect();

virtual QString type() const override { return QStringLiteral( "dropShadow" ); }
virtual QString type() const override;
virtual QgsDropShadowEffect *clone() const override;

protected:

virtual bool exteriorShadow() const override { return true; }
virtual bool exteriorShadow() const override;

};

Expand All @@ -228,12 +228,12 @@ class CORE_EXPORT QgsInnerShadowEffect : public QgsShadowEffect

QgsInnerShadowEffect();

virtual QString type() const override { return QStringLiteral( "innerShadow" ); }
virtual QString type() const override;
virtual QgsInnerShadowEffect *clone() const override;

protected:

virtual bool exteriorShadow() const override { return false; }
virtual bool exteriorShadow() const override;

};

Expand Down
29 changes: 29 additions & 0 deletions src/core/geometry/qgsabstractgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ QgsRectangle QgsAbstractGeometry::calculateBoundingBox() const
return QgsRectangle( xmin, ymin, xmax, ymax );
}

void QgsAbstractGeometry::clearCache() const
{
}

int QgsAbstractGeometry::nCoordinates() const
{
int nCoords = 0;
Expand All @@ -137,6 +141,21 @@ int QgsAbstractGeometry::nCoordinates() const
return nCoords;
}

double QgsAbstractGeometry::length() const
{
return 0.0;
}

double QgsAbstractGeometry::perimeter() const
{
return 0.0;
}

double QgsAbstractGeometry::area() const
{
return 0.0;
}

QString QgsAbstractGeometry::wktTypeStr() const
{
QString wkt = geometryType();
Expand Down Expand Up @@ -237,6 +256,11 @@ bool QgsAbstractGeometry::isEmpty() const
return !nextVertex( vId, vertex );
}

bool QgsAbstractGeometry::hasCurvedSegments() const
{
return false;
}


QgsAbstractGeometry *QgsAbstractGeometry::segmentize( double tolerance, SegmentationToleranceType toleranceType ) const
{
Expand All @@ -245,3 +269,8 @@ QgsAbstractGeometry *QgsAbstractGeometry::segmentize( double tolerance, Segmenta
return clone();
}

QgsAbstractGeometry *QgsAbstractGeometry::toCurveType() const
{
return 0;
}

12 changes: 6 additions & 6 deletions src/core/geometry/qgsabstractgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,19 @@ class CORE_EXPORT QgsAbstractGeometry
* \see area()
* \see perimeter()
*/
virtual double length() const { return 0.0; }
virtual double length() const;

/** Returns the perimeter of the geometry.
* \see area()
* \see length()
*/
virtual double perimeter() const { return 0.0; }
virtual double perimeter() const;

/** Returns the area of the geometry.
* \see length()
* \see perimeter()
*/
virtual double area() const { return 0.0; }
virtual double area() const;

//! Returns the centroid of the geometry
virtual QgsPointV2 centroid() const;
Expand All @@ -329,7 +329,7 @@ class CORE_EXPORT QgsAbstractGeometry

/** Returns true if the geometry contains curved segments
*/
virtual bool hasCurvedSegments() const { return false; }
virtual bool hasCurvedSegments() const;

/** Returns a version of the geometry without curves. Caller takes ownership of
* the returned geometry.
Expand All @@ -342,7 +342,7 @@ class CORE_EXPORT QgsAbstractGeometry
E.g. QgsLineString -> QgsCompoundCurve, QgsPolygonV2 -> QgsCurvePolygon,
QgsMultiLineString -> QgsMultiCurve, QgsMultiPolygonV2 -> QgsMultiSurface
\returns the converted geometry. Caller takes ownership*/
virtual QgsAbstractGeometry *toCurveType() const SIP_FACTORY { return 0; }
virtual QgsAbstractGeometry *toCurveType() const SIP_FACTORY;

/** Returns approximate angle at a vertex. This is usually the average angle between adjacent
* segments, and can be pictured as the orientation of a line following the curvature of the
Expand Down Expand Up @@ -422,7 +422,7 @@ class CORE_EXPORT QgsAbstractGeometry

/** Clears any cached parameters associated with the geometry, e.g., bounding boxes
*/
virtual void clearCache() const {}
virtual void clearCache() const;

};

Expand Down
25 changes: 25 additions & 0 deletions src/core/geometry/qgscurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ QgsCurve *QgsCurve::segmentize( double tolerance, SegmentationToleranceType tole
return curveToLine( tolerance, toleranceType );
}

int QgsCurve::vertexCount( int part, int ring ) const
{
Q_UNUSED( part );
Q_UNUSED( ring );
return numPoints();
}

int QgsCurve::ringCount( int part ) const
{
Q_UNUSED( part );
return numPoints() > 0 ? 1 : 0;
}

int QgsCurve::partCount() const
{
return numPoints() > 0 ? 1 : 0;
}

QgsPointV2 QgsCurve::vertexAt( QgsVertexId id ) const
{
QgsPointV2 v;
Expand Down Expand Up @@ -126,3 +144,10 @@ QPolygonF QgsCurve::asQPolygonF() const
return points;
}

void QgsCurve::clearCache() const
{
mBoundingBox = QgsRectangle();
mCoordinateSequence.clear();
QgsAbstractGeometry::clearCache();
}

8 changes: 4 additions & 4 deletions src/core/geometry/qgscurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
* \param toleranceType maximum segmentation angle or maximum difference between approximation and curve*/
QgsCurve *segmentize( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override SIP_FACTORY;

virtual int vertexCount( int part = 0, int ring = 0 ) const override { Q_UNUSED( part ); Q_UNUSED( ring ); return numPoints(); }
virtual int ringCount( int part = 0 ) const override { Q_UNUSED( part ); return numPoints() > 0 ? 1 : 0; }
virtual int partCount() const override { return numPoints() > 0 ? 1 : 0; }
virtual int vertexCount( int part = 0, int ring = 0 ) const override;
virtual int ringCount( int part = 0 ) const override;
virtual int partCount() const override;
virtual QgsPointV2 vertexAt( QgsVertexId id ) const override;

virtual QgsRectangle boundingBox() const override;
Expand All @@ -137,7 +137,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry

protected:

virtual void clearCache() const override { mBoundingBox = QgsRectangle(); mCoordinateSequence.clear(); QgsAbstractGeometry::clearCache(); }
virtual void clearCache() const override;

private:

Expand Down
Loading

0 comments on commit ac50214

Please sign in to comment.