Skip to content

Commit

Permalink
implement #2696
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13472 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 12, 2010
1 parent 477c662 commit 65e591c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/app/qgsmergeattributesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsattributeeditor.h"
#include <limits>
#include <QComboBox>

Expand Down Expand Up @@ -74,12 +75,13 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();

//insert attribute names
QStringList horizontalHeaderLabels;
int col = 0;
for ( ; fieldIt != fieldMap.constEnd(); ++fieldIt )
{
horizontalHeaderLabels << fieldIt.value().name();
QTableWidgetItem *item = new QTableWidgetItem( fieldIt.value().name() );
item->setData( Qt::UserRole, fieldIt.key() );
mTableWidget->setHorizontalHeaderItem( col++, item );
}
mTableWidget->setHorizontalHeaderLabels( horizontalHeaderLabels );

//insert the attribute values
int currentRow = 1;
Expand All @@ -97,7 +99,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
QTableWidgetItem* attributeValItem = new QTableWidgetItem( currentMapIt.value().toString() );
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mTableWidget->setItem( currentRow, col, attributeValItem );
++col;
mTableWidget->setCellWidget( currentRow, col++, QgsAttributeEditor::createAttributeEditor( mTableWidget, NULL, mVectorLayer, currentMapIt.key(), currentMapIt.value() ) );
}
++currentRow;
}
Expand All @@ -106,7 +108,6 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
verticalHeaderLabels << tr( "Merge" );
mTableWidget->setVerticalHeaderLabels( verticalHeaderLabels );


//insert currently merged values
for ( int i = 0; i < fieldMap.size(); ++i )
{
Expand Down Expand Up @@ -254,21 +255,22 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )

QString QgsMergeAttributesDialog::featureAttributeString( int featureId, int col )
{
QString resultText;
for ( int i = 0; i < mFeatureList.size(); ++i )
int idx = mTableWidget->horizontalHeaderItem( col )->data( Qt::UserRole ).toInt();

int i;
for ( i = 0; i < mFeatureList.size() && mFeatureList[i].id() != featureId; i++ )
;

QVariant value;
if ( i < mFeatureList.size() &&
QgsAttributeEditor::retrieveValue( mTableWidget->cellWidget( i + 1, col ), mVectorLayer, idx, value ) )
{
int currentFid = mFeatureList[i].id();
if ( currentFid == featureId )
{
QTableWidgetItem* currentItem = mTableWidget->item( i + 1, col );
if ( !currentItem )
{
continue;
}
resultText = currentItem->text();
}
return value.toString();
}
else
{
return "";
}
return resultText;
}

QString QgsMergeAttributesDialog::minimumAttributeString( int col )
Expand Down

0 comments on commit 65e591c

Please sign in to comment.