Skip to content
Permalink
Browse files
implement #2696
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 65e591c9804678d12b8a276bda623aa27aaa074b
Showing with 20 additions and 18 deletions.
  1. +20 −18 src/app/qgsmergeattributesdialog.cpp
@@ -22,6 +22,7 @@
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsattributeeditor.h"
#include <limits>
#include <QComboBox>

@@ -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;
@@ -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;
}
@@ -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 )
{
@@ -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 )

0 comments on commit 65e591c

Please sign in to comment.