Skip to content
Permalink
Browse files
[composer] Some tweaks to label display name, add display name for le…
…gends
  • Loading branch information
nyalldawson committed Jul 31, 2014
1 parent a309a6c commit 3480ef2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
@@ -412,9 +412,14 @@ QString QgsComposerLabel::displayName() const
return id();
}

if ( mHtmlState )
{
return tr( "<HTML label>" );
}

//if no id, default to portion of label text
QString text = displayText();
if ( text.isEmpty() || mHtmlState )
if ( text.isEmpty() )
{
return tr( "<label>" );
}
@@ -21,6 +21,7 @@
#include "qgscomposerlegenditem.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgscomposermodel.h"
#include "qgslegendrenderer.h"
#include "qgslogger.h"
#include <QDomDocument>
@@ -101,7 +102,16 @@ void QgsComposerLegend::adjustBoxSize()
}
}

void QgsComposerLegend::setTitle( const QString& t ) { mSettings.setTitle( t ); }
void QgsComposerLegend::setTitle( const QString& t )
{
mSettings.setTitle( t );

if ( mComposition && id().isEmpty() )
{
//notify the model that the display name has changed
mComposition->itemsModel()->updateItemDisplayName( this );
}
}
QString QgsComposerLegend::title() const { return mSettings.title(); }

Qt::AlignmentFlag QgsComposerLegend::titleAlignment() const { return mSettings.titleAlignment(); }
@@ -335,6 +345,29 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument
return true;
}

QString QgsComposerLegend::displayName() const
{
if ( !id().isEmpty() )
{
return id();
}

//if no id, default to portion of title text
QString text = mSettings.title();
if ( text.isEmpty() )
{
return tr( "<legend>" );
}
if ( text.length() > 25 )
{
return QString( tr( "%1..." ) ).arg( text.left( 25 ) );
}
else
{
return text;
}
}

void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )
{
mComposerMap = map;
@@ -139,6 +139,9 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
*/
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

//Overriden to show legend title
virtual QString displayName() const;

public slots:
/**Data changed*/
void synchronizeWithModel();

0 comments on commit 3480ef2

Please sign in to comment.