Skip to content

Commit

Permalink
Move some invokables to properties
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 17, 2024
1 parent 5d796e9 commit 37af25e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/core/qgsfields.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class CORE_EXPORT QgsFields
{
Q_GADGET

Q_PROPERTY( bool isEmpty READ isEmpty )
Q_PROPERTY( int count READ count )
Q_PROPERTY( QStringList names READ names )

public:

enum FieldOrigin
Expand Down Expand Up @@ -144,10 +148,10 @@ class CORE_EXPORT QgsFields
void extend( const QgsFields &other );

//! Checks whether the container is empty
Q_INVOKABLE bool isEmpty() const;
bool isEmpty() const;

//! Returns number of items
Q_INVOKABLE int count() const;
int count() const;

#ifdef SIP_RUN
int __len__() const;
Expand All @@ -163,12 +167,12 @@ class CORE_EXPORT QgsFields
#endif

//! Returns number of items
Q_INVOKABLE int size() const;
int size() const;

/**
* Returns a list with field names
*/
Q_INVOKABLE QStringList names() const;
QStringList names() const;

/**
* Returns if a field index is valid
Expand Down
3 changes: 2 additions & 1 deletion src/core/vector/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
Q_PROPERTY( bool supportsEditing READ supportsEditing NOTIFY supportsEditingChanged )
Q_PROPERTY( QgsFields fields READ fields NOTIFY updatedFields )

public:

Expand Down Expand Up @@ -1660,7 +1661,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* \returns A list of fields
*/
Q_INVOKABLE QgsFields fields() const FINAL;
QgsFields fields() const FINAL;

/**
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Expand Down

0 comments on commit 37af25e

Please sign in to comment.