Skip to content

Commit

Permalink
Some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 7, 2016
1 parent 174947b commit 3cfaceb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/featuremodel.cpp
Expand Up @@ -37,9 +37,9 @@ void FeatureModel::setFeature( const Feature& feature, bool force )
{
beginResetModel();
if ( feature.layer() )
mProtectedAttributes.resize( feature.layer()->fields().count() );
mRememberedAttributes.resize( feature.layer()->fields().count() );
else
mProtectedAttributes.resize( 0 );
mRememberedAttributes.resize( 0 );
mFeature = feature;
endResetModel();
}
Expand Down Expand Up @@ -109,7 +109,7 @@ QVariant FeatureModel::data( const QModelIndex& index, int role ) const
break;

case RememberValue:
return mProtectedAttributes.at( index.row() ) ? Qt::Checked : Qt::Unchecked;
return mRememberedAttributes.at( index.row() ) ? Qt::Checked : Qt::Unchecked;
break;
}

Expand All @@ -120,7 +120,7 @@ bool FeatureModel::setData( const QModelIndex& index, const QVariant& value, int
{
if ( role == RememberValue )
{
mProtectedAttributes[index.row()] = value.toBool();
mRememberedAttributes[index.row()] = value.toBool();
return true;
}

Expand Down Expand Up @@ -158,12 +158,12 @@ bool FeatureModel::suppressFeatureForm() const
return mFeature.layer()->editFormConfig()->suppress();
}

void FeatureModel::resetUnprotectedAttributes()
void FeatureModel::resetAttributes( bool skipRemembered )
{
beginResetModel();
for ( int i = 0; i < mFeature.layer()->fields().count(); ++i )
{
if ( !mProtectedAttributes.at( i ) )
if ( !mRememberedAttributes.at( i ) || !skipRemembered )
{
mFeature.setAttribute( i, QVariant() );
}
Expand Down
4 changes: 2 additions & 2 deletions src/featuremodel.h
Expand Up @@ -89,7 +89,7 @@ class FeatureModel : public QAbstractListModel

Q_INVOKABLE bool suppressFeatureForm() const;

Q_INVOKABLE void resetUnprotectedAttributes();
Q_INVOKABLE void resetAttributes( bool skipRemembered = true );

public slots:
void applyGeometry();
Expand All @@ -104,7 +104,7 @@ class FeatureModel : public QAbstractListModel
private:
Feature mFeature;
Geometry* mGeometry;
QVector<bool> mProtectedAttributes;
QVector<bool> mRememberedAttributes;
};

#endif // FEATUREMODEL_H
2 changes: 1 addition & 1 deletion src/qml/qgismobileapp.qml
Expand Up @@ -314,7 +314,7 @@ Rectangle {

if ( !digitizingFeature.suppressFeatureForm() )
{
digitizingFeature.resetUnprotectedAttributes();
digitizingFeature.resetAttributes();
overlayFeatureForm.visible = true;
overlayFeatureForm.state = "Add"
}
Expand Down

0 comments on commit 3cfaceb

Please sign in to comment.