Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
471 additions
and 13 deletions.
- +7 −0 src/app/CMakeLists.txt
- +11 −1 src/app/qgisapp.cpp
- +5 −12 src/app/qgisapp.h
- +33 −0 src/app/qgsgeometryvalidationdock.cpp
- +41 −0 src/app/qgsgeometryvalidationdock.h
- +67 −0 src/app/qgsgeometryvalidationmodel.cpp
- +30 −0 src/app/qgsgeometryvalidationmodel.h
- +102 −0 src/app/qgsgeometryvalidationservice.cpp
- +71 −0 src/app/qgsgeometryvalidationservice.h
- +6 −0 src/core/qgsgeometrycheckqueue.cpp
- +15 −0 src/core/qgsgeometrycheckqueue.h
- +83 −0 src/ui/qgsgeometryvalidationdockbase.ui
@@ -0,0 +1,33 @@ | ||
/*************************************************************************** | ||
qgsgeometryvalidationdock.cpp | ||
-------------------------------------- | ||
Date : 7.9.2018 | ||
Copyright : (C) 2018 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgeometryvalidationdock.h" | ||
#include "qgsgeometryvalidationmodel.h" | ||
|
||
QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QWidget *parent, Qt::WindowFlags flags ) | ||
: QgsDockWidget( title, parent, flags ) | ||
{ | ||
setupUi( this ); | ||
} | ||
|
||
QgsGeometryValidationModel *QgsGeometryValidationDock::geometryValidationModel() const | ||
{ | ||
return mGeometryValidationModel; | ||
} | ||
|
||
void QgsGeometryValidationDock::setGeometryValidationModel( QgsGeometryValidationModel *geometryValidationModel ) | ||
{ | ||
mGeometryValidationModel = geometryValidationModel; | ||
} |
@@ -0,0 +1,41 @@ | ||
/*************************************************************************** | ||
qgsgeometryvalidationdock.h | ||
-------------------------------------- | ||
Date : 7.9.2018 | ||
Copyright : (C) 2018 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGEOMETRYVALIDATIONPANEL_H | ||
#define QGSGEOMETRYVALIDATIONPANEL_H | ||
|
||
#include "ui_qgsgeometryvalidationdockbase.h" | ||
#include "qgsdockwidget.h" | ||
|
||
class QgsGeometryValidationModel; | ||
|
||
/** | ||
* @brief The QgsGeometryValidationDock class | ||
*/ | ||
class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryValidationDockBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsGeometryValidationDock( const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr ); | ||
|
||
QgsGeometryValidationModel *geometryValidationModel() const; | ||
void setGeometryValidationModel( QgsGeometryValidationModel *geometryValidationModel ); | ||
|
||
private: | ||
QgsGeometryValidationModel *mGeometryValidationModel = nullptr; | ||
}; | ||
|
||
#endif // QGSGEOMETRYVALIDATIONPANEL_H |
@@ -0,0 +1,67 @@ | ||
#include "qgsgeometryvalidationmodel.h" | ||
|
||
#include "qgsvectorlayer.h" | ||
|
||
QgsGeometryValidationModel::QgsGeometryValidationModel( QgsGeometryValidationService *geometryValidationService, QObject *parent ) | ||
: QAbstractItemModel( parent ) | ||
, mGeometryValidationService( geometryValidationService ) | ||
{ | ||
|
||
} | ||
|
||
QModelIndex QgsGeometryValidationModel::index( int row, int column, const QModelIndex &parent ) const | ||
{ | ||
Q_UNUSED( parent ) | ||
return createIndex( row, column ); | ||
} | ||
|
||
QModelIndex QgsGeometryValidationModel::parent( const QModelIndex &child ) const | ||
{ | ||
Q_UNUSED( child ) | ||
return QModelIndex(); | ||
} | ||
|
||
int QgsGeometryValidationModel::rowCount( const QModelIndex &parent ) const | ||
{ | ||
Q_UNUSED( parent ) | ||
return mGeometryValidationService->featureErrors( mCurrentLayer ).size(); | ||
} | ||
|
||
int QgsGeometryValidationModel::columnCount( const QModelIndex &parent ) const | ||
{ | ||
Q_UNUSED( parent ) | ||
return 1; | ||
} | ||
|
||
QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role ) const | ||
{ | ||
switch ( role ) | ||
{ | ||
case Qt::DisplayRole: | ||
QgsGeometryValidationService::FeatureError error = mGeometryValidationService->featureError( mCurrentLayer, index.row() ); | ||
QgsFeature feature = mCurrentLayer->getFeature( error.featureId ); | ||
mExpressionContext.setFeature( feature ); | ||
QString featureTitle = mDisplayExpression.evaluate( &mExpressionContext ).toString(); | ||
return QStringLiteral( "<b>%1</b>: %2" ).arg( featureTitle, error.error.what() ); | ||
} | ||
|
||
return QVariant(); | ||
} | ||
|
||
QgsVectorLayer *QgsGeometryValidationModel::currentLayer() const | ||
{ | ||
return mCurrentLayer; | ||
} | ||
|
||
void QgsGeometryValidationModel::setCurrentLayer( QgsVectorLayer *currentLayer ) | ||
{ | ||
if ( mCurrentLayer == currentLayer ) | ||
return; | ||
|
||
beginResetModel(); | ||
mCurrentLayer = currentLayer; | ||
mDisplayExpression = mCurrentLayer->displayExpression(); | ||
mExpressionContext = QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( mCurrentLayer ) ); | ||
mDisplayExpression.prepare( &mExpressionContext ); | ||
endResetModel(); | ||
} |
@@ -0,0 +1,30 @@ | ||
#ifndef QGSGEOMETRYVALIDATIONMODEL_H | ||
#define QGSGEOMETRYVALIDATIONMODEL_H | ||
|
||
#include <QAbstractItemModel> | ||
#include "qgsgeometryvalidationservice.h" | ||
#include "qgsexpression.h" | ||
#include "qgsexpressioncontext.h" | ||
|
||
class QgsGeometryValidationModel : public QAbstractItemModel | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsGeometryValidationModel( QgsGeometryValidationService *geometryValidationService, QObject *parent = nullptr ); | ||
QModelIndex index( int row, int column, const QModelIndex &parent ) const override; | ||
QModelIndex parent( const QModelIndex &child ) const override; | ||
int rowCount( const QModelIndex &parent ) const override; | ||
int columnCount( const QModelIndex &parent ) const override; | ||
QVariant data( const QModelIndex &index, int role ) const override; | ||
QgsVectorLayer *currentLayer() const; | ||
void setCurrentLayer( QgsVectorLayer *currentLayer ); | ||
|
||
private: | ||
QgsGeometryValidationService *mGeometryValidationService = nullptr; | ||
QgsVectorLayer *mCurrentLayer = nullptr; | ||
mutable QgsExpression mDisplayExpression; | ||
mutable QgsExpressionContext mExpressionContext; | ||
}; | ||
|
||
#endif // QGSGEOMETRYVALIDATIONMODEL_H |
Oops, something went wrong.