Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better naming and docs
  • Loading branch information
signedav committed Jan 9, 2020
1 parent f5e01d3 commit 7bdfc6d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/gui/CMakeLists.txt
Expand Up @@ -308,7 +308,6 @@ SET(QGIS_GUI_SRCS
qgsfilewidget.cpp
qgsfilterlineedit.cpp
qgsfindfilesbypatternwidget.cpp
qgsfixattributedialog.cpp
qgsfloatingwidget.cpp
qgsfocuswatcher.cpp
qgsfontbutton.cpp
Expand Down
38 changes: 26 additions & 12 deletions src/gui/qgsfixattributedialog.cpp
@@ -1,3 +1,17 @@
/***************************************************************************
qgsfixattributedialog.cpp
---------------------
begin : January 2020
copyright : (C) 2020 by David Signer
email : david at opengis dot 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 "qgsfixattributedialog.h"

#include "qgsattributeform.h"
Expand All @@ -21,7 +35,7 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer )
context.setFormMode( QgsAttributeEditorContext::StandaloneDialog );

mUnfixedFeatures = mFeatures;
currentFeature = mFeatures.begin();
mCurrentFeature = mFeatures.begin();

QGridLayout *infoLayout = new QGridLayout();
QWidget *infoBox = new QWidget();
Expand All @@ -35,7 +49,7 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer )
mProgressBar->setRange( 0, mFeatures.count() );
infoLayout->addWidget( mProgressBar );
QgsFeature feature;
mAttributeForm = new QgsAttributeForm( layer, *currentFeature, context, this );
mAttributeForm = new QgsAttributeForm( layer, *mCurrentFeature, context, this );
mAttributeForm->setMode( QgsAttributeEditorContext::SingleEditMode );
mAttributeForm->disconnectButtonBox();
layout()->addWidget( mAttributeForm );
Expand Down Expand Up @@ -68,43 +82,43 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer )

QString QgsFixAttributeDialog::descriptionText()
{
return tr( "%1 of %2 features fixed\n%3 of %4 features canceled" ).arg( fixedFeatures().count() ).arg( mFeatures.count() ).arg( currentFeature - mFeatures.begin() - fixedFeatures().count() ).arg( mFeatures.count() );
return tr( "%1 of %2 features fixed\n%3 of %4 features canceled" ).arg( fixedFeatures().count() ).arg( mFeatures.count() ).arg( mCurrentFeature - mFeatures.begin() - fixedFeatures().count() ).arg( mFeatures.count() );
}

void QgsFixAttributeDialog::accept()
{
mAttributeForm->save();
mFixedFeatures << mAttributeForm->feature();
mUnfixedFeatures.removeOne( *currentFeature );
mUnfixedFeatures.removeOne( *mCurrentFeature );

//next feature
++currentFeature;
if ( currentFeature != mFeatures.end() )
++mCurrentFeature;
if ( mCurrentFeature != mFeatures.end() )
{
mAttributeForm->setFeature( *currentFeature );
mAttributeForm->setFeature( *mCurrentFeature );
}
else
{
done( CopyValid );
}

mProgressBar->setValue( currentFeature - mFeatures.begin() );
mProgressBar->setValue( mCurrentFeature - mFeatures.begin() );
mDescription->setText( descriptionText() );
}

void QgsFixAttributeDialog::reject()
{
//next feature
++currentFeature;
if ( currentFeature != mFeatures.end() )
++mCurrentFeature;
if ( mCurrentFeature != mFeatures.end() )
{
mAttributeForm->setFeature( *currentFeature );
mAttributeForm->setFeature( *mCurrentFeature );
}
else
{
done( CopyValid );
}

mProgressBar->setValue( currentFeature - mFeatures.begin() );
mProgressBar->setValue( mCurrentFeature - mFeatures.begin() );
mDescription->setText( descriptionText() );
}
49 changes: 35 additions & 14 deletions src/gui/qgsfixattributedialog.h
@@ -1,3 +1,18 @@
/***************************************************************************
qgsfixattributedialog.h
---------------------
begin : January 2020
copyright : (C) 2020 by David Signer
email : david at opengis dot 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 QGSFIXATTRIBUTEDIALOG_H
#define QGSFIXATTRIBUTEDIALOG_H

Expand All @@ -12,32 +27,40 @@
#include "qgis_gui.h"

/**
* \ingroup gui
* \class QgsFixAttributeDialog
* \since 3.12
*/
* \ingroup gui
* \class QgsFixAttributeDialog
* \brief Dialog to fix a list of invalid feature regarding constraints
* \since 3.12
*/

class GUI_EXPORT QgsFixAttributeDialog : public QDialog
{
Q_OBJECT

public:

/**
* Feedback code on closing the dialog
*/
enum Feedback
{
VanishAll,
CopyValid,
CopyAll
VanishAll, //!< Feedback to cancel copy of all features (even valid ones)
CopyValid, //!< Feedback to copy the valid features and vanishe the invalid ones
CopyAll //!< Feedback to copy all features, no matter if valid or invalid
};

/**
* Constructor for QgsFixAttributeDialog
*/
QgsFixAttributeDialog( QgsVectorLayer *vl, QgsFeatureList &features, QWidget *parent SIP_TRANSFERTHIS = nullptr );

/*
* returns fixed features
/**
* Returns fixed features
*/
QgsFeatureList fixedFeatures() { return mFixedFeatures; }

/*
* returns unfixed features
/**
* Returns unfixed features (canceled or not handeled)
*/
QgsFeatureList unfixedFeatures() { return mUnfixedFeatures; }

Expand All @@ -50,11 +73,9 @@ class GUI_EXPORT QgsFixAttributeDialog : public QDialog
QString descriptionText();

QgsFeatureList mFeatures;
QgsFeatureList::iterator currentFeature;
QgsFeatureList::iterator mCurrentFeature;

//the fixed features
QgsFeatureList mFixedFeatures;
//the not yet fixed and the canceled features
QgsFeatureList mUnfixedFeatures;

QgsAttributeForm *mAttributeForm = nullptr;
Expand Down

0 comments on commit 7bdfc6d

Please sign in to comment.