Skip to content

Commit ea116fd

Browse files
authored
Merge pull request #2857 from nyalldawson/properties2
Properties framework
2 parents 5753576 + 69d10fa commit ea116fd

File tree

243 files changed

+10240
-5310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+10240
-5310
lines changed

doc/api_break.dox

+68-5
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,13 @@ QgsComposerNodesItem {#qgis_api_break_3_0_QgsComposerNodesItem}
596596
- _writeXMLStyle() has been renamed to _writeXMLStyle()
597597
- unselectNode() has been renamed to deselectNode() <!--#spellok-->
598598

599+
QgsComposerObject {#qgis_api_break_3_0_QgsComposerObject}
600+
-----------------
601+
602+
- dataDefinedProperty() and setDataDefinedProperty() no longer use QgsDataDefined objects.
603+
Instead these methods have been ported to the QgsProperty framework.
604+
- dataDefinedEvaluate() was removed. Use the QgsProperty evaluation methods instead.
605+
599606

600607
QgsComposerPicture {#qgis_api_break_3_0_QgsComposerPicture}
601608
------------------
@@ -610,6 +617,13 @@ QgsComposerObject::dataDefinedProperty instead.
610617
QgsComposerObject::setDataDefinedProperty() instead.
611618
- updatePictureExpression() was removed.
612619

620+
QgsComposerScaleBar {#qgis_api_break_3_0_QgsComposerScaleBar}
621+
-------------------
622+
623+
- setBrush() was removed. Use setFillColor() instead.
624+
- setBrush2() was removed. Use setFillColor2() instead.
625+
- setPen() was removed. Use setLineColor() and setLineWidth() instead.
626+
613627

614628
QgsComposerTable {#qgis_api_break_3_0_QgsComposerTable}
615629
----------------
@@ -633,6 +647,16 @@ QgsComposerTableV2 {#qgis_api_break_3_0_QgsComposerTableV2}
633647
- unselectNode() has been renamed to deselectNode() <!--#spellok-->
634648

635649

650+
QgsComposerUtils {#qgis_api_break_3_0_QgsComposerUtils}
651+
-----------------
652+
653+
- readDataDefinedPropertyMap() was renamed to readOldDataDefinedPropertyMap() and the signature has changed
654+
to use a QgsPropertyCollection object.
655+
- readDataDefinedProperty() was renamed to readOldDataDefinedProperty() and the signature has changed
656+
to use the QgsProperty framework objects.
657+
- writeDataDefinedPropertyMap() was removed. This is now handled by QgsPropertyCollection::writeXml()
658+
659+
636660
QgsComposition {#qgis_api_break_3_0_QgsComposition}
637661
--------------
638662

@@ -648,6 +672,8 @@ were removed. Use setSnapTolerance() and snapTolerance() instead.
648672
- addComposerTable(), composerTableAdded() were removed.
649673
- setAllUnselected() has been renamed to setAllDeselected. <!--#spellok-->
650674
- worldFileMap() and setWorldFileMap() have been renamed to referenceMap() and setReferenceMap()
675+
- dataDefinedProperty() and setDataDefinedProperty() now use the QgsProperty framework instead
676+
of QgsDataDefined objects.
651677

652678

653679
QgsCoordinateReferenceSystem {#qgis_api_break_3_0_QgsCoordinateReferenceSystem}
@@ -751,14 +777,19 @@ QgsDataDefinedButton {#qgis_api_break_3_0_QgsDataDefinedButton}
751777
- registerGetExpressionContextCallback has been removed in favor of registerExpressionContextGenerator
752778

753779

754-
755780
QgsDataDefinedSymbolDialog {#qgis_api_break_3_0_QgsDataDefinedSymbolDialog}
756781
--------------------------
757782

758783
- QgsDataDefinedSymbolDialog was removed. Code using this dialog should be reworked to use QgsDataDefinedButton
759784
instead.
760785

761786

787+
QgsDataDefinedValueDialog {#qgis_api_break_3_0_QgsDataDefinedValueDialog}
788+
--------------------------
789+
790+
- These classes and subclasses now use QgsProperty objects instead of QgsDataDefined.
791+
792+
762793
QgsDataItem {#qgis_api_break_3_0_QgsDataItem}
763794
-----------
764795

@@ -813,6 +844,7 @@ QgsDiagramRenderer {#qgis_api_break_3_0_QgsDiagramRenderer}
813844
------------------
814845
- xform, fields were no longer required and are removed.
815846
- referencedFields() no longer takes a QgsFields argument.
847+
- renderDiagram() now takes an optional data defined overrides collection argument.
816848

817849

818850
QgsDiagramLayerSettings {#qgis_api_break_3_0_QgsDiagramLayerSettings}
@@ -832,6 +864,18 @@ place of a null pointer.
832864
- The dist member variable was removed. setDistance() and distance() should be used instead.
833865
- The renderer member variable was removed, and getRenderer() was renamed to renderer()
834866
- The showAll member variable was removed. setShowAllDiagrams() and showAllDiagrams() should be used instead.
867+
- The xPosColumn, yPosColumn and showColumn attributes were removed. Use setDataDefinedProperties() for
868+
setting data defined properties instead.
869+
- The LinePlacementFlags enum was renamed to LinePlacementFlag
870+
- The placement member variable was removed, and getPlacement() was renamed to placement()
871+
- The placementFlags member variable was removed
872+
- The priority member variable was removed, and getPriority() was renamed to priority()
873+
- The zIndex member variable was removed, and getZIndex() was renamed to zIndex()
874+
- The obstacle member variable was removed. setIsObstacle() and isObstacle() should be used instead.
875+
- The dist member variable was removed. setDistance() and distance() should be used instead.
876+
- The renderer member variable was removed, and getRenderer() was renamed to renderer()
877+
- The showAll member variable was removed. setShowAllDiagrams() and showAllDiagrams() should be used instead.
878+
- referencedFields() no longer requires a QgsFields argument.
835879

836880
QgsDiagramSettings {#qgis_api_break_3_0_QgsDiagramSettings}
837881
------------------
@@ -957,6 +1001,8 @@ QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
9571001
- symbolsForFeature( QgsFeature& feat ) has been removed. The symbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) method should be used instead (previously available as symbolsForFeature2 in PyQGIS bindings).
9581002
- originalSymbolsForFeature( QgsFeature& feat ) has been removed. The originalSymbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) method should be used instead (previously available as originalSymbolsForFeature2 in PyQGIS bindings).
9591003
- copyPaintEffect() was removed. copyRendererData() should be used instead.
1004+
- usedAttributes() now requires a QgsRenderContext argument.
1005+
9601006

9611007
QgsFeatureRequest {#qgis_api_break_3_0_QgsFeatureRequest}
9621008
-----------------
@@ -1406,6 +1452,13 @@ QgsPalLayerSettings {#qgis_api_break_3_0_QgsPalLayerSettings}
14061452
- ct is now a QgsCoordinateTransform object, not a pointer. An invalid QgsCoordinateTransform will
14071453
be used instead of a null pointer if no transformation is required.
14081454
- prepareGeometry() and geometryRequiresPreparation() now take a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.
1455+
- The DataDefinedProperties enum was renamed to Property
1456+
- dataDefinedProperty(), setDataDefinedProperty(), removeDataDefinedProperty(),
1457+
removeAllDataDefinedProperties(), updateDataDefinedString(), dataDefinedMap(),
1458+
dataDefinedValue(), dataDefinedEvaluate(), dataDefinedIsActive(),
1459+
dataDefinedUseExpression(), dataDefinedProperties() and dataDefinedNames()
1460+
members were removed. Use the QgsProperty framework through dataDefinedProperties()
1461+
and setDataDefinedProperties() instead.
14091462

14101463

14111464
QgsPanelWidgetStack {#qgis_api_break_3_0_QgsPanelWidgetStack}
@@ -1678,17 +1731,26 @@ parameters or QgsSymbol::OutputUnitList parameters now take QgsUnitTypes::Render
16781731
data defined rotation.
16791732
- setRenderHints() and renderHints() now accept and return a QgsSymbol::RenderHints flag rather
16801733
than an integer value
1734+
- usedAttributes() now requires a QgsRenderContext argument.
1735+
- setDataDefinedAngle(), dataDefinedAngle(), setDataDefinedSize(), dataDefinedSize(), setDataDefinedWidth() and dataDefinedWidth()
1736+
now work with QgsProperty objects instead of QgsDataDefined.
16811737

16821738

16831739
QgsSymbolLayer (renamed from QgsSymbolLayerV2) {#qgis_api_break_3_0_QgsSymbolLayer}
16841740
----------------------------------------------
16851741

16861742
- The deprecated prepareExpressions( const QgsFields* fields, double scale = -1.0 ) method has been removed. Use
16871743
the variant which takes QgsSymbolRenderContext instead.
1688-
- The deprecated methods dataDefinedProperty( const QString& property ) and dataDefinedPropertyString() were removed. Use getDataDefinedProperty() instead.
1689-
- setDataDefinedProperty( const QString& property, const QString& expressionString ) was removed. Use setDataDefinedProperty( const QString& property, QgsDataDefined* dataDefined ) instead.
1690-
- evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature ) was removed. Use the variant which takes QgsSymbolRenderContext instead.
1691-
- expression() was removed. Use getDataDefinedProperty or evaluateDataDefinedProperty instead.
1744+
- The deprecated methods dataDefinedProperty( const QString& property ) and dataDefinedPropertyString() were removed. Use dataDefinedProperties() instead.
1745+
- setDataDefinedProperty now requires a QgsSymbolLayer.Property argument instead of the string based key.
1746+
- removeDataDefinedProperty(), removeDataDefinedProperties(), hasDataDefinedProperties(), hasDataDefinedProperty(), evaluateDataDefinedProperty()
1747+
were removed. Use the QgsProperty/QgsPropertyCollection methods instead.
1748+
- getDataDefinedProperty() was removed. Use dataDefinedProperties() instead.
1749+
- expression() was removed.
1750+
- usedAttributes() now requires a QgsRenderContext argument
1751+
- saveDataDefinedProperties() was removed. This is no longer required.
1752+
- restoreDataDefinedProperties() was renamed to restoreOldDataDefinedProperties()
1753+
16921754

16931755
QgsSymbolLayerRegistry {#qgis_api_break_3_0_QgsSymbolLayerRegistry}
16941756
----------------------
@@ -1729,6 +1791,7 @@ QgsSymbolSelectorWidget {#qgis_api_break_3_0_QgsSymbolSelectorWidget}
17291791
-----------------------
17301792

17311793
- saveSymbol() was removed.
1794+
- registerDataDefinedButton now works with QgsPropertyOverrideButton and QgsProperty keys
17321795

17331796

17341797
QgsSymbolSelectorDialog {#qgis_api_break_3_0_QgsSymbolSelectorDialog}

python/core/composer/qgscomposerlegend.sip

+4
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,13 @@ class QgsComposerLegend : QgsComposerItem
242242
//Overridden to show legend title
243243
virtual QString displayName() const;
244244

245+
const QgsLegendSettings& legendSettings() const;
246+
245247
public slots:
246248
/** Data changed*/
247249
void synchronizeWithModel();
248250
/** Sets mCompositionMap to 0 if the map is deleted*/
249251
void invalidateCurrentMap();
252+
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr );
253+
250254
};

python/core/composer/qgscomposerobject.sip

+29-24
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class QgsComposerObject : QObject, QgsExpressionContextGenerator
3232
Transparency, /*!< item transparency */
3333
BlendMode, /*!< item blend mode */
3434
ExcludeFromExports, /*!< exclude item from exports */
35+
FrameColor, //!< Item frame color
36+
BackgroundColor, //!< Item background color
3537
//composer map
3638
MapRotation, /*!< map rotation */
3739
MapScale, /*!< map scale */
@@ -44,10 +46,22 @@ class QgsComposerObject : QObject, QgsExpressionContextGenerator
4446
MapStylePreset, /*!< layer and style visibility preset */
4547
//composer picture
4648
PictureSource, /*!< picture source url */
49+
PictureSvgBackgroundColor, //!< SVG background color
50+
PictureSvgOutlineColor, //!< SVG outline color
51+
PictureSvgOutlineWidth, //!< SVG outline width
4752
//html item
4853
SourceUrl /*!< html source url */
54+
//legend item
55+
LegendTitle, //!< Legend title
56+
LegendColumnCount, //!< Legend column count
57+
ScalebarFillColor, //!< Scalebar fill color
58+
ScalebarFillColor2, //!< Scalebar secondary fill color
59+
ScalebarLineColor, //!< Scalebar line color
60+
ScalebarLineWidth, //!< Scalebar line width
4961
};
5062

63+
static const QgsPropertiesDefinition PROPERTY_DEFINITIONS;
64+
5165
/** Specifies whether the value returned by a function should be the original, user
5266
* set value, or the current evaluated value for the property. This may differ if
5367
* a property has a data defined expression active.
@@ -84,21 +98,24 @@ class QgsComposerObject : QObject, QgsExpressionContextGenerator
8498
*/
8599
virtual bool readXml( const QDomElement& itemElem, const QDomDocument& doc );
86100

87-
/** Returns a reference to the data defined settings for one of the item's data defined properties.
88-
* @param property data defined property to return
89-
* @note this method was added in version 2.5
101+
/** Returns a reference to the object's property collection, used for data defined overrides.
102+
* @note added in QGIS 3.0
103+
* @see setDataDefinedProperties()
90104
*/
91-
QgsDataDefined* dataDefinedProperty( const DataDefinedProperty property ) const;
105+
QgsPropertyCollection& dataDefinedProperties();
92106

93-
/** Sets parameters for a data defined property for the item
94-
* @param property data defined property to set
95-
* @param active true if data defined property is active, false if it is disabled
96-
* @param useExpression true if the expression should be used
97-
* @param expression expression for data defined property
98-
* @param field field name if the data defined property should take its value from a field
99-
* @note this method was added in version 2.5
107+
/** Returns a reference to the object's property collection, used for data defined overrides.
108+
* @note added in QGIS 3.0
109+
* @see setDataDefinedProperties()
110+
*/
111+
//const QgsPropertyCollection& dataDefinedProperties() const;
112+
113+
/** Sets the objects's property collection, used for data defined overrides.
114+
* @param collection property collection. Existing properties will be replaced.
115+
* @note added in QGIS 3.0
116+
* @see dataDefinedProperties()
100117
*/
101-
void setDataDefinedProperty( const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field );
118+
void setDataDefinedProperties( const QgsPropertyCollection& collection );
102119

103120
/** Set a custom property for the object.
104121
* @param key property key. If a property with the same key already exists it will be overwritten.
@@ -159,18 +176,6 @@ class QgsComposerObject : QObject, QgsExpressionContextGenerator
159176
*/
160177
virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties, const QgsExpressionContext* context = 0 );
161178

162-
protected:
163-
164-
/** Evaluate a data defined property and return the calculated value
165-
* @returns true if data defined property could be successfully evaluated
166-
* @param property data defined property to evaluate
167-
* @param expressionValue QVariant for storing the evaluated value
168-
* @param context expression context for evaluating expressions. Must have feature and fields set to current
169-
* atlas feature and coverage layer fields prior to calling this method.
170-
* @note this method was added in version 2.5
171-
*/
172-
bool dataDefinedEvaluate( const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, const QgsExpressionContext& context = QgsExpressionContext() ) const;
173-
174179
signals:
175180
/** Emitted when the item changes. Signifies that the item widgets must update the
176181
* gui elements.

python/core/composer/qgscomposerscalebar.sip

+53-23
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,65 @@ class QgsComposerScaleBar: QgsComposerItem
134134
*/
135135
void setFontColor( const QColor& c );
136136

137+
/** Returns the color used for fills in the scalebar.
138+
* @see setFillColor()
139+
* @see fillColor2()
140+
* @note added in QGIS 3.0
141+
*/
142+
QColor fillColor() const;
143+
144+
/** Sets the color used for fills in the scalebar.
145+
* @see fillColor()
146+
* @see setFillColor2()
147+
* @note added in QGIS 3.0
148+
*/
149+
void setFillColor( const QColor& color );
150+
151+
/** Returns the secondary color used for fills in the scalebar.
152+
* @see setFillColor2()
153+
* @see fillColor()
154+
* @note added in QGIS 3.0
155+
*/
156+
QColor fillColor2() const;
157+
158+
/** Sets the secondary color used for fills in the scalebar.
159+
* @see fillColor2()
160+
* @see setFillColor2()
161+
* @note added in QGIS 3.0
162+
*/
163+
void setFillColor2( const QColor& color );
164+
165+
/** Returns the color used for lines in the scalebar.
166+
* @see setLineColor()
167+
* @note added in QGIS 3.0
168+
*/
169+
QColor lineColor() const;
170+
171+
/** Sets the color used for lines in the scalebar.
172+
* @see lineColor()
173+
* @note added in QGIS 3.0
174+
*/
175+
void setLineColor( const QColor& color );
176+
177+
/** Returns the line width in millimeters for lines in the scalebar.
178+
* @see setLineWidth()
179+
* @note added in QGIS 3.0
180+
*/
181+
double lineWidth() const;
182+
183+
/** Sets the line width in millimeters for lines in the scalebar.
184+
* @see lineWidth()
185+
* @note added in QGIS 3.0
186+
*/
187+
void setLineWidth( double width );
188+
137189
/** Returns the pen used for drawing the scalebar.
138190
* @returns QPen used for drawing the scalebar outlines.
139191
* @see setPen
140192
* @see brush
141193
*/
142194
QPen pen() const;
143195

144-
/** Sets the pen used for drawing the scalebar.
145-
* @param pen QPen to use for drawing the scalebar outlines.
146-
* @see pen
147-
* @see setBrush
148-
*/
149-
void setPen( const QPen& pen );
150-
151196
/** Returns the primary brush for the scalebar.
152197
* @returns QBrush used for filling the scalebar
153198
* @see setBrush
@@ -156,14 +201,6 @@ class QgsComposerScaleBar: QgsComposerItem
156201
*/
157202
QBrush brush() const;
158203

159-
/** Sets primary brush for the scalebar.
160-
* @param brush QBrush to use for filling the scalebar
161-
* @see brush
162-
* @see setBrush2
163-
* @see setPen
164-
*/
165-
void setBrush( const QBrush& brush );
166-
167204
/** Returns the secondary brush for the scalebar. This is used for alternating color style scalebars, such
168205
* as single and double box styles.
169206
* @returns QBrush used for secondary color areas
@@ -172,14 +209,6 @@ class QgsComposerScaleBar: QgsComposerItem
172209
*/
173210
QBrush brush2() const;
174211

175-
/** Sets secondary brush for the scalebar. This is used for alternating color style scalebars, such
176-
* as single and double box styles.
177-
* @param brush QBrush to use for secondary color areas
178-
* @see brush2
179-
* @see setBrush
180-
*/
181-
void setBrush2( const QBrush& brush );
182-
183212
double height() const;
184213
void setHeight( double h );
185214

@@ -280,6 +309,7 @@ class QgsComposerScaleBar: QgsComposerItem
280309
void updateSegmentSize();
281310
/** Sets mCompositionMap to 0 if the map is deleted*/
282311
void invalidateCurrentMap();
312+
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr );
283313

284314
protected:
285315
/** Calculates with of a segment in mm and stores it in mSegmentMillimeters*/

0 commit comments

Comments
 (0)