29 #include <QGraphicsRectItem> 32 #include <QMouseEvent> 43 mItemMetadataId = metadataId;
48 if ( event->button() != Qt::LeftButton )
55 mMousePressStartPos =
event->pos();
63 mRubberBand->start( event->
snappedPoint(),
event->modifiers() );
69 if ( mDrawing && mRubberBand )
71 mRubberBand->update( event->
snappedPoint(),
event->modifiers() );
81 if ( event->button() != Qt::LeftButton || !mDrawing )
88 QRectF rect = mRubberBand->finish( event->
snappedPoint(),
event->modifiers() );
93 undoText = tr(
"Create %1" ).arg( metadata->visibleName() );
97 undoText = tr(
"Create Item" );
109 bool clickOnly = !
isClickAndDrag( mMousePressStartPos, event->pos() );
144 if ( item->scene() !=
layout() )
157 mRubberBand->finish();
165 return mItemMetadataId;
void pushStatusMessage(const QString &message)
Pushes a new status bar message to the view.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
void setItemPosition(QgsLayoutPoint position)
Sets the item position to show in the dialog.
Base class for graphical items within a QgsLayout.
A graphical widget to display and interact with QgsLayouts.
This class is a composition of two QSettings instances:
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
void setLayout(QgsLayout *layout)
Sets the layout associated with the dialog.
double height() const
Returns the height of the size.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
double width() const
Returns the width of the size.
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items...
int page() const
Returns the page number for the new item.
A dialog for configuring properties like the size and position of layout items.
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
void sizeChanged(const QString &size)
Emitted when the size of the rubber band is changed.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView...
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
QgsLayoutSize itemSize() const
Returns the item size defined by the dialog.
QgsLayoutItemAbstractGuiMetadata * itemMetadata(int metadataId) const
Returns the metadata for the specified item metadataId.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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.
void addLayoutItem(QgsLayoutItem *item)
Adds an item to the layout.
void newItemAddedToLayout(int metadataId, QgsLayoutItem *item)
Called when a newly created item of the associated metadata metadataId has been added to a layout...
QgsUnitTypes::LayoutUnit units() const
Returns the native units for the layout.
QgsLayoutItem::ReferencePoint referencePoint() const
Returns the item reference point defined by the dialog.
void endMacro()
Ends a macro command.
QgsLayoutPoint itemPosition() const
Returns the current item position defined by the dialog.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
QgsLayoutItem * createItem(int metadataId, QgsLayout *layout) const
Creates a new instance of a layout item given the item metadata metadataId, target layout...
QPointF snappedPoint() const
Returns the snapped event point location in layout coordinates.