Skip to content

Commit 57c5a6f

Browse files
committedJan 25, 2021
make virtual methods protected so they can be overidden in Python
1 parent df17603 commit 57c5a6f

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed
 

‎python/gui/auto_generated/qgsabstractrelationeditorwidget.sip.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,34 +217,38 @@ Unlinks the features with ``fids``
217217
%End
218218

219219

220-
private:
221220
virtual void updateUi();
222221
%Docstring
223222
A hook called every time the state of the relation editor widget has changed via calling its `set*` methods or slots,
224223
e.g. changed relation, added feature, etc.
225224
Should be used to refresh the UI regarding the new data.
226225
Check QgsRealationEditorWidget as an example.
227226
%End
227+
228228
virtual void setTitle( const QString &title );
229229
%Docstring
230230
Sets the title of the widget, if it is wrapped within a :py:class:`QgsCollapsibleGroupBox`
231231
Check QgsRealationEditorWidget as an example.
232232
%End
233+
233234
virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
234235
%Docstring
235236
A hook called right before :py:func:`~QgsAbstractRelationEditorWidget.setRelationFeature` is executed. Used to update the UI once setting the relation feature is done.
236237
Check QgsRealationEditorWidget as an example.
237238
%End
239+
238240
virtual void afterSetRelationFeature();
239241
%Docstring
240242
A hook called right after :py:func:`~QgsAbstractRelationEditorWidget.setRelationFeature` is executed, but before :py:func:`~QgsAbstractRelationEditorWidget.updateUi` is called. Used to update the UI once setting the relation feature is done.
241243
Check QgsRealationEditorWidget as an example.
242244
%End
245+
243246
virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation );
244247
%Docstring
245248
A hook called right before :py:func:`~QgsAbstractRelationEditorWidget.setRelations` is executed. Used to manipulate UI once setting the relations is done.
246249
Check QgsRealationEditorWidget as an example.
247250
%End
251+
248252
virtual void afterSetRelations();
249253
%Docstring
250254
A hook called right after :py:func:`~QgsAbstractRelationEditorWidget.setRelations` is executed, but before :py:func:`~QgsAbstractRelationEditorWidget.updateUi` is called. Used to update the UI once setting the relations is done.

‎python/gui/auto_generated/qgsrelationeditorwidget.sip.in

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,17 @@ Sets the title of the root groupbox
145145
virtual void parentFormValueChanged( const QString &attribute, const QVariant &newValue );
146146

147147

148-
private:
148+
protected:
149149
virtual void updateUi();
150+
virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
151+
152+
virtual void afterSetRelationFeature();
153+
154+
virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation );
155+
156+
virtual void afterSetRelations();
157+
158+
150159
};
151160

152161

‎src/gui/qgsabstractrelationeditorwidget.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,46 +244,45 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
244244
*/
245245
void unlinkFeatures( const QgsFeatureIds &fids );
246246

247-
248-
private:
247+
// Following virtual methods need to be protected so they can be overridden in bindings
249248

250249
/**
251250
* A hook called every time the state of the relation editor widget has changed via calling its `set*` methods or slots,
252251
* e.g. changed relation, added feature, etc.
253252
* Should be used to refresh the UI regarding the new data.
254253
* Check QgsRealationEditorWidget as an example.
255254
*/
256-
virtual void updateUi() SIP_FORCE;
255+
virtual void updateUi();
257256

258257
/**
259258
* Sets the title of the widget, if it is wrapped within a QgsCollapsibleGroupBox
260259
* Check QgsRealationEditorWidget as an example.
261260
*/
262-
virtual void setTitle( const QString &title ) SIP_FORCE;
261+
virtual void setTitle( const QString &title );
263262

264263
/**
265264
* A hook called right before setRelationFeature() is executed. Used to update the UI once setting the relation feature is done.
266265
* Check QgsRealationEditorWidget as an example.
267266
*/
268-
virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature ) SIP_FORCE;
267+
virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
269268

270269
/**
271270
* A hook called right after setRelationFeature() is executed, but before updateUi() is called. Used to update the UI once setting the relation feature is done.
272271
* Check QgsRealationEditorWidget as an example.
273272
*/
274-
virtual void afterSetRelationFeature() SIP_FORCE;
273+
virtual void afterSetRelationFeature();
275274

276275
/**
277276
* A hook called right before setRelations() is executed. Used to manipulate UI once setting the relations is done.
278277
* Check QgsRealationEditorWidget as an example.
279278
*/
280-
virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation ) SIP_FORCE;
279+
virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation );
281280

282281
/**
283282
* A hook called right after setRelations() is executed, but before updateUi() is called. Used to update the UI once setting the relations is done.
284283
* Check QgsRealationEditorWidget as an example.
285284
*/
286-
virtual void afterSetRelations() SIP_FORCE;
285+
virtual void afterSetRelations();
287286
};
288287

289288

‎src/gui/qgsrelationeditorwidget.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
193193
public slots:
194194
void parentFormValueChanged( const QString &attribute, const QVariant &newValue ) override;
195195

196+
protected:
197+
virtual void updateUi() override;
198+
void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature ) override;
199+
void afterSetRelationFeature() override;
200+
void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation ) override;
201+
void afterSetRelations() override;
202+
196203
private slots:
197204
void setViewMode( int mode ) {setViewMode( static_cast<QgsDualView::ViewMode>( mode ) );}
198205
void updateButtons();
@@ -206,7 +213,6 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
206213
void onDigitizingCompleted( const QgsFeature &feature );
207214

208215
private:
209-
virtual void updateUi() override SIP_FORCE;
210216
void initDualView( QgsVectorLayer *layer, const QgsFeatureRequest &request );
211217
void setMapTool( QgsMapTool *mapTool );
212218
void unsetMapTool();
@@ -234,11 +240,6 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
234240

235241
Buttons mButtonsVisibility = Button::AllButtons;
236242
bool mVisible = true;
237-
238-
void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature ) override;
239-
void afterSetRelationFeature() override;
240-
void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation ) override;
241-
void afterSetRelations() override;
242243
};
243244

244245

0 commit comments

Comments
 (0)
Please sign in to comment.