mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Mark QgsReadWriteContext::pushMessage as const, mutable
Avoids the need to remove const from all the QgsReadWriteContext references used throughout QGIS XML loading just to be able to push warning messages to the context.
This commit is contained in:
		
							parent
							
								
									2bed84d24a
								
							
						
					
					
						commit
						b086e6e656
					
				@ -64,14 +64,14 @@ Returns path resolver for conversion between relative and absolute paths
 | 
			
		||||
Sets up path resolver for conversion between relative and absolute paths
 | 
			
		||||
%End
 | 
			
		||||
 | 
			
		||||
    void pushMessage( const QString &message, Qgis::MessageLevel level = Qgis::Warning );
 | 
			
		||||
    void pushMessage( const QString &message, Qgis::MessageLevel level = Qgis::Warning ) const;
 | 
			
		||||
%Docstring
 | 
			
		||||
Append a message to the context
 | 
			
		||||
 | 
			
		||||
.. versionadded:: 3.2
 | 
			
		||||
%End
 | 
			
		||||
 | 
			
		||||
QgsReadWriteContextCategoryPopper enterCategory( const QString &category, const QString &details = QString() ) /PyName=_enterCategory/;
 | 
			
		||||
QgsReadWriteContextCategoryPopper enterCategory( const QString &category, const QString &details = QString() ) const /PyName=_enterCategory/;
 | 
			
		||||
%Docstring
 | 
			
		||||
Push a category to the stack
 | 
			
		||||
 | 
			
		||||
@ -148,7 +148,7 @@ This would happen when it gets out of scope.
 | 
			
		||||
#include "qgsreadwritecontext.h"
 | 
			
		||||
%End
 | 
			
		||||
  public:
 | 
			
		||||
    QgsReadWriteContextCategoryPopper( QgsReadWriteContext &context );
 | 
			
		||||
    QgsReadWriteContextCategoryPopper( const QgsReadWriteContext &context );
 | 
			
		||||
%Docstring
 | 
			
		||||
Creates a popper
 | 
			
		||||
%End
 | 
			
		||||
 | 
			
		||||
@ -54,12 +54,12 @@ void QgsReadWriteContext::setPathResolver( const QgsPathResolver &resolver )
 | 
			
		||||
  mPathResolver = resolver;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsReadWriteContext::pushMessage( const QString &message, Qgis::MessageLevel level )
 | 
			
		||||
void QgsReadWriteContext::pushMessage( const QString &message, Qgis::MessageLevel level ) const
 | 
			
		||||
{
 | 
			
		||||
  mMessages.append( ReadWriteMessage( message, level, mCategories ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsReadWriteContextCategoryPopper QgsReadWriteContext::enterCategory( const QString &category, const QString &details )
 | 
			
		||||
QgsReadWriteContextCategoryPopper QgsReadWriteContext::enterCategory( const QString &category, const QString &details ) const
 | 
			
		||||
{
 | 
			
		||||
  QString message = category;
 | 
			
		||||
  if ( !details.isEmpty() )
 | 
			
		||||
@ -68,7 +68,7 @@ QgsReadWriteContextCategoryPopper QgsReadWriteContext::enterCategory( const QStr
 | 
			
		||||
  return QgsReadWriteContextCategoryPopper( *this );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsReadWriteContext::leaveCategory()
 | 
			
		||||
void QgsReadWriteContext::leaveCategory() const
 | 
			
		||||
{
 | 
			
		||||
  if ( !mCategories.isEmpty() )
 | 
			
		||||
    mCategories.pop_back();
 | 
			
		||||
 | 
			
		||||
@ -80,7 +80,7 @@ class CORE_EXPORT QgsReadWriteContext
 | 
			
		||||
     * Append a message to the context
 | 
			
		||||
     * \since QGIS 3.2
 | 
			
		||||
     */
 | 
			
		||||
    void pushMessage( const QString &message, Qgis::MessageLevel level = Qgis::Warning );
 | 
			
		||||
    void pushMessage( const QString &message, Qgis::MessageLevel level = Qgis::Warning ) const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Push a category to the stack
 | 
			
		||||
@ -93,7 +93,7 @@ class CORE_EXPORT QgsReadWriteContext
 | 
			
		||||
     * \endcode
 | 
			
		||||
     * \since QGIS 3.2
 | 
			
		||||
     */
 | 
			
		||||
    MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory( const QString &category, const QString &details = QString() ) SIP_PYNAME( _enterCategory );
 | 
			
		||||
    MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory( const QString &category, const QString &details = QString() ) const SIP_PYNAME( _enterCategory );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the stored messages and remove them
 | 
			
		||||
@ -136,11 +136,11 @@ class CORE_EXPORT QgsReadWriteContext
 | 
			
		||||
  private:
 | 
			
		||||
 | 
			
		||||
    //! Pop the last category
 | 
			
		||||
    void leaveCategory();
 | 
			
		||||
    void leaveCategory() const;
 | 
			
		||||
 | 
			
		||||
    QgsPathResolver mPathResolver;
 | 
			
		||||
    QList<ReadWriteMessage> mMessages;
 | 
			
		||||
    QStringList mCategories = QStringList();
 | 
			
		||||
    mutable QList<ReadWriteMessage> mMessages;
 | 
			
		||||
    mutable QStringList mCategories = QStringList();
 | 
			
		||||
    QgsProjectTranslator *mProjectTranslator = nullptr;
 | 
			
		||||
    friend class QgsReadWriteContextCategoryPopper;
 | 
			
		||||
    QgsCoordinateTransformContext mCoordinateTransformContext = QgsCoordinateTransformContext();
 | 
			
		||||
@ -159,14 +159,14 @@ class CORE_EXPORT QgsReadWriteContextCategoryPopper
 | 
			
		||||
{
 | 
			
		||||
  public:
 | 
			
		||||
    //! Creates a popper
 | 
			
		||||
    QgsReadWriteContextCategoryPopper( QgsReadWriteContext &context ) : mContext( context ) {}
 | 
			
		||||
    QgsReadWriteContextCategoryPopper( const QgsReadWriteContext &context ) : mContext( context ) {}
 | 
			
		||||
    ~QgsReadWriteContextCategoryPopper() {mContext.leaveCategory();}
 | 
			
		||||
  private:
 | 
			
		||||
#ifdef SIP_RUN
 | 
			
		||||
    QgsReadWriteContextCategoryPopper &operator=( const QgsReadWriteContextCategoryPopper & );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    QgsReadWriteContext &mContext;
 | 
			
		||||
    const QgsReadWriteContext &mContext;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // QGSREADWRITECONTEXT_H
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user