Skip to content
Permalink
Browse files

add support "sum" operation to merge attribute dialog

  • Loading branch information
jef-n committed Sep 17, 2011
1 parent d934c87 commit 8905274a1237c132e09243e8c2d634d55ca26945
Showing with 38 additions and 9 deletions.
  1. +15 −9 i18n/qgis_de.ts
  2. +21 −0 src/app/qgsmergeattributesdialog.cpp
  3. +2 −0 src/app/qgsmergeattributesdialog.h
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="132"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="439"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="492"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="460"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="513"/>
<source>feature %1</source>
<translation>Objekt %1</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="137"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="233"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="234"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="138"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="237"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="238"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="139"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="245"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="246"/>
<source>Median</source>
<translation>Mittel</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="143"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="249"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="140"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="250"/>
<source>Sum</source>
<translation>Summe</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="144"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="254"/>
<source>Concatenation</source>
<translation>Verkettung</translation>
</message>
<message>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="147"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="241"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="148"/>
<location filename="../src/app/qgsmergeattributesdialog.cpp" line="242"/>
<source>Mean</source>
<translation>Durchschnitt</translation>
</message>
@@ -137,6 +137,7 @@ QComboBox* QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
newComboBox->addItem( tr( "Minimum" ) );
newComboBox->addItem( tr( "Maximum" ) );
newComboBox->addItem( tr( "Median" ) );
newComboBox->addItem( tr( "Sum" ) );
}
else if ( columnType == QVariant::String )
{
@@ -246,6 +247,10 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
{
evalText = medianAttributeString( col );
}
else if ( mergeBehaviourString == tr( "Sum" ) )
{
evalText = sumAttributeString( col );
}
else if ( mergeBehaviourString == tr( "Concatenation" ) )
{
evalText = concatenationAttributeString( col );
@@ -390,6 +395,22 @@ QString QgsMergeAttributesDialog::medianAttributeString( int col )
return QString::number( medianValue, 'f' );
}

QString QgsMergeAttributesDialog::sumAttributeString( int col )
{
double sum = 0.0;
bool conversion = false;

for ( int i = 0; i < mFeatureList.size(); ++i )
{
double currentValue = mTableWidget->item( i + 1, col )->text().toDouble( &conversion );
if ( conversion )
{
sum += currentValue;
}
}
return QString::number( sum, 'f' );
}

QString QgsMergeAttributesDialog::concatenationAttributeString( int col )
{
QStringList concatString;
@@ -63,6 +63,8 @@ class QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeAttributesDi
QString meanAttributeString( int col );
/**Calculates and inserts the median value of a column*/
QString medianAttributeString( int col );
/**Calculates and inserts the sum of a column*/
QString sumAttributeString( int col );
/**Appends the values of the features for the final value*/
QString concatenationAttributeString( int col );
/**Sets mSelectionRubberBand to a new feature*/

0 comments on commit 8905274

Please sign in to comment.
You can’t perform that action at this time.