Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move layer notes utils to a new QgsLayerNotesUtils class so that they…
… are accessible from core
- Loading branch information
1 parent
d07348d
commit 3bdb2bb
Showing
9 changed files
with
180 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgslayernotesutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLayerNotesUtils | ||
{ | ||
%Docstring(signature="appended") | ||
|
||
Contains utility functions for working with layer notes. | ||
|
||
.. versionadded:: 3.20 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayernotesutils.h" | ||
%End | ||
public: | ||
|
||
static QString layerNotes( QgsMapLayer *layer ); | ||
%Docstring | ||
Returns the notes for the specified ``layer``. | ||
|
||
The returned string is a HTML formatted set of user notations for the layer. | ||
%End | ||
|
||
static void setLayerNotes( QgsMapLayer *layer, const QString ¬es ); | ||
%Docstring | ||
Sets the ``notes`` for the specified ``layer``, where ``notes`` is a HTML formatted string. | ||
%End | ||
|
||
static bool layerHasNotes( QgsMapLayer *layer ); | ||
%Docstring | ||
Returns ``True`` if the specified ``layer`` has notes available. | ||
%End | ||
|
||
static void removeNotes( QgsMapLayer *layer ); | ||
%Docstring | ||
Removes any notes for the specified ``layer``. | ||
%End | ||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgslayernotesutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*************************************************************************** | ||
qgslayernotesutils.cpp | ||
-------------------------------------- | ||
Date : April 2021 | ||
Copyright : (C) 2021 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayernotesutils.h" | ||
#include "qgsmaplayer.h" | ||
|
||
QString QgsLayerNotesUtils::layerNotes( QgsMapLayer *layer ) | ||
{ | ||
if ( !layer ) | ||
return nullptr; | ||
|
||
return layer->customProperty( QStringLiteral( "userNotes" ) ).toString(); | ||
} | ||
|
||
void QgsLayerNotesUtils::setLayerNotes( QgsMapLayer *layer, const QString ¬es ) | ||
{ | ||
if ( !layer ) | ||
return; | ||
|
||
if ( notes.isEmpty() ) | ||
layer->removeCustomProperty( QStringLiteral( "userNotes" ) ); | ||
else | ||
layer->setCustomProperty( QStringLiteral( "userNotes" ), notes ); | ||
} | ||
|
||
bool QgsLayerNotesUtils::layerHasNotes( QgsMapLayer *layer ) | ||
{ | ||
if ( !layer ) | ||
return false; | ||
|
||
return !layer->customProperty( QStringLiteral( "userNotes" ) ).toString().isEmpty(); | ||
} | ||
|
||
void QgsLayerNotesUtils::removeNotes( QgsMapLayer *layer ) | ||
{ | ||
if ( layer ) | ||
layer->removeCustomProperty( QStringLiteral( "userNotes" ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*************************************************************************** | ||
qgslayernotesutils.h | ||
-------------------------------------- | ||
Date : April 2021 | ||
Copyright : (C) 2021 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSLAYERNOTESUTILS_H | ||
#define QGSLAYERNOTESUTILS_H | ||
|
||
#include "qgis_core.h" | ||
#include <QString> | ||
|
||
class QgsMapLayer; | ||
|
||
/** | ||
* \ingroup core | ||
* | ||
* \brief Contains utility functions for working with layer notes. | ||
* | ||
* \since QGIS 3.20 | ||
*/ | ||
class CORE_EXPORT QgsLayerNotesUtils | ||
{ | ||
public: | ||
|
||
/** | ||
* Returns the notes for the specified \a layer. | ||
* | ||
* The returned string is a HTML formatted set of user notations for the layer. | ||
*/ | ||
static QString layerNotes( QgsMapLayer *layer ); | ||
|
||
/** | ||
* Sets the \a notes for the specified \a layer, where \a notes is a HTML formatted string. | ||
*/ | ||
static void setLayerNotes( QgsMapLayer *layer, const QString ¬es ); | ||
|
||
/** | ||
* Returns TRUE if the specified \a layer has notes available. | ||
*/ | ||
static bool layerHasNotes( QgsMapLayer *layer ); | ||
|
||
/** | ||
* Removes any notes for the specified \a layer. | ||
*/ | ||
static void removeNotes( QgsMapLayer *layer ); | ||
|
||
}; | ||
|
||
|
||
#endif // QGSLAYERNOTESUTILS_H |