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() )
38bool QgsLayoutMultiFrameUndoCommand::mergeWith(
const QUndoCommand *command )
40 if ( command->id() == 0 )
43 const QgsLayoutMultiFrameUndoCommand *
c =
dynamic_cast<const QgsLayoutMultiFrameUndoCommand *
>( command );
48 if (
c->multiFrameUuid() != multiFrameUuid() )
51 setAfterState(
c->afterState() );
55void QgsLayoutMultiFrameUndoCommand::saveState( QDomDocument &stateDoc )
const
58 QDomElement documentElement = stateDoc.createElement( u
"ItemState"_s );
61 Q_ASSERT_X( item,
"QgsLayoutMultiFrameUndoCommand::saveState",
"could not retrieve item for saving state" );
64 stateDoc.appendChild( documentElement );
67void QgsLayoutMultiFrameUndoCommand::restoreState( QDomDocument &stateDoc )
74 item = recreateItem( mItemType, mLayout );
79 mLayout->project()->setDirty(
true );
85 mLayout->addMultiFrame( item );
89QString QgsLayoutMultiFrameUndoCommand::multiFrameUuid()
const
94QgsLayout *QgsLayoutMultiFrameUndoCommand::layout()
const
104QgsLayoutMultiFrameDeleteUndoCommand::QgsLayoutMultiFrameDeleteUndoCommand(
QgsLayoutMultiFrame *item,
const QString &text,
int id, QUndoCommand *parent )
105 : QgsLayoutMultiFrameUndoCommand( item, text, id, parent )
110bool QgsLayoutMultiFrameDeleteUndoCommand::mergeWith(
const QUndoCommand * )
115void QgsLayoutMultiFrameDeleteUndoCommand::redo()
133QgsLayoutMultiFrameAddItemCommand::QgsLayoutMultiFrameAddItemCommand(
QgsLayoutMultiFrame *frame,
const QString &text,
int id, QUndoCommand *parent )
134 : QgsLayoutMultiFrameUndoCommand( frame, text, id, parent )
139bool QgsLayoutMultiFrameAddItemCommand::containsChange()
const
144bool QgsLayoutMultiFrameAddItemCommand::mergeWith(
const QUndoCommand * )
149void 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