Skip to content
Permalink
Browse files

[composer] Option for fixed frame sizes set by multi frame (sponsored

by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Sep 2, 2014
1 parent fefc243 commit d1e26f24e5a49587fd3380e7f3b3c65344e7a151
@@ -26,4 +26,7 @@ class QgsComposerFrame: QgsComposerItem

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

//Overriden to handle fixed frame sizes set by multi frame
void setSceneRect( const QRectF& rectangle );
};
@@ -19,6 +19,15 @@ class QgsComposerMultiFrame: QgsComposerObject
QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );
virtual ~QgsComposerMultiFrame();
virtual QSizeF totalSize() const = 0;

/**Returns a fixed size for the frames, if desired.
* @returns fixed size for frames. If the size has a width or height of 0, then
* the frame size is not fixed in that direction and frames can have variable width
* or height accordingly.
* @note added in version 2.5
*/
virtual QSizeF fixedFrameSize() const;

virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;

virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
@@ -77,6 +77,22 @@ QString QgsComposerFrame::displayName() const
return tr( "<frame>" );
}

void QgsComposerFrame::setSceneRect( const QRectF &rectangle )
{
QRectF fixedRect = rectangle;
QSizeF fixedSize = mMultiFrame->fixedFrameSize();
if ( fixedSize.width() > 0 )
{
fixedRect.setWidth( fixedSize.width() );
}
if ( fixedSize.height() > 0 )
{
fixedRect.setHeight( fixedSize.height() );
}

QgsComposerItem::setSceneRect( fixedRect );
}

void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
Q_UNUSED( itemStyle );
@@ -46,6 +46,9 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem
//Overriden to allow multiframe to set display name
virtual QString displayName() const;

//Overriden to handle fixed frame sizes set by multi frame
void setSceneRect( const QRectF& rectangle );

private:
QgsComposerFrame(); //forbidden
QgsComposerMultiFrame* mMultiFrame;
@@ -46,6 +46,15 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );
virtual ~QgsComposerMultiFrame();
virtual QSizeF totalSize() const = 0;

/**Returns a fixed size for the frames, if desired.
* @returns fixed size for frames. If the size has a width or height of 0, then
* the frame size is not fixed in that direction and frames can have variable width
* or height accordingly.
* @note added in version 2.5
*/
virtual QSizeF fixedFrameSize() const { return QSizeF( 0, 0 ); }

virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;

virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
@@ -354,6 +354,11 @@ QMap<int, QString> QgsComposerTableV2::headerLabels() const
return headers;
}

QSizeF QgsComposerTableV2::fixedFrameSize() const
{
return QSizeF( mTableSize.width(), 0 );
}

void QgsComposerTableV2::refreshAttributes()
{
mMaxColumnWidthMap.clear();
@@ -231,6 +231,9 @@ class CORE_EXPORT QgsComposerTableV2: public QgsComposerMultiFrame
*/
virtual bool getTableContents( QgsComposerTableContents &contents ) = 0;

//reimplemented to return fixed table width
virtual QSizeF fixedFrameSize() const;

public slots:

/**Refreshes the contents shown in the table by querying for new data.

0 comments on commit d1e26f2

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