Skip to content

Commit

Permalink
Add legend text for new diagram attributes by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 20, 2015
1 parent 3487471 commit 09192ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/qgsdiagramproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,22 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int inde
mAngleOffsetLabel->hide();
}
}

QString QgsDiagramProperties::guessLegendText( const QString& expression )
{
//trim unwanted characters from expression text for legend
QString text = expression.mid( expression.startsWith( "\"" ) ? 1 : 0 );
if ( text.endsWith( "\"" ) )
text.chop( 1 );
return text;
}

void QgsDiagramProperties::addAttribute( QTreeWidgetItem * item )
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );

newItem->setText( 0, item->text( 0 ) );
newItem->setText( 2, guessLegendText( item->text( 0 ) ) );
newItem->setData( 0, Qt::UserRole, item->data( 0, Qt::UserRole ) );
newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

Expand Down Expand Up @@ -777,6 +788,7 @@ void QgsDiagramProperties::showAddAttributeExpressionDialog()
QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );

newItem->setText( 0, expression );
newItem->setText( 2, expression );
newItem->setData( 0, Qt::UserRole, expression );
newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsdiagramproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr

QgsVectorLayer* mLayer;

private:

QString guessLegendText( const QString &expression );

};

#endif // QGSDIAGRAMPROPERTIES_H

0 comments on commit 09192ee

Please sign in to comment.