Skip to content

Commit

Permalink
[composer] Option for fixed frame sizes set by multi frame (sponsored
Browse files Browse the repository at this point in the history
by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Sep 17, 2014
1 parent fefc243 commit d1e26f2
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/composer/qgscomposerframe.sip
Expand Up @@ -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 );
};
9 changes: 9 additions & 0 deletions python/core/composer/qgscomposermultiframe.sip
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/core/composer/qgscomposerframe.cpp
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/core/composer/qgscomposerframe.h
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/core/composer/qgscomposermultiframe.h
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/composer/qgscomposertablev2.cpp
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/core/composer/qgscomposertablev2.h
Expand Up @@ -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.
Expand Down

0 comments on commit d1e26f2

Please sign in to comment.