Skip to content

Commit

Permalink
Revert "Use /TransferBack/ instead of /Factory/ in layout registry fa…
Browse files Browse the repository at this point in the history
…ctory methods"

This reverts commit da59316.
  • Loading branch information
nyalldawson committed Dec 21, 2020
1 parent da59316 commit c1913dc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 117 deletions.
11 changes: 4 additions & 7 deletions python/core/auto_generated/layout/qgslayoutitemregistry.sip.in
Expand Up @@ -58,8 +58,7 @@ Returns a translated, user visible name for plurals of the layout item class (e.
.. versionadded:: 3.10
%End


virtual QgsLayoutItem *createItem( QgsLayout *layout ) = 0 /TransferBack/;
virtual QgsLayoutItem *createItem( QgsLayout *layout ) = 0 /Factory/;
%Docstring
Creates a layout item of this class for a specified ``layout``.
%End
Expand Down Expand Up @@ -121,8 +120,7 @@ Returns an icon representing the layout multiframe type.
Returns a translated, user visible name for the layout multiframe class.
%End


virtual QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) = 0 /TransferBack/;
virtual QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) = 0 /Factory/;
%Docstring
Creates a layout multiframe of this class for a specified ``layout``.
%End
Expand Down Expand Up @@ -235,7 +233,6 @@ a corresponding type was not found in the registry.
.. seealso:: :py:func:`itemMetadata`
%End


bool addLayoutItemType( QgsLayoutItemAbstractMetadata *metadata /Transfer/ );
%Docstring
Registers a new layout item type. Takes ownership of the metadata instance.
Expand All @@ -250,14 +247,14 @@ Registers a new layout multiframe type. Takes ownership of the metadata instance
.. seealso:: :py:func:`addLayoutItemType`
%End

QgsLayoutItem *createItem( int type, QgsLayout *layout ) const /TransferBack/;
QgsLayoutItem *createItem( int type, QgsLayout *layout ) const /Factory/;
%Docstring
Creates a new instance of a layout item given the item ``type``, and target ``layout``.

.. seealso:: :py:func:`createMultiFrame`
%End

QgsLayoutMultiFrame *createMultiFrame( int type, QgsLayout *layout ) const /TransferBack/;
QgsLayoutMultiFrame *createMultiFrame( int type, QgsLayout *layout ) const /Factory/;
%Docstring
Creates a new instance of a layout multiframe given the multiframe ``type``, and target ``layout``.

Expand Down
15 changes: 6 additions & 9 deletions python/gui/auto_generated/layout/qgslayoutitemguiregistry.sip.in
Expand Up @@ -79,29 +79,28 @@ Returns a translated, user visible name identifying the corresponding layout ite
Returns an icon representing creation of the layout item type.
%End


virtual QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) /TransferBack/;
virtual QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) /Factory/;
%Docstring
Creates a configuration widget for an ``item`` of this type. Can return ``None`` if no configuration GUI is required.
%End

virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) /TransferBack/;
virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) /Factory/;
%Docstring
Creates a rubber band for use when creating layout items of this type. Can return ``None`` if no rubber band
should be created. The default behavior is to create a rectangular rubber band.

.. seealso:: :py:func:`createNodeRubberBand`
%End

virtual QAbstractGraphicsShapeItem *createNodeRubberBand( QgsLayoutView *view ) /TransferBack/;
virtual QAbstractGraphicsShapeItem *createNodeRubberBand( QgsLayoutView *view ) /Factory/;
%Docstring
Creates a rubber band for use when creating layout node based items of this type. Can return ``None`` if no rubber band
should be created. The default behavior is to return ``None``.

.. seealso:: :py:func:`createRubberBand`
%End

virtual QgsLayoutItem *createItem( QgsLayout *layout ) /TransferBack/;
virtual QgsLayoutItem *createItem( QgsLayout *layout ) /Factory/;
%Docstring
Creates an instance of the corresponding item type.
%End
Expand Down Expand Up @@ -213,8 +212,7 @@ Returns a reference to the item group with matching ``id``.
.. seealso:: :py:func:`addItemGroup`
%End


QgsLayoutItem *createItem( int metadataId, QgsLayout *layout ) const /TransferBack/;
QgsLayoutItem *createItem( int metadataId, QgsLayout *layout ) const /Factory/;
%Docstring
Creates a new instance of a layout item given the item metadata ``metadataId``, target ``layout``.
%End
Expand All @@ -227,8 +225,7 @@ This is only called for additions which result from GUI operations - i.e. it is
called for items added from templates.
%End


QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) const /TransferBack/;
QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) const /Factory/;
%Docstring
Creates a new instance of a layout item configuration widget for the specified ``item``.
%End
Expand Down
53 changes: 4 additions & 49 deletions src/core/layout/qgslayoutitemregistry.h
Expand Up @@ -77,25 +77,10 @@ class CORE_EXPORT QgsLayoutItemAbstractMetadata
*/
QString visiblePluralName() const { return mVisibleNamePlural; }

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Creates a layout item of this class for a specified \a layout.
*/
virtual QgsLayoutItem *createItem( QgsLayout *layout ) = 0 SIP_TRANSFERBACK;
virtual QgsLayoutItem *createItem( QgsLayout *layout ) = 0 SIP_FACTORY;

/**
* Resolve paths in the item's \a properties (if there are any paths).
Expand Down Expand Up @@ -216,25 +201,10 @@ class CORE_EXPORT QgsLayoutMultiFrameAbstractMetadata
*/
QString visibleName() const { return mVisibleName; }

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Creates a layout multiframe of this class for a specified \a layout.
*/
virtual QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) = 0 SIP_TRANSFERBACK;
virtual QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) = 0 SIP_FACTORY;

/**
* Resolve paths in the item's \a properties (if there are any paths).
Expand Down Expand Up @@ -409,21 +379,6 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
*/
QgsLayoutMultiFrameAbstractMetadata *multiFrameMetadata( int type ) const;

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Registers a new layout item type. Takes ownership of the metadata instance.
* \see addLayoutMultiFrameType()
Expand All @@ -440,13 +395,13 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
* Creates a new instance of a layout item given the item \a type, and target \a layout.
* \see createMultiFrame()
*/
QgsLayoutItem *createItem( int type, QgsLayout *layout ) const SIP_TRANSFERBACK;
QgsLayoutItem *createItem( int type, QgsLayout *layout ) const SIP_FACTORY;

/**
* Creates a new instance of a layout multiframe given the multiframe \a type, and target \a layout.
* \see createItem()
*/
QgsLayoutMultiFrame *createMultiFrame( int type, QgsLayout *layout ) const SIP_TRANSFERBACK;
QgsLayoutMultiFrame *createMultiFrame( int type, QgsLayout *layout ) const SIP_FACTORY;

/**
* Resolve paths in properties of a particular symbol layer.
Expand Down
2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitemundocommand.h
Expand Up @@ -70,7 +70,7 @@ class CORE_EXPORT QgsLayoutItemUndoCommand: public QgsAbstractLayoutUndoCommand
void saveState( QDomDocument &stateDoc ) const override;
void restoreState( QDomDocument &stateDoc ) override;

virtual QgsLayoutItem *recreateItem( int itemType, QgsLayout *layout );
virtual QgsLayoutItem *recreateItem( int itemType, QgsLayout *layout ) SIP_FACTORY;

private:

Expand Down
57 changes: 6 additions & 51 deletions src/gui/layout/qgslayoutitemguiregistry.h
Expand Up @@ -103,44 +103,29 @@ class GUI_EXPORT QgsLayoutItemAbstractGuiMetadata
*/
virtual QIcon creationIcon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ); }

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Creates a configuration widget for an \a item of this type. Can return NULLPTR if no configuration GUI is required.
*/
virtual QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) SIP_TRANSFERBACK { Q_UNUSED( item ) return nullptr; }
virtual QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) SIP_FACTORY { Q_UNUSED( item ) return nullptr; }

/**
* Creates a rubber band for use when creating layout items of this type. Can return NULLPTR if no rubber band
* should be created. The default behavior is to create a rectangular rubber band.
* \see createNodeRubberBand()
*/
virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) SIP_TRANSFERBACK;
virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) SIP_FACTORY;

/**
* Creates a rubber band for use when creating layout node based items of this type. Can return NULLPTR if no rubber band
* should be created. The default behavior is to return NULLPTR.
* \see createRubberBand()
*/
virtual QAbstractGraphicsShapeItem *createNodeRubberBand( QgsLayoutView *view ) SIP_TRANSFERBACK;
virtual QAbstractGraphicsShapeItem *createNodeRubberBand( QgsLayoutView *view ) SIP_FACTORY;

/**
* Creates an instance of the corresponding item type.
*/
virtual QgsLayoutItem *createItem( QgsLayout *layout ) SIP_TRANSFERBACK;
virtual QgsLayoutItem *createItem( QgsLayout *layout ) SIP_FACTORY;

/**
* Called when a newly created item of the associated type has been added to a layout.
Expand Down Expand Up @@ -392,25 +377,10 @@ class GUI_EXPORT QgsLayoutItemGuiRegistry : public QObject
*/
const QgsLayoutItemGuiGroup &itemGroup( const QString &id );

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Creates a new instance of a layout item given the item metadata \a metadataId, target \a layout.
*/
QgsLayoutItem *createItem( int metadataId, QgsLayout *layout ) const SIP_TRANSFERBACK;
QgsLayoutItem *createItem( int metadataId, QgsLayout *layout ) const SIP_FACTORY;

/**
* Called when a newly created item of the associated metadata \a metadataId has been added to a layout.
Expand All @@ -420,25 +390,10 @@ class GUI_EXPORT QgsLayoutItemGuiRegistry : public QObject
*/
void newItemAddedToLayout( int metadataId, QgsLayoutItem *item );

/*
* IMPORTANT: While it seems like /Factory/ would be the correct annotations here, that's not
* the case.
* As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
*
* "
* /Factory/ is used when the instance returned is guaranteed to be new to Python.
* In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
* (However for a different sub-class implemented in C++ then it would be the first time it was seen
* by Python so the /Factory/ on create() would be correct.)
*
* You might try using /TransferBack/ on create() instead - that might be the best compromise.
* "
*/

/**
* Creates a new instance of a layout item configuration widget for the specified \a item.
*/
QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) const SIP_TRANSFERBACK;
QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) const SIP_FACTORY;

/**
* Creates a new rubber band item for the specified item \a metadataId and destination \a view.
Expand Down

0 comments on commit c1913dc

Please sign in to comment.