[composer] More improvements to item dispayName methods

This commit is contained in:
Nyall Dawson 2014-07-29 21:28:39 +10:00
parent 950c9b89f1
commit 87e775a1e7
13 changed files with 73 additions and 6 deletions

View File

@ -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;
};

View File

@ -181,6 +181,8 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @note added in 2.5
*/
bool userStylesheetEnabled() const;
virtual QString displayName() const;
public slots:

View File

@ -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();

View File

@ -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

View File

@ -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 );

View File

@ -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;

View File

@ -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" );

View File

@ -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.

View File

@ -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 ) );

View File

@ -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 )

5
src/core/composer/qgscomposermap.h Executable file → Normal file
View File

@ -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*/

View File

@ -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 );

View File

@ -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