Skip to content
Permalink
Browse files

Extend content to next pages if resize mode is extend

  • Loading branch information
mhugent committed Jul 26, 2012
1 parent a928d57 commit b9d2615e7ca32084a2e097ca80d16e89bc00167b
@@ -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();
}

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

0 comments on commit b9d2615

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