Skip to content

Commit 15e0d87

Browse files
3nidsnyalldawson
authored andcommittedSep 14, 2018
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
1 parent 4e58411 commit 15e0d87

20 files changed

+238
-155
lines changed
 

‎python/core/auto_additions/qgsmaplayer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
QgsMapLayer.LayerFlag.baseClass = QgsMapLayer
33
QgsMapLayer.LayerFlags.baseClass = QgsMapLayer
44
LayerFlags = QgsMapLayer # dirty hack since SIP seems to introduce the flags in module
5+
QgsMapLayer.StyleCategory.baseClass = QgsMapLayer
6+
QgsMapLayer.StyleCategories.baseClass = QgsMapLayer
7+
StyleCategories = QgsMapLayer # dirty hack since SIP seems to introduce the flags in module

‎python/core/auto_additions/qgsmaplayerstyle.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎python/core/auto_generated/mesh/qgsmeshlayer.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ QgsMeshLayer cannot be copied.
110110
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
111111

112112
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
113-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
113+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
114114
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
115-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
115+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
116116
virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
117117

118118
virtual QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const;

‎python/core/auto_generated/qgsmaplayer.sip.in

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,33 @@ This is the base class for all map layer types (vector, raster).
7575
typedef QFlags<QgsMapLayer::LayerFlag> LayerFlags;
7676

7777

78+
enum StyleCategory
79+
{
80+
LayerConfiguration,
81+
Symbology,
82+
Labels,
83+
Fields,
84+
Forms,
85+
Actions,
86+
MapTips,
87+
Diagrams,
88+
AttributeTable,
89+
Rendering,
90+
CustomProperties,
91+
AllCategories
92+
};
93+
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;
94+
95+
96+
struct ReadableStyleCategory
97+
{
98+
public:
99+
ReadableStyleCategory( const QString &name, const QString &toolTip = QString() );
100+
101+
QString name() const;
102+
QString toolTip() const;
103+
};
104+
78105
QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, const QString &name = QString(), const QString &source = QString() );
79106
%Docstring
80107
Constructor for QgsMapLayer
@@ -137,6 +164,15 @@ Returns the extension of a Property.
137164
.. versionadded:: 3.0
138165
%End
139166

167+
static ReadableStyleCategory readableStyleCategory( StyleCategory category );
168+
%Docstring
169+
Readable and Translated category
170+
171+
.. versionadded:: 3.4
172+
%End
173+
174+
175+
140176
QString id() const;
141177
%Docstring
142178
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
784820
%End
785821

786822
virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, QgsReadWriteContext &context,
787-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
823+
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
788824
%Docstring
789825
Export the properties of this layer as named style in a QDomDocument
790826

@@ -867,7 +903,7 @@ Attempts to style the layer using the formatting from an SLD type file.
867903

868904

869905
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
870-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) = 0;
906+
QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0;
871907
%Docstring
872908
Read the symbology for the current layer from the Dom node supplied.
873909

@@ -879,7 +915,7 @@ Read the symbology for the current layer from the Dom node supplied.
879915
%End
880916

881917
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
882-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
918+
QgsReadWriteContext &context, StyleCategories categories = AllCategories );
883919
%Docstring
884920
Read the style for the current layer from the Dom node supplied.
885921

@@ -897,7 +933,7 @@ Read the style for the current layer from the Dom node supplied.
897933
%End
898934

899935
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
900-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const = 0;
936+
StyleCategories categories = AllCategories ) const = 0;
901937
%Docstring
902938
Write the style for the layer into the docment provided.
903939

@@ -914,7 +950,7 @@ Write the style for the layer into the docment provided.
914950
%End
915951

916952
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
917-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
953+
StyleCategories categories = AllCategories ) const;
918954
%Docstring
919955
Write just the symbology information for the layer into the document
920956

@@ -1490,15 +1526,15 @@ Write style manager's configuration (if exists). To be called by subclasses.
14901526

14911527
void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
14921528
const QgsReadWriteContext &context,
1493-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
1529+
StyleCategories categories = AllCategories ) const;
14941530
%Docstring
14951531
Write style data common to all layer types
14961532

14971533
.. versionadded:: 3.0
14981534
%End
14991535

15001536
void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
1501-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
1537+
StyleCategories categories = AllCategories );
15021538
%Docstring
15031539
Read style data common to all layer types
15041540

@@ -1537,6 +1573,9 @@ Checks whether a new set of dependencies will introduce a cycle
15371573

15381574
QFlags<QgsMapLayer::LayerFlag> operator|(QgsMapLayer::LayerFlag f1, QFlags<QgsMapLayer::LayerFlag> f2);
15391575

1576+
QFlags<QgsMapLayer::StyleCategory> operator|(QgsMapLayer::StyleCategory f1, QFlags<QgsMapLayer::StyleCategory> f2);
1577+
1578+
15401579

15411580

15421581
/************************************************************************

‎python/core/auto_generated/qgsmaplayerstyle.sip.in

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ only possible to read or write layer's current style.
2626
#include "qgsmaplayerstyle.h"
2727
%End
2828
public:
29-
static const QMetaObject staticMetaObject;
30-
31-
public:
32-
33-
enum StyleCategory
34-
{
35-
LayerConfiguration,
36-
Symbology,
37-
Labels,
38-
Fields,
39-
Forms,
40-
Actions,
41-
MapTips,
42-
Diagrams,
43-
AttributeTable,
44-
Rendering,
45-
CustomProperties,
46-
All
47-
};
48-
typedef QFlags<QgsMapLayerStyle::StyleCategory> StyleCategories;
49-
50-
5129
QgsMapLayerStyle();
5230
%Docstring
5331
construct invalid style
@@ -93,9 +71,6 @@ Write style configuration (for project file writing)
9371

9472
};
9573

96-
QFlags<QgsMapLayerStyle::StyleCategory> operator|(QgsMapLayerStyle::StyleCategory f1, QFlags<QgsMapLayerStyle::StyleCategory> f2);
97-
98-
9974

10075
class QgsMapLayerStyleOverride
10176
{

‎python/core/auto_generated/qgsvectorlayer.sip.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ Returns the current auxiliary layer.
871871

872872

873873
virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
874-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
874+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
875875
%Docstring
876876
Read the symbology for the current layer from the Dom node supplied.
877877

@@ -883,7 +883,7 @@ Read the symbology for the current layer from the Dom node supplied.
883883
%End
884884

885885
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
886-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
886+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
887887
%Docstring
888888
Read the style for the current layer from the Dom node supplied.
889889

@@ -895,7 +895,7 @@ Read the style for the current layer from the Dom node supplied.
895895
%End
896896

897897
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
898-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
898+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
899899
%Docstring
900900
Write the symbology for the layer into the docment provided.
901901

@@ -908,7 +908,7 @@ Write the symbology for the layer into the docment provided.
908908
%End
909909

910910
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
911-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
911+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
912912
%Docstring
913913
Write just the style information for the layer into the document
914914

‎python/core/auto_generated/raster/qgsrasterlayer.sip.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,16 @@ Draws a preview of the rasterlayer into a QImage
348348
void showStatusMessage( const QString &message );
349349

350350
protected:
351-
virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
351+
virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
352352

353-
virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
353+
virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
354354

355355
virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
356356

357357
virtual bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage,
358-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
358+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
359359
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
360-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
360+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
361361
virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
362362

363363
virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;

‎src/app/qgisapp.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8847,7 +8847,7 @@ std::unique_ptr<QgsVectorLayer> QgisApp::pasteToNewMemoryVector()
88478847
return layer;
88488848
}
88498849

8850-
void QgisApp::copyStyle( QgsMapLayer *sourceLayer )
8850+
void QgisApp::copyStyle( QgsMapLayer *sourceLayer, QgsMapLayer::StyleCategories categories )
88518851
{
88528852
QgsMapLayer *selectionLayer = sourceLayer ? sourceLayer : activeLayer();
88538853

@@ -8856,8 +8856,7 @@ void QgisApp::copyStyle( QgsMapLayer *sourceLayer )
88568856
QString errorMsg;
88578857
QDomDocument doc( QStringLiteral( "qgis" ) );
88588858
QgsReadWriteContext context;
8859-
selectionLayer->exportNamedStyle( doc, errorMsg, context );
8860-
8859+
selectionLayer->exportNamedStyle( doc, errorMsg, context, categories );
88618860

88628861
if ( !errorMsg.isEmpty() )
88638862
{

‎src/app/qgisapp.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
830830
//! copies style of the active layer to the clipboard
831831

832832
/**
833-
\param sourceLayer The layer where the style will be taken from
834-
(defaults to the active layer on the legend)
833+
* Copy the style of a map layer
834+
* \param sourceLayer The layer where the style will be taken from
835+
(defaults to the active layer on the legend)
836+
* \param categories The style categories to copy
835837
*/
836-
void copyStyle( QgsMapLayer *sourceLayer = nullptr );
838+
void copyStyle( QgsMapLayer *sourceLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories );
837839
//! pastes style on the clipboard to the active layer
838840

839841
/**

‎src/app/qgsapplayertreeviewmenuprovider.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,22 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
316316
QMenu *menuStyleManager = new QMenu( tr( "Styles" ), menu );
317317

318318
QgisApp *app = QgisApp::instance();
319-
menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
319+
if ( layer->type() == QgsMapLayer::VectorLayer )
320+
{
321+
QMenu *copyStyleMenu = menuStyleManager->addMenu( tr( "Copy Style…" ) );
322+
copyStyleMenu->setToolTipsVisible( true );
323+
auto enumMap = qgsEnumMap<QgsMapLayer::StyleCategory>();
324+
for ( auto it = enumMap.constBegin(); it != enumMap.constEnd(); ++it )
325+
{
326+
QgsMapLayer::ReadableStyleCategory category = QgsMapLayer::readableStyleCategory( it.key() );
327+
QAction *action = copyStyleMenu->addAction( category.name(), app, SLOT( copyStyle() ) );
328+
action->setToolTip( category.toolTip() );
329+
}
330+
}
331+
else
332+
{
333+
menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
334+
}
320335

321336
if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
322337
{

‎src/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ SET(QGIS_CORE_HDRS
890890
qgsmaplayerdependency.h
891891
qgsmaplayerrenderer.h
892892
qgsmaplayerstyle.h
893-
qgsmaplayerstylemanager.h
894893
qgsmapsettings.h
895894
qgsmapsettingsutils.h
896895
qgsmaptopixel.h

‎src/core/mesh/qgsmeshlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ QgsMapLayerRenderer *QgsMeshLayer::createMapRenderer( QgsRenderContext &renderer
243243
}
244244

245245
bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
246-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
246+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
247247
{
248248
Q_UNUSED( errorMessage );
249249
// TODO: implement categories for raster layer
@@ -260,7 +260,7 @@ bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
260260
}
261261

262262
bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
263-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
263+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
264264
{
265265
Q_UNUSED( errorMessage );
266266
// TODO: implement categories for raster layer

‎src/core/mesh/qgsmeshlayer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
126126
QgsRectangle extent() const override;
127127
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
128128
bool readSymbology( const QDomNode &node, QString &errorMessage,
129-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
129+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
130130
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
131-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
131+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
132132
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
133133
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
134134
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;

‎src/core/qgsmaplayer.cpp

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@ QString QgsMapLayer::extensionPropertyType( QgsMapLayer::PropertyType type )
6767
return QString();
6868
}
6969

70+
QgsMapLayer::ReadableStyleCategory QgsMapLayer::readableStyleCategory( QgsMapLayer::StyleCategory category )
71+
{
72+
switch ( category )
73+
{
74+
case LayerConfiguration:
75+
return ReadableStyleCategory( tr( "Layer Configuration" ), tr( "Flags, display expression, read-only" ) );
76+
case Symbology :
77+
return ReadableStyleCategory( tr( "Symbology" ) );
78+
case Labels :
79+
return ReadableStyleCategory( tr( "Labels" ) );
80+
case Fields :
81+
return ReadableStyleCategory( tr( "Fields" ), tr( "Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields" ) );
82+
case Forms :
83+
return ReadableStyleCategory( tr( "Forms" ) );
84+
case Actions :
85+
return ReadableStyleCategory( tr( "Actions" ) );
86+
case MapTips :
87+
return ReadableStyleCategory( tr( "Map Tips" ) );
88+
case Diagrams :
89+
return ReadableStyleCategory( tr( "Diagrams" ) );
90+
case AttributeTable :
91+
return ReadableStyleCategory( tr( "Attribute Table" ) );
92+
case Rendering :
93+
return ReadableStyleCategory( tr( "Rendering" ), tr( "Scale visibility, simplify method, opacity" ) );
94+
case CustomProperties :
95+
return ReadableStyleCategory( tr( "Custom Properties" ) );
96+
case AllCategories :
97+
return ReadableStyleCategory( tr( "All categories" ) );
98+
}
99+
}
100+
70101
QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
71102
const QString &lyrname,
72103
const QString &source )
@@ -549,17 +580,17 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume
549580
}
550581

551582
void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
552-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
583+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
553584
{
554-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
585+
if ( categories.testFlag( Rendering ) )
555586
{
556587
// use scale dependent visibility flag
557588
layerElement.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
558589
layerElement.setAttribute( QStringLiteral( "maxScale" ), QString::number( maximumScale() ) );
559590
layerElement.setAttribute( QStringLiteral( "minScale" ), QString::number( minimumScale() ) );
560591
}
561592

562-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
593+
if ( categories.testFlag( Symbology ) )
563594
{
564595
if ( m3DRenderer )
565596
{
@@ -570,7 +601,7 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
570601
}
571602
}
572603

573-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
604+
if ( categories.testFlag( LayerConfiguration ) )
574605
{
575606
// flags
576607
// this code is saving automatically all the flags entries
@@ -587,7 +618,7 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
587618
}
588619

589620
// custom properties
590-
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
621+
if ( categories.testFlag( CustomProperties ) )
591622
{
592623
writeCustomProperties( layerElement, document );
593624
}
@@ -1103,7 +1134,7 @@ void QgsMapLayer::exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) co
11031134
doc = myDocument;
11041135
}
11051136

1106-
void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
1137+
void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
11071138
{
11081139
QDomImplementation DomImplementation;
11091140
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 )
15591590
return QString();
15601591
}
15611592

1562-
bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
1593+
bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
15631594
{
15641595
Q_UNUSED( node );
15651596
Q_UNUSED( errorMessage );
@@ -1569,7 +1600,7 @@ bool QgsMapLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsRea
15691600
}
15701601

15711602
bool QgsMapLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1572-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
1603+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
15731604
{
15741605
Q_UNUSED( node );
15751606
Q_UNUSED( doc );
@@ -1580,9 +1611,9 @@ bool QgsMapLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorM
15801611
}
15811612

15821613
void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
1583-
QgsMapLayerStyle::StyleCategories categories )
1614+
QgsMapLayer::StyleCategories categories )
15841615
{
1585-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
1616+
if ( categories.testFlag( Symbology ) )
15861617
{
15871618
QgsAbstract3DRenderer *r3D = nullptr;
15881619
QDomElement renderer3DElem = layerElement.firstChildElement( QStringLiteral( "renderer-3d" ) );
@@ -1598,15 +1629,15 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
15981629
setRenderer3D( r3D );
15991630
}
16001631

1601-
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
1632+
if ( categories.testFlag( CustomProperties ) )
16021633
{
16031634
// read custom properties before passing reading further to a subclass, so that
16041635
// the subclass can also read custom properties
16051636
readCustomProperties( layerElement );
16061637
}
16071638

16081639
// use scale dependent visibility flag
1609-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
1640+
if ( categories.testFlag( Rendering ) )
16101641
{
16111642
setScaleBasedVisibility( layerElement.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
16121643
if ( layerElement.hasAttribute( QStringLiteral( "minimumScale" ) ) )
@@ -1622,7 +1653,7 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
16221653
}
16231654
}
16241655

1625-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
1656+
if ( categories.testFlag( LayerConfiguration ) )
16261657
{
16271658
// flags
16281659
QDomElement flagsElem = layerElement.firstChildElement( QStringLiteral( "flags" ) );

‎src/core/qgsmaplayer.h

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,48 @@ class CORE_EXPORT QgsMapLayer : public QObject
134134
Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
135135
Q_FLAG( LayerFlags )
136136

137+
/**
138+
* Categories of style to distinguish appropriate sections for import/export
139+
* \since QGIS 3.4
140+
*/
141+
enum StyleCategory
142+
{
143+
LayerConfiguration = 1 << 0, //!< Flags, display expression, read-only
144+
Symbology = 1 << 1,
145+
Labels = 1 << 2,
146+
Fields = 1 << 3, //!< Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields
147+
Forms = 1 << 4,
148+
Actions = 1 << 5,
149+
MapTips = 1 << 6,
150+
Diagrams = 1 << 7,
151+
AttributeTable = 7 << 8,
152+
Rendering = 1 << 9, //!< Scale visibility, simplify method, opacity
153+
CustomProperties = 1 << 10,
154+
AllCategories = LayerConfiguration | Symbology | Labels | Fields | Forms | Actions |
155+
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties,
156+
};
157+
Q_ENUM( StyleCategory )
158+
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
159+
Q_FLAG( StyleCategories )
160+
161+
/**
162+
* Style category with its name and its tooltip translated and readable
163+
* \since QGIS 3.4
164+
*/
165+
struct ReadableStyleCategory
166+
{
167+
public:
168+
ReadableStyleCategory( const QString &name, const QString &toolTip = QString() )
169+
: mName( name ), mToolTip( toolTip )
170+
{}
171+
172+
QString name() const {return mName;}
173+
QString toolTip() const {return mToolTip;}
174+
private:
175+
QString mName;
176+
QString mToolTip;
177+
};
178+
137179
/**
138180
* Constructor for QgsMapLayer
139181
* \param type layer type
@@ -187,6 +229,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
187229
*/
188230
static QString extensionPropertyType( PropertyType type );
189231

232+
/**
233+
* Readable and Translated category
234+
* \since QGIS 3.4
235+
*/
236+
static ReadableStyleCategory readableStyleCategory( StyleCategory category );
237+
238+
239+
190240
//! Returns the layer's unique ID, which is used to access this layer from QgsProject.
191241
QString id() const;
192242

@@ -738,7 +788,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
738788
* during the execution of writeSymbology
739789
*/
740790
virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, QgsReadWriteContext &context,
741-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
791+
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const;
742792

743793

744794
/**
@@ -809,7 +859,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
809859
* \returns true in case of success.
810860
*/
811861
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
812-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) = 0;
862+
QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0;
813863

814864
/**
815865
* Read the style for the current layer from the Dom node supplied.
@@ -821,7 +871,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
821871
* \since QGIS 2.16
822872
*/
823873
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
824-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
874+
QgsReadWriteContext &context, StyleCategories categories = AllCategories );
825875

826876
/**
827877
* Write the style for the layer into the docment provided.
@@ -833,7 +883,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
833883
* \returns true in case of success.
834884
*/
835885
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
836-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const = 0;
886+
StyleCategories categories = AllCategories ) const = 0;
837887

838888
/**
839889
* Write just the symbology information for the layer into the document
@@ -847,7 +897,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
847897
* \since QGIS 2.16
848898
*/
849899
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
850-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
900+
StyleCategories categories = AllCategories ) const;
851901

852902
//! Returns pointer to layer's undo stack
853903
QUndoStack *undoStack();
@@ -1294,14 +1344,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
12941344
*/
12951345
void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
12961346
const QgsReadWriteContext &context,
1297-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const;
1347+
StyleCategories categories = AllCategories ) const;
12981348

12991349
/**
13001350
* Read style data common to all layer types
13011351
* \since QGIS 3.0
13021352
*/
13031353
void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
1304-
QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All );
1354+
StyleCategories categories = AllCategories );
13051355

13061356
#ifndef SIP_RUN
13071357
#if 0
@@ -1430,6 +1480,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
14301480

14311481
Q_DECLARE_METATYPE( QgsMapLayer * )
14321482
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1483+
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1484+
14331485

14341486
#ifndef SIP_RUN
14351487

‎src/core/qgsmaplayerstyle.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,7 @@ class QgsMapLayer;
3939
*/
4040
class CORE_EXPORT QgsMapLayerStyle
4141
{
42-
Q_GADGET
4342
public:
44-
45-
/**
46-
* Categories of style to distinguish appropriate sections for import/export
47-
* \since QGIS 3.4
48-
*/
49-
enum StyleCategory
50-
{
51-
LayerConfiguration = 1 << 0, //!< Flags, display expression, read-only
52-
Symbology = 1 << 1,
53-
Labels = 1 << 2,
54-
Fields = 1 << 3, //!< Aliases, WMS/WFS, expressions, constraints, virtual fields
55-
Forms = 1 << 4,
56-
Actions = 1 << 5,
57-
MapTips = 1 << 6,
58-
Diagrams = 1 << 2,
59-
AttributeTable = 7 << 8,
60-
Rendering = 1 << 9, //!< Scale visibility, simplify method, opacity
61-
CustomProperties = 1 << 10,
62-
All = LayerConfiguration | Symbology | Labels | Fields | Forms | Actions |
63-
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties,
64-
};
65-
Q_ENUM( StyleCategory )
66-
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
67-
Q_FLAG( StyleCategories )
68-
6943
//! construct invalid style
7044
QgsMapLayerStyle() = default;
7145

@@ -95,8 +69,6 @@ class CORE_EXPORT QgsMapLayerStyle
9569
QString mXmlData;
9670
};
9771

98-
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayerStyle::StyleCategories )
99-
10072

10173
/**
10274
* \ingroup core

‎src/core/qgsvectorlayer.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,11 +1858,11 @@ void QgsVectorLayer::resolveReferences( QgsProject *project )
18581858

18591859

18601860
bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMessage,
1861-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
1861+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
18621862
{
18631863
QgsReadWriteContextCategoryPopper p = context.enterCategory( tr( "Symbology" ) );
18641864

1865-
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
1865+
if ( categories.testFlag( Fields ) )
18661866
{
18671867
if ( !mExpressionFieldBuffer )
18681868
mExpressionFieldBuffer = new QgsExpressionFieldBuffer();
@@ -1877,31 +1877,31 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
18771877

18781878
readStyle( layerNode, errorMessage, context, categories );
18791879

1880-
if ( categories.testFlag( QgsMapLayerStyle::MapTips ) )
1880+
if ( categories.testFlag( MapTips ) )
18811881
mMapTipTemplate = layerNode.namedItem( QStringLiteral( "mapTip" ) ).toElement().text();
18821882

1883-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
1883+
if ( categories.testFlag( LayerConfiguration ) )
18841884
mDisplayExpression = layerNode.namedItem( QStringLiteral( "previewExpression" ) ).toElement().text();
18851885

18861886
// Try to migrate pre QGIS 3.0 display field property
18871887
QString displayField = layerNode.namedItem( QStringLiteral( "displayfield" ) ).toElement().text();
18881888
if ( mFields.lookupField( displayField ) < 0 )
18891889
{
18901890
// if it's not a field, it's a maptip
1891-
if ( mMapTipTemplate.isEmpty() && categories.testFlag( QgsMapLayerStyle::MapTips ) )
1891+
if ( mMapTipTemplate.isEmpty() && categories.testFlag( MapTips ) )
18921892
mMapTipTemplate = displayField;
18931893
}
18941894
else
18951895
{
1896-
if ( mDisplayExpression.isEmpty() && categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
1896+
if ( mDisplayExpression.isEmpty() && categories.testFlag( LayerConfiguration ) )
18971897
mDisplayExpression = QgsExpression::quotedColumnRef( displayField );
18981898
}
18991899

19001900
// process the attribute actions
1901-
if ( categories.testFlag( QgsMapLayerStyle::Actions ) )
1901+
if ( categories.testFlag( Actions ) )
19021902
mActions->readXml( layerNode );
19031903

1904-
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
1904+
if ( categories.testFlag( Fields ) )
19051905
{
19061906
mAttributeAliasMap.clear();
19071907
QDomNode aliasesNode = layerNode.namedItem( QStringLiteral( "aliases" ) );
@@ -2064,26 +2064,26 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
20642064
}
20652065
}
20662066

2067-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
2067+
if ( categories.testFlag( LayerConfiguration ) )
20682068
{
20692069
QDomElement geometryOptionsElement = layerNode.namedItem( QStringLiteral( "geometryOptions" ) ).toElement();
20702070
mGeometryFixes->setGeometryPrecision( geometryOptionsElement.attribute( QStringLiteral( "geometryPrecision" ), QStringLiteral( "0.0" ) ).toDouble() );
20712071
mGeometryFixes->setRemoveDuplicateNodes( geometryOptionsElement.attribute( QStringLiteral( "removeDuplicateNodes" ), QStringLiteral( "0" ) ).toInt() == 1 );
20722072
}
2073-
if ( categories.testFlag( QgsMapLayerStyle::Forms ) )
2073+
if ( categories.testFlag( Forms ) )
20742074
mEditFormConfig.readXml( layerNode, context );
20752075

2076-
if ( categories.testFlag( QgsMapLayerStyle::AttributeTable ) )
2076+
if ( categories.testFlag( AttributeTable ) )
20772077
{
20782078
mAttributeTableConfig.readXml( layerNode );
20792079
mConditionalStyles->readXml( layerNode, context );
20802080
}
20812081

2082-
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
2082+
if ( categories.testFlag( CustomProperties ) )
20832083
readCustomProperties( layerNode, QStringLiteral( "variable" ) );
20842084

20852085
QDomElement mapLayerNode = layerNode.toElement();
2086-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration )
2086+
if ( categories.testFlag( LayerConfiguration )
20872087
&& mapLayerNode.attribute( QStringLiteral( "readOnly" ), QStringLiteral( "0" ) ).toInt() == 1 )
20882088
mReadOnly = true;
20892089

@@ -2093,15 +2093,15 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
20932093
}
20942094

20952095
bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
2096-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
2096+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
20972097
{
20982098
bool result = true;
20992099
emit readCustomSymbology( node.toElement(), errorMessage );
21002100

21012101
if ( isSpatial() )
21022102
{
21032103
// try renderer v2 first
2104-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
2104+
if ( categories.testFlag( Symbology ) )
21052105
{
21062106
QDomElement rendererElement = node.firstChildElement( RENDERER_TAG_NAME );
21072107
if ( !rendererElement.isNull() )
@@ -2124,7 +2124,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
21242124
}
21252125

21262126
// read labeling definition
2127-
if ( categories.testFlag( QgsMapLayerStyle::Labels ) )
2127+
if ( categories.testFlag( Labels ) )
21282128
{
21292129
QDomElement labelingElement = node.firstChildElement( QStringLiteral( "labeling" ) );
21302130
QgsAbstractVectorLayerLabeling *labeling = nullptr;
@@ -2151,7 +2151,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
21512151
mLabelsEnabled = true;
21522152
}
21532153

2154-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
2154+
if ( categories.testFlag( Symbology ) )
21552155
{
21562156
// get and set the blend mode if it exists
21572157
QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
@@ -2171,7 +2171,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
21712171
}
21722172

21732173
// get and set the layer transparency if it exists
2174-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
2174+
if ( categories.testFlag( Rendering ) )
21752175
{
21762176
QDomNode layerTransparencyNode = node.namedItem( QStringLiteral( "layerTransparency" ) );
21772177
if ( !layerTransparencyNode.isNull() )
@@ -2187,7 +2187,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
21872187
}
21882188
}
21892189

2190-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
2190+
if ( categories.testFlag( Rendering ) )
21912191
{
21922192
QDomElement e = node.toElement();
21932193

@@ -2200,7 +2200,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
22002200
}
22012201

22022202
//diagram renderer and diagram layer settings
2203-
if ( categories.testFlag( QgsMapLayerStyle::Diagrams ) )
2203+
if ( categories.testFlag( Diagrams ) )
22042204
{
22052205
delete mDiagramRenderer;
22062206
mDiagramRenderer = nullptr;
@@ -2279,22 +2279,22 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
22792279

22802280

22812281
bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
2282-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
2282+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
22832283
{
22842284
QDomElement layerElement = node.toElement();
22852285
writeCommonStyle( layerElement, doc, context, categories );
22862286

22872287
( void )writeStyle( node, doc, errorMessage, context );
22882288

2289-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
2289+
if ( categories.testFlag( LayerConfiguration ) )
22902290
{
22912291
QDomElement geometryOptionsElement = doc.createElement( QStringLiteral( "geometryOptions" ) );
22922292
node.appendChild( geometryOptionsElement );
22932293
geometryOptionsElement.setAttribute( QStringLiteral( "removeDuplicateNodes" ), mGeometryFixes->removeDuplicateNodes() ? 1 : 0 );
22942294
geometryOptionsElement.setAttribute( QStringLiteral( "geometryPrecision" ), mGeometryFixes->geometryPrecision() );
22952295
}
22962296

2297-
if ( categories.testFlag( QgsMapLayerStyle::Fields ) )
2297+
if ( categories.testFlag( Fields ) )
22982298
{
22992299
QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral( "fieldConfiguration" ) );
23002300
node.appendChild( fieldConfigurationElement );
@@ -2410,24 +2410,24 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
24102410
}
24112411

24122412
// add attribute actions
2413-
if ( categories.testFlag( QgsMapLayerStyle::Actions ) )
2413+
if ( categories.testFlag( Actions ) )
24142414
mActions->writeXml( node );
24152415

2416-
if ( categories.testFlag( QgsMapLayerStyle::AttributeTable ) )
2416+
if ( categories.testFlag( AttributeTable ) )
24172417
{
24182418
mAttributeTableConfig.writeXml( node );
24192419
mConditionalStyles->writeXml( node, doc, context );
24202420
}
24212421

2422-
if ( categories.testFlag( QgsMapLayerStyle::Forms ) )
2422+
if ( categories.testFlag( Forms ) )
24232423
mEditFormConfig.writeXml( node, context );
24242424

24252425
// save readonly state
2426-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
2426+
if ( categories.testFlag( LayerConfiguration ) )
24272427
node.toElement().setAttribute( QStringLiteral( "readOnly" ), mReadOnly );
24282428

24292429
// save preview expression
2430-
if ( categories.testFlag( QgsMapLayerStyle::LayerConfiguration ) )
2430+
if ( categories.testFlag( LayerConfiguration ) )
24312431
{
24322432
QDomElement prevExpElem = doc.createElement( QStringLiteral( "previewExpression" ) );
24332433
QDomText prevExpText = doc.createTextNode( mDisplayExpression );
@@ -2436,7 +2436,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
24362436
}
24372437

24382438
// save map tip
2439-
if ( categories.testFlag( QgsMapLayerStyle::MapTips ) )
2439+
if ( categories.testFlag( MapTips ) )
24402440
{
24412441
QDomElement mapTipElem = doc.createElement( QStringLiteral( "mapTip" ) );
24422442
QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
@@ -2448,15 +2448,15 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
24482448
}
24492449

24502450
bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
2451-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
2451+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
24522452
{
24532453
QDomElement mapLayerNode = node.toElement();
24542454

24552455
emit writeCustomSymbology( mapLayerNode, doc, errorMessage );
24562456

24572457
if ( isSpatial() )
24582458
{
2459-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
2459+
if ( categories.testFlag( Symbology ) )
24602460
{
24612461
if ( mRenderer )
24622462
{
@@ -2465,7 +2465,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
24652465
}
24662466
}
24672467

2468-
if ( categories.testFlag( QgsMapLayerStyle::Labels ) )
2468+
if ( categories.testFlag( Labels ) )
24692469
{
24702470
if ( mLabeling )
24712471
{
@@ -2476,7 +2476,7 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
24762476
}
24772477

24782478
// save the simplification drawing settings
2479-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
2479+
if ( categories.testFlag( Rendering ) )
24802480
{
24812481
mapLayerNode.setAttribute( QStringLiteral( "simplifyDrawingHints" ), QString::number( mSimplifyMethod.simplifyHints() ) );
24822482
mapLayerNode.setAttribute( QStringLiteral( "simplifyAlgorithm" ), QString::number( mSimplifyMethod.simplifyAlgorithm() ) );
@@ -2486,12 +2486,12 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
24862486
}
24872487

24882488
//save customproperties
2489-
if ( categories.testFlag( QgsMapLayerStyle::CustomProperties ) )
2489+
if ( categories.testFlag( CustomProperties ) )
24902490
{
24912491
writeCustomProperties( node, doc );
24922492
}
24932493

2494-
if ( categories.testFlag( QgsMapLayerStyle::Symbology ) )
2494+
if ( categories.testFlag( Symbology ) )
24952495
{
24962496
// add the blend mode field
24972497
QDomElement blendModeElem = doc.createElement( QStringLiteral( "blendMode" ) );
@@ -2507,15 +2507,15 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
25072507
}
25082508

25092509
// add the layer opacity
2510-
if ( categories.testFlag( QgsMapLayerStyle::Rendering ) )
2510+
if ( categories.testFlag( Rendering ) )
25112511
{
25122512
QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
25132513
QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
25142514
layerOpacityElem.appendChild( layerOpacityText );
25152515
node.appendChild( layerOpacityElem );
25162516
}
25172517

2518-
if ( categories.testFlag( QgsMapLayerStyle::Diagrams ) && mDiagramRenderer )
2518+
if ( categories.testFlag( Diagrams ) && mDiagramRenderer )
25192519
{
25202520
mDiagramRenderer->writeXml( mapLayerNode, doc, context );
25212521
if ( mDiagramLayerSettings )

‎src/core/qgsvectorlayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
881881
* \returns true in case of success.
882882
*/
883883
bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
884-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
884+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
885885

886886
/**
887887
* Read the style for the current layer from the Dom node supplied.
@@ -891,7 +891,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
891891
* \returns true in case of success.
892892
*/
893893
bool readStyle( const QDomNode &node, QString &errorMessage,
894-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
894+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
895895

896896
/**
897897
* Write the symbology for the layer into the docment provided.
@@ -902,7 +902,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
902902
* \returns true in case of success.
903903
*/
904904
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
905-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
905+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
906906

907907
/**
908908
* Write just the style information for the layer into the document
@@ -913,7 +913,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
913913
* \returns true in case of success.
914914
*/
915915
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
916-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
916+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
917917

918918
/**
919919
* Writes the symbology of the layer into the document provided in SLD 1.1 format

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ QImage QgsRasterLayer::previewAsImage( QSize size, const QColor &bgColor, QImage
13071307
* \return true in case of success.
13081308
*/
13091309
bool QgsRasterLayer::readSymbology( const QDomNode &layer_node, QString &errorMessage,
1310-
QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
1310+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
13111311
{
13121312
Q_UNUSED( errorMessage );
13131313
// TODO: implement categories for raster layer
@@ -1401,7 +1401,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode &layer_node, QString &errorMe
14011401
return true;
14021402
}
14031403

1404-
bool QgsRasterLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories )
1404+
bool QgsRasterLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
14051405
{
14061406
return readSymbology( node, errorMessage, context, categories );
14071407
}
@@ -1549,7 +1549,7 @@ bool QgsRasterLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &c
15491549
* \return true in case of success.
15501550
*/
15511551
bool QgsRasterLayer::writeSymbology( QDomNode &layer_node, QDomDocument &document, QString &errorMessage,
1552-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
1552+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
15531553
{
15541554
Q_UNUSED( errorMessage );
15551555
// TODO: implement categories for raster layer
@@ -1580,7 +1580,7 @@ bool QgsRasterLayer::writeSymbology( QDomNode &layer_node, QDomDocument &documen
15801580
}
15811581

15821582
bool QgsRasterLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1583-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories ) const
1583+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
15841584
{
15851585
return writeSymbology( node, doc, errorMessage, context, categories );
15861586
} // bool QgsRasterLayer::writeSymbology

‎src/core/raster/qgsrasterlayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
404404
void showStatusMessage( const QString &message );
405405

406406
protected:
407-
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
408-
bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) override;
407+
bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
408+
bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override;
409409
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
410410
bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage,
411-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
411+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
412412
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
413-
const QgsReadWriteContext &context, QgsMapLayerStyle::StyleCategories categories = QgsMapLayerStyle::All ) const override;
413+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override;
414414
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
415415
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
416416
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;

0 commit comments

Comments
 (0)
Please sign in to comment.