QGIS API Documentation  3.5.0-Master (bebc34b)
Classes | Public Member Functions | Friends | List of all members
QgsReadWriteContext Class Reference

The class is used as a container of context for various read/write operations on other objects. More...

#include <qgsreadwritecontext.h>

Classes

struct  ReadWriteMessage
 Struct for QgsReadWriteContext error or warning messages. More...
 

Public Member Functions

 QgsReadWriteContext ()
 Constructor for QgsReadWriteContext. More...
 
 ~QgsReadWriteContext ()
 
MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory (const QString &category, const QString &details=QString())
 Push a category to the stack. More...
 
const QgsPathResolverpathResolver () const
 Returns path resolver for conversion between relative and absolute paths. More...
 
const QgsProjectTranslatorprojectTranslator () const
 Returns the project translator. More...
 
void pushMessage (const QString &message, Qgis::MessageLevel level=Qgis::Warning)
 Append a message to the context. More...
 
void setPathResolver (const QgsPathResolver &resolver)
 Sets up path resolver for conversion between relative and absolute paths. More...
 
void setProjectTranslator (QgsProjectTranslator *projectTranslator)
 Sets the project translator. More...
 
QList< QgsReadWriteContext::ReadWriteMessagetakeMessages ()
 Returns the stored messages and remove them. More...
 

Friends

class QgsReadWriteContextCategoryPopper
 

Detailed Description

The class is used as a container of context for various read/write operations on other objects.

Since
QGIS 3.0

Definition at line 33 of file qgsreadwritecontext.h.

Constructor & Destructor Documentation

◆ QgsReadWriteContext()

QgsReadWriteContext::QgsReadWriteContext ( )

Constructor for QgsReadWriteContext.

Definition at line 17 of file qgsreadwritecontext.cpp.

◆ ~QgsReadWriteContext()

QgsReadWriteContext::~QgsReadWriteContext ( )

Definition at line 23 of file qgsreadwritecontext.cpp.

Member Function Documentation

◆ enterCategory()

QgsReadWriteContextCategoryPopper QgsReadWriteContext::enterCategory ( const QString &  category,
const QString &  details = QString() 
)

Push a category to the stack.

Note
The return value should always be used so category can be automatically left.
It is not aimed at being used in Python. Instead use the context manager.
with QgsReadWriteContext.enterCategory(context, category, details):
# do something
Since
QGIS 3.2

Definition at line 44 of file qgsreadwritecontext.cpp.

◆ pathResolver()

const QgsPathResolver & QgsReadWriteContext::pathResolver ( ) const

Returns path resolver for conversion between relative and absolute paths.

Definition at line 29 of file qgsreadwritecontext.cpp.

◆ projectTranslator()

const QgsProjectTranslator* QgsReadWriteContext::projectTranslator ( ) const
inline

Returns the project translator.

Since
QGIS 3.4

Definition at line 107 of file qgsreadwritecontext.h.

◆ pushMessage()

void QgsReadWriteContext::pushMessage ( const QString &  message,
Qgis::MessageLevel  level = Qgis::Warning 
)

Append a message to the context.

Since
QGIS 3.2

Definition at line 39 of file qgsreadwritecontext.cpp.

◆ setPathResolver()

void QgsReadWriteContext::setPathResolver ( const QgsPathResolver resolver)

Sets up path resolver for conversion between relative and absolute paths.

Definition at line 34 of file qgsreadwritecontext.cpp.

◆ setProjectTranslator()

void QgsReadWriteContext::setProjectTranslator ( QgsProjectTranslator projectTranslator)

Sets the project translator.

Means it shouldn't conform mDefaultTranslator anymore. It's usually the QgsProject where the function with the context is made and won't be changed anymore.

Since
QGIS 3.4

Definition at line 59 of file qgsreadwritecontext.cpp.

◆ takeMessages()

QList< QgsReadWriteContext::ReadWriteMessage > QgsReadWriteContext::takeMessages ( )

Returns the stored messages and remove them.

Since
QGIS 3.2

Definition at line 64 of file qgsreadwritecontext.cpp.

Friends And Related Function Documentation

◆ QgsReadWriteContextCategoryPopper

friend class QgsReadWriteContextCategoryPopper
friend

Definition at line 133 of file qgsreadwritecontext.h.


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