Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add merge policies #60710

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
25 changes: 25 additions & 0 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6928,6 +6928,11 @@
Qgis.FieldDomainMergePolicy.DefaultValue.__doc__ = "Use default field value"
Qgis.FieldDomainMergePolicy.Sum.__doc__ = "Sum of values"
Qgis.FieldDomainMergePolicy.GeometryWeighted.__doc__ = "New values are computed as the weighted average of the source values"
Qgis.FieldDomainMergePolicy.UnsetField.__doc__ = "Clears the field value so that the data provider backend will populate using any backend triggers or similar logic \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.LargestGeometry.__doc__ = "Use value from the feature with the largest geometry \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.MinimumValue.__doc__ = "Use the minimum value from the features-to-be-merged \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.MaximumValue.__doc__ = "Use the maximum value from the features-to-be-merged \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.SetToNull.__doc__ = "Use a null value \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.__doc__ = """Merge policy for field domains.

When a feature is built by merging multiple features, defines how the value of
Expand All @@ -6938,6 +6943,26 @@
* ``DefaultValue``: Use default field value
* ``Sum``: Sum of values
* ``GeometryWeighted``: New values are computed as the weighted average of the source values
* ``UnsetField``: Clears the field value so that the data provider backend will populate using any backend triggers or similar logic

.. versionadded:: 3.44

* ``LargestGeometry``: Use value from the feature with the largest geometry

.. versionadded:: 3.44

* ``MinimumValue``: Use the minimum value from the features-to-be-merged

.. versionadded:: 3.44

* ``MaximumValue``: Use the maximum value from the features-to-be-merged

.. versionadded:: 3.44

* ``SetToNull``: Use a null value

.. versionadded:: 3.44


"""
# --
Expand Down
5 changes: 5 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,11 @@ The development version
DefaultValue,
Sum,
GeometryWeighted,
UnsetField,
LargestGeometry,
MinimumValue,
MaximumValue,
SetToNull,
};

enum class FieldDuplicatePolicy /BaseType=IntEnum/
Expand Down
20 changes: 20 additions & 0 deletions python/PyQt6/core/auto_generated/qgsfield.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,26 @@ be handled during a duplicate operation.
.. seealso:: :py:func:`duplicatePolicy`

.. versionadded:: 3.38
%End

Qgis::FieldDomainMergePolicy mergePolicy() const /HoldGIL/;
%Docstring
Returns the field's merge policy, which indicates how field values should
be handled during a merge operation.

.. seealso:: :py:func:`setMergePolicy`

.. versionadded:: 3.44
%End

void setMergePolicy( Qgis::FieldDomainMergePolicy policy ) /HoldGIL/;
%Docstring
Sets the field's merge ``policy``, which indicates how field values should
be handled during a merge operation.

.. seealso:: :py:func:`mergePolicy`

.. versionadded:: 3.44
%End

SIP_PYOBJECT __repr__();
Expand Down
21 changes: 21 additions & 0 deletions python/PyQt6/core/auto_generated/vector/qgsvectorlayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,27 @@ Sets a duplicate ``policy`` for the field with the specified index.
}
%End

void setFieldMergePolicy( int index, Qgis::FieldDomainMergePolicy policy );
%Docstring
Sets a merge ``policy`` for the field with the specified index.

:raises KeyError: if no field with the specified index exists

.. versionadded:: 3.44
%End

%MethodCode
if ( a0 < 0 || a0 >= sipCpp->fields().count() )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
else
{
sipCpp->setFieldMergePolicy( a0, a1 );
}
%End

QSet<QString> excludeAttributesWms() const /Deprecated="Since 3.16. Use fields().configurationFlags() instead."/;
%Docstring
A set of attributes that are not advertised in WMS requests with QGIS server.
Expand Down
25 changes: 25 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6862,6 +6862,11 @@
Qgis.FieldDomainMergePolicy.DefaultValue.__doc__ = "Use default field value"
Qgis.FieldDomainMergePolicy.Sum.__doc__ = "Sum of values"
Qgis.FieldDomainMergePolicy.GeometryWeighted.__doc__ = "New values are computed as the weighted average of the source values"
Qgis.FieldDomainMergePolicy.UnsetField.__doc__ = "Clears the field value so that the data provider backend will populate using any backend triggers or similar logic \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.LargestGeometry.__doc__ = "Use value from the feature with the largest geometry \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.MinimumValue.__doc__ = "Use the minimum value from the features-to-be-merged \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.MaximumValue.__doc__ = "Use the maximum value from the features-to-be-merged \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.SetToNull.__doc__ = "Use a null value \n.. versionadded:: 3.44"
Qgis.FieldDomainMergePolicy.__doc__ = """Merge policy for field domains.

When a feature is built by merging multiple features, defines how the value of
Expand All @@ -6872,6 +6877,26 @@
* ``DefaultValue``: Use default field value
* ``Sum``: Sum of values
* ``GeometryWeighted``: New values are computed as the weighted average of the source values
* ``UnsetField``: Clears the field value so that the data provider backend will populate using any backend triggers or similar logic

.. versionadded:: 3.44

* ``LargestGeometry``: Use value from the feature with the largest geometry

.. versionadded:: 3.44

* ``MinimumValue``: Use the minimum value from the features-to-be-merged

.. versionadded:: 3.44

* ``MaximumValue``: Use the maximum value from the features-to-be-merged

.. versionadded:: 3.44

* ``SetToNull``: Use a null value

.. versionadded:: 3.44


"""
# --
Expand Down
5 changes: 5 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,11 @@ The development version
DefaultValue,
Sum,
GeometryWeighted,
UnsetField,
LargestGeometry,
MinimumValue,
MaximumValue,
SetToNull,
};

enum class FieldDuplicatePolicy
Expand Down
20 changes: 20 additions & 0 deletions python/core/auto_generated/qgsfield.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,26 @@ be handled during a duplicate operation.
.. seealso:: :py:func:`duplicatePolicy`

.. versionadded:: 3.38
%End

Qgis::FieldDomainMergePolicy mergePolicy() const /HoldGIL/;
%Docstring
Returns the field's merge policy, which indicates how field values should
be handled during a merge operation.

.. seealso:: :py:func:`setMergePolicy`

.. versionadded:: 3.44
%End

void setMergePolicy( Qgis::FieldDomainMergePolicy policy ) /HoldGIL/;
%Docstring
Sets the field's merge ``policy``, which indicates how field values should
be handled during a merge operation.

.. seealso:: :py:func:`mergePolicy`

.. versionadded:: 3.44
%End

SIP_PYOBJECT __repr__();
Expand Down
21 changes: 21 additions & 0 deletions python/core/auto_generated/vector/qgsvectorlayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,27 @@ Sets a duplicate ``policy`` for the field with the specified index.
}
%End

void setFieldMergePolicy( int index, Qgis::FieldDomainMergePolicy policy );
%Docstring
Sets a merge ``policy`` for the field with the specified index.

:raises KeyError: if no field with the specified index exists

.. versionadded:: 3.44
%End

%MethodCode
if ( a0 < 0 || a0 >= sipCpp->fields().count() )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
else
{
sipCpp->setFieldMergePolicy( a0, a1 );
}
%End

QSet<QString> excludeAttributesWms() const /Deprecated="Since 3.16. Use fields().configurationFlags() instead."/;
%Docstring
A set of attributes that are not advertised in WMS requests with QGIS server.
Expand Down
15 changes: 15 additions & 0 deletions src/app/browser/qgsinbuiltdataitemproviders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,21 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const
case Qgis::FieldDomainMergePolicy::GeometryWeighted:
metadata += tr( "Use geometry weighted value" );
break;
case Qgis::FieldDomainMergePolicy::UnsetField:
metadata += tr( "Unset field" );
break;
case Qgis::FieldDomainMergePolicy::LargestGeometry:
metadata += tr( "Largest geometry" );
break;
case Qgis::FieldDomainMergePolicy::MaximumValue:
metadata += tr( "Maximum value" );
break;
case Qgis::FieldDomainMergePolicy::MinimumValue:
metadata += tr( "Minimum value" );
break;
case Qgis::FieldDomainMergePolicy::SetToNull:
metadata += tr( "Skip attribute" );
break;
}

metadata += QLatin1String( "</table>\n<br><br>" );
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9451,9 +9451,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
QgsFeatureList featureList = vl->selectedFeatures();

//merge the attributes together
QgsMergeAttributesDialog d( featureList, vl, mapCanvas() );
//initialize dialog with all columns set to skip
d.setAllToSkip();
QgsMergeAttributesDialog d( featureList, vl, mapCanvas(), true );

if ( d.exec() == QDialog::Rejected )
{
return;
Expand Down
Loading
Loading