Skip to content
Permalink
Browse files

More multiframe undo improvements

  • Loading branch information
mhugent committed Aug 8, 2012
1 parent b40d0af commit c2f768fa9313f327bca1c071e7aa64e12f1b0321
@@ -46,8 +46,6 @@ class QgsComposerFrame: public QgsComposerItem

private:
QgsComposerFrame(); //forbidden

QgsComposition* mComposition;
QgsComposerMultiFrame* mMultiFrame;
QRectF mSection;
};
@@ -160,13 +160,16 @@ void QgsComposerMultiFrame::update()

void QgsComposerMultiFrame::deleteFrames()
{
ResizeMode bkResizeMode = mResizeMode;
mResizeMode = UseExistingFrames;
QList<QgsComposerFrame*>::iterator frameIt = mFrameItems.begin();
for ( ; frameIt != mFrameItems.end(); ++frameIt )
{
mComposition->removeComposerItem( *frameIt );
mComposition->removeComposerItem( *frameIt, false );
delete *frameIt;
}
mFrameItems.clear();
mResizeMode = bkResizeMode;
}

bool QgsComposerMultiFrame::_writeXML( QDomElement& elem, QDomDocument& doc, bool ignoreFrames ) const
@@ -38,7 +38,7 @@ void QgsComposerMultiFrameCommand::undo()

void QgsComposerMultiFrameCommand::redo()
{
if ( !checkFirstRun() )
if ( checkFirstRun() )
{
return;
}
@@ -1176,7 +1176,7 @@ void QgsComposition::addComposerHtmlFrame( QgsComposerHtml* html, QgsComposerFra
emit selectedItemChanged( frame );
}

void QgsComposition::removeComposerItem( QgsComposerItem* item )
void QgsComposition::removeComposerItem( QgsComposerItem* item, bool createCommand )
{
QgsComposerMap* map = dynamic_cast<QgsComposerMap *>( item );
if ( !map || !map->isDrawing() ) //don't delete a composer map while it draws
@@ -1203,14 +1203,23 @@ void QgsComposition::removeComposerItem( QgsComposerItem* item )
}
else
{
emit itemRemoved( item );
if ( item->type() == QgsComposerItem::ComposerFrame ) //multiframe tracks item changes
if ( createCommand )
{

if ( item->type() == QgsComposerItem::ComposerFrame ) //multiframe tracks item changes
{
item->beginItemCommand( tr( "Frame deleted" ) );
emit itemRemoved( item );
item->endItemCommand();
}
else
{
emit itemRemoved( item );
pushAddRemoveCommand( item, tr( "Item deleted" ), QgsAddRemoveItemCommand::Removed );
}
}
else
{
pushAddRemoveCommand( item, tr( "Item deleted" ), QgsAddRemoveItemCommand::Removed );
emit itemRemoved( item );
}
}
}
@@ -229,7 +229,7 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
void addComposerHtmlFrame( QgsComposerHtml* html, QgsComposerFrame* frame );

/**Remove item from the graphics scene. Additionally to QGraphicsScene::removeItem, this function considers undo/redo command*/
void removeComposerItem( QgsComposerItem* item );
void removeComposerItem( QgsComposerItem* item, bool createCommand = true );

/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );

0 comments on commit c2f768f

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