Skip to content

Commit

Permalink
Resurrect tests for html item
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 24, 2017
1 parent aec0326 commit 2cf9911
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/core/layout/qgslayout.cpp
Expand Up @@ -24,6 +24,7 @@
#include "qgslayoutitemundocommand.h"
#include "qgslayoutitemgroup.h"
#include "qgslayoutitemgroupundocommand.h"
#include "qgslayoutmultiframe.h"

QgsLayout::QgsLayout( QgsProject *project )
: mProject( project )
Expand All @@ -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();

Expand Down Expand Up @@ -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" ) ) );
Expand Down
3 changes: 2 additions & 1 deletion src/core/layout/qgslayout.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/core/layout/qgslayoutmultiframe.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/CMakeLists.txt
Expand Up @@ -133,6 +133,7 @@ SET(TESTS
testqgslayertree.cpp
testqgslayout.cpp
testqgslayoutcontext.cpp
testqgslayouthtml.cpp
testqgslayoutitem.cpp
testqgslayoutitemgroup.cpp
testqgslayoutlabel.cpp
Expand Down

0 comments on commit 2cf9911

Please sign in to comment.