Skip to content
Permalink
Browse files
Use consistent names for data defined property collections
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent fa26b45 commit e06192ec3f6fd1a37c1f7bf7dab6bac307b6ef05
Showing with 528 additions and 554 deletions.
  1. +3 −16 python/core/qgsdiagramrenderer.sip
  2. +3 −16 python/core/qgspallabeling.sip
  3. +37 −37 src/app/dwg/qgsdwgimportdialog.cpp
  4. +4 −4 src/app/qgsdiagramproperties.cpp
  5. +1 −1 src/app/qgsdiagramproperties.h
  6. +4 −4 src/app/qgslabelinggui.cpp
  7. +1 −1 src/app/qgslabelinggui.h
  8. +1 −1 src/app/qgslabelpropertydialog.cpp
  9. +5 −5 src/app/qgsmaptoollabel.cpp
  10. +1 −1 src/core/composer/qgscomposerhtml.cpp
  11. +10 −10 src/core/composer/qgscomposeritem.cpp
  12. +2 −2 src/core/composer/qgscomposerlegend.cpp
  13. +10 −10 src/core/composer/qgscomposermap.cpp
  14. +4 −4 src/core/composer/qgscomposerobject.cpp
  15. +4 −4 src/core/composer/qgscomposerobject.h
  16. +6 −6 src/core/composer/qgscomposerpicture.cpp
  17. +4 −4 src/core/composer/qgscomposerscalebar.cpp
  18. +13 −13 src/core/composer/qgscomposition.cpp
  19. +4 −4 src/core/composer/qgscomposition.h
  20. +10 −10 src/core/qgsdiagramrenderer.cpp
  21. +6 −6 src/core/qgsdiagramrenderer.h
  22. +70 −70 src/core/qgspallabeling.cpp
  23. +7 −7 src/core/qgspallabeling.h
  24. +19 −19 src/core/qgsvectorlayerdiagramprovider.cpp
  25. +2 −2 src/core/qgsvectorlayerlabelprovider.cpp
  26. +14 −14 src/core/symbology-ng/qgsarrowsymbollayer.cpp
  27. +33 −33 src/core/symbology-ng/qgsellipsesymbollayer.cpp
  28. +96 −96 src/core/symbology-ng/qgsfillsymbollayer.cpp
  29. +30 −30 src/core/symbology-ng/qgslinesymbollayer.cpp
  30. +89 −89 src/core/symbology-ng/qgsmarkersymbollayer.cpp
  31. +9 −9 src/core/symbology-ng/qgssymbollayer.cpp
  32. +4 −4 src/core/symbology-ng/qgssymbollayer.h
  33. +12 −12 tests/src/core/testqgsdiagram.cpp
  34. +6 −6 tests/src/core/testqgslabelingengine.cpp
  35. +4 −4 tests/src/python/test_qgspallabeling_placement.py
@@ -203,24 +203,11 @@ class QgsDiagramLayerSettings
*/
QSet< QString > referencedFields( const QgsExpressionContext& context = QgsExpressionContext() ) const;

/** Returns a reference to the diagram's property collection, used for data defined overrides.
* @note added in QGIS 2.16
* @see setProperties()
*/
QgsPropertyCollection& properties();
QgsPropertyCollection& dataDefinedProperties();

/** Returns a reference to the diagram's property collection, used for data defined overrides.
* @note added in QGIS 2.16
* @see setProperties()
*/
//const QgsPropertyCollection& properties() const;
//const dataDefinedProperties& properties() const;

/** Sets the diagram's property collection, used for data defined overrides.
* @param collection property collection. Existing properties will be replaced.
* @note adde in QGIS 2.16
* @see properties()
*/
void setProperties( const QgsPropertyCollection& collection );
void setDataDefinedProperties( const QgsPropertyCollection& collection );

};

@@ -427,24 +427,11 @@ class QgsPalLayerSettings
*/
QDomElement writeXml( QDomDocument& doc );

/** Returns a reference to the label's property collection, used for data defined overrides.
* @note added in QGIS 3.0
* @see setProperties()
*/
QgsPropertyCollection& properties();
QgsPropertyCollection& dataDefinedProperties();

/** Returns a reference to the label's property collection, used for data defined overrides.
* @note added in QGIS 3.0
* @see setProperties()
*/
//const QgsPropertyCollection& properties() const { return mProperties; }
//const QgsPropertyCollection& dataDefinedProperties() const;

/** Sets the label's property collection, used for data defined overrides.
* @param collection property collection. Existing properties will be replaced.
* @note added in QGIS 3.0
* @see properties()
*/
void setProperties( const QgsPropertyCollection& collection );
void setDataDefinedProperties( const QgsPropertyCollection& collection );

/** Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
* @see setFormat()
@@ -359,43 +359,43 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, QString name, QS
pls.fieldName = "text";
pls.wrapChar = "\\P";

pls.properties().setProperty( QgsPalLayerSettings::Size, QgsProperty::fromField( QStringLiteral( "height" ) ) );
pls.properties().setProperty( QgsPalLayerSettings::Color, QgsProperty::fromField( QStringLiteral( "color" ) ) );
pls.properties().setProperty( QgsPalLayerSettings::MultiLineHeight, QgsProperty::fromExpression( QStringLiteral( "CASE WHEN interlin<0 THEN 1 ELSE interlin*1.5 END" ) ) );
pls.properties().setProperty( QgsPalLayerSettings::PositionX, QgsProperty::fromExpression( QStringLiteral( "$x" ) ) );
pls.properties().setProperty( QgsPalLayerSettings::PositionY, QgsProperty::fromExpression( QStringLiteral( "$y" ) ) );
pls.properties().setProperty( QgsPalLayerSettings::Hali, QgsProperty::fromExpression( QStringLiteral( "CASE"
" WHEN etype=%1 THEN"
" CASE"
" WHEN alignv IN (1,4,7) THEN 'Left'"
" WHEN alignv IN (2,5,6) THEN 'Center'"
" ELSE 'Right'"
" END"
" ELSE"
" CASE"
" WHEN alignh=0 THEN 'Left'"
" WHEN alignh=1 THEN 'Center'"
" WHEN alignh=2 THEN 'Right'"
" WHEN alignh=3 THEN 'Left'"
" WHEN alignh=4 THEN 'Left'"
" END "
" END" ).arg( DRW::MTEXT ) ) );
pls.properties().setProperty( QgsPalLayerSettings::Vali, QgsProperty::fromExpression( QStringLiteral( "CASE"
" WHEN etype=%1 THEN"
" CASE"
" WHEN alignv < 4 THEN 'Top'"
" WHEN alignv < 7 THEN 'Half'"
" ELSE 'Bottom'"
" END"
" ELSE"
" CASE"
" WHEN alignv=0 THEN 'Base'"
" WHEN alignv=1 THEN 'Bottom'"
" WHEN alignv=2 THEN 'Half'"
" WHEN alignv=3 THEN 'Top'"
" END"
" END" ).arg( DRW::MTEXT ) ) );
pls.properties().setProperty( QgsPalLayerSettings::Rotation, QgsProperty::fromExpression( QStringLiteral( "angle*180.0/pi()" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Size, QgsProperty::fromField( QStringLiteral( "height" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Color, QgsProperty::fromField( QStringLiteral( "color" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::MultiLineHeight, QgsProperty::fromExpression( QStringLiteral( "CASE WHEN interlin<0 THEN 1 ELSE interlin*1.5 END" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::PositionX, QgsProperty::fromExpression( QStringLiteral( "$x" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::PositionY, QgsProperty::fromExpression( QStringLiteral( "$y" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Hali, QgsProperty::fromExpression( QStringLiteral( "CASE"
" WHEN etype=%1 THEN"
" CASE"
" WHEN alignv IN (1,4,7) THEN 'Left'"
" WHEN alignv IN (2,5,6) THEN 'Center'"
" ELSE 'Right'"
" END"
" ELSE"
" CASE"
" WHEN alignh=0 THEN 'Left'"
" WHEN alignh=1 THEN 'Center'"
" WHEN alignh=2 THEN 'Right'"
" WHEN alignh=3 THEN 'Left'"
" WHEN alignh=4 THEN 'Left'"
" END "
" END" ).arg( DRW::MTEXT ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Vali, QgsProperty::fromExpression( QStringLiteral( "CASE"
" WHEN etype=%1 THEN"
" CASE"
" WHEN alignv < 4 THEN 'Top'"
" WHEN alignv < 7 THEN 'Half'"
" ELSE 'Bottom'"
" END"
" ELSE"
" CASE"
" WHEN alignv=0 THEN 'Base'"
" WHEN alignv=1 THEN 'Bottom'"
" WHEN alignv=2 THEN 'Half'"
" WHEN alignv=3 THEN 'Top'"
" END"
" END" ).arg( DRW::MTEXT ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Rotation, QgsProperty::fromExpression( QStringLiteral( "angle*180.0/pi()" ) ) );

pls.placement = QgsPalLayerSettings::OrderedPositionsAroundPoint;
pls.writeToLayer( l );
@@ -383,7 +383,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare

mShowAllCheckBox->setChecked( dls->showAllDiagrams() );

mProperties = dls->properties();
mDataDefinedProperties = dls->dataDefinedProperties();
}

if ( dr->diagram() )
@@ -429,7 +429,7 @@ QgsDiagramProperties::~QgsDiagramProperties()

void QgsDiagramProperties::registerDataDefinedButton( QgsPropertyOverrideButton * button, QgsDiagramLayerSettings::Property key )
{
button->init( key, mProperties, QgsDiagramLayerSettings::PROPERTY_DEFINITIONS, mLayer );
button->init( key, mDataDefinedProperties, QgsDiagramLayerSettings::PROPERTY_DEFINITIONS, mLayer );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsDiagramProperties::updateProperty );
button->registerExpressionContextGenerator( this );
}
@@ -438,7 +438,7 @@ void QgsDiagramProperties::updateProperty()
{
QgsPropertyOverrideButton* button = qobject_cast<QgsPropertyOverrideButton*>( sender() );
QgsDiagramLayerSettings::Property key = static_cast< QgsDiagramLayerSettings::Property >( button->propertyKey() );
mProperties.setProperty( key, button->toProperty() );
mDataDefinedProperties.setProperty( key, button->toProperty() );
}

void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int index )
@@ -821,7 +821,7 @@ void QgsDiagramProperties::apply()
mLayer->setDiagramRenderer( renderer );

QgsDiagramLayerSettings dls;
dls.setProperties( mProperties );
dls.setDataDefinedProperties( mDataDefinedProperties );
dls.setDistance( mDiagramDistanceSpinBox->value() );
dls.setPriority( mPrioritySlider->value() );
dls.setZIndex( mZIndexSpinBox->value() );
@@ -76,7 +76,7 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr

QString showExpressionBuilder( const QString& initialExpression );

QgsPropertyCollection mProperties;
QgsPropertyCollection mDataDefinedProperties;

// Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
QString mDiagramType;
@@ -44,7 +44,7 @@ QgsExpressionContext QgsLabelingGui::createExpressionContext() const

void QgsLabelingGui::registerDataDefinedButton( QgsPropertyOverrideButton* button, QgsPalLayerSettings::Property key )
{
button->init( key, mProperties, QgsPalLayerSettings::PROPERTY_DEFINITIONS, mLayer );
button->init( key, mDataDefinedProperties, QgsPalLayerSettings::PROPERTY_DEFINITIONS, mLayer );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLabelingGui::updateProperty );
button->registerExpressionContextGenerator( this );
}
@@ -53,7 +53,7 @@ void QgsLabelingGui::updateProperty()
{
QgsPropertyOverrideButton* button = qobject_cast<QgsPropertyOverrideButton*>( sender() );
QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
mProperties.setProperty( key, button->toProperty() );
mDataDefinedProperties.setProperty( key, button->toProperty() );
}

QgsLabelingGui::QgsLabelingGui( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsPalLayerSettings* layerSettings, QWidget* parent )
@@ -264,7 +264,7 @@ void QgsLabelingGui::setLayer( QgsMapLayer* mapLayer )

mZIndexSpinBox->setValue( lyr.zIndex );

mProperties = lyr.properties();
mDataDefinedProperties = lyr.dataDefinedProperties();

updatePlacementWidgets();
updateLinePlacementOptions();
@@ -452,7 +452,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()

lyr.zIndex = mZIndexSpinBox->value();

lyr.setProperties( mProperties );
lyr.setDataDefinedProperties( mDataDefinedProperties );

return lyr;
}
@@ -57,7 +57,7 @@ class APP_EXPORT QgsLabelingGui : public QgsTextFormatWidget, private QgsExpress
private:
QgsVectorLayer* mLayer;
const QgsPalLayerSettings* mSettings;
QgsPropertyCollection mProperties;
QgsPropertyCollection mDataDefinedProperties;
LabelMode mMode;

QgsExpressionContext createExpressionContext() const override;
@@ -150,7 +150,7 @@ void QgsLabelPropertyDialog::init( const QString& layerId, const QString& provid

disableGuiElements();

mDataDefinedProperties = layerSettings.properties();
mDataDefinedProperties = layerSettings.dataDefinedProperties();

//set widget values from data defined results
setDataDefinedValues( vlayer );
@@ -410,10 +410,10 @@ bool QgsMapToolLabel::hasDataDefinedColumn( QgsPalLayerSettings::DataDefinedProp

QString QgsMapToolLabel::dataDefinedColumnName( QgsPalLayerSettings::Property p, const QgsPalLayerSettings& labelSettings ) const
{
if ( !labelSettings.properties().isActive( p ) )
if ( !labelSettings.dataDefinedProperties().isActive( p ) )
return QString();

QgsProperty prop = labelSettings.properties().property( p );
QgsProperty prop = labelSettings.dataDefinedProperties().property( p );
if ( prop.propertyType() != QgsProperty::FieldBasedProperty )
return QString();

@@ -568,15 +568,15 @@ bool QgsMapToolLabel::diagramMoveable( QgsVectorLayer* vlayer, int& xCol, int& y
if ( dls )
{
xCol = -1;
if ( QgsProperty ddX = dls->properties().property( QgsDiagramLayerSettings::PositionX ) )
if ( QgsProperty ddX = dls->dataDefinedProperties().property( QgsDiagramLayerSettings::PositionX ) )
{
if ( ddX.propertyType() == QgsProperty::FieldBasedProperty && ddX.isActive() )
{
xCol = vlayer->fields().lookupField( ddX.field() );
}
}
yCol = -1;
if ( QgsProperty ddY = dls->properties().property( QgsDiagramLayerSettings::PositionY ) )
if ( QgsProperty ddY = dls->dataDefinedProperties().property( QgsDiagramLayerSettings::PositionY ) )
{
if ( ddY.propertyType() == QgsProperty::FieldBasedProperty && ddY.isActive() )
{
@@ -672,7 +672,7 @@ bool QgsMapToolLabel::diagramCanShowHide( QgsVectorLayer* vlayer, int& showCol )
{
if ( const QgsDiagramLayerSettings *dls = vlayer->diagramLayerSettings() )
{
if ( QgsProperty ddShow = dls->properties().property( QgsDiagramLayerSettings::Show ) )
if ( QgsProperty ddShow = dls->dataDefinedProperties().property( QgsDiagramLayerSettings::Show ) )
{
if ( ddShow.propertyType() == QgsProperty::FieldBasedProperty && ddShow.isActive() )
{
@@ -143,7 +143,7 @@ void QgsComposerHtml::loadHtml( const bool useCache, const QgsExpressionContext

//data defined url set?
bool ok = false;
currentUrl = mProperties.valueAsString( QgsComposerObject::SourceUrl, *evalContext, currentUrl, &ok );
currentUrl = mDataDefinedProperties.valueAsString( QgsComposerObject::SourceUrl, *evalContext, currentUrl, &ok );
if ( ok )
{
currentUrl = currentUrl.trimmed();
@@ -718,13 +718,13 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect, const bool resizeOn

//data defined position or size set? if so, update rect with data defined values
bool ok = false;
double ddWidth = mProperties.valueAsDouble( QgsComposerObject::ItemWidth, *evalContext, 0, &ok );
double ddWidth = mDataDefinedProperties.valueAsDouble( QgsComposerObject::ItemWidth, *evalContext, 0, &ok );
//evaulate width and height first, since they may affect position if non-top-left reference point set
if ( ok )
{
result.setWidth( ddWidth );
}
double ddHeight = mProperties.valueAsDouble( QgsComposerObject::ItemHeight, *evalContext, 0, &ok );
double ddHeight = mDataDefinedProperties.valueAsDouble( QgsComposerObject::ItemHeight, *evalContext, 0, &ok );
if ( ok )
{
result.setHeight( ddHeight );
@@ -755,7 +755,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect, const bool resizeOn
x += rect().width();
}
}
double ddPosX = mProperties.valueAsDouble( QgsComposerObject::PositionX, *evalContext, 0.0, &ok );
double ddPosX = mDataDefinedProperties.valueAsDouble( QgsComposerObject::PositionX, *evalContext, 0.0, &ok );
if ( ok )
{
x = ddPosX;
@@ -786,7 +786,7 @@ QRectF QgsComposerItem::evalItemRect( const QRectF &newRect, const bool resizeOn
y += rect().height();
}
}
double ddPosY = mProperties.valueAsDouble( QgsComposerObject::PositionY, *evalContext, 0, &ok );
double ddPosY = mDataDefinedProperties.valueAsDouble( QgsComposerObject::PositionY, *evalContext, 0, &ok );
if ( ok )
{
y = ddPosY;
@@ -873,7 +873,7 @@ void QgsComposerItem::refreshBlendMode( const QgsExpressionContext& context )

//data defined blend mode set?
bool ok = false;
QString blendStr = mProperties.valueAsString( QgsComposerObject::BlendMode, context, QString(), &ok );
QString blendStr = mDataDefinedProperties.valueAsString( QgsComposerObject::BlendMode, context, QString(), &ok );
if ( ok && !blendStr.isEmpty() )
{
QString blendstr = blendStr.trimmed();
@@ -899,7 +899,7 @@ void QgsComposerItem::refreshTransparency( const bool updateItem, const QgsExpre
int transparency = mTransparency;

//data defined transparency set?
transparency = mProperties.valueAsInt( QgsComposerObject::Transparency, context, mTransparency );
transparency = mDataDefinedProperties.valueAsInt( QgsComposerObject::Transparency, context, mTransparency );

// Set the QGraphicItem's opacity
setOpacity( 1. - ( transparency / 100. ) );
@@ -914,7 +914,7 @@ void QgsComposerItem::refreshFrameColor( const bool updateItem, const QgsExpress
{
//data defined outline color set?
bool ok = false;
QColor frameColor = mProperties.valueAsColor( QgsComposerObject::FrameColor, context, mFrameColor, &ok );
QColor frameColor = mDataDefinedProperties.valueAsColor( QgsComposerObject::FrameColor, context, mFrameColor, &ok );
if ( ok )
{
QPen itemPen = pen();
@@ -937,7 +937,7 @@ void QgsComposerItem::refreshBackgroundColor( const bool updateItem, const QgsEx
{
//data defined color set?
bool ok = false;
QColor backgroundColor = mProperties.valueAsColor( QgsComposerObject::BackgroundColor, context, mBackgroundColor, &ok );
QColor backgroundColor = mDataDefinedProperties.valueAsColor( QgsComposerObject::BackgroundColor, context, mBackgroundColor, &ok );
if ( ok )
{
setBrush( QBrush( backgroundColor, Qt::SolidPattern ) );
@@ -1016,7 +1016,7 @@ void QgsComposerItem::refreshRotation( const bool updateItem, const bool adjustP
double rotation = mItemRotation;

//data defined rotation set?
rotation = mProperties.valueAsDouble( QgsComposerObject::ItemRotation, context, rotation );
rotation = mDataDefinedProperties.valueAsDouble( QgsComposerObject::ItemRotation, context, rotation );

if ( qgsDoubleNear( rotation, mEvaluatedItemRotation ) )
{
@@ -1154,7 +1154,7 @@ void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataD
{
bool exclude = mExcludeFromExports;
//data defined exclude from exports set?
exclude = mProperties.valueAsBool( QgsComposerObject::ExcludeFromExports, *evalContext, exclude );
exclude = mDataDefinedProperties.valueAsBool( QgsComposerObject::ExcludeFromExports, *evalContext, exclude );
mEvaluatedExcludeFromExports = exclude;
}

@@ -655,7 +655,7 @@ void QgsComposerLegend::refreshDataDefinedProperty( const QgsComposerObject::Dat
if ( property == QgsComposerObject::LegendTitle || property == QgsComposerObject::AllProperties )
{
bool ok = false;
QString t = mProperties.valueAsString( QgsComposerObject::LegendTitle, *evalContext, mTitle, &ok );
QString t = mDataDefinedProperties.valueAsString( QgsComposerObject::LegendTitle, *evalContext, mTitle, &ok );
if ( ok )
{
mSettings.setTitle( t );
@@ -665,7 +665,7 @@ void QgsComposerLegend::refreshDataDefinedProperty( const QgsComposerObject::Dat
if ( property == QgsComposerObject::LegendColumnCount || property == QgsComposerObject::AllProperties )
{
bool ok = false;
int cols = mProperties.valueAsInt( QgsComposerObject::LegendColumnCount, *evalContext, mColumnCount, &ok );
int cols = mDataDefinedProperties.valueAsInt( QgsComposerObject::LegendColumnCount, *evalContext, mColumnCount, &ok );
if ( ok && cols >= 0 )
{
mSettings.setColumnCount( cols );

0 comments on commit e06192e

Please sign in to comment.