Skip to content

Commit

Permalink
Extend content to next pages if resize mode is extend
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 26, 2012
1 parent a928d57 commit b9d2615
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/core/composer/qgscomposerhtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ QgsComposerHtml::QgsComposerHtml( QgsComposition* c, qreal x, qreal y, qreal wid
setUrl( QUrl( "http://www.qgis.org" ) );//test
QgsComposerFrame* frame = new QgsComposerFrame( c, this, x, y, width, height );
addFrame( frame );
mComposition->addItem( frame );
recalculateFrameSizes();
}

Expand Down
41 changes: 26 additions & 15 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,21 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
double currentHeight = 0;
QgsComposerFrame* currentItem = 0;

QList<QgsComposerFrame*>::iterator frameIt = mFrameItems.begin();
for ( ; frameIt != mFrameItems.end(); ++frameIt )
for ( int i = 0; i < mFrameItems.size(); ++i )
{
if ( currentY >= totalHeight )
{
if ( mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode
{
for ( int j = mFrameItems.size(); j > i; --j )
{
removeFrame( j - 1 );
}
}
return;
}
currentItem = *frameIt;

currentItem = mFrameItems.value( i );
currentHeight = currentItem->rect().height();
currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) );
currentItem->update();
Expand All @@ -64,9 +71,8 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
{
//find out on which page the lower left point of the last frame is
int page = currentItem->transform().dy() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
//double offset = currentItem->transform().dy() - page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );

//e.v. add a new page
//add new pages if necessary
if ( mComposition->numPages() < ( page + 2 ) )
{
mComposition->setNumPages( page + 2 );
Expand All @@ -79,22 +85,27 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
currentY += newFrame->rect().height();
currentItem = newFrame;
addFrame( newFrame );
mComposition->addItem( newFrame );
}
}

#if 0
if ( mFrameItems.size() > 0 )
{
QSizeF size = totalSize();
QgsComposerFrame* item = mFrameItems[0];
item->setContentSection( QRectF( 0, 0, item->rect().width(), item->rect().height() ) );
}
#endif //0
}

void QgsComposerMultiFrame::addFrame( QgsComposerFrame* frame )
{
mFrameItems.push_back( frame );
QObject::connect( frame, SIGNAL( sizeChanged() ), this, SLOT( recalculateFrameSizes() ) );
QObject::connect( frame, SIGNAL( destroyed() ), this, SLOT( recalculateFrameSizes() ) );
if ( mComposition )
{
mComposition->addItem( frame );
}
}

void QgsComposerMultiFrame::removeFrame( int i )
{
QgsComposerFrame* frameItem = mFrameItems[i];
if ( mComposition )
{
mComposition->removeComposerItem( frameItem );
}
mFrameItems.removeAt( i );
}
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermultiframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class QgsComposerMultiFrame: public QObject
virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;

void addFrame( QgsComposerFrame* frame );
void removeFrame( int i );

void setResizeMode( ResizeMode mode ) { mResizeMode = mode; }
ResizeMode resizeMode() const { return mResizeMode; }
Expand Down

0 comments on commit b9d2615

Please sign in to comment.