/
qgsmaplayer.sip.in
1755 lines (1251 loc) · 48.5 KB
/
qgsmaplayer.sip.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmaplayer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
enum class QgsMapLayerType
{
VectorLayer,
RasterLayer,
PluginLayer,
MeshLayer,
VectorTileLayer,
AnnotationLayer,
};
class QgsMapLayer : QObject
{
%Docstring
Base class for all map layer types.
This is the base class for all map layer types (vector, raster).
%End
%TypeHeaderCode
#include "qgsmaplayer.h"
%End
%ConvertToSubClassCode
QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );
sipType = 0;
if ( layer )
{
switch ( layer->type() )
{
case QgsMapLayerType::VectorLayer:
sipType = sipType_QgsVectorLayer;
break;
case QgsMapLayerType::RasterLayer:
sipType = sipType_QgsRasterLayer;
break;
case QgsMapLayerType::PluginLayer:
sipType = sipType_QgsPluginLayer;
break;
case QgsMapLayerType::MeshLayer:
sipType = sipType_QgsMeshLayer;
break;
case QgsMapLayerType::VectorTileLayer:
sipType = sipType_QgsVectorTileLayer;
break;
case QgsMapLayerType::AnnotationLayer:
sipType = sipType_QgsAnnotationLayer;
break;
default:
sipType = nullptr;
break;
}
}
%End
public:
enum PropertyType
{
Style,
Metadata,
};
enum LayerFlag
{
Identifiable,
Removable,
Searchable,
};
typedef QFlags<QgsMapLayer::LayerFlag> LayerFlags;
enum StyleCategory
{
LayerConfiguration,
Symbology,
Symbology3D,
Labeling,
Fields,
Forms,
Actions,
MapTips,
Diagrams,
AttributeTable,
Rendering,
CustomProperties,
GeometryOptions,
Relations,
Temporal,
Legend,
AllStyleCategories
};
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;
QgsMapLayer( QgsMapLayerType type = QgsMapLayerType::VectorLayer, const QString &name = QString(), const QString &source = QString() );
%Docstring
Constructor for QgsMapLayer
:param type: layer type
:param name: display name for the layer
:param source: datasource of layer
%End
~QgsMapLayer();
virtual QgsMapLayer *clone() const = 0;
%Docstring
Returns a new instance equivalent to this one except for the id which
is still unique.
:return: a new layer instance
.. versionadded:: 3.0
%End
QgsMapLayerType type() const;
%Docstring
Returns the type of the layer.
%End
QgsMapLayer::LayerFlags flags() const;
%Docstring
Returns the flags for this layer.
.. note::
Flags are options specified by the user used for the UI but are not preventing any API call.
For instance, even if the Removable flag is not set, the layer can still be removed with the API
but the action will not be listed in the legend menu.
.. versionadded:: 3.4
%End
void setFlags( QgsMapLayer::LayerFlags flags );
%Docstring
Returns the flags for this layer.
.. note::
Flags are options specified by the user used for the UI but are not preventing any API call.
For instance, even if the Removable flag is not set, the layer can still be removed with the API
but the action will not be listed in the legend menu.
.. versionadded:: 3.4
%End
static QString extensionPropertyType( PropertyType type );
%Docstring
Returns the extension of a Property.
:return: The extension
.. versionadded:: 3.0
%End
QString id() const;
%Docstring
Returns the layer's unique ID, which is used to access this layer from :py:class:`QgsProject`.
%End
void setName( const QString &name );
%Docstring
Set the display ``name`` of the layer.
.. seealso:: :py:func:`name`
.. versionadded:: 2.16
%End
QString name() const;
%Docstring
Returns the display name of the layer.
.. seealso:: :py:func:`setName`
%End
virtual QgsDataProvider *dataProvider();
%Docstring
Returns the layer's data provider, it may be ``None``.
%End
void setShortName( const QString &shortName );
%Docstring
Sets the short name of the layer
used by QGIS Server to identify the layer.
:return: the layer short name
.. seealso:: :py:func:`shortName`
%End
QString shortName() const;
%Docstring
Returns the short name of the layer
used by QGIS Server to identify the layer.
.. seealso:: :py:func:`setShortName`
%End
void setTitle( const QString &title );
%Docstring
Sets the title of the layer
used by QGIS Server in GetCapabilities request.
.. seealso:: :py:func:`title`
%End
QString title() const;
%Docstring
Returns the title of the layer
used by QGIS Server in GetCapabilities request.
:return: the layer title
.. seealso:: :py:func:`setTitle`
%End
void setAbstract( const QString &abstract );
%Docstring
Sets the abstract of the layer
used by QGIS Server in GetCapabilities request.
:return: the layer abstract
.. seealso:: :py:func:`abstract`
%End
QString abstract() const;
%Docstring
Returns the abstract of the layer
used by QGIS Server in GetCapabilities request.
:return: the layer abstract
.. seealso:: :py:func:`setAbstract`
%End
void setKeywordList( const QString &keywords );
%Docstring
Sets the keyword list of the layer
used by QGIS Server in GetCapabilities request.
:return: the layer keyword list
.. seealso:: :py:func:`keywordList`
%End
QString keywordList() const;
%Docstring
Returns the keyword list of the layer
used by QGIS Server in GetCapabilities request.
:return: the layer keyword list
.. seealso:: :py:func:`setKeywordList`
%End
void setDataUrl( const QString &dataUrl );
%Docstring
Sets the DataUrl of the layer
used by QGIS Server in GetCapabilities request.
DataUrl is a a link to the underlying data represented by a particular layer.
:return: the layer DataUrl
.. seealso:: :py:func:`dataUrl`
%End
QString dataUrl() const;
%Docstring
Returns the DataUrl of the layer
used by QGIS Server in GetCapabilities request.
DataUrl is a a link to the underlying data represented by a particular layer.
:return: the layer DataUrl
.. seealso:: :py:func:`setDataUrl`
%End
void setDataUrlFormat( const QString &dataUrlFormat );
%Docstring
Sets the DataUrl format of the layer
used by QGIS Server in GetCapabilities request.
DataUrl is a a link to the underlying data represented by a particular layer.
:return: the layer DataUrl format
.. seealso:: :py:func:`dataUrlFormat`
%End
QString dataUrlFormat() const;
%Docstring
Returns the DataUrl format of the layer
used by QGIS Server in GetCapabilities request.
DataUrl is a a link to the underlying data represented by a particular layer.
:return: the layer DataUrl format
.. seealso:: :py:func:`setDataUrlFormat`
%End
void setAttribution( const QString &attrib );
%Docstring
Sets the attribution of the layer
used by QGIS Server in GetCapabilities request.
Attribution indicates the provider of a layer or collection of layers.
:return: the layer attribution
.. seealso:: :py:func:`attribution`
%End
QString attribution() const;
%Docstring
Returns the attribution of the layer
used by QGIS Server in GetCapabilities request.
Attribution indicates the provider of a layer or collection of layers.
:return: the layer attribution
.. seealso:: :py:func:`setAttribution`
%End
void setAttributionUrl( const QString &attribUrl );
%Docstring
Sets the attribution URL of the layer
used by QGIS Server in GetCapabilities request.
Attribution indicates the provider of a layer or collection of layers.
:return: the layer attribution URL
.. seealso:: :py:func:`attributionUrl`
%End
QString attributionUrl() const;
%Docstring
Returns the attribution URL of the layer
used by QGIS Server in GetCapabilities request.
Attribution indicates the provider of a layer or collection of layers.
:return: the layer attribution URL
.. seealso:: :py:func:`setAttributionUrl`
%End
void setMetadataUrl( const QString &metaUrl );
%Docstring
Sets the metadata URL of the layer
used by QGIS Server in GetCapabilities request.
MetadataUrl is a a link to the detailed, standardized metadata about the data.
:return: the layer metadata URL
.. seealso:: :py:func:`metadataUrl`
%End
QString metadataUrl() const;
%Docstring
Returns the metadata URL of the layer
used by QGIS Server in GetCapabilities request.
MetadataUrl is a a link to the detailed, standardized metadata about the data.
:return: the layer metadata URL
.. seealso:: :py:func:`setMetadataUrl`
%End
void setMetadataUrlType( const QString &metaUrlType );
%Docstring
Set the metadata type of the layer
used by QGIS Server in GetCapabilities request
MetadataUrlType indicates the standard to which the metadata complies.
:return: the layer metadata type
.. seealso:: :py:func:`metadataUrlType`
%End
QString metadataUrlType() const;
%Docstring
Returns the metadata type of the layer
used by QGIS Server in GetCapabilities request.
MetadataUrlType indicates the standard to which the metadata complies.
:return: the layer metadata type
.. seealso:: :py:func:`setMetadataUrlType`
%End
void setMetadataUrlFormat( const QString &metaUrlFormat );
%Docstring
Sets the metadata format of the layer
used by QGIS Server in GetCapabilities request.
MetadataUrlType indicates how the metadata is structured.
:return: the layer metadata format
.. seealso:: :py:func:`metadataUrlFormat`
%End
QString metadataUrlFormat() const;
%Docstring
Returns the metadata format of the layer
used by QGIS Server in GetCapabilities request.
MetadataUrlType indicates how the metadata is structured.
:return: the layer metadata format
.. seealso:: :py:func:`setMetadataUrlFormat`
%End
void setBlendMode( QPainter::CompositionMode blendMode );
%Docstring
Set the blending mode used for rendering a layer.
:param blendMode: new blending mode
.. seealso:: :py:func:`blendMode`
%End
QPainter::CompositionMode blendMode() const;
%Docstring
Returns the current blending mode for a layer.
.. seealso:: :py:func:`setBlendMode`
%End
bool readOnly() const;
%Docstring
Returns if this layer is read only.
%End
virtual void reload();
%Docstring
Synchronises with changes in the datasource
%End
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) = 0 /Factory/;
%Docstring
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context
.. versionadded:: 2.4
%End
virtual QgsRectangle extent() const;
%Docstring
Returns the extent of the layer.
%End
bool isValid() const;
%Docstring
Returns the status of the layer. An invalid layer is one which has a bad datasource
or other problem. Child classes set this flag when initialized.
:return: ``True`` if the layer is valid and can be accessed
%End
QString publicSource() const;
%Docstring
Gets a version of the internal layer definition that has sensitive
bits removed (for example, the password). This function should
be used when displaying the source name for general viewing.
.. seealso:: :py:func:`source`
%End
QString source() const;
%Docstring
Returns the source for the layer. This source may contain usernames, passwords
and other sensitive information.
.. seealso:: :py:func:`publicSource`
%End
virtual QStringList subLayers() const;
%Docstring
Returns the sublayers of this layer.
(Useful for providers that manage their own layers, such as WMS).
%End
virtual void setLayerOrder( const QStringList &layers );
%Docstring
Reorders the *previously selected* sublayers of this layer from bottom to top.
(Useful for providers that manage their own layers, such as WMS).
%End
virtual void setSubLayerVisibility( const QString &name, bool visible );
%Docstring
Set the visibility of the given sublayer name.
:param name: sublayer name
:param visible: sublayer visibility
%End
virtual bool isEditable() const;
%Docstring
Returns ``True`` if the layer can be edited.
%End
virtual bool isSpatial() const;
%Docstring
Returns ``True`` if the layer is considered a spatial layer, ie it has some form of geometry associated with it.
.. versionadded:: 2.16
%End
virtual bool isTemporary() const;
%Docstring
Returns ``True`` if the layer is considered a temporary layer.
These include memory-only layers such as those created by the "memory" data provider, layers
stored inside a local temporary folder (such as the "/tmp" folder on Linux)
or layer with temporary data (as temporary mesh layer dataset)
.. versionadded:: 3.10.1
%End
enum ReadFlag
{
FlagDontResolveLayers,
FlagTrustLayerMetadata,
};
typedef QFlags<QgsMapLayer::ReadFlag> ReadFlags;
bool readLayerXml( const QDomElement &layerElement, QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
%Docstring
Sets state from DOM document
:param layerElement: The DOM element corresponding to ``maplayer'' tag
:param context: writing context (e.g. for conversion between relative and absolute paths)
:param flags: optional argument which can be used to control layer reading behavior.
\note
The DOM node corresponds to a DOM document project file XML element read
by :py:class:`QgsProject`.
This, in turn, calls :py:func:`~QgsMapLayer.readXml` (and then :py:func:`~QgsMapLayer.readSymbology`), which is overridable
by sub-classes so that they can read their own specific state from the given DOM node.
Invoked by :py:func:`QgsProject.read()`.
:return: ``True`` if successful
%End
bool writeLayerXml( QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Stores state in DOM node
:param layerElement: is a DOM element corresponding to ``maplayer'' tag
:param document: is a the DOM document being written
:param context: reading context (e.g. for conversion between relative and absolute paths)
\note
The DOM node corresponds to a DOM document project file XML element to be
written by :py:class:`QgsProject`.
This, in turn, calls :py:func:`~QgsMapLayer.writeXml` (and then writeSymbology), which is over-rideable
by sub-classes so that they can write their own specific state to the given DOM node.
Invoked by :py:func:`QgsProject.write()`.
:return: ``True`` if successful
%End
virtual void resolveReferences( QgsProject *project );
%Docstring
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
.. versionadded:: 3.0
%End
QStringList customPropertyKeys() const;
%Docstring
Returns list of all keys within custom properties. Properties are stored in a map and saved in project file.
.. seealso:: :py:func:`customProperty`
.. versionadded:: 3.0
%End
void setCustomProperty( const QString &key, const QVariant &value );
%Docstring
Set a custom property for layer. Properties are stored in a map and saved in project file.
.. seealso:: :py:func:`customProperty`
.. seealso:: :py:func:`removeCustomProperty`
%End
QVariant customProperty( const QString &value, const QVariant &defaultValue = QVariant() ) const;
%Docstring
Read a custom property from layer. Properties are stored in a map and saved in project file.
.. seealso:: :py:func:`setCustomProperty`
%End
void setCustomProperties( const QgsObjectCustomProperties &properties );
%Docstring
Set custom properties for layer. Current properties are dropped.
.. versionadded:: 3.0
%End
const QgsObjectCustomProperties &customProperties() const;
%Docstring
Read all custom properties from layer. Properties are stored in a map and saved in project file.
.. seealso:: :py:func:`setCustomProperties`
.. versionadded:: 3.14
%End
void removeCustomProperty( const QString &key );
%Docstring
Remove a custom property from layer. Properties are stored in a map and saved in project file.
.. seealso:: :py:func:`setCustomProperty`
%End
virtual QgsError error() const;
%Docstring
Gets current status error. This error describes some principal problem
for which layer cannot work and thus is not valid. It is not last error
after accessing data by :py:func:`~QgsMapLayer.draw` etc.
%End
QgsCoordinateReferenceSystem crs() const;
%Docstring
Returns the layer's spatial reference system.
.. versionadded:: 1.4
%End
void setCrs( const QgsCoordinateReferenceSystem &srs, bool emitSignal = true );
%Docstring
Sets layer's spatial reference system
%End
QgsCoordinateTransformContext transformContext( ) const;
%Docstring
Returns the layer data provider coordinate transform context
or a default transform context if the layer does not have a valid data provider.
.. versionadded:: 3.8
%End
static QString formatLayerName( const QString &name );
%Docstring
A convenience function to capitalize and format a layer ``name``.
.. versionadded:: 3.0
%End
virtual QString metadataUri() const;
%Docstring
Retrieve the metadata URI for this layer
(either as a .qmd file on disk or as a
record in the users style table in their personal qgis.db)
:return: a QString with the metadata file name
.. versionadded:: 3.0
%End
void exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) const;
%Docstring
Export the current metadata of this layer as named metadata in a QDomDocument
:param doc: the target QDomDocument
:param errorMsg: this QString will be initialized on error
.. versionadded:: 3.0
%End
virtual QString saveDefaultMetadata( bool &resultFlag /Out/ );
%Docstring
Save the current metadata of this layer as the default metadata
(either as a .qmd file on disk or as a
record in the users style table in their personal qgis.db)
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to save the default metadata.
.. versionadded:: 3.0
%End
QString saveNamedMetadata( const QString &uri, bool &resultFlag );
%Docstring
Save the current metadata of this layer as a named metadata
(either as a .qmd file on disk or as a
record in the users style table in their personal qgis.db)
:param uri: the file name or other URI for the
metadata file. First an attempt will be made to see if this
is a file and save to that, if that fails the qgis.db metadata
table will be used to create a metadata entry who's
key matches the URI.
:param resultFlag: a reference to a flag that will be set to ``False`` if
we did not manage to save the default metadata.
:return: a QString with any status messages
.. versionadded:: 3.0
%End
virtual QString loadNamedMetadata( const QString &uri, bool &resultFlag /Out/ );
%Docstring
Retrieve a named metadata for this layer if one
exists (either as a .qmd file on disk or as a
record in the users style table in their personal qgis.db)
:param uri: - the file name or other URI for the
metadata file. First an attempt will be made to see if this
is a file and load that, if that fails the qgis.db metadata
table will be consulted to see if there is a metadata who's
key matches the URI.
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to load the default metadata.
.. versionadded:: 3.0
%End
virtual QString loadDefaultMetadata( bool &resultFlag );
%Docstring
Retrieve the default metadata for this layer if one
exists (either as a .qmd file on disk or as a
record in the users metadata table in their personal qgis.db)
:param resultFlag: a reference to a flag that will be set to ``False`` if
we did not manage to load the default metadata.
:return: a QString with any status messages
.. versionadded:: 3.0
%End
bool loadNamedMetadataFromDatabase( const QString &db, const QString &uri, QString &qmd );
%Docstring
Retrieve a named metadata for this layer from a sqlite database.
:param db: path to sqlite database
:param uri: uri for table
:param qmd: will be set to QMD xml metadata content from database
:return: ``True`` if style was successfully loaded
.. versionadded:: 3.0
%End
bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
%Docstring
Import the metadata of this layer from a QDomDocument
:param document: source QDomDocument
:param errorMessage: this QString will be initialized on error
:return: ``True`` on success
.. versionadded:: 3.0
%End
virtual QString styleURI() const;
%Docstring
Retrieve the style URI for this layer
(either as a .qml file on disk or as a
record in the users style table in their personal qgis.db)
:return: a QString with the style file name
.. seealso:: :py:func:`also`
%End
virtual QString loadDefaultStyle( bool &resultFlag /Out/ );
%Docstring
Retrieve the default style for this layer if one
exists (either as a .qml file on disk or as a
record in the users style table in their personal qgis.db)
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to load the default style.
.. seealso:: :py:func:`also`
%End
virtual QString loadNamedStyle( const QString &uri, bool &resultFlag /Out/, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
%Docstring
Retrieve a named style for this layer if one
exists (either as a .qml file on disk or as a
record in the users style table in their personal qgis.db)
:param uri: - the file name or other URI for the
style file. First an attempt will be made to see if this
is a file and load that, if that fails the qgis.db styles
table will be consulted to see if there is a style who's
key matches the URI.
:param categories: the style categories to be loaded.
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to load the default style.
.. seealso:: :py:func:`also`
%End
virtual bool loadNamedStyleFromDatabase( const QString &db, const QString &uri, QString &qml /Out/ );
%Docstring
Retrieve a named style for this layer from a sqlite database.
:param db: path to sqlite database
:param uri: uri for table
:return: - ``True`` if style was successfully loaded
- qml: will be set to QML style content from database
%End
virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg /Out/,
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
%Docstring
Import the properties of this layer from a QDomDocument
:param doc: source QDomDocument
:param errorMsg: this QString will be initialized on error
during the execution of readSymbology
:param categories: the style categories to import
:return: ``True`` on success
.. versionadded:: 2.8
%End
virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, const QgsReadWriteContext &context = QgsReadWriteContext(),
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
%Docstring
Export the properties of this layer as named style in a QDomDocument
:param doc: the target QDomDocument
:param errorMsg: this QString will be initialized on error
:param context: read write context
:param categories: the style categories to export
during the execution of writeSymbology
%End
virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg ) const;
%Docstring
Export the properties of this layer as SLD style in a QDomDocument
:param doc: the target QDomDocument
:param errorMsg: this QString will be initialized on error
during the execution of writeSymbology
%End
virtual QString saveDefaultStyle( bool &resultFlag /Out/ );
%Docstring
Save the properties of this layer as the default style
(either as a .qml file on disk or as a
record in the users style table in their personal qgis.db)
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to save the default style.
.. seealso:: :py:func:`loadNamedStyle`
%End
virtual QString saveNamedStyle( const QString &uri, bool &resultFlag /Out/, StyleCategories categories = AllStyleCategories );
%Docstring
Save the properties of this layer as a named style
(either as a .qml file on disk or as a
record in the users style table in their personal qgis.db)
:param uri: the file name or other URI for the
style file. First an attempt will be made to see if this
is a file and save to that, if that fails the qgis.db styles
table will be used to create a style entry who's
key matches the URI.
:param categories: the style categories to be saved.
:return: - a QString with any status messages
- resultFlag: a reference to a flag that will be set to ``False`` if we did not manage to save the default style.
.. seealso:: :py:func:`saveDefaultStyle`
%End
virtual QString saveSldStyle( const QString &uri, bool &resultFlag ) const;
%Docstring
Saves the properties of this layer to an SLD format file.
:param uri: uri of destination for exported SLD file.
:param resultFlag: a reference to a flag that will be set to ``False`` if
the SLD file could not be generated
:return: a string with any status or error messages
.. seealso:: :py:func:`loadSldStyle`
%End
virtual QString loadSldStyle( const QString &uri, bool &resultFlag );
%Docstring
Attempts to style the layer using the formatting from an SLD type file.
:param uri: uri of source SLD file
:param resultFlag: a reference to a flag that will be set to ``False`` if
the SLD file could not be loaded
:return: a string with any status or error messages
.. seealso:: :py:func:`saveSldStyle`
%End
virtual bool readSld( const QDomNode &node, QString &errorMessage );
virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) = 0;
%Docstring
Read the symbology for the current layer from the DOM node supplied.
:param node: node that will contain the symbology definition for this layer.
:param errorMessage: reference to string that will be updated with any error messages
:param context: reading context (used for transform from relative to absolute paths)
:param categories: the style categories to be read
:return: ``True`` in case of success.
%End
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories );
%Docstring
Read the style for the current layer from the DOM node supplied.
:param node: node that will contain the style definition for this layer.
:param errorMessage: reference to string that will be updated with any error messages
:param context: reading context (used for transform from relative to absolute paths)
:param categories: the style categories to be read
:return: ``True`` in case of success.
.. note::
To be implemented in subclasses. Default implementation does nothing and returns ``False``.
.. versionadded:: 2.16
%End
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
StyleCategories categories = AllStyleCategories ) const = 0;
%Docstring
Write the style for the layer into the docment provided.
:param node: the node that will have the style element added to it.
:param doc: the document that will have the QDomNode added.
:param errorMessage: reference to string that will be updated with any error messages
:param context: writing context (used for transform from absolute to relative paths)
:param categories: the style categories to be written
.. note::
There is a confusion of terms with the GUI. This method actually writes what is called a style in the application.
:return: ``True`` in case of success.
%End
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
StyleCategories categories = AllStyleCategories ) const;
%Docstring
Write just the symbology information for the layer into the document
:param node: the node that will have the style element added to it.
:param doc: the document that will have the QDomNode added.
:param errorMessage: reference to string that will be updated with any error messages
:param context: writing context (used for transform from absolute to relative paths)
:param categories: the style categories to be written
:return: ``True`` in case of success.