26 QgsLayoutMultiFrameUndoCommand::QgsLayoutMultiFrameUndoCommand(
QgsLayoutMultiFrame *frame,
const QString &text,
int id, QUndoCommand *parent )
28 , mFrameUuid( frame->uuid() )
29 , mLayout( frame->layout() )
30 , mItemType( frame->type() )
35 bool QgsLayoutMultiFrameUndoCommand::mergeWith(
const QUndoCommand *command )
37 if ( command->id() == 0 )
40 const QgsLayoutMultiFrameUndoCommand *
c =
dynamic_cast<const QgsLayoutMultiFrameUndoCommand *
>( command );
45 if ( c->multiFrameUuid() != multiFrameUuid() )
48 setAfterState( c->afterState() );
52 void QgsLayoutMultiFrameUndoCommand::saveState( QDomDocument &stateDoc )
const 55 QDomElement documentElement = stateDoc.createElement( QStringLiteral(
"ItemState" ) );
58 Q_ASSERT_X( item,
"QgsLayoutMultiFrameUndoCommand::saveState",
"could not retrieve item for saving state" );
61 stateDoc.appendChild( documentElement );
64 void QgsLayoutMultiFrameUndoCommand::restoreState( QDomDocument &stateDoc )
71 item = recreateItem( mItemType,
mLayout );
76 mLayout->project()->setDirty(
true );
86 QString QgsLayoutMultiFrameUndoCommand::multiFrameUuid()
const 91 QgsLayout *QgsLayoutMultiFrameUndoCommand::layout()
const 101 QgsLayoutMultiFrameDeleteUndoCommand::QgsLayoutMultiFrameDeleteUndoCommand(
QgsLayoutMultiFrame *item,
const QString &text,
int id, QUndoCommand *parent )
102 : QgsLayoutMultiFrameUndoCommand( item, text, id, parent )
107 bool QgsLayoutMultiFrameDeleteUndoCommand::mergeWith(
const QUndoCommand * )
112 void QgsLayoutMultiFrameDeleteUndoCommand::redo()
130 QgsLayoutMultiFrameAddItemCommand::QgsLayoutMultiFrameAddItemCommand(
QgsLayoutMultiFrame *
frame,
const QString &text,
int id, QUndoCommand *parent )
131 : QgsLayoutMultiFrameUndoCommand( frame, text, id, parent )
136 bool QgsLayoutMultiFrameAddItemCommand::containsChange()
const 141 bool QgsLayoutMultiFrameAddItemCommand::mergeWith(
const QUndoCommand * )
146 void QgsLayoutMultiFrameAddItemCommand::undo()
The class is used as a container of context for various read/write operations on other objects...
Base class for commands to undo/redo layout and layout object changes.
bool readXml(const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false)
Sets the item state from a DOM element.
QgsLayoutMultiFrame * multiFrameByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout multiframe with matching uuid unique identifier, or a nullptr if a matching multif...
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
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
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
QPointer< QgsLayout > mLayout
void removeMultiFrame(QgsLayoutMultiFrame *multiFrame)
Removes a multiFrame from the layout (but does not delete it).
QgsLayoutMultiFrame * createMultiFrame(int type, QgsLayout *layout) const
Creates a new instance of a layout multiframe given the multiframe type, and target layout...
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) const
Stores the multiframe state in a DOM element.
QgsLayoutFrame * frame(int index) const
Returns the child frame at a specified index from the multiframe.
const QgsLayout * layout() const
Returns the layout the object is attached to.