Skip to content

Commit

Permalink
Remove QgsAuxiliaryField class
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Oct 9, 2017
1 parent fc0ebb7 commit 7483c6e
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 284 deletions.
94 changes: 38 additions & 56 deletions python/core/qgsauxiliarystorage.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,6 @@



class QgsAuxiliaryField : QgsField
{
%Docstring


Class allowing to manage fields from of auxiliary layers

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsauxiliarystorage.h"
%End
public:

explicit QgsAuxiliaryField( const QgsPropertyDefinition &def );
%Docstring
Constructor

\param def Definition of the property to be stored by this auxiliary
field.
%End

virtual ~QgsAuxiliaryField();
%Docstring
Destructor
%End

QgsPropertyDefinition propertyDefinition() const;
%Docstring
Returns the property definition corresponding to this field.
:rtype: QgsPropertyDefinition
%End

static QString nameFromProperty( const QgsPropertyDefinition &def, bool joined = false );
%Docstring
Returns the name of the auxiliary field for a property definition.

:return: def The property definition
:return: joined The join prefix is tok into account if true
:rtype: str
%End

};

typedef QList<QgsAuxiliaryField> QgsAuxiliaryFields;

class QgsAuxiliaryLayer : QgsVectorLayer
{
%Docstring
Expand Down Expand Up @@ -166,10 +119,10 @@ class QgsAuxiliaryLayer : QgsVectorLayer
:rtype: bool
%End

QgsAuxiliaryFields auxiliaryFields() const;
QgsFields auxiliaryFields() const;
%Docstring
Returns a list of all auxiliary fields currently managed by the layer.
:rtype: QgsAuxiliaryFields
:rtype: QgsFields
%End

bool save();
Expand Down Expand Up @@ -200,7 +153,7 @@ class QgsAuxiliaryLayer : QgsVectorLayer
:rtype: bool
%End

int indexOfProperty( const QgsPropertyDefinition &definition ) const;
int indexOfPropertyDefinition( const QgsPropertyDefinition &definition ) const;
%Docstring
Returns the index of the auxiliary field for a specific property
definition.
Expand All @@ -219,8 +172,6 @@ class QgsAuxiliaryLayer : QgsVectorLayer
happened.

\param index The index of the field

.. versionadded:: 3.0
:rtype: int
%End

Expand All @@ -229,14 +180,12 @@ class QgsAuxiliaryLayer : QgsVectorLayer
Returns the property definition fir the underlying field index.

\param index The index of the field

.. versionadded:: 3.0
:rtype: QgsPropertyDefinition
%End

static int createProperty( QgsPalLayerSettings::Property property, const QString &providerId, QgsVectorLayer *vlayer );
%Docstring
Create if necessary a new auxiliary field for a PAL property and
Creates if necessary a new auxiliary field for a PAL property and
activate this property in settings.

\param property The property to create
Expand All @@ -249,7 +198,7 @@ class QgsAuxiliaryLayer : QgsVectorLayer

static int createProperty( QgsDiagramLayerSettings::Property property, QgsVectorLayer *vlayer );
%Docstring
Create if necessary a new auxiliary field for a diagram's property and
Creates if necessary a new auxiliary field for a diagram's property and
activate this this property in settings.

\param property The property to create
Expand All @@ -259,6 +208,39 @@ class QgsAuxiliaryLayer : QgsVectorLayer
:rtype: int
%End

static QgsField createAuxiliaryField( const QgsPropertyDefinition &definition );
%Docstring
Creates a new auxiliary field from a property definition.

\param definition The property definition of the auxiliary field to create
:rtype: QgsField
%End

static QgsField createAuxiliaryField( const QgsField &field );
%Docstring
Creates a new auxiliary field from a field.

\param field The field to use to create the auxiliary field
:rtype: QgsField
%End

static QString nameFromProperty( const QgsPropertyDefinition &def, bool joined = false );
%Docstring
Returns the name of the auxiliary field for a property definition.

\param def The property definition
\param joined The join prefix is taken into account if true
:rtype: str
%End

static QgsPropertyDefinition propertyDefinitionFromField( const QgsField &field );
%Docstring
Returns the property definition from an auxiliary field.

\param field The auxiliary field
:rtype: QgsPropertyDefinition
%End

};


Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdiagramproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ void QgsDiagramProperties::createAuxiliaryField()

// update property with join field name from auxiliary storage
QgsProperty property = button->toProperty();
property.setField( QgsAuxiliaryField::nameFromProperty( def, true ) );
property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
property.setActive( true );
button->updateFieldLists();
button->setToProperty( property );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void QgsLabelingGui::createAuxiliaryField()

// update property with join field name from auxiliary storage
QgsProperty property = button->toProperty();
property.setField( QgsAuxiliaryField::nameFromProperty( def, true ) );
property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
property.setActive( true );
button->updateFieldLists();
button->setToProperty( property );
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ void QgsVectorLayerProperties::updateAuxiliaryStoragePage( bool reset )

// add fields
mAuxiliaryStorageFieldsTree->clear();
Q_FOREACH ( const QgsAuxiliaryField &field, alayer->auxiliaryFields() )
Q_FOREACH ( const QgsField &field, alayer->auxiliaryFields() )
{
const QgsPropertyDefinition prop = field.propertyDefinition();
const QgsPropertyDefinition prop = QgsAuxiliaryLayer::propertyDefinitionFromField( field );
QTreeWidgetItem *item = new QTreeWidgetItem();

item->setText( 0, prop.origin() );
Expand Down Expand Up @@ -1620,7 +1620,7 @@ void QgsVectorLayerProperties::onAuxiliaryLayerDelete()
// defined buttons
while ( alayer->auxiliaryFields().size() > 0 )
{
QgsAuxiliaryField aField = alayer->auxiliaryFields()[0];
QgsField aField = alayer->auxiliaryFields()[0];
deleteAuxiliaryField( alayer->fields().indexOf( aField.name() ) );
}

Expand Down Expand Up @@ -1661,7 +1661,7 @@ void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
def.setName( item->text( 1 ) );
def.setComment( item->text( 2 ) );

const QString fieldName = QgsAuxiliaryField::nameFromProperty( def );
const QString fieldName = QgsAuxiliaryLayer::nameFromProperty( def );

const int index = mLayer->auxiliaryLayer()->fields().indexOf( fieldName );
if ( index < 0 )
Expand Down
Loading

0 comments on commit 7483c6e

Please sign in to comment.