QGIS/python/core/auto_generated/qgsauxiliarystorage.sip.in

376 lines
11 KiB
Plaintext
Raw Normal View History

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsauxiliarystorage.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsAuxiliaryLayer : QgsVectorLayer
{
%Docstring
2017-12-15 10:36:55 -04:00
Class allowing to manage the auxiliary storage for a vector layer.
Such auxiliary data are data used mostly for the needs of QGIS (symbology)
and have no real interest in being stored with the native raw geospatial
data.
The need arises from the restrictions existing in the manual placement of
labels. Manual placement of labels are possible in QGIS by setting some
labeling properties (X and Y position, and rotation angle optionally) as
being "data-defined", meaning that values come from a column (or an
expression). But setting this up on an existing layer requires either to
add new columns to the source layer, while it is not always possible or
desirable.
This QgsAuxiliaryLayer provides the solution to this limitation. Actually
it's an editable join to the original vector layer with some
synchronisation mechanisms activated such as "Upsert On Edit" or "Delete
Cascade". Thus, auxiliary fields are editable even if the
source layer is not and edition of a joined field is also possible.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsauxiliarystorage.h"
%End
public:
QgsAuxiliaryLayer( const QString &pkField, const QString &filename, const QString &table, QgsVectorLayer *vlayer );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor
2017-12-15 10:36:55 -04:00
:param pkField: The primary key to use for joining
:param filename: The database path
:param table: The table name
:param vlayer: The target vector layer in join definition
%End
2017-09-02 18:47:36 +01:00
QgsAuxiliaryLayer *clone( QgsVectorLayer *layer ) const /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Returns a new instance equivalent to this one. The underlying table
is duplicate for the layer given in parameter. Note that the current
auxiliary layer should be saved to have a proper duplicated table.
2017-09-02 18:47:36 +01:00
2017-12-15 10:36:55 -04:00
:param layer: The layer for which the clone is made
2017-09-02 18:47:36 +01:00
%End
2017-08-29 08:59:42 +01:00
QgsVectorLayer *toSpatialLayer() const;
%Docstring
2017-12-15 10:36:55 -04:00
An auxiliary layer is not spatial. This method returns a spatial
representation of auxiliary data.
:return: A new spatial vector layer
2017-08-29 08:59:42 +01:00
%End
2017-08-29 08:32:27 +01:00
bool clear();
%Docstring
2017-12-15 10:36:55 -04:00
Deletes all features from the layer. Changes are automatically committed
and the layer remains editable.
2019-02-26 19:54:09 +10:00
:return: ``True`` if changes are committed without error, ``False`` otherwise.
2017-08-29 08:32:27 +01:00
%End
QgsVectorLayerJoinInfo joinInfo() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns information to use for joining with primary key and so on.
%End
bool exists( const QgsPropertyDefinition &definition ) const;
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the property is stored in the layer already, ``False``
2017-12-15 10:36:55 -04:00
otherwise.
2017-12-15 10:36:55 -04:00
:param definition: The property definition to check
2019-02-26 19:54:09 +10:00
:return: ``True`` if the property is stored, ``False`` otherwise
%End
bool addAuxiliaryField( const QgsPropertyDefinition &definition );
%Docstring
2017-12-15 10:36:55 -04:00
Adds an auxiliary field for the given property. Setup for widget
editors are updated in the target layer as well as the attribute
table config to hide auxiliary fields by default.
:param definition: The definition of the property to add
2019-02-26 19:54:09 +10:00
:return: ``True`` if the auxiliary field is well added, ``False`` otherwise
%End
2017-09-06 01:47:30 +01:00
QgsFields auxiliaryFields() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns a list of all auxiliary fields currently managed by the layer.
%End
bool save();
%Docstring
2017-12-15 10:36:55 -04:00
Commits changes and starts editing then.
2019-02-26 19:54:09 +10:00
:return: ``True`` if commit step passed, ``False`` otherwise
%End
2017-08-29 09:45:01 +01:00
virtual bool deleteAttribute( int attr );
2017-08-29 09:45:01 +01:00
%Docstring
2017-12-15 10:36:55 -04:00
Removes attribute from the layer and commits changes. The layer remains
editable.
2017-08-29 09:45:01 +01:00
2017-12-15 10:36:55 -04:00
:param attr: The index of the attribute to remove
2019-02-26 19:54:09 +10:00
:return: ``True`` if the attribute is well deleted, ``False`` otherwise
2017-08-29 09:45:01 +01:00
%End
bool isHiddenProperty( int index ) const;
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the underlying field has to be hidden from editing
tools like attribute table, ``False`` otherwise.
2017-12-15 10:36:55 -04:00
:param index: The index of the field for which visibility is checked
%End
2017-09-06 01:47:30 +01:00
int indexOfPropertyDefinition( const QgsPropertyDefinition &definition ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the index of the auxiliary field for a specific property
definition.
2017-12-15 10:36:55 -04:00
:param definition: The property definition
:return: The index of the field corresponding to the property or -1
%End
int propertyFromIndex( int index ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the underlying property key for the field index. The key may be
a PAL, diagram or symbology property according to the underlying
property definition of the field. The key -1 is returned if an error
happened.
:param index: The index of the field
%End
QgsPropertyDefinition propertyDefinitionFromIndex( int index ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the property definition for the underlying field index.
2017-12-15 10:36:55 -04:00
:param index: The index of the field
%End
static int createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer );
%Docstring
2017-12-15 10:36:55 -04:00
Creates if necessary a new auxiliary field for a PAL property and
activates this property in settings.
:param property: The property to create
:param vlayer: The vector layer
2017-12-15 10:36:55 -04:00
:return: The index of the auxiliary field or -1
%End
static int createProperty( QgsDiagramLayerSettings::Property property, QgsVectorLayer *vlayer );
%Docstring
2017-12-15 10:36:55 -04:00
Creates if necessary a new auxiliary field for a diagram's property and
activates this property in settings.
2017-12-15 10:36:55 -04:00
:param property: The property to create
:param vlayer: The vector layer
:return: The index of the auxiliary field or -1
%End
2017-09-06 01:47:30 +01:00
static QgsField createAuxiliaryField( const QgsPropertyDefinition &definition );
%Docstring
2017-12-15 10:36:55 -04:00
Creates a new auxiliary field from a property definition.
:param definition: The property definition of the auxiliary field to create
2017-09-06 01:47:30 +01:00
%End
static QgsField createAuxiliaryField( const QgsField &field );
%Docstring
2017-12-15 10:36:55 -04:00
Creates a new auxiliary field from a field.
2017-09-06 01:47:30 +01:00
2017-12-15 10:36:55 -04:00
:param field: The field to use to create the auxiliary field
2017-09-06 01:47:30 +01:00
%End
static QString nameFromProperty( const QgsPropertyDefinition &def, bool joined = false );
%Docstring
2017-12-15 10:36:55 -04:00
Returns the name of the auxiliary field for a property definition.
:param def: The property definition
2019-02-26 19:54:09 +10:00
:param joined: The join prefix is taken into account if ``True``
2017-09-06 01:47:30 +01:00
%End
static QgsPropertyDefinition propertyDefinitionFromField( const QgsField &field );
%Docstring
2017-12-15 10:36:55 -04:00
Returns the property definition from an auxiliary field.
2017-09-06 01:47:30 +01:00
2017-12-15 10:36:55 -04:00
:param field: The auxiliary field
2017-09-06 01:47:30 +01:00
%End
};
class QgsAuxiliaryStorage
{
%Docstring
Class providing some utility methods to manage auxiliary storage.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsauxiliarystorage.h"
%End
public:
QgsAuxiliaryStorage( const QgsProject &project, bool copy = true );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor.
2017-12-15 10:36:55 -04:00
The project filename is used to build a database path at the same
location, but with a different extension. Then, it's the same logic as
described for :py:class:`QgsAuxiliaryStorage`(const QString &, bool copy).
2017-12-15 10:36:55 -04:00
:param project: The project for which the auxiliary storage has to be used
:param copy: Parameter indicating if a copy of the database has to be used
%End
QgsAuxiliaryStorage( const QString &filename = QString(), bool copy = true );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor.
2017-12-15 10:36:55 -04:00
If a valid database path is given in parameter and copy mode is
deactivated, then every changes is directly committed on the original
database. But if the copy mode is activated, then changes are committed
on a copy of the database (a temporary file) and a save action is
therefore necessary to keep modifications in the original file.
2017-12-15 10:36:55 -04:00
If an empty string for the database path is given in parameter, then
a database is created in a temporary file whatever the copy mode.
2017-12-15 10:36:55 -04:00
If the database path given in parameter is not empty but does not exist,
then a database is created at this location when copy mode is
deactivated. When copy mode is activated, a temporary database is used
instead and a save action will be necessary to create the database at
the original location given in parameter.
2017-12-15 10:36:55 -04:00
:param filename: The path of the database
:param copy: Parameter indicating if a copy of the database has to be used
%End
virtual ~QgsAuxiliaryStorage();
bool isValid() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the status of the auxiliary storage currently defined.
2019-02-26 19:54:09 +10:00
:return: ``True`` if the auxiliary storage is valid, ``False`` otherwise
%End
QString fileName() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the target filename of the database.
%End
QString currentFileName() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the path of the current database used. It may be different from
the target filename if the auxiliary storage is opened in copy mode.
%End
2018-10-01 10:00:44 +01:00
QString errorString() const;
%Docstring
2018-10-01 12:54:18 +01:00
Returns the underlying error string describing potential errors
2019-01-01 21:53:37 +01:00
happening in saveAs(). Empty by default.
2018-10-01 10:00:44 +01:00
.. versionadded:: 3.4
%End
bool saveAs( const QString &filename );
%Docstring
2017-12-15 10:36:55 -04:00
Saves the current database to a new path.
2019-02-26 19:54:09 +10:00
:return: ``True`` if everything is saved, ``False`` otherwise
%End
2018-10-01 10:00:44 +01:00
bool saveAs( const QgsProject &project );
%Docstring
2017-12-15 10:36:55 -04:00
Saves the current database to a new path for a specific project.
Actually, the current filename of the project is used to deduce the
path of the database to save.
2019-02-26 19:54:09 +10:00
:return: ``True`` if everything is saved, ``False`` otherwise
%End
bool save() const;
%Docstring
2017-12-15 10:36:55 -04:00
Saves the current database.
2019-02-26 19:54:09 +10:00
:return: ``True`` if everything is saved, ``False`` otherwise
%End
QgsAuxiliaryLayer *createAuxiliaryLayer( const QgsField &field, QgsVectorLayer *layer ) const /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Creates an auxiliary layer for a vector layer. A new table is created if
necessary. The primary key to use to construct the auxiliary layer is
given in parameter.
:param field: The primary key to join
:param layer: The vector layer for which the auxiliary layer has to be created
2017-12-15 10:36:55 -04:00
:return: A new auxiliary layer or a None if an error happened.
%End
2017-08-29 08:46:10 +01:00
static bool deleteTable( const QgsDataSourceUri &uri );
%Docstring
2017-12-15 10:36:55 -04:00
Removes a table from the auxiliary storage.
2017-08-29 08:46:10 +01:00
2017-12-15 10:36:55 -04:00
:param uri: The uri of the table to remove
2019-02-26 19:54:09 +10:00
:return: ``True`` if the table is well deleted, ``False`` otherwise
2017-08-29 08:46:10 +01:00
%End
2017-09-02 18:47:36 +01:00
static bool duplicateTable( const QgsDataSourceUri &uri, const QString &newTable );
%Docstring
2017-12-15 10:36:55 -04:00
Duplicates a table and its content.
:param uri: The uri of the table to duplicate
:param newTable: The name of the new table
2017-09-02 18:47:36 +01:00
2019-02-26 19:54:09 +10:00
:return: ``True`` if the table is well duplicated, ``False`` otherwise
2017-09-02 18:47:36 +01:00
%End
static QString extension();
%Docstring
2017-12-15 10:36:55 -04:00
Returns the extension used for auxiliary databases.
%End
static bool exists( const QgsProject &project );
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the auxiliary database yet exists for a project, ``False`` otherwise.
:param project: The project for which the database is checked
.. versionadded:: 3.2
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsauxiliarystorage.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/