QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
29 #include <QGraphicsRectItem>
32 #include <QMouseEvent>
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 QRectF rect = mRubberBand ? mRubberBand->finish( event->
snappedPoint(), event->modifiers() ) : QRectF();
94 undoText = tr(
"Create %1" ).arg( metadata->visibleName() );
98 undoText = tr(
"Create Item" );
110 bool clickOnly = !
isClickAndDrag( mMousePressStartPos, event->pos() );
111 if ( clickOnly && mRubberBand )
129 else if ( mRubberBand )
153 if ( item->scene() !=
layout() )
167 mRubberBand->finish();
175 return mItemMetadataId;
void newItemAddedToLayout(int metadataId, QgsLayoutItem *item)
Called when a newly created item of the associated metadata metadataId has been added to a layout.
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 ...
double width() const
Returns the width of the size.
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
void endMacro()
Ends a macro command.
This class is a composition of two QSettings instances:
void sizeChanged(const QString &size)
Emitted when the size of the rubber band is changed.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
void setLayout(QgsLayout *layout)
Sets the layout associated with the dialog.
void setItemPosition(QgsLayoutPoint position)
Sets the item position to show in the dialog.
int page() const
Returns the page number for the new item.
QgsLayoutPoint itemPosition() const
Returns the current item position defined by the dialog.
QgsLayoutItem::ReferencePoint referencePoint() const
Returns the item reference point defined by the dialog.
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.
Base class for graphical items within a QgsLayout.
QPointF snappedPoint() const
Returns the snapped event point location in layout coordinates.
QgsLayoutItem * createItem(int metadataId, QgsLayout *layout) const
Creates a new instance of a layout item given the item metadata metadataId, target layout.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
double height() const
Returns the height of the 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.
QgsLayoutSize itemSize() const
Returns the item size defined by the dialog.
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
A graphical widget to display and interact with QgsLayouts.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
@ LayoutMillimeters
Millimeters.
This class provides a method of storing points, consisting of an x and y coordinate,...
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
A dialog for configuring properties like the size and position of layout items.