Skip to content

Commit

Permalink
merge attributes: new vector api can skip attributes - use default va…
Browse files Browse the repository at this point in the history
…lue for skipped field (fixes #5758)
  • Loading branch information
jef-n committed Feb 13, 2014
1 parent d6c51a7 commit 28fb634
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/qgsmergeattributesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsattributeeditor.h"

#include <limits>
Expand Down Expand Up @@ -588,18 +589,25 @@ QgsAttributes QgsMergeAttributesDialog::mergedAttributes() const
{
int idx = mTableWidget->horizontalHeaderItem( i )->data( Qt::UserRole ).toInt();

QComboBox* comboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
if ( comboBox && comboBox->currentText() == tr( "Skip attribute" ) )
QComboBox *comboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
if ( !comboBox )
continue;

QTableWidgetItem* currentItem = mTableWidget->item( mFeatureList.size() + 1, i );
QTableWidgetItem *currentItem = mTableWidget->item( mFeatureList.size() + 1, i );
if ( !currentItem )
continue;

if ( idx >= results.count() )
results.resize( idx + 1 ); // make sure the results vector is long enough (maybe not necessary)

results[idx] = currentItem->data( Qt::DisplayRole );
if ( comboBox->currentText() != tr( "Skip attribute" ) )
{
results[idx] = currentItem->data( Qt::DisplayRole );
}
else if ( mVectorLayer->dataProvider() )
{
results[idx] = mVectorLayer->dataProvider()->defaultValue( idx );
}
}

return results;
Expand Down

0 comments on commit 28fb634

Please sign in to comment.