Branch data Line data Source code
1 : : /*************************************************************************** 2 : : qgsgeometrycheckregistry.cpp 3 : : -------------------------------------- 4 : : Date : September 2018 5 : : Copyright : (C) 2018 Matthias Kuhn 6 : : Email : matthias@opengis.ch 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 : : 16 : : #include "qgsgeometrycheckregistry.h" 17 : : #include "qgsgeometrycheckfactory.h" 18 : : #include "qgis.h" 19 : : 20 : : 21 : 0 : QgsGeometryCheckRegistry::~QgsGeometryCheckRegistry() 22 : : { 23 : 0 : qDeleteAll( mGeometryCheckFactories ); 24 : 0 : } 25 : : 26 : 0 : QgsGeometryCheck *QgsGeometryCheckRegistry::geometryCheck( const QString &checkId, QgsGeometryCheckContext *context, const QVariantMap &geometryCheckConfig ) 27 : : { 28 : 0 : QgsGeometryCheckFactory *factory = mGeometryCheckFactories.value( checkId ); 29 : 0 : if ( factory ) 30 : 0 : return factory->createGeometryCheck( context, geometryCheckConfig ); 31 : : else 32 : 0 : return nullptr; 33 : 0 : } 34 : : 35 : 0 : QList<QgsGeometryCheckFactory *> QgsGeometryCheckRegistry::geometryCheckFactories( QgsVectorLayer *layer, QgsGeometryCheck::CheckType type, QgsGeometryCheck::Flags flags ) const 36 : : { 37 : 0 : QList<QgsGeometryCheckFactory *> factories; 38 : 0 : for ( QgsGeometryCheckFactory *factory : mGeometryCheckFactories ) 39 : : { 40 : 0 : if ( factory->checkType() == type && ( factory->flags() & flags ) == flags && factory->isCompatible( layer ) ) 41 : 0 : factories << factory; 42 : : } 43 : 0 : return factories; 44 : 0 : } 45 : : 46 : 0 : void QgsGeometryCheckRegistry::registerGeometryCheck( QgsGeometryCheckFactory *checkFactory ) 47 : : { 48 : 0 : mGeometryCheckFactories.insert( checkFactory->id(), checkFactory ); 49 : 0 : }