QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
QgsPathResolver Class Reference

Resolves relative paths into absolute paths and vice versa. More...

#include <qgspathresolver.h>

Public Member Functions

 QgsPathResolver (const QString &baseFileName=QString(), const QString &attachmentDir=QString())
 Initialize path resolver with a base filename. Null filename means no conversion between relative/absolute path.
 
QString readPath (const QString &filename) const
 Turn filename read from the project file to an absolute path.
 
QString writePath (const QString &filename) const
 Prepare a filename to save it to the project file.
 

Static Public Member Functions

static bool removePathPreprocessor (const QString &id)
 Removes the custom pre-processor function with matching id.
 
static bool removePathWriter (const QString &id)
 Removes the custom writer function with matching id.
 
static QString setPathPreprocessor (const std::function< QString(const QString &filename)> &processor)
 Sets a path pre-processor function, which allows for manipulation of paths and data sources prior to resolving them to file references or layer sources.
 
static QString setPathWriter (const std::function< QString(const QString &filename)> &writer)
 Sets a path writer function, which allows for manipulation of paths and data sources prior to writing them to the project file.
 

Detailed Description

Resolves relative paths into absolute paths and vice versa.

Used for writing

Definition at line 30 of file qgspathresolver.h.

Constructor & Destructor Documentation

◆ QgsPathResolver()

QgsPathResolver::QgsPathResolver ( const QString &  baseFileName = QString(),
const QString &  attachmentDir = QString() 
)
explicit

Initialize path resolver with a base filename. Null filename means no conversion between relative/absolute path.

Definition at line 35 of file qgspathresolver.cpp.

Member Function Documentation

◆ readPath()

QString QgsPathResolver::readPath ( const QString &  filename) const

Turn filename read from the project file to an absolute path.

Definition at line 41 of file qgspathresolver.cpp.

◆ removePathPreprocessor()

bool QgsPathResolver::removePathPreprocessor ( const QString &  id)
static

Removes the custom pre-processor function with matching id.

The id must correspond to a pre-processor previously added via a call to setPathPreprocessor().

Returns true if processor existed and was removed.

See also
setPathPreprocessor()
Since
QGIS 3.10

Definition at line 207 of file qgspathresolver.cpp.

◆ removePathWriter()

bool QgsPathResolver::removePathWriter ( const QString &  id)
static

Removes the custom writer function with matching id.

The id must correspond to a writer previously added via a call to setPathWriter().

Returns true if writer existed and was removed.

See also
setPathWriter()
Since
QGIS 3.22

Definition at line 224 of file qgspathresolver.cpp.

◆ setPathPreprocessor()

QString QgsPathResolver::setPathPreprocessor ( const std::function< QString(const QString &filename)> &  processor)
static

Sets a path pre-processor function, which allows for manipulation of paths and data sources prior to resolving them to file references or layer sources.

The processor function must accept a single string argument (representing the original file path or data source), and return a processed version of this path.

The path pre-processor function is called before any bad layer handler.

If multiple preprocessors are set, they will be called in sequence based on the order in which they were originally set.

Returns
An auto-generated string uniquely identifying the preprocessor, which can later be used to remove the processor (via a call to removePathPreprocessor()).
See also
removePathPreprocessor()
Since
QGIS 3.10

Definition at line 200 of file qgspathresolver.cpp.

◆ setPathWriter()

QString QgsPathResolver::setPathWriter ( const std::function< QString(const QString &filename)> &  writer)
static

Sets a path writer function, which allows for manipulation of paths and data sources prior to writing them to the project file.

The writer function must accept a single string argument (representing the original file path or data source), and return a processed version of this path.

The path writer function is called before any bad layer handler.

If multiple writers are set, they will be called in sequence based on the order in which they were originally set.

Returns
An auto-generated string uniquely identifying the writer, which can later be used to remove the writer (via a call to removePathWriter()).
See also
removePathWriter()
Since
QGIS 3.22

Definition at line 217 of file qgspathresolver.cpp.

◆ writePath()

QString QgsPathResolver::writePath ( const QString &  filename) const

Prepare a filename to save it to the project file.

Creates an absolute or relative path according to the project settings. Paths written to the project file should be prepared with this method.

Definition at line 234 of file qgspathresolver.cpp.


The documentation for this class was generated from the following files: