Skip to content

Commit 87a6708

Browse files
committed
[sipify] Always add virtual keyword for overridden methods
sip often requires the virtual keyword to be present, or it chokes on covariant return types in overridden methods
1 parent 1805a70 commit 87a6708

File tree

14 files changed

+71
-67
lines changed

14 files changed

+71
-67
lines changed

python/core/annotations/qgshtmlannotation.sip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class QgsHtmlAnnotation: QgsAnnotation
3131

3232
~QgsHtmlAnnotation();
3333

34-
QSizeF minimumFrameSize() const;
34+
virtual QSizeF minimumFrameSize() const;
3535

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

52-
void setAssociatedFeature( const QgsFeature &feature );
52+
virtual void setAssociatedFeature( const QgsFeature &feature );
5353

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

6060
protected:
6161

62-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
62+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
6363

6464
};
6565

python/core/annotations/qgssvgannotation.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class QgsSvgAnnotation: QgsAnnotation
5050

5151
protected:
5252

53-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
53+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
5454

5555
};
5656

python/core/annotations/qgstextannotation.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class QgsTextAnnotation: QgsAnnotation
5252

5353
protected:
5454

55-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
55+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
5656

5757
};
5858

python/core/layertree/qgslayertreegroup.sip

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class QgsLayerTreeGroup : QgsLayerTreeNode
3030
%End
3131

3232

33-
QString name() const;
33+
virtual QString name() const;
3434
%Docstring
3535
Returns the group's name.
3636
:rtype: str
3737
%End
3838

39-
void setName( const QString &n );
39+
virtual void setName( const QString &n );
4040
%Docstring
4141
Sets the group's name.
4242
%End
@@ -213,8 +213,13 @@ class QgsLayerTreeGroup : QgsLayerTreeNode
213213

214214

215215

216+
216217
private:
218+
217219
QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
220+
%Docstring
221+
Copies are not allowed
222+
%End
218223
};
219224

220225

python/core/layertree/qgslayertreelayer.sip

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QgsLayerTreeLayer : QgsLayerTreeNode
3535

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

4141
QString layerId() const;
@@ -48,14 +48,14 @@ class QgsLayerTreeLayer : QgsLayerTreeNode
4848
:rtype: QgsMapLayer
4949
%End
5050

51-
QString name() const;
51+
virtual QString name() const;
5252
%Docstring
5353
Returns the layer's name.
5454
.. versionadded:: 3.0
5555
:rtype: str
5656
%End
5757

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

8181
virtual QString dump() const;
82-
%Docstring
83-
:rtype: str
84-
%End
8582

8683
virtual QgsLayerTreeLayer *clone() const /Factory/;
87-
%Docstring
88-
:rtype: QgsLayerTreeLayer
89-
%End
9084

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

113107

114108
private:
109+
115110
QgsLayerTreeLayer( const QgsLayerTreeLayer &other );
111+
%Docstring
112+
Copies are not allowed
113+
%End
116114
};
117115

118116

python/core/qgscolorramp.sip

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class QgsLimitedRandomColorRamp : QgsColorRamp
302302
virtual QString type() const;
303303
virtual QgsLimitedRandomColorRamp *clone() const /Factory/;
304304
virtual QgsStringMap properties() const;
305-
int count() const;
305+
virtual int count() const;
306306

307307
static QList<QColor> randomColors( int count,
308308
int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN,
@@ -420,11 +420,11 @@ class QgsRandomColorRamp: QgsColorRamp
420420
public:
421421
QgsRandomColorRamp();
422422

423-
int count() const;
423+
virtual int count() const;
424424

425-
double value( int index ) const;
425+
virtual double value( int index ) const;
426426

427-
QColor color( double value ) const;
427+
virtual QColor color( double value ) const;
428428

429429
virtual void setTotalColorCount( const int colorCount );
430430
%Docstring
@@ -435,7 +435,7 @@ class QgsRandomColorRamp: QgsColorRamp
435435
.. versionadded:: 2.5
436436
%End
437437

438-
QString type() const;
438+
virtual QString type() const;
439439

440440
virtual QgsRandomColorRamp *clone() const /Factory/;
441441

@@ -483,7 +483,7 @@ class QgsPresetSchemeColorRamp : QgsColorRamp, QgsColorScheme
483483
:rtype: QgsColorRamp
484484
%End
485485

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

501501
virtual double value( int index ) const;
502-
%Docstring
503-
QgsColorRamp interface
504-
:rtype: float
505-
%End
506502
virtual QColor color( double value ) const;
507503
virtual QString type() const;
508504
virtual void invert();
509505
virtual QgsPresetSchemeColorRamp *clone() const /Factory/;
510506
virtual QgsStringMap properties() const;
511-
int count() const;
507+
virtual int count() const;
512508

513-
QString schemeName() const;
514-
%Docstring
515-
QgsColorScheme interface
516-
:rtype: str
517-
%End
518-
QgsNamedColorList fetchColors( const QString &context = QString(),
519-
const QColor &baseColor = QColor() );
520-
bool isEditable() const;
509+
virtual QString schemeName() const;
510+
virtual QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() );
511+
virtual bool isEditable() const;
521512

522513
};
523514

python/core/qgsvectorlayer.sip

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ Return the provider type for this layer
772772
:rtype: str
773773
%End
774774

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

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

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

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

824-
bool readSld( const QDomNode &node, QString &errorMessage );
824+
virtual bool readSld( const QDomNode &node, QString &errorMessage );
825825

826826
long featureCount( const QString &legendKey ) const;
827827
%Docstring
@@ -1099,7 +1099,7 @@ Synchronises with changes in the datasource
10991099
:rtype: QgsMapLayerRenderer
11001100
%End
11011101

1102-
QgsRectangle extent() const;
1102+
virtual QgsRectangle extent() const;
11031103
%Docstring
11041104
Return the extent of the layer
11051105
:rtype: QgsRectangle
@@ -1627,7 +1627,7 @@ Returns the current transparency for the vector layer
16271627
:rtype: int
16281628
%End
16291629

1630-
QString htmlMetadata() const;
1630+
virtual QString htmlMetadata() const;
16311631

16321632

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

1698-
QgsExpressionContext createExpressionContext() const;
1698+
virtual QgsExpressionContext createExpressionContext() const;
16991699

17001700
QgsEditFormConfig editFormConfig() const;
17011701
%Docstring
@@ -2041,7 +2041,7 @@ Signal emitted when setLayerTransparency() is called
20412041

20422042

20432043
protected:
2044-
void setExtent( const QgsRectangle &rect );
2044+
virtual void setExtent( const QgsRectangle &rect );
20452045
%Docstring
20462046
Set the extent
20472047
%End

python/gui/qgscolorbutton.sip

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,48 +346,48 @@ class QgsColorButton : QToolButton
346346

347347
protected:
348348

349-
bool event( QEvent *e );
350-
void changeEvent( QEvent *e );
351-
void showEvent( QShowEvent *e );
352-
void resizeEvent( QResizeEvent *event );
349+
virtual bool event( QEvent *e );
350+
virtual void changeEvent( QEvent *e );
351+
virtual void showEvent( QShowEvent *e );
352+
virtual void resizeEvent( QResizeEvent *event );
353353

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

360-
void mousePressEvent( QMouseEvent *e );
360+
virtual void mousePressEvent( QMouseEvent *e );
361361
%Docstring
362362
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors
363363
%End
364364

365-
void mouseMoveEvent( QMouseEvent *e );
365+
virtual void mouseMoveEvent( QMouseEvent *e );
366366
%Docstring
367367
Reimplemented to allow dragging colors from button
368368
%End
369369

370-
void mouseReleaseEvent( QMouseEvent *e );
370+
virtual void mouseReleaseEvent( QMouseEvent *e );
371371
%Docstring
372372
Reimplemented to allow color picking
373373
%End
374374

375-
void keyPressEvent( QKeyEvent *e );
375+
virtual void keyPressEvent( QKeyEvent *e );
376376
%Docstring
377377
Reimplemented to allow canceling color pick via keypress, and sample via space bar press
378378
%End
379379

380-
void dragEnterEvent( QDragEnterEvent *e );
380+
virtual void dragEnterEvent( QDragEnterEvent *e );
381381
%Docstring
382382
Reimplemented to accept dragged colors
383383
%End
384384

385-
void dragLeaveEvent( QDragLeaveEvent *e );
385+
virtual void dragLeaveEvent( QDragLeaveEvent *e );
386386
%Docstring
387387
Reimplemented to reset button appearance after drag leave
388388
%End
389389

390-
void dropEvent( QDropEvent *e );
390+
virtual void dropEvent( QDropEvent *e );
391391
%Docstring
392392
Reimplemented to accept dropped colors
393393
%End

python/gui/qgscolorrampbutton.sip

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ class QgsColorRampButton : QToolButton
257257

258258
protected:
259259

260-
bool event( QEvent *e );
261-
void changeEvent( QEvent *e );
262-
void showEvent( QShowEvent *e );
263-
void resizeEvent( QResizeEvent *event );
260+
virtual bool event( QEvent *e );
261+
virtual void changeEvent( QEvent *e );
262+
virtual void showEvent( QShowEvent *e );
263+
virtual void resizeEvent( QResizeEvent *event );
264264

265-
void mousePressEvent( QMouseEvent *e );
265+
virtual void mousePressEvent( QMouseEvent *e );
266266
%Docstring
267267
Reimplemented to detect right mouse button clicks on the color ramp button
268268
%End

python/gui/qgsmessagelogviewer.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class QgsMessageLogViewer: QDialog
3535
%End
3636

3737
protected:
38-
void closeEvent( QCloseEvent *e );
39-
void reject();
38+
virtual void closeEvent( QCloseEvent *e );
39+
virtual void reject();
4040

4141
};
4242

0 commit comments

Comments
 (0)