mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
select categories in copy style in legend menu entry
not working yet, just set the menu entries QgsMapLayerStyle::StyleCategory has moved to QgsMapLayer to avoid making QgsMapLayerStyle a QObject and they are mostly used in QgsMapLayer
This commit is contained in:
parent
4e584113c4
commit
15e0d873d9
@ -2,3 +2,6 @@
|
||||
QgsMapLayer.LayerFlag.baseClass = QgsMapLayer
|
||||
QgsMapLayer.LayerFlags.baseClass = QgsMapLayer
|
||||
LayerFlags = QgsMapLayer # dirty hack since SIP seems to introduce the flags in module
|
||||
QgsMapLayer.StyleCategory.baseClass = QgsMapLayer
|
||||
QgsMapLayer.StyleCategories.baseClass = QgsMapLayer
|
||||
StyleCategories = QgsMapLayer # dirty hack since SIP seems to introduce the flags in module
|
||||
|
@ -1,4 +0,0 @@
|
||||
# The following has been generated automatically from src/core/qgsmaplayerstyle.h
|
||||
QgsMapLayerStyle.StyleCategory.baseClass = QgsMapLayerStyle
|
||||
QgsMapLayerStyle.StyleCategories.baseClass = QgsMapLayerStyle
|
||||
StyleCategories = QgsMapLayerStyle # dirty hack since SIP seems to introduce the flags in module
|
@ -110,9 +110,9 @@ QgsMeshLayer cannot be copied.
|
||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
|
||||
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
|
||||
|
||||
virtual QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const;
|
||||
|
@ -75,6 +75,33 @@ This is the base class for all map layer types (vector, raster).
|
||||
typedef QFlags<QgsMapLayer::LayerFlag> LayerFlags;
|
||||
|
||||
|
||||
enum StyleCategory
|
||||
{
|
||||
LayerConfiguration,
|
||||
Symbology,
|
||||
Labels,
|
||||
Fields,
|
||||
Forms,
|
||||
Actions,
|
||||
MapTips,
|
||||
Diagrams,
|
||||
AttributeTable,
|
||||
Rendering,
|
||||
CustomProperties,
|
||||
AllCategories
|
||||
};
|
||||
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;
|
||||
|
||||
|
||||
struct ReadableStyleCategory
|
||||
{
|
||||
public:
|
||||
ReadableStyleCategory( const QString &name, const QString &toolTip = QString() );
|
||||
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
};
|
||||
|
||||
QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, const QString &name = QString(), const QString &source = QString() );
|
||||
%Docstring
|
||||
Constructor for QgsMapLayer
|
||||
@ -137,6 +164,15 @@ Returns the extension of a Property.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
static ReadableStyleCategory readableStyleCategory( StyleCategory category );
|
||||
%Docstring
|
||||
Readable and Translated category
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
|
||||
|
||||
QString id() const;
|
||||
%Docstring
|
||||
Returns the layer's unique ID, which is used to access this layer from :py:class:`QgsProject`.
|
||||
@ -784,7 +820,7 @@ Import the properties of this layer from a QDomDocument
|
||||
%End
|
||||
|
||||
virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
%Docstring
|
||||
Export the properties of this layer as named style in a QDomDocument
|
||||
|
||||
@ -867,7 +903,7 @@ Attempts to style the layer using the formatting from an SLD type file.
|
||||
|
||||
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) = 0;
|
||||
QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0;
|
||||
%Docstring
|
||||
Read the symbology for the current layer from the Dom node supplied.
|
||||
|
||||
@ -879,7 +915,7 @@ Read the symbology for the current layer from the Dom node supplied.
|
||||
%End
|
||||
|
||||
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
QgsReadWriteContext &context, StyleCategories categories = AllCategories );
|
||||
%Docstring
|
||||
Read the style for the current layer from the Dom node supplied.
|
||||
|
||||
@ -897,7 +933,7 @@ Read the style for the current layer from the Dom node supplied.
|
||||
%End
|
||||
|
||||
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const = 0;
|
||||
StyleCategories categories = AllCategories ) const = 0;
|
||||
%Docstring
|
||||
Write the style for the layer into the docment provided.
|
||||
|
||||
@ -914,7 +950,7 @@ Write the style for the layer into the docment provided.
|
||||
%End
|
||||
|
||||
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
StyleCategories categories = AllCategories ) const;
|
||||
%Docstring
|
||||
Write just the symbology information for the layer into the document
|
||||
|
||||
@ -1490,7 +1526,7 @@ Write style manager's configuration (if exists). To be called by subclasses.
|
||||
|
||||
void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
|
||||
const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
StyleCategories categories = AllCategories ) const;
|
||||
%Docstring
|
||||
Write style data common to all layer types
|
||||
|
||||
@ -1498,7 +1534,7 @@ Write style data common to all layer types
|
||||
%End
|
||||
|
||||
void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
StyleCategories categories = AllCategories );
|
||||
%Docstring
|
||||
Read style data common to all layer types
|
||||
|
||||
@ -1537,6 +1573,9 @@ Checks whether a new set of dependencies will introduce a cycle
|
||||
|
||||
QFlags<QgsMapLayer::LayerFlag> operator|(QgsMapLayer::LayerFlag f1, QFlags<QgsMapLayer::LayerFlag> f2);
|
||||
|
||||
QFlags<QgsMapLayer::StyleCategory> operator|(QgsMapLayer::StyleCategory f1, QFlags<QgsMapLayer::StyleCategory> f2);
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
@ -26,28 +26,6 @@ only possible to read or write layer's current style.
|
||||
#include "qgsmaplayerstyle.h"
|
||||
%End
|
||||
public:
|
||||
static const QMetaObject staticMetaObject;
|
||||
|
||||
public:
|
||||
|
||||
enum StyleCategory
|
||||
{
|
||||
LayerConfiguration,
|
||||
Symbology,
|
||||
Labels,
|
||||
Fields,
|
||||
Forms,
|
||||
Actions,
|
||||
MapTips,
|
||||
Diagrams,
|
||||
AttributeTable,
|
||||
Rendering,
|
||||
CustomProperties,
|
||||
All
|
||||
};
|
||||
typedef QFlags<QgsMapLayerStyle::StyleCategory> StyleCategories;
|
||||
|
||||
|
||||
QgsMapLayerStyle();
|
||||
%Docstring
|
||||
construct invalid style
|
||||
@ -93,9 +71,6 @@ Write style configuration (for project file writing)
|
||||
|
||||
};
|
||||
|
||||
QFlags<QgsMapLayerStyle::StyleCategory> operator|(QgsMapLayerStyle::StyleCategory f1, QFlags<QgsMapLayerStyle::StyleCategory> f2);
|
||||
|
||||
|
||||
|
||||
class QgsMapLayerStyleOverride
|
||||
{
|
||||
|
@ -871,7 +871,7 @@ Returns the current auxiliary layer.
|
||||
|
||||
|
||||
virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
%Docstring
|
||||
Read the symbology for the current layer from the Dom node supplied.
|
||||
|
||||
@ -883,7 +883,7 @@ Read the symbology for the current layer from the Dom node supplied.
|
||||
%End
|
||||
|
||||
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
%Docstring
|
||||
Read the style for the current layer from the Dom node supplied.
|
||||
|
||||
@ -895,7 +895,7 @@ Read the style for the current layer from the Dom node supplied.
|
||||
%End
|
||||
|
||||
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
%Docstring
|
||||
Write the symbology for the layer into the docment provided.
|
||||
|
||||
@ -908,7 +908,7 @@ Write the symbology for the layer into the docment provided.
|
||||
%End
|
||||
|
||||
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
%Docstring
|
||||
Write just the style information for the layer into the document
|
||||
|
||||
|
@ -348,16 +348,16 @@ Draws a preview of the rasterlayer into a QImage
|
||||
void showStatusMessage( const QString &message );
|
||||
|
||||
protected:
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
|
||||
virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
|
||||
virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
|
||||
|
||||
virtual bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
|
||||
virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
|
||||
|
@ -8847,7 +8847,7 @@ std::unique_ptr<QgsVectorLayer> QgisApp::pasteToNewMemoryVector()
|
||||
return layer;
|
||||
}
|
||||
|
||||
void QgisApp::copyStyle( QgsMapLayer *sourceLayer )
|
||||
void QgisApp::copyStyle( QgsMapLayer *sourceLayer, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
QgsMapLayer *selectionLayer = sourceLayer ? sourceLayer : activeLayer();
|
||||
|
||||
@ -8856,8 +8856,7 @@ void QgisApp::copyStyle( QgsMapLayer *sourceLayer )
|
||||
QString errorMsg;
|
||||
QDomDocument doc( QStringLiteral( "qgis" ) );
|
||||
QgsReadWriteContext context;
|
||||
selectionLayer->exportNamedStyle( doc, errorMsg, context );
|
||||
|
||||
selectionLayer->exportNamedStyle( doc, errorMsg, context, categories );
|
||||
|
||||
if ( !errorMsg.isEmpty() )
|
||||
{
|
||||
|
@ -830,10 +830,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
//! copies style of the active layer to the clipboard
|
||||
|
||||
/**
|
||||
\param sourceLayer The layer where the style will be taken from
|
||||
(defaults to the active layer on the legend)
|
||||
* Copy the style of a map layer
|
||||
* \param sourceLayer The layer where the style will be taken from
|
||||
(defaults to the active layer on the legend)
|
||||
* \param categories The style categories to copy
|
||||
*/
|
||||
void copyStyle( QgsMapLayer *sourceLayer = nullptr );
|
||||
void copyStyle( QgsMapLayer *sourceLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
|
||||
//! pastes style on the clipboard to the active layer
|
||||
|
||||
/**
|
||||
|
@ -316,7 +316,22 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
||||
QMenu *menuStyleManager = new QMenu( tr( "Styles" ), menu );
|
||||
|
||||
QgisApp *app = QgisApp::instance();
|
||||
menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
|
||||
if ( layer->type() == QgsMapLayer::VectorLayer )
|
||||
{
|
||||
QMenu *copyStyleMenu = menuStyleManager->addMenu( tr( "Copy Style…" ) );
|
||||
copyStyleMenu->setToolTipsVisible( true );
|
||||
auto enumMap = qgsEnumMap<QgsMapLayer::StyleCategory>();
|
||||
for ( auto it = enumMap.constBegin(); it != enumMap.constEnd(); ++it )
|
||||
{
|
||||
QgsMapLayer::ReadableStyleCategory category = QgsMapLayer::readableStyleCategory( it.key() );
|
||||
QAction *action = copyStyleMenu->addAction( category.name(), app, SLOT( copyStyle() ) );
|
||||
action->setToolTip( category.toolTip() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
|
||||
}
|
||||
|
||||
if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
|
||||
{
|
||||
|
@ -890,7 +890,6 @@ SET(QGIS_CORE_HDRS
|
||||
qgsmaplayerdependency.h
|
||||
qgsmaplayerrenderer.h
|
||||
qgsmaplayerstyle.h
|
||||
qgsmaplayerstylemanager.h
|
||||
qgsmapsettings.h
|
||||
qgsmapsettingsutils.h
|
||||
qgsmaptopixel.h
|
||||
|
@ -243,7 +243,7 @@ QgsMapLayerRenderer *QgsMeshLayer::createMapRenderer( QgsRenderContext &renderer
|
||||
}
|
||||
|
||||
bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
Q_UNUSED( errorMessage );
|
||||
// TODO: implement categories for raster layer
|
||||
@ -260,7 +260,7 @@ bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
}
|
||||
|
||||
bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
Q_UNUSED( errorMessage );
|
||||
// TODO: implement categories for raster layer
|
||||
|
@ -126,9 +126,9 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
|
||||
QgsRectangle extent() const override;
|
||||
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
|
||||
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
|
||||
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
|
||||
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
|
||||
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
|
||||
|
@ -67,6 +67,37 @@ QString QgsMapLayer::extensionPropertyType( QgsMapLayer::PropertyType type )
|
||||
return QString();
|
||||
}
|
||||
|
||||
QgsMapLayer::ReadableStyleCategory QgsMapLayer::readableStyleCategory( QgsMapLayer::StyleCategory category )
|
||||
{
|
||||
switch ( category )
|
||||
{
|
||||
case LayerConfiguration:
|
||||
return ReadableStyleCategory( tr( "Layer Configuration" ), tr( "Flags, display expression, read-only" ) );
|
||||
case Symbology :
|
||||
return ReadableStyleCategory( tr( "Symbology" ) );
|
||||
case Labels :
|
||||
return ReadableStyleCategory( tr( "Labels" ) );
|
||||
case Fields :
|
||||
return ReadableStyleCategory( tr( "Fields" ), tr( "Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields" ) );
|
||||
case Forms :
|
||||
return ReadableStyleCategory( tr( "Forms" ) );
|
||||
case Actions :
|
||||
return ReadableStyleCategory( tr( "Actions" ) );
|
||||
case MapTips :
|
||||
return ReadableStyleCategory( tr( "Map Tips" ) );
|
||||
case Diagrams :
|
||||
return ReadableStyleCategory( tr( "Diagrams" ) );
|
||||
case AttributeTable :
|
||||
return ReadableStyleCategory( tr( "Attribute Table" ) );
|
||||
case Rendering :
|
||||
return ReadableStyleCategory( tr( "Rendering" ), tr( "Scale visibility, simplify method, opacity" ) );
|
||||
case CustomProperties :
|
||||
return ReadableStyleCategory( tr( "Custom Properties" ) );
|
||||
case AllCategories :
|
||||
return ReadableStyleCategory( tr( "All categories" ) );
|
||||
}
|
||||
}
|
||||
|
||||
QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
|
||||
const QString &lyrname,
|
||||
const QString &source )
|
||||
@ -549,9 +580,9 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume
|
||||
}
|
||||
|
||||
void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
// use scale dependent visibility flag
|
||||
layerElement.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
|
||||
@ -559,7 +590,7 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
|
||||
layerElement.setAttribute( QStringLiteral( "minScale" ), QString::number( minimumScale() ) );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
if ( m3DRenderer )
|
||||
{
|
||||
@ -570,7 +601,7 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
|
||||
}
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
{
|
||||
// flags
|
||||
// this code is saving automatically all the flags entries
|
||||
@ -587,7 +618,7 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
|
||||
}
|
||||
|
||||
// custom properties
|
||||
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
|
||||
if ( categories.testFlag( CustomProperties ) )
|
||||
{
|
||||
writeCustomProperties( layerElement, document );
|
||||
}
|
||||
@ -1103,7 +1134,7 @@ void QgsMapLayer::exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) co
|
||||
doc = myDocument;
|
||||
}
|
||||
|
||||
void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
QDomImplementation DomImplementation;
|
||||
QDomDocumentType documentType = DomImplementation.createDocumentType( QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) );
|
||||
@ -1559,7 +1590,7 @@ QString QgsMapLayer::loadSldStyle( const QString &uri, bool &resultFlag )
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
Q_UNUSED( node );
|
||||
Q_UNUSED( errorMessage );
|
||||
@ -1569,7 +1600,7 @@ bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsRea
|
||||
}
|
||||
|
||||
bool QgsMapLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
Q_UNUSED( node );
|
||||
Q_UNUSED( doc );
|
||||
@ -1580,9 +1611,9 @@ bool QgsMapLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorM
|
||||
}
|
||||
|
||||
void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories )
|
||||
QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
QgsAbstract3DRenderer *r3D = nullptr;
|
||||
QDomElement renderer3DElem = layerElement.firstChildElement( QStringLiteral( "renderer-3d" ) );
|
||||
@ -1598,7 +1629,7 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
|
||||
setRenderer3D( r3D );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
|
||||
if ( categories.testFlag( CustomProperties ) )
|
||||
{
|
||||
// read custom properties before passing reading further to a subclass, so that
|
||||
// the subclass can also read custom properties
|
||||
@ -1606,7 +1637,7 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
|
||||
}
|
||||
|
||||
// use scale dependent visibility flag
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
setScaleBasedVisibility( layerElement.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
|
||||
if ( layerElement.hasAttribute( QStringLiteral( "minimumScale" ) ) )
|
||||
@ -1622,7 +1653,7 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
|
||||
}
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
{
|
||||
// flags
|
||||
QDomElement flagsElem = layerElement.firstChildElement( QStringLiteral( "flags" ) );
|
||||
|
@ -134,6 +134,48 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
|
||||
Q_FLAG( LayerFlags )
|
||||
|
||||
/**
|
||||
* Categories of style to distinguish appropriate sections for import/export
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
enum StyleCategory
|
||||
{
|
||||
LayerConfiguration = 1 << 0, //!< Flags, display expression, read-only
|
||||
Symbology = 1 << 1,
|
||||
Labels = 1 << 2,
|
||||
Fields = 1 << 3, //!< Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields
|
||||
Forms = 1 << 4,
|
||||
Actions = 1 << 5,
|
||||
MapTips = 1 << 6,
|
||||
Diagrams = 1 << 7,
|
||||
AttributeTable = 7 << 8,
|
||||
Rendering = 1 << 9, //!< Scale visibility, simplify method, opacity
|
||||
CustomProperties = 1 << 10,
|
||||
AllCategories = LayerConfiguration | Symbology | Labels | Fields | Forms | Actions |
|
||||
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties,
|
||||
};
|
||||
Q_ENUM( StyleCategory )
|
||||
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
|
||||
Q_FLAG( StyleCategories )
|
||||
|
||||
/**
|
||||
* Style category with its name and its tooltip translated and readable
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
struct ReadableStyleCategory
|
||||
{
|
||||
public:
|
||||
ReadableStyleCategory( const QString &name, const QString &toolTip = QString() )
|
||||
: mName( name ), mToolTip( toolTip )
|
||||
{}
|
||||
|
||||
QString name() const {return mName;}
|
||||
QString toolTip() const {return mToolTip;}
|
||||
private:
|
||||
QString mName;
|
||||
QString mToolTip;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsMapLayer
|
||||
* \param type layer type
|
||||
@ -187,6 +229,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
*/
|
||||
static QString extensionPropertyType( PropertyType type );
|
||||
|
||||
/**
|
||||
* Readable and Translated category
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static ReadableStyleCategory readableStyleCategory( StyleCategory category );
|
||||
|
||||
|
||||
|
||||
//! Returns the layer's unique ID, which is used to access this layer from QgsProject.
|
||||
QString id() const;
|
||||
|
||||
@ -738,7 +788,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
* during the execution of writeSymbology
|
||||
*/
|
||||
virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
|
||||
|
||||
|
||||
/**
|
||||
@ -809,7 +859,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) = 0;
|
||||
QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0;
|
||||
|
||||
/**
|
||||
* Read the style for the current layer from the Dom node supplied.
|
||||
@ -821,7 +871,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
* \since QGIS 2.16
|
||||
*/
|
||||
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
QgsReadWriteContext &context, StyleCategories categories = AllCategories );
|
||||
|
||||
/**
|
||||
* Write the style for the layer into the docment provided.
|
||||
@ -833,7 +883,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const = 0;
|
||||
StyleCategories categories = AllCategories ) const = 0;
|
||||
|
||||
/**
|
||||
* Write just the symbology information for the layer into the document
|
||||
@ -847,7 +897,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
* \since QGIS 2.16
|
||||
*/
|
||||
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
StyleCategories categories = AllCategories ) const;
|
||||
|
||||
//! Returns pointer to layer's undo stack
|
||||
QUndoStack *undoStack();
|
||||
@ -1294,14 +1344,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
*/
|
||||
void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
|
||||
const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
|
||||
StyleCategories categories = AllCategories ) const;
|
||||
|
||||
/**
|
||||
* Read style data common to all layer types
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
|
||||
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
|
||||
StyleCategories categories = AllCategories );
|
||||
|
||||
#ifndef SIP_RUN
|
||||
#if 0
|
||||
@ -1430,6 +1480,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
|
||||
Q_DECLARE_METATYPE( QgsMapLayer * )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
|
||||
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
|
@ -39,33 +39,7 @@ class QgsMapLayer;
|
||||
*/
|
||||
class CORE_EXPORT QgsMapLayerStyle
|
||||
{
|
||||
Q_GADGET
|
||||
public:
|
||||
|
||||
/**
|
||||
* Categories of style to distinguish appropriate sections for import/export
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
enum StyleCategory
|
||||
{
|
||||
LayerConfiguration = 1 << 0, //!< Flags, display expression, read-only
|
||||
Symbology = 1 << 1,
|
||||
Labels = 1 << 2,
|
||||
Fields = 1 << 3, //!< Aliases, WMS/WFS, expressions, constraints, virtual fields
|
||||
Forms = 1 << 4,
|
||||
Actions = 1 << 5,
|
||||
MapTips = 1 << 6,
|
||||
Diagrams = 1 << 2,
|
||||
AttributeTable = 7 << 8,
|
||||
Rendering = 1 << 9, //!< Scale visibility, simplify method, opacity
|
||||
CustomProperties = 1 << 10,
|
||||
All = LayerConfiguration | Symbology | Labels | Fields | Forms | Actions |
|
||||
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties,
|
||||
};
|
||||
Q_ENUM( StyleCategory )
|
||||
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
|
||||
Q_FLAG( StyleCategories )
|
||||
|
||||
//! construct invalid style
|
||||
QgsMapLayerStyle() = default;
|
||||
|
||||
@ -95,8 +69,6 @@ class CORE_EXPORT QgsMapLayerStyle
|
||||
QString mXmlData;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayerStyle::StyleCategories )
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
|
@ -1858,11 +1858,11 @@ void QgsVectorLayer::resolveReferences( QgsProject *project )
|
||||
|
||||
|
||||
bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
QgsReadWriteContextCategoryPopper p = context.enterCategory( tr( "Symbology" ) );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
|
||||
if ( categories.testFlag( Fields ) )
|
||||
{
|
||||
if ( !mExpressionFieldBuffer )
|
||||
mExpressionFieldBuffer = new QgsExpressionFieldBuffer();
|
||||
@ -1877,10 +1877,10 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
|
||||
|
||||
readStyle( layerNode, errorMessage, context, categories );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::MapTips ) )
|
||||
if ( categories.testFlag( MapTips ) )
|
||||
mMapTipTemplate = layerNode.namedItem( QStringLiteral( "mapTip" ) ).toElement().text();
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
mDisplayExpression = layerNode.namedItem( QStringLiteral( "previewExpression" ) ).toElement().text();
|
||||
|
||||
// Try to migrate pre QGIS 3.0 display field property
|
||||
@ -1888,20 +1888,20 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
|
||||
if ( mFields.lookupField( displayField ) < 0 )
|
||||
{
|
||||
// if it's not a field, it's a maptip
|
||||
if ( mMapTipTemplate.isEmpty() && categories.testFlag( QgsMapLayerStyle::MapTips ) )
|
||||
if ( mMapTipTemplate.isEmpty() && categories.testFlag( MapTips ) )
|
||||
mMapTipTemplate = displayField;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mDisplayExpression.isEmpty() && categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( mDisplayExpression.isEmpty() && categories.testFlag( LayerConfiguration ) )
|
||||
mDisplayExpression = QgsExpression::quotedColumnRef( displayField );
|
||||
}
|
||||
|
||||
// process the attribute actions
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Actions ) )
|
||||
if ( categories.testFlag( Actions ) )
|
||||
mActions->readXml( layerNode );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
|
||||
if ( categories.testFlag( Fields ) )
|
||||
{
|
||||
mAttributeAliasMap.clear();
|
||||
QDomNode aliasesNode = layerNode.namedItem( QStringLiteral( "aliases" ) );
|
||||
@ -2064,26 +2064,26 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
|
||||
}
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
{
|
||||
QDomElement geometryOptionsElement = layerNode.namedItem( QStringLiteral( "geometryOptions" ) ).toElement();
|
||||
mGeometryFixes->setGeometryPrecision( geometryOptionsElement.attribute( QStringLiteral( "geometryPrecision" ), QStringLiteral( "0.0" ) ).toDouble() );
|
||||
mGeometryFixes->setRemoveDuplicateNodes( geometryOptionsElement.attribute( QStringLiteral( "removeDuplicateNodes" ), QStringLiteral( "0" ) ).toInt() == 1 );
|
||||
}
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Forms ) )
|
||||
if ( categories.testFlag( Forms ) )
|
||||
mEditFormConfig.readXml( layerNode, context );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::AttributeTable ) )
|
||||
if ( categories.testFlag( AttributeTable ) )
|
||||
{
|
||||
mAttributeTableConfig.readXml( layerNode );
|
||||
mConditionalStyles->readXml( layerNode, context );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
|
||||
if ( categories.testFlag( CustomProperties ) )
|
||||
readCustomProperties( layerNode, QStringLiteral( "variable" ) );
|
||||
|
||||
QDomElement mapLayerNode = layerNode.toElement();
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration )
|
||||
if ( categories.testFlag( LayerConfiguration )
|
||||
&& mapLayerNode.attribute( QStringLiteral( "readOnly" ), QStringLiteral( "0" ) ).toInt() == 1 )
|
||||
mReadOnly = true;
|
||||
|
||||
@ -2093,7 +2093,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
bool result = true;
|
||||
emit readCustomSymbology( node.toElement(), errorMessage );
|
||||
@ -2101,7 +2101,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
if ( isSpatial() )
|
||||
{
|
||||
// try renderer v2 first
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
QDomElement rendererElement = node.firstChildElement( RENDERER_TAG_NAME );
|
||||
if ( !rendererElement.isNull() )
|
||||
@ -2124,7 +2124,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
}
|
||||
|
||||
// read labeling definition
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Labels ) )
|
||||
if ( categories.testFlag( Labels ) )
|
||||
{
|
||||
QDomElement labelingElement = node.firstChildElement( QStringLiteral( "labeling" ) );
|
||||
QgsAbstractVectorLayerLabeling *labeling = nullptr;
|
||||
@ -2151,7 +2151,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
mLabelsEnabled = true;
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
// get and set the blend mode if it exists
|
||||
QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
|
||||
@ -2171,7 +2171,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
}
|
||||
|
||||
// get and set the layer transparency if it exists
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
QDomNode layerTransparencyNode = node.namedItem( QStringLiteral( "layerTransparency" ) );
|
||||
if ( !layerTransparencyNode.isNull() )
|
||||
@ -2187,7 +2187,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
QDomElement e = node.toElement();
|
||||
|
||||
@ -2200,7 +2200,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
}
|
||||
|
||||
//diagram renderer and diagram layer settings
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Diagrams ) )
|
||||
if ( categories.testFlag( Diagrams ) )
|
||||
{
|
||||
delete mDiagramRenderer;
|
||||
mDiagramRenderer = nullptr;
|
||||
@ -2279,14 +2279,14 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
|
||||
|
||||
|
||||
bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
QDomElement layerElement = node.toElement();
|
||||
writeCommonStyle( layerElement, doc, context, categories );
|
||||
|
||||
( void )writeStyle( node, doc, errorMessage, context );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
{
|
||||
QDomElement geometryOptionsElement = doc.createElement( QStringLiteral( "geometryOptions" ) );
|
||||
node.appendChild( geometryOptionsElement );
|
||||
@ -2294,7 +2294,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
|
||||
geometryOptionsElement.setAttribute( QStringLiteral( "geometryPrecision" ), mGeometryFixes->geometryPrecision() );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
|
||||
if ( categories.testFlag( Fields ) )
|
||||
{
|
||||
QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral( "fieldConfiguration" ) );
|
||||
node.appendChild( fieldConfigurationElement );
|
||||
@ -2410,24 +2410,24 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
|
||||
}
|
||||
|
||||
// add attribute actions
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Actions ) )
|
||||
if ( categories.testFlag( Actions ) )
|
||||
mActions->writeXml( node );
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::AttributeTable ) )
|
||||
if ( categories.testFlag( AttributeTable ) )
|
||||
{
|
||||
mAttributeTableConfig.writeXml( node );
|
||||
mConditionalStyles->writeXml( node, doc, context );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Forms ) )
|
||||
if ( categories.testFlag( Forms ) )
|
||||
mEditFormConfig.writeXml( node, context );
|
||||
|
||||
// save readonly state
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
node.toElement().setAttribute( QStringLiteral( "readOnly" ), mReadOnly );
|
||||
|
||||
// save preview expression
|
||||
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
|
||||
if ( categories.testFlag( LayerConfiguration ) )
|
||||
{
|
||||
QDomElement prevExpElem = doc.createElement( QStringLiteral( "previewExpression" ) );
|
||||
QDomText prevExpText = doc.createTextNode( mDisplayExpression );
|
||||
@ -2436,7 +2436,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
|
||||
}
|
||||
|
||||
// save map tip
|
||||
if ( categories.testFlag( QgsMapLayerStyle::MapTips ) )
|
||||
if ( categories.testFlag( MapTips ) )
|
||||
{
|
||||
QDomElement mapTipElem = doc.createElement( QStringLiteral( "mapTip" ) );
|
||||
QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
|
||||
@ -2448,7 +2448,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
QDomElement mapLayerNode = node.toElement();
|
||||
|
||||
@ -2456,7 +2456,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
|
||||
if ( isSpatial() )
|
||||
{
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
if ( mRenderer )
|
||||
{
|
||||
@ -2465,7 +2465,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
}
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Labels ) )
|
||||
if ( categories.testFlag( Labels ) )
|
||||
{
|
||||
if ( mLabeling )
|
||||
{
|
||||
@ -2476,7 +2476,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
}
|
||||
|
||||
// save the simplification drawing settings
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
mapLayerNode.setAttribute( QStringLiteral( "simplifyDrawingHints" ), QString::number( mSimplifyMethod.simplifyHints() ) );
|
||||
mapLayerNode.setAttribute( QStringLiteral( "simplifyAlgorithm" ), QString::number( mSimplifyMethod.simplifyAlgorithm() ) );
|
||||
@ -2486,12 +2486,12 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
}
|
||||
|
||||
//save customproperties
|
||||
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
|
||||
if ( categories.testFlag( CustomProperties ) )
|
||||
{
|
||||
writeCustomProperties( node, doc );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
|
||||
if ( categories.testFlag( Symbology ) )
|
||||
{
|
||||
// add the blend mode field
|
||||
QDomElement blendModeElem = doc.createElement( QStringLiteral( "blendMode" ) );
|
||||
@ -2507,7 +2507,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
}
|
||||
|
||||
// add the layer opacity
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
|
||||
if ( categories.testFlag( Rendering ) )
|
||||
{
|
||||
QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
|
||||
QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
|
||||
@ -2515,7 +2515,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
|
||||
node.appendChild( layerOpacityElem );
|
||||
}
|
||||
|
||||
if ( categories.testFlag( QgsMapLayerStyle::Diagrams ) && mDiagramRenderer )
|
||||
if ( categories.testFlag( Diagrams ) && mDiagramRenderer )
|
||||
{
|
||||
mDiagramRenderer->writeXml( mapLayerNode, doc, context );
|
||||
if ( mDiagramLayerSettings )
|
||||
|
@ -881,7 +881,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
|
||||
|
||||
/**
|
||||
* Read the style for the current layer from the Dom node supplied.
|
||||
@ -891,7 +891,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool readStyle( const QDomNode &node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
|
||||
|
||||
/**
|
||||
* Write the symbology for the layer into the docment provided.
|
||||
@ -902,7 +902,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
|
||||
|
||||
/**
|
||||
* Write just the style information for the layer into the document
|
||||
@ -913,7 +913,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* \returns true in case of success.
|
||||
*/
|
||||
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
|
||||
|
||||
/**
|
||||
* Writes the symbology of the layer into the document provided in SLD 1.1 format
|
||||
|
@ -1307,7 +1307,7 @@ QImage QgsRasterLayer::previewAsImage( QSize size, const QColor &bgColor, QImage
|
||||
* \return true in case of success.
|
||||
*/
|
||||
bool QgsRasterLayer::readSymbology( const QDomNode &layer_node, QString &errorMessage,
|
||||
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
Q_UNUSED( errorMessage );
|
||||
// TODO: implement categories for raster layer
|
||||
@ -1401,7 +1401,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode &layer_node, QString &errorMe
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsRasterLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
|
||||
bool QgsRasterLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
return readSymbology( node, errorMessage, context, categories );
|
||||
}
|
||||
@ -1549,7 +1549,7 @@ bool QgsRasterLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &c
|
||||
* \return true in case of success.
|
||||
*/
|
||||
bool QgsRasterLayer::writeSymbology( QDomNode &layer_node, QDomDocument &document, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
Q_UNUSED( errorMessage );
|
||||
// TODO: implement categories for raster layer
|
||||
@ -1580,7 +1580,7 @@ bool QgsRasterLayer::writeSymbology( QDomNode &layer_node, QDomDocument &documen
|
||||
}
|
||||
|
||||
bool QgsRasterLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
|
||||
{
|
||||
return writeSymbology( node, doc, errorMessage, context, categories );
|
||||
} // bool QgsRasterLayer::writeSymbology
|
||||
|
@ -404,13 +404,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
|
||||
void showStatusMessage( const QString &message );
|
||||
|
||||
protected:
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
|
||||
bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
|
||||
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
|
||||
bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
|
||||
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
|
||||
bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
|
||||
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
|
||||
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
|
||||
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
|
||||
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
|
||||
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user