29#include <QGraphicsRectItem>
43 mItemMetadataId = metadataId;
48 if ( event->button() != Qt::LeftButton )
55 mMousePressStartPos =
event->pos();
56 mMousePressStartLayoutPos =
event->layoutPoint();
62 view()->pushStatusMessage( size );
64 mRubberBand->start( event->
snappedPoint(), event->modifiers() );
70 if ( mDrawing && mRubberBand )
72 mRubberBand->update( event->
snappedPoint(), event->modifiers() );
82 if ( event->button() != Qt::LeftButton || !mDrawing )
89 const QRectF rect = mRubberBand ? mRubberBand->finish( event->
snappedPoint(), event->modifiers() ) : QRectF();
94 undoText = tr(
"Create %1" ).arg( metadata->visibleName() );
98 undoText = tr(
"Create Item" );
110 const bool clickOnly = !
isClickAndDrag( mMousePressStartPos, event->pos() );
111 if ( clickOnly && mRubberBand )
129 else if ( mRubberBand )
153 if ( item->scene() !=
layout() )
164 mCustomProperties.clear();
173 mRubberBand->finish();
181 return mCustomProperties;
191 return mItemMetadataId;
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
void newItemAddedToLayout(int metadataId, QgsLayoutItem *item, const QVariantMap &properties=QVariantMap())
Called when a newly created item of the associated metadata metadataId has been added to a layout.
QgsLayoutItem * createItem(int metadataId, QgsLayout *layout) const
Creates a new instance of a layout item given the item metadata metadataId, target layout.
A dialog for configuring properties like the size and position of layout items.
QgsLayoutSize itemSize() const
Returns the item size defined by the dialog.
QgsLayoutItem::ReferencePoint referencePoint() const
Returns the item reference point defined by the dialog.
void setLayout(QgsLayout *layout)
Sets the layout associated with the dialog.
QgsLayoutPoint itemPosition() const
Returns the current item position defined by the dialog.
int page() const
Returns the page number for the new item.
void setItemPosition(QgsLayoutPoint position)
Sets the item position to show in the dialog.
Base class for graphical items within a QgsLayout.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
virtual void attemptMove(const QgsLayoutPoint &point, bool useReferencePoint=true, bool includesFrame=false, int page=-1)
Attempts to move the item to a specified point.
void setReferencePoint(ReferencePoint point)
Sets the reference point for positioning of the layout item.
This class provides a method of storing points, consisting of an x and y coordinate,...
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
double height() const
Returns the height of the size.
double width() const
Returns the width of the size.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void endMacro()
Ends a macro command.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
QPointF snappedPoint() const
Returns the snapped event point location in layout coordinates.
void sizeChanged(const QString &size)
Emitted when the size of the rubber band is changed.
A graphical widget to display and interact with QgsLayouts.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
void addLayoutItem(QgsLayoutItem *item)
Adds an item to the layout.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
This class is a composition of two QSettings instances:
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
@ LayoutMillimeters
Millimeters.