Skip to content
Permalink
Browse files

Revert "Use /TransferBack/ instead of /Factory/ in layout registry fa…

…ctory methods"

This reverts commit da59316.
  • Loading branch information
nyalldawson committed Dec 21, 2020
1 parent da59316 commit c1913dc963e747c372dc40be5a67a3202189e7c0
@@ -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
@@ -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
@@ -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.
@@ -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``.

@@ -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
@@ -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
@@ -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
@@ -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).
@@ -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).
@@ -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()
@@ -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.
@@ -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:

@@ -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.
@@ -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.
@@ -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.

0 comments on commit c1913dc

Please sign in to comment.
You can’t perform that action at this time.