Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
FlowLayout Class Reference

#include <flow_layout.h>

Inheritance diagram for FlowLayout:
[legend]
Collaboration diagram for FlowLayout:
[legend]

Public Member Functions

 FlowLayout (QWidget *parent=nullptr)
 FlowLayout (QWidget *parent, Qt::Orientation _flowDirection, int margin=0, int hSpacing=0, int vSpacing=0)
 Constructs a FlowLayout instance with the specified parent widget, margin, and spacing values.
 ~FlowLayout () override
 Destructor for FlowLayout, which cleans up all items in the layout.
void insertWidgetAtIndex (QWidget *toInsert, int index)
QSize calculateMinimumSizeHorizontal () const
 Calculates the minimum size for horizontal flow direction.
QSize calculateSizeHintVertical () const
 Calculates the size hint for vertical flow direction.
QSize calculateMinimumSizeVertical () const
 Calculates the minimum size for vertical flow direction.
void addItem (QLayoutItem *item) override
 Adds a new item to the layout.
int count () const override
 Retrieves the count of items in the layout.
QLayoutItem * itemAt (int index) const override
 Returns the layout item at the specified index.
QLayoutItem * takeAt (int index) override
 Removes and returns the item at the specified index.
int horizontalSpacing () const
 Gets the horizontal spacing between items.
Qt::Orientations expandingDirections () const override
 Indicates the layout's support for expansion in both horizontal and vertical directions.
bool hasHeightForWidth () const override
 Indicates that this layout's height depends on its width.
int heightForWidth (int width) const override
 Calculates the required height to display all items within the specified width.
int verticalSpacing () const
 Gets the vertical spacing between items.
int doLayout (const QRect &rect, bool testOnly) const
int smartSpacing (QStyle::PixelMetric pm) const
 Calculates smart spacing based on the parent widget style.
int getParentScrollAreaWidth () const
 Gets the width of the parent scroll area, if any.
int getParentScrollAreaHeight () const
 Gets the height of the parent scroll area, if any.
void setGeometry (const QRect &rect) override
 Arranges layout items in rows within the specified rectangle bounds.
virtual int layoutAllRows (int originX, int originY, int availableWidth)
 Lays out items into rows according to the available width, starting from a given origin. Each row is arranged within availableWidth, wrapping to a new row as necessary.
virtual void layoutSingleRow (const QVector< QLayoutItem * > &rowItems, int x, int y)
 Arranges a single row of items within specified x and y starting positions.
int layoutAllColumns (int originX, int originY, int availableHeight)
 Lays out items into columns according to the available height, starting from a given origin. Each column is arranged within availableHeight, wrapping to a new column as necessary.
void layoutSingleColumn (const QVector< QLayoutItem * > &colItems, int x, int y)
 Arranges a single column of items within specified x and y starting positions.
QSize sizeHint () const override
 Calculates the preferred size of the layout based on the flow direction.
QSize minimumSize () const override
 Calculates the minimum size required by the layout based on the flow direction.
QSize calculateSizeHintHorizontal () const
 Calculates the size hint for horizontal flow direction.

Protected Attributes

QList< QLayoutItem * > items
Qt::Orientation flowDirection
int horizontalMargin
int verticalMargin

Constructor & Destructor Documentation

◆ FlowLayout() [1/2]

FlowLayout::FlowLayout ( QWidget * parent = nullptr)
explicit

◆ FlowLayout() [2/2]

FlowLayout::FlowLayout ( QWidget * parent,
Qt::Orientation _flowDirection,
int margin = 0,
int hSpacing = 0,
int vSpacing = 0 )

Constructs a FlowLayout instance with the specified parent widget, margin, and spacing values.

Parameters
parentThe parent widget for this layout.
marginThe layout margin.
hSpacingThe horizontal spacing between items.
vSpacingThe vertical spacing between items.

◆ ~FlowLayout()

FlowLayout::~FlowLayout ( )
override

Destructor for FlowLayout, which cleans up all items in the layout.

Here is the call graph for this function:

Member Function Documentation

◆ addItem()

void FlowLayout::addItem ( QLayoutItem * item)
override

Adds a new item to the layout.

Parameters
itemThe layout item to add.

◆ calculateMinimumSizeHorizontal()

QSize FlowLayout::calculateMinimumSizeHorizontal ( ) const
nodiscard

Calculates the minimum size for horizontal flow direction.

Returns
A QSize representing the minimum required dimensions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateMinimumSizeVertical()

QSize FlowLayout::calculateMinimumSizeVertical ( ) const
nodiscard

Calculates the minimum size for vertical flow direction.

Returns
A QSize representing the minimum required dimensions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateSizeHintHorizontal()

QSize FlowLayout::calculateSizeHintHorizontal ( ) const
nodiscard

Calculates the size hint for horizontal flow direction.

Returns
A QSize representing the preferred dimensions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateSizeHintVertical()

QSize FlowLayout::calculateSizeHintVertical ( ) const
nodiscard

Calculates the size hint for vertical flow direction.

Returns
A QSize representing the preferred dimensions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ count()

int FlowLayout::count ( ) const
nodiscardoverride

Retrieves the count of items in the layout.

Returns
The number of layout items.

◆ doLayout()

int FlowLayout::doLayout ( const QRect & rect,
bool testOnly ) const
nodiscard

◆ expandingDirections()

Qt::Orientations FlowLayout::expandingDirections ( ) const
nodiscardoverride

Indicates the layout's support for expansion in both horizontal and vertical directions.

Returns
The orientations (Qt::Horizontal | Qt::Vertical) this layout can expand to fill.

◆ getParentScrollAreaHeight()

int FlowLayout::getParentScrollAreaHeight ( ) const
nodiscard

Gets the height of the parent scroll area, if any.

Returns
The height of the scroll area's viewport, or 0 if not found.
Here is the caller graph for this function:

◆ getParentScrollAreaWidth()

int FlowLayout::getParentScrollAreaWidth ( ) const
nodiscard

Gets the width of the parent scroll area, if any.

Returns
The width of the scroll area's viewport, or 0 if not found.
Here is the caller graph for this function:

◆ hasHeightForWidth()

bool FlowLayout::hasHeightForWidth ( ) const
nodiscardoverride

Indicates that this layout's height depends on its width.

Returns
True, as the layout adjusts its height to fit the specified width.

◆ heightForWidth()

int FlowLayout::heightForWidth ( int width) const
nodiscardoverride

Calculates the required height to display all items within the specified width.

Parameters
widthThe available width for arranging items.
Returns
The total height needed to fit all items in rows constrained by the specified width.
Here is the call graph for this function:

◆ horizontalSpacing()

int FlowLayout::horizontalSpacing ( ) const
nodiscard

Gets the horizontal spacing between items.

Returns
The horizontal spacing if set, otherwise a smart default.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertWidgetAtIndex()

void FlowLayout::insertWidgetAtIndex ( QWidget * toInsert,
int index )

◆ itemAt()

QLayoutItem * FlowLayout::itemAt ( int index) const
nodiscardoverride

Returns the layout item at the specified index.

Parameters
indexThe index of the item to retrieve.
Returns
A pointer to the item at the specified index, or nullptr if out of range.

◆ layoutAllColumns()

int FlowLayout::layoutAllColumns ( int originX,
int originY,
int availableHeight )

Lays out items into columns according to the available height, starting from a given origin. Each column is arranged within availableHeight, wrapping to a new column as necessary.

Parameters
originXThe x-coordinate for the layout start position.
originYThe y-coordinate for the layout start position.
availableHeightThe height within which each column is constrained.
Returns
The total width after arranging all columns.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ layoutAllRows()

int FlowLayout::layoutAllRows ( int originX,
int originY,
int availableWidth )
virtual

Lays out items into rows according to the available width, starting from a given origin. Each row is arranged within availableWidth, wrapping to a new row as necessary.

Parameters
originXThe x-coordinate for the layout start position.
originYThe y-coordinate for the layout start position.
availableWidthThe width within which each row is constrained.
Returns
The total height after arranging all rows.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ layoutSingleColumn()

void FlowLayout::layoutSingleColumn ( const QVector< QLayoutItem * > & colItems,
int x,
int y )

Arranges a single column of items within specified x and y starting positions.

Parameters
colItemsA list of items to be arranged in the column.
xThe starting x-coordinate for the column.
yThe starting y-coordinate for the column.
Here is the caller graph for this function:

◆ layoutSingleRow()

void FlowLayout::layoutSingleRow ( const QVector< QLayoutItem * > & rowItems,
int x,
int y )
virtual

Arranges a single row of items within specified x and y starting positions.

Parameters
rowItemsA list of items to be arranged in the row.
xThe starting x-coordinate for the row.
yThe starting y-coordinate for the row.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimumSize()

QSize FlowLayout::minimumSize ( ) const
nodiscardoverride

Calculates the minimum size required by the layout based on the flow direction.

Returns
A QSize representing the minimum required dimensions.
Here is the call graph for this function:

◆ setGeometry()

void FlowLayout::setGeometry ( const QRect & rect)
override

Arranges layout items in rows within the specified rectangle bounds.

Parameters
rectThe area within which to position layout items.
Here is the call graph for this function:

◆ sizeHint()

QSize FlowLayout::sizeHint ( ) const
nodiscardoverride

Calculates the preferred size of the layout based on the flow direction.

Returns
A QSize representing the ideal dimensions of the layout.
Here is the call graph for this function:

◆ smartSpacing()

int FlowLayout::smartSpacing ( QStyle::PixelMetric pm) const
nodiscard

Calculates smart spacing based on the parent widget style.

Parameters
pmThe pixel metric to calculate.
Returns
The calculated spacing value.
Here is the caller graph for this function:

◆ takeAt()

QLayoutItem * FlowLayout::takeAt ( int index)
override

Removes and returns the item at the specified index.

Parameters
indexThe index of the item to remove.
Returns
A pointer to the removed item, or nullptr if out of range.
Here is the caller graph for this function:

◆ verticalSpacing()

int FlowLayout::verticalSpacing ( ) const
nodiscard

Gets the vertical spacing between items.

Returns
The vertical spacing if set, otherwise a smart default.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ flowDirection

Qt::Orientation FlowLayout::flowDirection
protected

◆ horizontalMargin

int FlowLayout::horizontalMargin
protected

◆ items

QList<QLayoutItem *> FlowLayout::items
protected

◆ verticalMargin

int FlowLayout::verticalMargin
protected

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