Skip to content

Commit

Permalink
expose QgsField configuration flags in python bindings (#54753)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored Sep 27, 2023
1 parent c561e1b commit 68f025b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
30 changes: 30 additions & 0 deletions python/core/auto_generated/qgsfield.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ length, and if applicable, precision.

public:

enum class ConfigurationFlag
{
None,
NotSearchable,
HideFromWms,
HideFromWfs,
};
typedef QFlags<QgsField::ConfigurationFlag> ConfigurationFlags;


QgsField( const QString &name = QString(),
QVariant::Type type = QVariant::Invalid,
Expand Down Expand Up @@ -342,13 +351,31 @@ Sets the alias for the field (the friendly displayed name of the field ).
.. versionadded:: 3.0
%End

QgsField::ConfigurationFlags configurationFlags() const;
%Docstring
Returns the Flags for the field (searchable, …)

.. versionadded:: 3.16
%End

void setConfigurationFlags( QgsField::ConfigurationFlags configurationFlags );
%Docstring
Sets the Flags for the field (searchable, …)

.. versionadded:: 3.16
%End

QString displayString( const QVariant &v ) const;
%Docstring
Formats string for display
%End

static QString readableConfigurationFlag( QgsField::ConfigurationFlag flag );
%Docstring
Returns the readable and translated value of the configuration flag

.. versionadded:: 3.16
%End


bool convertCompatible( QVariant &v ) const;
Expand Down Expand Up @@ -477,6 +504,9 @@ be handled during a split operation.
}; // class QgsField


QFlags<QgsField::ConfigurationFlag> operator|(QgsField::ConfigurationFlag f1, QFlags<QgsField::ConfigurationFlag> f2);




/************************************************************************
Expand Down
11 changes: 4 additions & 7 deletions src/core/qgsfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class CORE_EXPORT QgsField

public:

#ifndef SIP_RUN

/**
* Configuration flags for fields
* These flags are meant to be user-configurable
Expand All @@ -88,7 +86,6 @@ class CORE_EXPORT QgsField
Q_ENUM( ConfigurationFlag )
Q_DECLARE_FLAGS( ConfigurationFlags, ConfigurationFlag )
Q_FLAG( ConfigurationFlags )
#endif

/**
* Constructor. Constructs a new QgsField object.
Expand Down Expand Up @@ -378,13 +375,13 @@ class CORE_EXPORT QgsField
* Returns the Flags for the field (searchable, …)
* \since QGIS 3.16
*/
QgsField::ConfigurationFlags configurationFlags() const SIP_SKIP;
QgsField::ConfigurationFlags configurationFlags() const;

/**
* Sets the Flags for the field (searchable, …)
* \since QGIS 3.16
*/
void setConfigurationFlags( QgsField::ConfigurationFlags configurationFlags ) SIP_SKIP;
void setConfigurationFlags( QgsField::ConfigurationFlags configurationFlags );

//! Formats string for display
QString displayString( const QVariant &v ) const;
Expand All @@ -393,7 +390,7 @@ class CORE_EXPORT QgsField
* Returns the readable and translated value of the configuration flag
* \since QGIS 3.16
*/
static QString readableConfigurationFlag( QgsField::ConfigurationFlag flag ) SIP_SKIP;
static QString readableConfigurationFlag( QgsField::ConfigurationFlag flag );

#ifndef SIP_RUN

Expand Down Expand Up @@ -548,7 +545,7 @@ class CORE_EXPORT QgsField

Q_DECLARE_METATYPE( QgsField )

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsField::ConfigurationFlags ) SIP_SKIP
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsField::ConfigurationFlags )

//! Writes the field to stream out. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsField &field );
Expand Down

0 comments on commit 68f025b

Please sign in to comment.