Skip to content
Permalink
Browse files

Resurrect tests for html item

  • Loading branch information
nyalldawson committed Oct 31, 2017
1 parent aec0326 commit 2cf99116d74c6834cb08619955220ecea954da47
@@ -24,6 +24,7 @@
#include "qgslayoutitemundocommand.h"
#include "qgslayoutitemgroup.h"
#include "qgslayoutitemgroupundocommand.h"
#include "qgslayoutmultiframe.h"

QgsLayout::QgsLayout( QgsProject *project )
: mProject( project )
@@ -41,7 +42,7 @@ QgsLayout::QgsLayout( QgsProject *project )
QgsLayout::~QgsLayout()
{
// no need for undo commands when we're destroying the layout
mBlockUndoCommands = true;
mBlockUndoCommandCount++;

deleteAndRemoveMultiFrames();

@@ -402,7 +403,7 @@ void QgsLayout::addLayoutItem( QgsLayoutItem *item )
void QgsLayout::removeLayoutItem( QgsLayoutItem *item )
{
std::unique_ptr< QgsLayoutItemDeleteUndoCommand > deleteCommand;
if ( !mBlockUndoCommands )
if ( mBlockUndoCommandCount == 0 )
{
mUndoStack->beginMacro( tr( "Delete Items" ) );
deleteCommand.reset( new QgsLayoutItemDeleteUndoCommand( item, tr( "Delete Item" ) ) );
@@ -551,7 +551,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
std::unique_ptr< QgsLayoutUndoStack > mUndoStack;
QgsLayoutExporter mExporter;

bool mBlockUndoCommands = false;
int mBlockUndoCommandCount = 0;

//! List of multiframe objects
QSet<QgsLayoutMultiFrame *> mMultiFrames;
@@ -579,6 +579,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
friend class QgsLayoutUndoCommand;
friend class QgsLayoutItemGroupUndoCommand;
friend class QgsLayoutModel;
friend class QgsLayoutMultiFrame;
};

#endif //QGSLAYOUT_H
@@ -141,7 +141,7 @@ void QgsLayoutMultiFrame::recalculateFrameSizes()
while ( ( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight )
{
//find out on which page the lower left point of the last frame is
int page = mLayout->pageCollection()->predictPageNumberForPoint( QPointF( 0, currentItem->pos().y() + currentItem->rect().height() ) );
int page = mLayout->pageCollection()->predictPageNumberForPoint( QPointF( 0, currentItem->pos().y() + currentItem->rect().height() ) ) + 1;

if ( mResizeMode == RepeatOnEveryPage )
{
@@ -343,14 +343,14 @@ void QgsLayoutMultiFrame::removeFrame( int i, const bool removeEmptyPages )
mIsRecalculatingSize = true;
int pageNumber = frameItem->page();
//remove item, but don't create undo command
#if 0 //TODO - block undo commands
#endif
mLayout->mBlockUndoCommandCount++;
mLayout->removeLayoutItem( frameItem );
//if frame was the only item on the page, remove the page
if ( removeEmptyPages && mLayout->pageCollection()->pageIsEmpty( pageNumber ) )
{
mLayout->pageCollection()->deletePage( pageNumber );
}
mLayout->mBlockUndoCommandCount--;
mIsRecalculatingSize = false;
}
mFrameItems.removeAt( i );
@@ -369,12 +369,12 @@ void QgsLayoutMultiFrame::deleteFrames()
mBlockUpdates = true;
ResizeMode bkResizeMode = mResizeMode;
mResizeMode = UseExistingFrames;
mLayout->mBlockUndoCommandCount++;
for ( QgsLayoutFrame *frame : qgis::as_const( mFrameItems ) )
{
#if 0 //TODO -block undo commands
#endif
mLayout->removeLayoutItem( frame );
}
mLayout->mBlockUndoCommandCount--;
mFrameItems.clear();
mResizeMode = bkResizeMode;
mBlockUpdates = false;
@@ -133,6 +133,7 @@ SET(TESTS
testqgslayertree.cpp
testqgslayout.cpp
testqgslayoutcontext.cpp
testqgslayouthtml.cpp
testqgslayoutitem.cpp
testqgslayoutitemgroup.cpp
testqgslayoutlabel.cpp

0 comments on commit 2cf9911

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