Skip to content

Commit 87e775a

Browse files
committed
[composer] More improvements to item dispayName methods
1 parent 950c9b8 commit 87e775a

13 files changed

+73
-6
lines changed

python/core/composer/qgscomposerframe.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ class QgsComposerFrame: QgsComposerItem
2323
int type() const;
2424

2525
QgsComposerMultiFrame* multiFrame() const;
26+
27+
//Overriden to allow multiframe to set display name
28+
virtual QString displayName() const;
2629
};

python/core/composer/qgscomposerhtml.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class QgsComposerHtml: QgsComposerMultiFrame
181181
* @note added in 2.5
182182
*/
183183
bool userStylesheetEnabled() const;
184+
185+
virtual QString displayName() const;
184186

185187
public slots:
186188

python/core/composer/qgscomposermap.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ class QgsComposerMap : QgsComposerItem
494494
* @see currentMapExtent
495495
*/
496496
QPolygonF visibleExtentPolygon() const;
497+
498+
//overriden to show "Map 1" type names
499+
virtual QString displayName() const;
497500

498501
signals:
499502
void extentChanged();

python/core/composer/qgscomposermultiframe.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ class QgsComposerMultiFrame: QgsComposerObject
6767
*/
6868
QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
6969

70+
/**Get multiframe display name.
71+
* @returns display name for item
72+
* @note added in version 2.5
73+
*/
74+
virtual QString displayName() const;
75+
7076
public slots:
7177

7278
/**Recalculates the portion of the multiframe item which is shown in each of it's

src/core/composer/qgscomposerframe.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ bool QgsComposerFrame::readXML( const QDomElement& itemElem, const QDomDocument&
6262
return _readXML( composerItem, doc );
6363
}
6464

65+
QString QgsComposerFrame::displayName() const
66+
{
67+
if ( !id().isEmpty() )
68+
{
69+
return id();
70+
}
71+
72+
if ( mMultiFrame )
73+
{
74+
return mMultiFrame->displayName();
75+
}
76+
77+
return tr( "<frame>" );
78+
}
79+
6580
void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
6681
{
6782
Q_UNUSED( itemStyle );

src/core/composer/qgscomposerframe.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem
4343

4444
QgsComposerMultiFrame* multiFrame() const { return mMultiFrame; }
4545

46+
//Overriden to allow multiframe to set display name
47+
virtual QString displayName() const;
48+
4649
private:
4750
QgsComposerFrame(); //forbidden
4851
QgsComposerMultiFrame* mMultiFrame;

src/core/composer/qgscomposerhtml.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
441441
}
442442
}
443443

444+
QString QgsComposerHtml::displayName() const
445+
{
446+
return tr( "<html frame>" );
447+
}
448+
444449
bool QgsComposerHtml::writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
445450
{
446451
QDomElement htmlElem = doc.createElement( "ComposerHtml" );

src/core/composer/qgscomposerhtml.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
205205
*/
206206
bool userStylesheetEnabled() const { return mEnableUserStylesheet; }
207207

208+
virtual QString displayName() const;
209+
208210
public slots:
209211

210212
/**Reloads the html source from the url and redraws the item.

src/core/composer/qgscomposerlabel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ QString QgsComposerLabel::displayName() const
391391

392392
//if no id, default to portion of label text
393393
QString text = displayText();
394+
if ( text.isEmpty() || mHtmlState )
395+
{
396+
return tr( "<label>" );
397+
}
394398
if ( text.length() > 25 )
395399
{
396400
return QString( tr( "%1..." ) ).arg( text.left( 25 ) );

src/core/composer/qgscomposermap.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,16 @@ QPolygonF QgsComposerMap::visibleExtentPolygon() const
19131913
return poly;
19141914
}
19151915

1916+
QString QgsComposerMap::displayName() const
1917+
{
1918+
if ( !QgsComposerItem::id().isEmpty() )
1919+
{
1920+
return QgsComposerItem::id();
1921+
}
1922+
1923+
return tr( "Map %1" ).arg( mId );
1924+
}
1925+
19161926
void QgsComposerMap::addGrid( QgsComposerMapGrid* grid )
19171927
{
19181928
mGrids.append( grid );
@@ -2094,11 +2104,11 @@ QList<QgsComposerMapOverview *> QgsComposerMap::mapOverviews() const
20942104

20952105
void QgsComposerMap::connectMapOverviewSignals()
20962106
{
2097-
QList< QgsComposerMapOverview* >::const_iterator it = mOverviews.begin();
2098-
for ( ; it != mOverviews.end(); ++it )
2099-
{
2100-
(*it)->connectSignals();
2101-
}
2107+
QList< QgsComposerMapOverview* >::const_iterator it = mOverviews.begin();
2108+
for ( ; it != mOverviews.end(); ++it )
2109+
{
2110+
( *it )->connectSignals();
2111+
}
21022112
}
21032113

21042114
void QgsComposerMap::requestedExtent( QgsRectangle& extent )

0 commit comments

Comments
 (0)