Skip to content
Permalink
Browse files

[composer] More improvements to item dispayName methods

  • Loading branch information
nyalldawson committed Jul 29, 2014
1 parent 950c9b8 commit 87e775a1e71a95e14f691b7a740fc83c2f4aecfd
@@ -23,4 +23,7 @@ class QgsComposerFrame: QgsComposerItem
int type() const;

QgsComposerMultiFrame* multiFrame() const;

//Overriden to allow multiframe to set display name
virtual QString displayName() const;
};
@@ -181,6 +181,8 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @note added in 2.5
*/
bool userStylesheetEnabled() const;

virtual QString displayName() const;

public slots:

@@ -494,6 +494,9 @@ class QgsComposerMap : QgsComposerItem
* @see currentMapExtent
*/
QPolygonF visibleExtentPolygon() const;

//overriden to show "Map 1" type names
virtual QString displayName() const;

signals:
void extentChanged();
@@ -67,6 +67,12 @@ class QgsComposerMultiFrame: QgsComposerObject
*/
QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );

/**Get multiframe display name.
* @returns display name for item
* @note added in version 2.5
*/
virtual QString displayName() const;

public slots:

/**Recalculates the portion of the multiframe item which is shown in each of it's
@@ -62,6 +62,21 @@ bool QgsComposerFrame::readXML( const QDomElement& itemElem, const QDomDocument&
return _readXML( composerItem, doc );
}

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

if ( mMultiFrame )
{
return mMultiFrame->displayName();
}

return tr( "<frame>" );
}

void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
Q_UNUSED( itemStyle );
@@ -43,6 +43,9 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem

QgsComposerMultiFrame* multiFrame() const { return mMultiFrame; }

//Overriden to allow multiframe to set display name
virtual QString displayName() const;

private:
QgsComposerFrame(); //forbidden
QgsComposerMultiFrame* mMultiFrame;
@@ -441,6 +441,11 @@ void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
}
}

QString QgsComposerHtml::displayName() const
{
return tr( "<html frame>" );
}

bool QgsComposerHtml::writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
{
QDomElement htmlElem = doc.createElement( "ComposerHtml" );
@@ -205,6 +205,8 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
*/
bool userStylesheetEnabled() const { return mEnableUserStylesheet; }

virtual QString displayName() const;

public slots:

/**Reloads the html source from the url and redraws the item.
@@ -391,6 +391,10 @@ QString QgsComposerLabel::displayName() const

//if no id, default to portion of label text
QString text = displayText();
if ( text.isEmpty() || mHtmlState )
{
return tr( "<label>" );
}
if ( text.length() > 25 )
{
return QString( tr( "%1..." ) ).arg( text.left( 25 ) );
@@ -1913,6 +1913,16 @@ QPolygonF QgsComposerMap::visibleExtentPolygon() const
return poly;
}

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

return tr( "Map %1" ).arg( mId );
}

void QgsComposerMap::addGrid( QgsComposerMapGrid* grid )
{
mGrids.append( grid );
@@ -2094,11 +2104,11 @@ QList<QgsComposerMapOverview *> QgsComposerMap::mapOverviews() const

void QgsComposerMap::connectMapOverviewSignals()
{
QList< QgsComposerMapOverview* >::const_iterator it = mOverviews.begin();
for ( ; it != mOverviews.end(); ++it )
{
(*it)->connectSignals();
}
QList< QgsComposerMapOverview* >::const_iterator it = mOverviews.begin();
for ( ; it != mOverviews.end(); ++it )
{
( *it )->connectSignals();
}
}

void QgsComposerMap::requestedExtent( QgsRectangle& extent )
@@ -539,6 +539,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
QPolygonF visibleExtentPolygon() const;

//overriden to show "Map 1" type names
virtual QString displayName() const;

/**Adds new map grid (takes ownership)*/
void addGrid( QgsComposerMapGrid* grid );
void removeGrid( const QString& name );
@@ -568,7 +571,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem

void connectMapOverviewSignals();

signals:
signals:
void extentChanged();

/**Is emitted on rotation change to notify north arrow pictures*/
@@ -184,6 +184,11 @@ QgsComposerFrame* QgsComposerMultiFrame::createNewFrame( QgsComposerFrame* curre
return newFrame;
}

QString QgsComposerMultiFrame::displayName() const
{
return tr( "<frame>" );
}

void QgsComposerMultiFrame::handleFrameRemoval( QgsComposerItem* item )
{
QgsComposerFrame* frame = dynamic_cast<QgsComposerFrame*>( item );
@@ -94,6 +94,12 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
*/
QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );

/**Get multiframe display name.
* @returns display name for item
* @note added in version 2.5
*/
virtual QString displayName() const;

public slots:

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

0 comments on commit 87e775a

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