QGIS API Documentation
4.3.0-Master (9dce731a7a1)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgslayernotesutils.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayernotesutils.cpp
3
--------------------------------------
4
Date : April 2021
5
Copyright : (C) 2021 by Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgslayernotesutils.h
"
17
18
#include "
qgsmaplayer.h
"
19
20
#include <QString>
21
22
using namespace
Qt::StringLiterals;
23
24
QString
QgsLayerNotesUtils::layerNotes
(
const
QgsMapLayer
*layer )
25
{
26
if
( !layer )
27
return
nullptr
;
28
29
return
layer->
customProperty
( u
"userNotes"
_s ).toString();
30
}
31
32
void
QgsLayerNotesUtils::setLayerNotes
(
QgsMapLayer
*layer,
const
QString ¬es )
33
{
34
if
( !layer )
35
return
;
36
37
if
( notes.isEmpty() )
38
layer->
removeCustomProperty
( u
"userNotes"
_s );
39
else
40
layer->
setCustomProperty
( u
"userNotes"
_s, notes );
41
}
42
43
bool
QgsLayerNotesUtils::layerHasNotes
(
const
QgsMapLayer
*layer )
44
{
45
if
( !layer )
46
return
false
;
47
48
return
!layer->
customProperty
( u
"userNotes"
_s ).toString().isEmpty();
49
}
50
51
void
QgsLayerNotesUtils::removeNotes
(
QgsMapLayer
*layer )
52
{
53
if
( layer )
54
layer->
removeCustomProperty
( u
"userNotes"
_s );
55
}
QgsLayerNotesUtils::setLayerNotes
static void setLayerNotes(QgsMapLayer *layer, const QString ¬es)
Sets the notes for the specified layer, where notes is a HTML formatted string.
Definition
qgslayernotesutils.cpp:32
QgsLayerNotesUtils::removeNotes
static void removeNotes(QgsMapLayer *layer)
Removes any notes for the specified layer.
Definition
qgslayernotesutils.cpp:51
QgsLayerNotesUtils::layerHasNotes
static bool layerHasNotes(const QgsMapLayer *layer)
Returns true if the specified layer has notes available.
Definition
qgslayernotesutils.cpp:43
QgsLayerNotesUtils::layerNotes
static QString layerNotes(const QgsMapLayer *layer)
Returns the notes for the specified layer.
Definition
qgslayernotesutils.cpp:24
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsMapLayer::customProperty
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Definition
qgsmaplayer.cpp:2612
QgsMapLayer::removeCustomProperty
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
Definition
qgsmaplayer.cpp:2620
QgsMapLayer::setCustomProperty
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
Definition
qgsmaplayer.cpp:2583
qgslayernotesutils.h
qgsmaplayer.h
Generated on
for QGIS API Documentation by
1.17.0