1 /*************************************************************************** 2 qgsvaliditycheckcontext.h 3 -------------------------- 4 begin : November 2018 5 copyright : (C) 2018 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 #ifndef QGSVALIDITYCHECKCONTEXT_H 16 #define QGSVALIDITYCHECKCONTEXT_H 17 18 #include "qgis_core.h" 19 #include "qgis_sip.h" 20 21 class QgsLayout; 22 23 /** 24 * \class QgsValidityCheckContext 25 * \ingroup core 26 * \brief Base class for validity check contexts. 27 * 28 * QgsAbstractValidityCheck subclasses are passed a QgsValidityCheckContext subclass which 29 * encapsulates the context around that particular check type. For instance, a QgsAbstractValidityCheck 30 * of the QgsAbstractValidityCheck::TypeLayoutCheck type will be passed a QgsLayoutValidityCheckContext 31 * context, containing a reference to the QgsLayout to be checked. 32 * 33 * \since QGIS 3.6 34 */ 35 class CORE_EXPORT QgsValidityCheckContext 36 { 37 38 #ifdef SIP_RUN 39 SIP_CONVERT_TO_SUBCLASS_CODE 40 if ( dynamic_cast<QgsLayoutValidityCheckContext *>( sipCpp ) != NULL ) 41 sipType = sipType_QgsLayoutValidityCheckContext; 42 else 43 sipType = 0; 44 SIP_END 45 #endif 46 47 public: 48 49 //! Available check context types 50 enum ContextType 51 { 52 TypeLayoutContext = 1, //!< Layout context, see QgsLayoutValidityCheckContext 53 TypeUserContext = 10001, //!< Starting point for user contexts 54 }; 55 56 /** 57 * Returns the context type. 58 */ 59 virtual int type() const = 0; 60 61 virtual ~QgsValidityCheckContext() = default; 62 63 }; 64 65 /** 66 * \class QgsLayoutValidityCheckContext 67 * \ingroup core 68 * \brief Validity check context for print layout validation. 69 * 70 * QgsLayoutValidityCheckContext are passed to QgsAbstractValidityCheck subclasses which 71 * indicate they are of the QgsAbstractValidityCheck::TypeLayoutCheck type. 72 * 73 * \since QGIS 3.6 74 */ 75 class CORE_EXPORT QgsLayoutValidityCheckContext : public QgsValidityCheckContext 76 { 77 public: 78 79 /** 80 * Constructor for QgsLayoutValidityCheckContext for the specified \a layout. 81 */ QgsLayoutValidityCheckContext(QgsLayout * layout)82 QgsLayoutValidityCheckContext( QgsLayout *layout ) 83 : layout( layout ) 84 {} 85 type()86 int type() const override { return TypeLayoutContext; } 87 88 /** 89 * Pointer to the layout which the check is being run against. 90 */ 91 QgsLayout *layout = nullptr; 92 93 }; 94 #endif // QGSVALIDITYCHECKCONTEXT_H 95