QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
QgsLayoutGuideCollection Class Reference

Stores and manages the snap guides used by a layout. More...

#include <qgslayoutguidecollection.h>

Inheritance diagram for QgsLayoutGuideCollection:
Inheritance graph
[legend]

Public Types

enum  Roles {
  OrientationRole = Qt::UserRole , PositionRole , UnitsRole , PageRole ,
  LayoutPositionRole
}
 Model roles. More...
 

Public Member Functions

 QgsLayoutGuideCollection (QgsLayout *layout, QgsLayoutPageCollection *pageCollection)
 Constructor for QgsLayoutGuideCollection belonging to the specified layout, and linked to the specified pageCollection.
 
 ~QgsLayoutGuideCollection () override
 
void addGuide (QgsLayoutGuide *guide)
 Adds a guide to the collection.
 
void applyGuidesToAllOtherPages (int sourcePage)
 Resets all other pages' guides to match the guides from the specified sourcePage.
 
void clear ()
 Removes all guides from the collection.
 
int columnCount (const QModelIndex &) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QList< QgsLayoutGuide * > guides ()
 Returns a list of all guides contained in the collection.
 
QList< QgsLayoutGuide * > guides (Qt::Orientation orientation, int page=-1)
 Returns the list of guides contained in the collection with the specified orientation and on a matching page.
 
QList< QgsLayoutGuide * > guidesOnPage (int page)
 Returns the list of guides contained on a matching page.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QgsLayoutlayout () override
 Returns the layout the object belongs to.
 
bool readXml (const QDomElement &collectionElement, const QDomDocument &document, const QgsReadWriteContext &context) override
 Sets the collection's state from a DOM element.
 
void removeGuide (QgsLayoutGuide *guide)
 Removes the specified guide, and deletes it.
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override
 
int rowCount (const QModelIndex &) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
void setGuideLayoutPosition (QgsLayoutGuide *guide, double position)
 Sets the absolute position (in layout coordinates) for guide within the layout.
 
void setVisible (bool visible)
 Sets whether the guide lines should be visible.
 
QString stringType () const override
 Returns the object type as a string.
 
void update ()
 Updates the position (and visibility) of all guide line items.
 
bool visible () const
 Returns true if the guide lines should be drawn.
 
bool writeXml (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override
 Stores the collection's state in a DOM element.
 
- Public Member Functions inherited from QgsLayoutSerializableObject
QgsAbstractLayoutUndoCommandcreateCommand (const QString &text, int id, QUndoCommand *parent=nullptr) override
 Creates a new layout undo command with the specified text and parent.
 
- Public Member Functions inherited from QgsLayoutUndoObjectInterface
virtual ~QgsLayoutUndoObjectInterface ()=default
 Destructor for QgsLayoutUndoObjectInterface.
 

Friends

class QgsLayoutGuideCollectionUndoCommand
 

Detailed Description

Stores and manages the snap guides used by a layout.

Since
QGIS 3.0

Definition at line 168 of file qgslayoutguidecollection.h.

Member Enumeration Documentation

◆ Roles

Model roles.

Enumerator
OrientationRole 

Guide orientation role.

PositionRole 

Guide position role.

UnitsRole 

Guide position units role.

PageRole 

Guide page role.

LayoutPositionRole 

Guide position in layout coordinates.

Definition at line 176 of file qgslayoutguidecollection.h.

Constructor & Destructor Documentation

◆ QgsLayoutGuideCollection()

QgsLayoutGuideCollection::QgsLayoutGuideCollection ( QgsLayout layout,
QgsLayoutPageCollection pageCollection 
)

Constructor for QgsLayoutGuideCollection belonging to the specified layout, and linked to the specified pageCollection.

Definition at line 193 of file qgslayoutguidecollection.cpp.

◆ ~QgsLayoutGuideCollection()

QgsLayoutGuideCollection::~QgsLayoutGuideCollection ( )
override

Definition at line 204 of file qgslayoutguidecollection.cpp.

Member Function Documentation

◆ addGuide()

void QgsLayoutGuideCollection::addGuide ( QgsLayoutGuide guide)

Adds a guide to the collection.

Ownership of the guide is transferred to the collection, and the guide will automatically have the correct layout set.

Definition at line 386 of file qgslayoutguidecollection.cpp.

◆ applyGuidesToAllOtherPages()

void QgsLayoutGuideCollection::applyGuidesToAllOtherPages ( int  sourcePage)

Resets all other pages' guides to match the guides from the specified sourcePage.

Definition at line 434 of file qgslayoutguidecollection.cpp.

◆ clear()

void QgsLayoutGuideCollection::clear ( )

Removes all guides from the collection.

See also
removeGuide()

Definition at line 424 of file qgslayoutguidecollection.cpp.

◆ columnCount()

int QgsLayoutGuideCollection::columnCount ( const QModelIndex &  parent) const
override

Definition at line 219 of file qgslayoutguidecollection.cpp.

◆ data()

QVariant QgsLayoutGuideCollection::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 227 of file qgslayoutguidecollection.cpp.

◆ flags()

Qt::ItemFlags QgsLayoutGuideCollection::flags ( const QModelIndex &  index) const
override

Definition at line 350 of file qgslayoutguidecollection.cpp.

◆ guides() [1/2]

QList< QgsLayoutGuide * > QgsLayoutGuideCollection::guides ( )

Returns a list of all guides contained in the collection.

Definition at line 477 of file qgslayoutguidecollection.cpp.

◆ guides() [2/2]

QList< QgsLayoutGuide * > QgsLayoutGuideCollection::guides ( Qt::Orientation  orientation,
int  page = -1 
)

Returns the list of guides contained in the collection with the specified orientation and on a matching page.

If page is -1, guides from all pages will be returned.

See also
guidesOnPage()

Definition at line 482 of file qgslayoutguidecollection.cpp.

◆ guidesOnPage()

QList< QgsLayoutGuide * > QgsLayoutGuideCollection::guidesOnPage ( int  page)

Returns the list of guides contained on a matching page.

See also
guides()

Definition at line 495 of file qgslayoutguidecollection.cpp.

◆ headerData()

QVariant QgsLayoutGuideCollection::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Definition at line 357 of file qgslayoutguidecollection.cpp.

◆ layout()

QgsLayout * QgsLayoutGuideCollection::layout ( )
overridevirtual

Returns the layout the object belongs to.

Implements QgsLayoutSerializableObject.

Definition at line 209 of file qgslayoutguidecollection.cpp.

◆ readXml()

bool QgsLayoutGuideCollection::readXml ( const QDomElement &  collectionElement,
const QDomDocument &  document,
const QgsReadWriteContext context 
)
overridevirtual

Sets the collection's state from a DOM element.

collectionElement is the DOM node corresponding to the collection.

See also
writeXml()

Implements QgsLayoutSerializableObject.

Definition at line 550 of file qgslayoutguidecollection.cpp.

◆ removeGuide()

void QgsLayoutGuideCollection::removeGuide ( QgsLayoutGuide guide)

Removes the specified guide, and deletes it.

See also
clear()

Definition at line 406 of file qgslayoutguidecollection.cpp.

◆ removeRows()

bool QgsLayoutGuideCollection::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
override

Definition at line 368 of file qgslayoutguidecollection.cpp.

◆ rowCount()

int QgsLayoutGuideCollection::rowCount ( const QModelIndex &  ) const
override

Definition at line 214 of file qgslayoutguidecollection.cpp.

◆ setData()

bool QgsLayoutGuideCollection::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
override

Definition at line 267 of file qgslayoutguidecollection.cpp.

◆ setGuideLayoutPosition()

void QgsLayoutGuideCollection::setGuideLayoutPosition ( QgsLayoutGuide guide,
double  position 
)

Sets the absolute position (in layout coordinates) for guide within the layout.

Definition at line 415 of file qgslayoutguidecollection.cpp.

◆ setVisible()

void QgsLayoutGuideCollection::setVisible ( bool  visible)

Sets whether the guide lines should be visible.

See also
visible()

Definition at line 512 of file qgslayoutguidecollection.cpp.

◆ stringType()

QString QgsLayoutGuideCollection::stringType ( ) const
inlineoverridevirtual

Returns the object type as a string.

This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"

Implements QgsLayoutSerializableObject.

Definition at line 192 of file qgslayoutguidecollection.h.

◆ update()

void QgsLayoutGuideCollection::update ( )

Updates the position (and visibility) of all guide line items.

Definition at line 468 of file qgslayoutguidecollection.cpp.

◆ visible()

bool QgsLayoutGuideCollection::visible ( ) const

Returns true if the guide lines should be drawn.

See also
setVisible()

Definition at line 507 of file qgslayoutguidecollection.cpp.

◆ writeXml()

bool QgsLayoutGuideCollection::writeXml ( QDomElement &  parentElement,
QDomDocument &  document,
const QgsReadWriteContext context 
) const
overridevirtual

Stores the collection's state in a DOM element.

The parentElement should refer to the parent layout's DOM element.

See also
readXml()

Implements QgsLayoutSerializableObject.

Definition at line 531 of file qgslayoutguidecollection.cpp.

Friends And Related Symbol Documentation

◆ QgsLayoutGuideCollectionUndoCommand

friend class QgsLayoutGuideCollectionUndoCommand
friend

Definition at line 302 of file qgslayoutguidecollection.h.


The documentation for this class was generated from the following files: