28using namespace Qt::StringLiterals;
31QgsLayoutMultiFrameUndoCommand::QgsLayoutMultiFrameUndoCommand(
QgsLayoutMultiFrame *frame,
const QString &text,
int id, QUndoCommand *parent )
33 , mFrameUuid( frame->uuid() )
34 , mLayout( frame->layout() )
35 , mItemType( frame->type() )
40bool QgsLayoutMultiFrameUndoCommand::mergeWith(
const QUndoCommand *command )
42 if ( command->id() == 0 )
45 const QgsLayoutMultiFrameUndoCommand *
c =
dynamic_cast<const QgsLayoutMultiFrameUndoCommand *
>( command );
50 if (
c->multiFrameUuid() != multiFrameUuid() )
53 setAfterState(
c->afterState() );
57void QgsLayoutMultiFrameUndoCommand::saveState( QDomDocument &stateDoc )
const
60 QDomElement documentElement = stateDoc.createElement( u
"ItemState"_s );
63 Q_ASSERT_X( item,
"QgsLayoutMultiFrameUndoCommand::saveState",
"could not retrieve item for saving state" );
66 stateDoc.appendChild( documentElement );
69void QgsLayoutMultiFrameUndoCommand::restoreState( QDomDocument &stateDoc )
76 item = recreateItem( mItemType, mLayout );
81 mLayout->project()->setDirty(
true );
87 mLayout->addMultiFrame( item );
91QString QgsLayoutMultiFrameUndoCommand::multiFrameUuid()
const
96QgsLayout *QgsLayoutMultiFrameUndoCommand::layout()
const
106QgsLayoutMultiFrameDeleteUndoCommand::QgsLayoutMultiFrameDeleteUndoCommand(
QgsLayoutMultiFrame *item,
const QString &text,
int id, QUndoCommand *parent )
107 : QgsLayoutMultiFrameUndoCommand( item, text, id, parent )
112bool QgsLayoutMultiFrameDeleteUndoCommand::mergeWith(
const QUndoCommand * )
117void QgsLayoutMultiFrameDeleteUndoCommand::redo()
135QgsLayoutMultiFrameAddItemCommand::QgsLayoutMultiFrameAddItemCommand(
QgsLayoutMultiFrame *frame,
const QString &text,
int id, QUndoCommand *parent )
136 : QgsLayoutMultiFrameUndoCommand( frame, text, id, parent )
141bool QgsLayoutMultiFrameAddItemCommand::containsChange()
const
146bool QgsLayoutMultiFrameAddItemCommand::mergeWith(
const QUndoCommand * )
151void QgsLayoutMultiFrameAddItemCommand::undo()
Base class for commands to undo/redo layout and layout object changes.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
QgsLayoutMultiFrame * createMultiFrame(int type, QgsLayout *layout) const
Creates a new instance of a layout multiframe given the multiframe type, and target layout.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) const
Stores the multiframe state in a DOM element.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
bool readXml(const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false)
Sets the item state from a DOM element.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void removeMultiFrame(QgsLayoutMultiFrame *multiFrame)
Removes a multiFrame from the layout (but does not delete it).
QgsLayoutMultiFrame * multiFrameByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout multiframe with matching uuid unique identifier, or nullptr if a matching multifra...
A container for the context for various read/write operations on objects.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c