Skip to content
Permalink
Browse files

Improving the UI

  • Loading branch information
m-kuhn committed Sep 28, 2018
1 parent 8142d5f commit c6159bfc52475170c7779fdda28696e1a33be2f0
@@ -16,10 +16,19 @@ email : matthias@opengis.ch
#include "qgsgeometryvalidationdock.h"
#include "qgsgeometryvalidationmodel.h"

#include <QButtonGroup>

QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QWidget *parent, Qt::WindowFlags flags )
: QgsDockWidget( title, parent, flags )
{
setupUi( this );

connect( mNextButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::gotoNextError );
connect( mPreviousButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::gotoPreviousError );
connect( mZoomToProblemButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::zoomToProblem );
connect( mZoomToFeatureButton, &QPushButton::clicked, this, &QgsGeometryValidationDock::zoomToFeature );

onCurrentErrorChanged( QModelIndex(), QModelIndex() );
}

QgsGeometryValidationModel *QgsGeometryValidationDock::geometryValidationModel() const
@@ -31,4 +40,48 @@ void QgsGeometryValidationDock::setGeometryValidationModel( QgsGeometryValidatio
{
mGeometryValidationModel = geometryValidationModel;
mErrorListView->setModel( mGeometryValidationModel );

connect( mErrorListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsGeometryValidationDock::onCurrentErrorChanged );
}

void QgsGeometryValidationDock::gotoNextError()
{
QItemSelectionModel *selectionModel = mErrorListView->selectionModel();
selectionModel->setCurrentIndex( mGeometryValidationModel->index( selectionModel->currentIndex().row() + 1, 0, QModelIndex() ), QItemSelectionModel::ClearAndSelect );
}

void QgsGeometryValidationDock::gotoPreviousError()
{
QItemSelectionModel *selectionModel = mErrorListView->selectionModel();
selectionModel->setCurrentIndex( mGeometryValidationModel->index( selectionModel->currentIndex().row() - 1, 0, QModelIndex() ), QItemSelectionModel::ClearAndSelect );
}

void QgsGeometryValidationDock::zoomToProblem()
{
mLastZoomToAction = ZoomToProblem;
}

void QgsGeometryValidationDock::zoomToFeature()
{
mLastZoomToAction = ZoomToFeature;
// mErrorListView->currentIndex().data( )
}

void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous )
{
mNextButton->setEnabled( current.isValid() && current.row() < mGeometryValidationModel->rowCount() - 1 );
mPreviousButton->setEnabled( current.isValid() && current.row() > 0 );

mProblemDetailWidget->setVisible( current.isValid() );
mProblemDescriptionLabel->setText( current.data().toString() );

switch ( mLastZoomToAction )
{
case ZoomToProblem:
zoomToProblem();
break;

case ZoomToFeature:
zoomToFeature();
}
}
@@ -34,8 +34,22 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
QgsGeometryValidationModel *geometryValidationModel() const;
void setGeometryValidationModel( QgsGeometryValidationModel *geometryValidationModel );

private slots:
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
void gotoNextError();
void gotoPreviousError();
void zoomToProblem();
void zoomToFeature();

private:
enum ZoomToAction
{
ZoomToFeature,
ZoomToProblem
};
ZoomToAction mLastZoomToAction = ZoomToFeature;
QgsGeometryValidationModel *mGeometryValidationModel = nullptr;
QButtonGroup *mZoomToButtonGroup = nullptr;
};

#endif // QGSGEOMETRYVALIDATIONPANEL_H
@@ -2,6 +2,7 @@
#define QGSGEOMETRYVALIDATIONMODEL_H

#include <QAbstractItemModel>

#include "qgsgeometryvalidationservice.h"
#include "qgsexpression.h"
#include "qgsexpressioncontext.h"
@@ -11,11 +12,18 @@ class QgsGeometryValidationModel : public QAbstractItemModel
Q_OBJECT

public:

enum Roles
{
FeatureExtentRole = Qt::UserRole,
ProblemExtentRole
};

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 rowCount( const QModelIndex &parent = QModelIndex() ) const override;
int columnCount( const QModelIndex &parent ) const override;
QVariant data( const QModelIndex &index, int role ) const override;

@@ -15,14 +15,44 @@
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0" colspan="3">
<widget class="QListView" name="mErrorListView"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mValidationRunningLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="3" column="0" colspan="3">
<widget class="QWidget" name="mProblemDetailWidget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="mZoomToProblemButton">
<property name="text">
<string>Zoom To Problem</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="mZoomToFeatureButton">
<property name="text">
<string>Zoom To Feature</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="mProblemDescriptionLabel">
<property name="text">
<string>Detailed Desctiption</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mTopologyChecksPendingButton">
<property name="text">
<string>...</string>
@@ -33,8 +63,23 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QListView" name="mErrorListView"/>
<item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="mPreviousButton">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mNextButton">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

0 comments on commit c6159bf

Please sign in to comment.
You can’t perform that action at this time.