Skip to content

Commit

Permalink
Merge pull request #4426 from wonder-sk/fix-relative-paths-svg
Browse files Browse the repository at this point in the history
Fix relative paths to SVG files in embedded projects
  • Loading branch information
wonder-sk authored May 14, 2017
2 parents 93c59f4 + 590526e commit 2857ef5
Show file tree
Hide file tree
Showing 145 changed files with 1,334 additions and 931 deletions.
60 changes: 58 additions & 2 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,16 @@ all these item added events.
- addComposerMap no longer takes a setDefaultPreviewStyle argument.
- the mapsToRestore parameter has been removed from addItemsFromXml

QgsConditionalLayerStyle {#qgis_api_break_3_0_QgsConditionalLayerStyle}
------------------------

- readXml() and writeXml() require a new argument: a reference to QgsReadWriteContext

QgsConditionalStyle {#qgis_api_break_3_0_QgsConditionalStyle}
-------------------

- readXml() and writeXml() require a new argument: a reference to QgsReadWriteContext

QgsCoordinateReferenceSystem {#qgis_api_break_3_0_QgsCoordinateReferenceSystem}
----------------------------

Expand Down Expand Up @@ -920,6 +930,9 @@ QgsDiagramRenderer {#qgis_api_break_3_0_QgsDiagramRenderer}
- xform, fields were no longer required and are removed.
- referencedFields() no longer takes a QgsFields argument.
- renderDiagram() now takes an optional data defined overrides collection argument.
- readXml(), _readXml(), writeXml(), _writeXml() do not take QgsVectorLayer as an argument anymore.
- readXml(), _readXml(), writeXml(), _writeXml() require a new argument: a reference to QgsReadWriteContext



QgsDiagramLayerSettings {#qgis_api_break_3_0_QgsDiagramLayerSettings}
Expand Down Expand Up @@ -951,11 +964,13 @@ setting data defined properties instead.
- The renderer member variable was removed, and getRenderer() was renamed to renderer()
- The showAll member variable was removed. setShowAllDiagrams() and showAllDiagrams() should be used instead.
- referencedFields() no longer requires a QgsFields argument.
- readXml() and writeXml() do not take QgsVectorLayer as an argument anymore.

QgsDiagramSettings {#qgis_api_break_3_0_QgsDiagramSettings}
------------------

- The SizeType enum was removed. Use QgsUnitTypes.RenderUnit instead.
- readXml() and writeXml() do not take QgsVectorLayer as an argument anymore.

QgsDial {#qgis_api_break_3_0_QgsDial}
-------
Expand Down Expand Up @@ -1095,6 +1110,8 @@ QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
- originalSymbolsForFeature( QgsFeature& feat ) has been removed. The originalSymbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) method should be used instead (previously available as originalSymbolsForFeature2 in PyQGIS bindings).
- copyPaintEffect() was removed. copyRendererData() should be used instead.
- usedAttributes() now requires a QgsRenderContext argument.
- save() expects QgsReadWriteContext reference as the last argument
- static create() method in subclasses expects QgsReadWriteContext reference as the last argument


QgsFeatureRequest {#qgis_api_break_3_0_QgsFeatureRequest}
Expand Down Expand Up @@ -1280,7 +1297,7 @@ QgsLayerDefinition {#qgis_api_break_3_0_QgsLayerDefinition}
------------------

- loadLayerDefinition() now also requires QgsProject as the second argument
- loadLayerDefinition() and exportLayerDefinition() variants that take QDomDocument as the first argument now expect QgsPathResolver as the last argument
- loadLayerDefinition() and exportLayerDefinition() variants that take QDomDocument as the first argument now expect QgsReadWriteContext as the last argument


QgsLayerPropertiesWidget {#qgis_api_break_3_0_QgsLayerPropertiesWidget}
Expand Down Expand Up @@ -1413,7 +1430,10 @@ screenUpdateRequested() were removed. These members have had no effect for a num
- capitaliseLayerName() was renamed to capitalizeLayerName() <!--#spellok-->
- asLayerDefinition(), fromLayerDefinition(), fromLayerDefinitionFile() were moved to QgsLayerDefinition class and renamed to exportLayerDefinitionLayers() resp. loadLayerDefinitionLayers()
- loadNamedStyleFromDb() was renamed to loadNamedStyleFromDatabase()
- readLayerXml() and writeLayerXml() expect QgsPathResolver reference as the last argument
- readLayerXml() and writeLayerXml() expect QgsReadWriteContext reference as the last argument
- readSymbology() and writeSymbology() expect QgsReadWriteContext reference as the last argument
- readStyle() and writeStyle() expect QgsReadWriteContext reference as the last argument
- readXml() and writeXml() expect QgsReadWriteContext reference as the last argument
- the invalidTransformInput() slot was removed - calling this slot had no effect
- metadata() was renamed to htmlMetadata()

Expand Down Expand Up @@ -1624,6 +1644,7 @@ dataDefinedValue(), dataDefinedEvaluate(), dataDefinedIsActive(),
dataDefinedUseExpression(), dataDefinedProperties() and dataDefinedNames()
members were removed. Use the QgsProperty framework through dataDefinedProperties()
and setDataDefinedProperties() instead.
- readXml() and writeXml() now expect a reference to QgsReadWriteContext.


QgsPanelWidgetStack {#qgis_api_break_3_0_QgsPanelWidgetStack}
Expand Down Expand Up @@ -1941,11 +1962,39 @@ QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache}
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::svgCache() to access an application-wide cache.
- containsParamsV2() was removed. Use containsParamsV3() instead.
- The rasterScaleFactor parameter was removed from all methods
- svgAsImage(), svgAsPicture(), svgViewboxSize(), svgContent(), insertSvg(), cacheEntry() only accept absolute path to SVG file (relative paths will not be resolved).

QgsSvgCacheEntry {#qgis_api_break_3_0_QgsSvgCacheEntry}
----------------

- The rasterScaleFactor member was removed.
- The lookupKey member was removed.
- The "file" member has been renamed to "path".
- Constructor does not take lookup key as an optional last argument


QgsSVGFillSymbolLayer {#qgis_api_break_3_0_QgsSVGFillSymbolLayer}
---------------------

- The first argument of the constructor (svgFilePath) does not have default value anymore.

QgsSvgMarkerSymbolLayer {#qgis_api_break_3_0_QgsSvgMarkerSymbolLayer}
-----------------------

- The first argument of the constructor (path) does not have a default value anymore.

QgsSvgSelectorWidget {#qgis_api_break_3_0_QgsSvgSelectorWidget}
--------------------

- create() has been removed - use ordinary constructor instead.
- currentSvgPathToName() has been removed - absolute paths are always used.
- groupsTreeView(), imagesListView(), filePathLineEdit(), filePathButton(), relativePathCheckbox(), selectorLayout() have been removed as they were leaking implementation details.

QgsSvgSelectorDialog {#qgis_api_break_3_0_QgsSvgSelectorDialog}
--------------------

- layout(), buttonBox() has been removed as they were leaking implementation details.


QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
----------------------------------
Expand Down Expand Up @@ -2022,6 +2071,8 @@ QgsSymbolLayerUtils (renamed from QgsSymbolLayerUtilsV2) {#qgis_api_break
- pixelSizeScaleFactor() was removed. Use QgsRenderContext::convertToPainterUnits() instead.
- mapUnitScaleFactor() was removed. Use QgsRenderContext::convertToMapUnits() instead.
- estimateMaxSymbolBleed() now requires a QgsRenderContext argument (since the bleed depends on render context for non-pixel units)
- loadSymbol(), saveSymbol(), loadSymbols(), saveSymbols(), loadSymbolLayer() now require a reference to QgsReadWriteContext
- symbolNameToPath() and symbolPathToName() have been renamed to svgSymbolNameToPath() and svgSymbolPathToName() and they require reference to QgsPathResolver


QgsSymbolSelectorWidget {#qgis_api_break_3_0_QgsSymbolSelectorWidget}
Expand Down Expand Up @@ -2251,6 +2302,11 @@ optional property map passing down layer level properties to the SLD encoders. I
- setScaleMethodToSymbol was removed. This is now handled using data defined scaling at a symbol layer level
- usedAttributes is now a const method and returns QSet<QString> instead of QStringList

QgsRendererAbstractMetadata {#qgis_api_break_3_0_QgsRendererAbstractMetadata}
---------------------------

- createRenderer() now expects a reference to QgsReadWriteContext as the second argument


Processing {#qgis_api_break_3_0_Processing}
----------
Expand Down
8 changes: 4 additions & 4 deletions python/core/annotations/qgsannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class QgsAnnotation : QObject

void render( QgsRenderContext &context ) const;

virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const = 0;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc ) = 0;
virtual void writeXml( QDomElement& elem, QDomDocument & doc, const QgsReadWriteContext &context ) const = 0;
virtual void readXml( const QDomElement& itemElem, const QgsReadWriteContext &context ) = 0;

void setMarkerSymbol( QgsMarkerSymbol *symbol /Transfer/ );
QgsMarkerSymbol *markerSymbol() const;
Expand All @@ -80,8 +80,8 @@ class QgsAnnotation : QObject

virtual QSizeF minimumFrameSize() const;

void _writeXml( QDomElement &itemElem, QDomDocument &doc ) const;
void _readXml( const QDomElement &annotationElem, const QDomDocument &doc );
void _writeXml( QDomElement& itemElem, QDomDocument& doc, const QgsReadWriteContext &context ) const;
void _readXml( const QDomElement& annotationElem, const QgsReadWriteContext &context );

void copyCommonProperties( QgsAnnotation *target ) const;

Expand Down
4 changes: 2 additions & 2 deletions python/core/annotations/qgsannotationmanager.sip
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ class QgsAnnotationManager : QObject
:rtype: list of QgsAnnotation
%End

bool readXml( const QDomElement &element, const QDomDocument &doc );
bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
%Docstring
Reads the manager's state from a DOM element, restoring all annotations
present in the XML document.
.. seealso:: writeXml()
:rtype: bool
%End

QDomElement writeXml( QDomDocument &doc ) const;
QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Returns a DOM element representing the state of the manager.
.. seealso:: readXml()
Expand Down
4 changes: 2 additions & 2 deletions python/core/annotations/qgshtmlannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class QgsHtmlAnnotation: QgsAnnotation
:rtype: str
%End

virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );
virtual void writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const;
virtual void readXml( const QDomElement &itemElem, const QgsReadWriteContext &context );

virtual void setAssociatedFeature( const QgsFeature &feature );

Expand Down
4 changes: 2 additions & 2 deletions python/core/annotations/qgssvgannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class QgsSvgAnnotation: QgsAnnotation
virtual QgsSvgAnnotation *clone() const /Factory/;


virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );
virtual void writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const;
virtual void readXml( const QDomElement &itemElem, const QgsReadWriteContext &context );

void setFilePath( const QString &file );
%Docstring
Expand Down
4 changes: 2 additions & 2 deletions python/core/annotations/qgstextannotation.sip
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class QgsTextAnnotation: QgsAnnotation
.. seealso:: document()
%End

virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );
virtual void writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const;
virtual void readXml( const QDomElement &itemElem, const QgsReadWriteContext &context );

static QgsTextAnnotation *create() /Factory/;
%Docstring
Expand Down
1 change: 1 addition & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
%Include qgsproviderregistry.sip
%Include qgspythonrunner.sip
%Include qgsrange.sip
%Include qgsreadwritecontext.sip
%Include qgsrelation.sip
%Include qgsrelationmanager.sip
%Include qgsrenderchecker.sip
Expand Down
8 changes: 4 additions & 4 deletions python/core/qgsconditionalstyle.sip
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class QgsConditionalLayerStyles
:rtype: list of QgsConditionalStyle
%End

bool readXml( const QDomNode &node );
bool readXml( const QDomNode &node, const QgsReadWriteContext &context );
%Docstring
Reads field ui properties specific state from Dom node.
:rtype: bool
%End

bool writeXml( QDomNode &node, QDomDocument &doc ) const;
bool writeXml( QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Write field ui properties specific state from Dom node.
:rtype: bool
Expand Down Expand Up @@ -244,13 +244,13 @@ class QgsConditionalStyle
:rtype: QgsConditionalStyle
%End

bool readXml( const QDomNode &node );
bool readXml( const QDomNode &node, const QgsReadWriteContext &context );
%Docstring
Reads vector conditional style specific state from layer Dom node.
:rtype: bool
%End

bool writeXml( QDomNode &node, QDomDocument &doc ) const;
bool writeXml( QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Write vector conditional style specific state from layer Dom node.
:rtype: bool
Expand Down
26 changes: 13 additions & 13 deletions python/core/qgsdiagramrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ class QgsDiagramLayerSettings
*/
void setShowAllDiagrams( bool showAllDiagrams );

void readXml( const QDomElement &elem, const QgsVectorLayer *layer );
void writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer ) const;
bool prepare( const QgsExpressionContext &context = QgsExpressionContext() ) const;
void readXml( const QDomElement& elem );
void writeXml( QDomElement& layerElem, QDomDocument& doc ) const;
bool prepare( const QgsExpressionContext& context = QgsExpressionContext() ) const;

/** Returns the set of any fields referenced by the layer's diagrams.
* @param context expression context the diagrams will be drawn using
Expand Down Expand Up @@ -294,8 +294,8 @@ class QgsDiagramSettings
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXml( const QDomElement &elem, const QgsVectorLayer *layer );
void writeXml( QDomElement &rendererElem, QDomDocument &doc, const QgsVectorLayer *layer ) const;
void readXml( const QDomElement& elem );
void writeXml( QDomElement& rendererElem, QDomDocument& doc ) const;

/** Returns list of legend nodes for the diagram
* @note caller is responsible for deletion of QgsLayerTreeModelLegendNodes
Expand Down Expand Up @@ -365,8 +365,8 @@ class QgsDiagramRenderer
/** Returns list with all diagram settings in the renderer*/
virtual QList<QgsDiagramSettings> diagramSettings() const = 0;

virtual void readXml( const QDomElement &elem, const QgsVectorLayer *layer ) = 0;
virtual void writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer ) const = 0;
virtual void readXml( const QDomElement& elem, const QgsReadWriteContext &context ) = 0;
virtual void writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsReadWriteContext &context ) const = 0;

/** Returns list of legend nodes for the diagram
* @note caller is responsible for deletion of QgsLayerTreeModelLegendNodes
Expand Down Expand Up @@ -442,8 +442,8 @@ class QgsDiagramRenderer
static int dpiPaintDevice( const QPainter* );

//read / write diagram
void _readXml( const QDomElement &elem, const QgsVectorLayer *layer );
void _writeXml( QDomElement &rendererElem, QDomDocument &doc, const QgsVectorLayer *layer ) const;
void _readXml( const QDomElement& elem, const QgsReadWriteContext &context );
void _writeXml( QDomElement& rendererElem, QDomDocument& doc, const QgsReadWriteContext &context ) const;
};

/** Renders the diagrams for all features with the same settings*/
Expand All @@ -467,8 +467,8 @@ class QgsSingleCategoryDiagramRenderer : QgsDiagramRenderer

QList<QgsDiagramSettings> diagramSettings() const;

void readXml( const QDomElement &elem, const QgsVectorLayer *layer );
void writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer ) const;
void readXml( const QDomElement& elem, const QgsReadWriteContext &context );
void writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsReadWriteContext &context ) const;

virtual QList< QgsLayerTreeModelLegendNode * > legendItems( QgsLayerTreeLayer *nodeLayer ) const /Factory/;

Expand Down Expand Up @@ -533,8 +533,8 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRenderer
bool classificationAttributeIsExpression() const;
void setClassificationAttributeIsExpression( bool isExpression );

void readXml( const QDomElement &elem, const QgsVectorLayer *layer );
void writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer ) const;
void readXml( const QDomElement& elem, const QgsReadWriteContext &context );
void writeXml( QDomElement& layerElem, QDomDocument& doc, const QgsReadWriteContext &context ) const;

virtual QList< QgsLayerTreeModelLegendNode * > legendItems( QgsLayerTreeLayer *nodeLayer ) const /Factory/;

Expand Down
12 changes: 6 additions & 6 deletions python/core/qgslayerdefinition.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class QgsLayerDefinition
#include <qgslayerdefinition.h>
%End
public:
static bool loadLayerDefinition( const QString &path, QgsProject *project, QgsLayerTreeGroup *rootGroup, QString &errorMessage /Out/ );
static bool loadLayerDefinition( QDomDocument doc, QgsProject *project, QgsLayerTreeGroup *rootGroup, QString &errorMessage /Out/, const QgsPathResolver &pathResolver );
static bool exportLayerDefinition( QString path, const QList<QgsLayerTreeNode*> &selectedTreeNodes, QString &errorMessage /Out/ );
static bool exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode*> &selectedTreeNodes, QString &errorMessage /Out/, const QgsPathResolver &pathResolver );
static bool loadLayerDefinition( const QString & path, QgsProject* project, QgsLayerTreeGroup* rootGroup, QString &errorMessage /Out/ );
static bool loadLayerDefinition( QDomDocument doc, QgsProject* project, QgsLayerTreeGroup* rootGroup, QString &errorMessage /Out/, const QgsReadWriteContext &context );
static bool exportLayerDefinition( QString path, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage /Out/ );
static bool exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage /Out/, const QgsReadWriteContext &context );

static QDomDocument exportLayerDefinitionLayers( const QList<QgsMapLayer*> &layers, const QgsPathResolver &pathResolver );
static QList<QgsMapLayer*> loadLayerDefinitionLayers( QDomDocument &document, const QgsPathResolver &pathResolver ) /Factory/;
static QDomDocument exportLayerDefinitionLayers( const QList<QgsMapLayer*>& layers, const QgsReadWriteContext &context );
static QList<QgsMapLayer*> loadLayerDefinitionLayers( QDomDocument& document, const QgsReadWriteContext &context ) /Factory/;
static QList<QgsMapLayer*> loadLayerDefinitionLayers( const QString &qlrfile ) /Factory/;

/**
Expand Down
Loading

0 comments on commit 2857ef5

Please sign in to comment.