QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlAutoGrid Class Reference

A simple grid container which rearrange the children based on its size. More...

Inheritance diagram for QtlAutoGrid:
QtlButtonGrid

Classes

class  ChildBox
 Description of one child widget in the grid. More...
 

Public Types

typedef QWidget SuperClass
 Reference to superclass. More...
 

Public Member Functions

 QtlAutoGrid (QWidget *parent=0)
 Constructor. More...
 
int bottomMargin () const
 Get the bottom margin in pixels. More...
 
virtual bool hasHeightForWidth () const Q_DECL_OVERRIDE
 Check if the preferred height of the widget depends on its width. More...
 
virtual int heightForWidth (int width) const Q_DECL_OVERRIDE
 Compute the widget height for a given width. More...
 
int horizontalSpacing () const
 Get the horizontal spacing in pixels. More...
 
int leftMargin () const
 Get the left margin in pixels. More...
 
virtual QSize minimumSizeHint () const Q_DECL_OVERRIDE
 Return the recommended minimum size for the widget. More...
 
int rightMargin () const
 Get the right margin in pixels. More...
 
void setBottomMargin (int bottomMargin)
 Set the bottom margin in pixels. More...
 
void setHorizontalSpacing (int horizontalSpacing)
 Set the horizontal spacing in pixels. More...
 
void setLeftMargin (int leftMargin)
 Set the left margin in pixels. More...
 
void setRightMargin (int rightMargin)
 Set the right margin in pixels. More...
 
void setTopMargin (int topMargin)
 Set the top margin in pixels. More...
 
void setVerticalSpacing (int verticalSpacing)
 Set the vertical spacing in pixels. More...
 
virtual QSize sizeHint () const Q_DECL_OVERRIDE
 Return the widget size hint. More...
 
int topMargin () const
 Get the top margin in pixels. More...
 
int verticalSpacing () const
 Get the vertical spacing in pixels. More...
 

Protected Member Functions

virtual void childEvent (QChildEvent *event) Q_DECL_OVERRIDE
 Invoked when a child is added, polished or removed. More...
 
virtual bool event (QEvent *event) Q_DECL_OVERRIDE
 General event handler. More...
 
virtual void resizeEvent (QResizeEvent *event) Q_DECL_OVERRIDE
 Invoked when the widget is resized. More...
 

Private Member Functions

bool addNewChild (QWidget *child)
 Register a new child, if not yet known. More...
 
int columnsForWidth (int width) const
 Compute the number of columns for a given widget width. More...
 
int columnWidth (int column, int rows) const
 Compute the width of a given column, assuming a given row/column layout. More...
 
void reorganizeLayout (bool needUpdateGeometry)
 Reorganize the layout of the children widgets. More...
 
int rowHeight (int row, int rows) const
 Compute the height of a given row, assuming a given row/column layout. More...
 
int rowsForColumns (int columns) const
 Compute the number of rows for a given number of columns. More...
 
int widthForColumns (int columns) const
 Compute the widget width for a given number of columns. More...
 

Private Attributes

int _bottomMargin
 Bottom margin in pixels. More...
 
QList< ChildBox_children
 List of managed children. More...
 
int _horizontalSpacing
 Horizontal spacing between pixels. More...
 
int _leftMargin
 Left margin in pixels. More...
 
int _rightMargin
 Right margin in pixels. More...
 
int _topMargin
 Top margin in pixels. More...
 
int _verticalSpacing
 Vertical spacing between pixels. More...
 

Detailed Description

A simple grid container which rearrange the children based on its size.

When the container is resized, the children are rearranged to fill rows first, ie. to occupy the maximum width.

Limitations:

  • This class should be implemented as a layout. It is not.
  • The geometry of the children is only based on their sizeHint(). Their sizePolicy() is ignored.
  • This is quick and dirty in fact...

Member Typedef Documentation

◆ SuperClass

typedef QWidget QtlAutoGrid::SuperClass

Reference to superclass.

Constructor & Destructor Documentation

◆ QtlAutoGrid()

QtlAutoGrid::QtlAutoGrid ( QWidget *  parent = 0)
explicit

Constructor.

Parameters
[in]parentOptional parent widget.

Member Function Documentation

◆ leftMargin()

int QtlAutoGrid::leftMargin ( ) const
inline

Get the left margin in pixels.

Returns
The left margin in pixels.

◆ setLeftMargin()

void QtlAutoGrid::setLeftMargin ( int  leftMargin)

Set the left margin in pixels.

Parameters
[in]leftMarginThe left margin in pixels.

◆ rightMargin()

int QtlAutoGrid::rightMargin ( ) const
inline

Get the right margin in pixels.

Returns
The right margin in pixels.

◆ setRightMargin()

void QtlAutoGrid::setRightMargin ( int  rightMargin)

Set the right margin in pixels.

Parameters
[in]rightMarginThe right margin in pixels.

◆ topMargin()

int QtlAutoGrid::topMargin ( ) const
inline

Get the top margin in pixels.

Returns
The top margin in pixels.

◆ setTopMargin()

void QtlAutoGrid::setTopMargin ( int  topMargin)

Set the top margin in pixels.

Parameters
[in]topMarginThe top margin in pixels.

◆ bottomMargin()

int QtlAutoGrid::bottomMargin ( ) const
inline

Get the bottom margin in pixels.

Returns
The bottom margin in pixels.

◆ setBottomMargin()

void QtlAutoGrid::setBottomMargin ( int  bottomMargin)

Set the bottom margin in pixels.

Parameters
[in]bottomMarginThe bottom margin in pixels.

◆ horizontalSpacing()

int QtlAutoGrid::horizontalSpacing ( ) const
inline

Get the horizontal spacing in pixels.

Returns
The horizontal spacing in pixels.

◆ setHorizontalSpacing()

void QtlAutoGrid::setHorizontalSpacing ( int  horizontalSpacing)

Set the horizontal spacing in pixels.

Parameters
[in]horizontalSpacingThe horizontal spacing in pixels.

◆ verticalSpacing()

int QtlAutoGrid::verticalSpacing ( ) const
inline

Get the vertical spacing in pixels.

Returns
The vertical spacing in pixels.

◆ setVerticalSpacing()

void QtlAutoGrid::setVerticalSpacing ( int  verticalSpacing)

Set the vertical spacing in pixels.

Parameters
[in]verticalSpacingThe vertical spacing in pixels.

◆ minimumSizeHint()

QSize QtlAutoGrid::minimumSizeHint ( ) const
virtual

Return the recommended minimum size for the widget.

Reimplemented from QWidget.

Returns
The recommended minimum size.

◆ sizeHint()

QSize QtlAutoGrid::sizeHint ( ) const
virtual

Return the widget size hint.

Reimplemented from QWidget.

Returns
The size hint.

◆ hasHeightForWidth()

virtual bool QtlAutoGrid::hasHeightForWidth ( ) const
inlinevirtual

Check if the preferred height of the widget depends on its width.

Reimplemented from QWidget.

Returns
True.

◆ heightForWidth()

int QtlAutoGrid::heightForWidth ( int  width) const
virtual

Compute the widget height for a given width.

Reimplemented from QWidget.

Parameters
[in]widthThe proposed width for the widget.
Returns
The corresponding height.

◆ event()

bool QtlAutoGrid::event ( QEvent *  event)
protectedvirtual

General event handler.

Reimplemented from QWidget and QObject.

Parameters
eventEvent.
Returns
True if the event was recognized and processed.

◆ childEvent()

void QtlAutoGrid::childEvent ( QChildEvent *  event)
protectedvirtual

Invoked when a child is added, polished or removed.

Reimplemented from QObject.

Parameters
[in]eventThe event to intercept.

Reimplemented in QtlButtonGrid.

◆ resizeEvent()

void QtlAutoGrid::resizeEvent ( QResizeEvent *  event)
protectedvirtual

Invoked when the widget is resized.

Reimplemented from QWidget.

Parameters
[in]eventThe event to intercept.

◆ columnsForWidth()

int QtlAutoGrid::columnsForWidth ( int  width) const
private

Compute the number of columns for a given widget width.

Parameters
[in]widthThe proposed width for the widget.
Returns
The corresponding number of columns.

◆ widthForColumns()

int QtlAutoGrid::widthForColumns ( int  columns) const
private

Compute the widget width for a given number of columns.

Parameters
[in]columnsThe proposed number of columns.
Returns
The corresponding width for the widget.

◆ rowsForColumns()

int QtlAutoGrid::rowsForColumns ( int  columns) const
private

Compute the number of rows for a given number of columns.

Parameters
[in]columnsThe number of columns.
Returns
The corresponding number of rows.

◆ rowHeight()

int QtlAutoGrid::rowHeight ( int  row,
int  rows 
) const
private

Compute the height of a given row, assuming a given row/column layout.

Parameters
[in]rowIndex of the row.
[in]rowsNumber of rows in the grid.
Returns
Height in pixels of row.

◆ columnWidth()

int QtlAutoGrid::columnWidth ( int  column,
int  rows 
) const
private

Compute the width of a given column, assuming a given row/column layout.

Parameters
[in]columnIndex of the column.
[in]rowsNumber of rows in the grid.
Returns
Width in pixels of column.

◆ addNewChild()

bool QtlAutoGrid::addNewChild ( QWidget *  child)
private

Register a new child, if not yet known.

Parameters
[in]childThe child to add.
Returns
True if the child was added, false if it was already known or is not a direct child of this object.

◆ reorganizeLayout()

void QtlAutoGrid::reorganizeLayout ( bool  needUpdateGeometry)
private

Reorganize the layout of the children widgets.

Parameters
[in]needUpdateGeometryIf true, invoke updateGeometry() even if no widget has been moved.

Member Data Documentation

◆ _leftMargin

int QtlAutoGrid::_leftMargin
private

Left margin in pixels.

◆ _rightMargin

int QtlAutoGrid::_rightMargin
private

Right margin in pixels.

◆ _topMargin

int QtlAutoGrid::_topMargin
private

Top margin in pixels.

◆ _bottomMargin

int QtlAutoGrid::_bottomMargin
private

Bottom margin in pixels.

◆ _horizontalSpacing

int QtlAutoGrid::_horizontalSpacing
private

Horizontal spacing between pixels.

◆ _verticalSpacing

int QtlAutoGrid::_verticalSpacing
private

Vertical spacing between pixels.

◆ _children

QList<ChildBox> QtlAutoGrid::_children
private

List of managed children.


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