17#include "moc_qgslayoutviewtooladditem.cpp"
27#include <QGraphicsRectItem>
41 mItemMetadataId = metadataId;
46 if ( event->button() != Qt::LeftButton )
53 mMousePressStartPos =
event->pos();
54 mMousePressStartLayoutPos =
event->layoutPoint();
59 view()->pushStatusMessage( size );
61 mRubberBand->start( event->
snappedPoint(), event->modifiers() );
67 if ( mDrawing && mRubberBand )
69 mRubberBand->update( event->
snappedPoint(), event->modifiers() );
79 if ( event->button() != Qt::LeftButton || !mDrawing )
86 const QRectF rect = mRubberBand ? mRubberBand->finish( event->
snappedPoint(), event->modifiers() ) : QRectF();
91 undoText = tr(
"Create %1" ).arg( metadata->visibleName() );
95 undoText = tr(
"Create Item" );
107 const bool clickOnly = !
isClickAndDrag( mMousePressStartPos, event->pos() );
108 if ( clickOnly && mRubberBand )
126 else if ( mRubberBand )
150 if ( item->scene() !=
layout() )
161 mCustomProperties.clear();
170 mRubberBand->finish();
178 return mCustomProperties;
188 return mItemMetadataId;
@ Millimeters
Millimeters.
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...
double height() const
Returns the height of the size.
Qgis::LayoutUnit units() const
Returns the units for 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.