mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[composer] Some tweaks to label display name, add display name for legends
This commit is contained in:
parent
a309a6c051
commit
3480ef2e47
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user