Skip to content

Commit

Permalink
[sipify] Always add virtual keyword for overridden methods
Browse files Browse the repository at this point in the history
sip often requires the virtual keyword to be present, or
it chokes on covariant return types in overridden methods
  • Loading branch information
nyalldawson committed Apr 18, 2017
1 parent 1805a70 commit 87a6708
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 67 deletions.
6 changes: 3 additions & 3 deletions python/core/annotations/qgshtmlannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class QgsHtmlAnnotation: QgsAnnotation

~QgsHtmlAnnotation();

QSizeF minimumFrameSize() const;
virtual QSizeF minimumFrameSize() const;

void setSourceFile( const QString &htmlFile );
%Docstring
Expand All @@ -49,7 +49,7 @@ class QgsHtmlAnnotation: QgsAnnotation
virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );

void setAssociatedFeature( const QgsFeature &feature );
virtual void setAssociatedFeature( const QgsFeature &feature );

static QgsHtmlAnnotation *create() /Factory/;
%Docstring
Expand All @@ -59,7 +59,7 @@ class QgsHtmlAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

Expand Down
2 changes: 1 addition & 1 deletion python/core/annotations/qgssvgannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class QgsSvgAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

Expand Down
2 changes: 1 addition & 1 deletion python/core/annotations/qgstextannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class QgsTextAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

Expand Down
9 changes: 7 additions & 2 deletions python/core/layertree/qgslayertreegroup.sip
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class QgsLayerTreeGroup : QgsLayerTreeNode
%End


QString name() const;
virtual QString name() const;
%Docstring
Returns the group's name.
:rtype: str
%End

void setName( const QString &n );
virtual void setName( const QString &n );
%Docstring
Sets the group's name.
%End
Expand Down Expand Up @@ -213,8 +213,13 @@ class QgsLayerTreeGroup : QgsLayerTreeNode




private:

QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
%Docstring
Copies are not allowed
%End
};


Expand Down
16 changes: 7 additions & 9 deletions python/core/layertree/qgslayertreelayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class QgsLayerTreeLayer : QgsLayerTreeNode

explicit QgsLayerTreeLayer( const QString &layerId, const QString &name = QString(), const QString &source = QString(), const QString &provider = QString() );
%Docstring
Constructor for QgsLayerTreeLayer using weak references to layer ID, name, public source, and provider key.
Constructor for QgsLayerTreeLayer using weak references to layer ID, ``name``, public ``source``, and ``provider`` key.
%End

QString layerId() const;
Expand All @@ -48,14 +48,14 @@ class QgsLayerTreeLayer : QgsLayerTreeNode
:rtype: QgsMapLayer
%End

QString name() const;
virtual QString name() const;
%Docstring
Returns the layer's name.
.. versionadded:: 3.0
:rtype: str
%End

void setName( const QString &n );
virtual void setName( const QString &n );
%Docstring
Sets the layer's name.
.. versionadded:: 3.0
Expand All @@ -79,14 +79,8 @@ class QgsLayerTreeLayer : QgsLayerTreeNode
virtual void writeXml( QDomElement &parentElement );

virtual QString dump() const;
%Docstring
:rtype: str
%End

virtual QgsLayerTreeLayer *clone() const /Factory/;
%Docstring
:rtype: QgsLayerTreeLayer
%End

virtual void resolveReferences( const QgsProject *project, bool looseMatching = false );
%Docstring
Expand All @@ -112,7 +106,11 @@ class QgsLayerTreeLayer : QgsLayerTreeNode


private:

QgsLayerTreeLayer( const QgsLayerTreeLayer &other );
%Docstring
Copies are not allowed
%End
};


Expand Down
29 changes: 10 additions & 19 deletions python/core/qgscolorramp.sip
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class QgsLimitedRandomColorRamp : QgsColorRamp
virtual QString type() const;
virtual QgsLimitedRandomColorRamp *clone() const /Factory/;
virtual QgsStringMap properties() const;
int count() const;
virtual int count() const;

static QList<QColor> randomColors( int count,
int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN,
Expand Down Expand Up @@ -420,11 +420,11 @@ class QgsRandomColorRamp: QgsColorRamp
public:
QgsRandomColorRamp();

int count() const;
virtual int count() const;

double value( int index ) const;
virtual double value( int index ) const;

QColor color( double value ) const;
virtual QColor color( double value ) const;

virtual void setTotalColorCount( const int colorCount );
%Docstring
Expand All @@ -435,7 +435,7 @@ class QgsRandomColorRamp: QgsColorRamp
.. versionadded:: 2.5
%End

QString type() const;
virtual QString type() const;

virtual QgsRandomColorRamp *clone() const /Factory/;

Expand Down Expand Up @@ -483,7 +483,7 @@ class QgsPresetSchemeColorRamp : QgsColorRamp, QgsColorScheme
:rtype: QgsColorRamp
%End

bool setColors( const QgsNamedColorList &colors, const QString & = QString(), const QColor & = QColor() );
virtual bool setColors( const QgsNamedColorList &colors, const QString & = QString(), const QColor & = QColor() );
%Docstring
Sets the list of colors used by the ramp.
\param colors list of colors
Expand All @@ -499,25 +499,16 @@ class QgsPresetSchemeColorRamp : QgsColorRamp, QgsColorScheme
%End

virtual double value( int index ) const;
%Docstring
QgsColorRamp interface
:rtype: float
%End
virtual QColor color( double value ) const;
virtual QString type() const;
virtual void invert();
virtual QgsPresetSchemeColorRamp *clone() const /Factory/;
virtual QgsStringMap properties() const;
int count() const;
virtual int count() const;

QString schemeName() const;
%Docstring
QgsColorScheme interface
:rtype: str
%End
QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() );
bool isEditable() const;
virtual QString schemeName() const;
virtual QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() );
virtual bool isEditable() const;

};

Expand Down
18 changes: 9 additions & 9 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ Return the provider type for this layer
:rtype: str
%End

bool readSymbology( const QDomNode &layerNode, QString &errorMessage );
virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage );
%Docstring
Read the symbology for the current layer from the Dom node supplied.
\param layerNode node that will contain the symbology definition for this layer.
Expand All @@ -781,7 +781,7 @@ Return the provider type for this layer
:rtype: bool
%End

bool readStyle( const QDomNode &node, QString &errorMessage );
virtual bool readStyle( const QDomNode &node, QString &errorMessage );
%Docstring
Read the style for the current layer from the Dom node supplied.
\param node node that will contain the style definition for this layer.
Expand All @@ -790,7 +790,7 @@ Return the provider type for this layer
:rtype: bool
%End

bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage ) const;
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage ) const;
%Docstring
Write the symbology for the layer into the docment provided.
\param node the node that will have the style element added to it.
Expand All @@ -800,7 +800,7 @@ Return the provider type for this layer
:rtype: bool
%End

bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage ) const;
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage ) const;
%Docstring
Write just the style information for the layer into the document
\param node the node that will have the style element added to it.
Expand All @@ -821,7 +821,7 @@ Return the provider type for this layer
:rtype: bool
%End

bool readSld( const QDomNode &node, QString &errorMessage );
virtual bool readSld( const QDomNode &node, QString &errorMessage );

long featureCount( const QString &legendKey ) const;
%Docstring
Expand Down Expand Up @@ -1099,7 +1099,7 @@ Synchronises with changes in the datasource
:rtype: QgsMapLayerRenderer
%End

QgsRectangle extent() const;
virtual QgsRectangle extent() const;
%Docstring
Return the extent of the layer
:rtype: QgsRectangle
Expand Down Expand Up @@ -1627,7 +1627,7 @@ Returns the current transparency for the vector layer
:rtype: int
%End

QString htmlMetadata() const;
virtual QString htmlMetadata() const;


void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
Expand Down Expand Up @@ -1695,7 +1695,7 @@ Returns the current transparency for the vector layer
.. versionadded:: 3.0
%End

QgsExpressionContext createExpressionContext() const;
virtual QgsExpressionContext createExpressionContext() const;

QgsEditFormConfig editFormConfig() const;
%Docstring
Expand Down Expand Up @@ -2041,7 +2041,7 @@ Signal emitted when setLayerTransparency() is called


protected:
void setExtent( const QgsRectangle &rect );
virtual void setExtent( const QgsRectangle &rect );
%Docstring
Set the extent
%End
Expand Down
22 changes: 11 additions & 11 deletions python/gui/qgscolorbutton.sip
Original file line number Diff line number Diff line change
Expand Up @@ -346,48 +346,48 @@ class QgsColorButton : QToolButton

protected:

bool event( QEvent *e );
void changeEvent( QEvent *e );
void showEvent( QShowEvent *e );
void resizeEvent( QResizeEvent *event );
virtual bool event( QEvent *e );
virtual void changeEvent( QEvent *e );
virtual void showEvent( QShowEvent *e );
virtual void resizeEvent( QResizeEvent *event );

static const QPixmap &transparentBackground();
%Docstring
Returns a checkboard pattern pixmap for use as a background to transparent colors
:rtype: QPixmap
%End

void mousePressEvent( QMouseEvent *e );
virtual void mousePressEvent( QMouseEvent *e );
%Docstring
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors
%End

void mouseMoveEvent( QMouseEvent *e );
virtual void mouseMoveEvent( QMouseEvent *e );
%Docstring
Reimplemented to allow dragging colors from button
%End

void mouseReleaseEvent( QMouseEvent *e );
virtual void mouseReleaseEvent( QMouseEvent *e );
%Docstring
Reimplemented to allow color picking
%End

void keyPressEvent( QKeyEvent *e );
virtual void keyPressEvent( QKeyEvent *e );
%Docstring
Reimplemented to allow canceling color pick via keypress, and sample via space bar press
%End

void dragEnterEvent( QDragEnterEvent *e );
virtual void dragEnterEvent( QDragEnterEvent *e );
%Docstring
Reimplemented to accept dragged colors
%End

void dragLeaveEvent( QDragLeaveEvent *e );
virtual void dragLeaveEvent( QDragLeaveEvent *e );
%Docstring
Reimplemented to reset button appearance after drag leave
%End

void dropEvent( QDropEvent *e );
virtual void dropEvent( QDropEvent *e );
%Docstring
Reimplemented to accept dropped colors
%End
Expand Down
10 changes: 5 additions & 5 deletions python/gui/qgscolorrampbutton.sip
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ class QgsColorRampButton : QToolButton

protected:

bool event( QEvent *e );
void changeEvent( QEvent *e );
void showEvent( QShowEvent *e );
void resizeEvent( QResizeEvent *event );
virtual bool event( QEvent *e );
virtual void changeEvent( QEvent *e );
virtual void showEvent( QShowEvent *e );
virtual void resizeEvent( QResizeEvent *event );

void mousePressEvent( QMouseEvent *e );
virtual void mousePressEvent( QMouseEvent *e );
%Docstring
Reimplemented to detect right mouse button clicks on the color ramp button
%End
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsmessagelogviewer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class QgsMessageLogViewer: QDialog
%End

protected:
void closeEvent( QCloseEvent *e );
void reject();
virtual void closeEvent( QCloseEvent *e );
virtual void reject();

};

Expand Down
8 changes: 4 additions & 4 deletions python/gui/symbology-ng/characterwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CharacterWidget : QWidget
Constructor for CharacterWidget.
%End

QSize sizeHint() const;
virtual QSize sizeHint() const;

int columns() const;
%Docstring
Expand Down Expand Up @@ -101,9 +101,9 @@ class CharacterWidget : QWidget
%End

protected:
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void paintEvent( QPaintEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mousePressEvent( QMouseEvent *event );
virtual void paintEvent( QPaintEvent *event );

};

Expand Down
Loading

0 comments on commit 87a6708

Please sign in to comment.