KD Reports API Documentation 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
KDReports::AutoTableElement Class Reference

#include <KDReportsAutoTableElement.h>

Inheritance diagram for KDReports::AutoTableElement:
Inheritance graph
[legend]
Collaboration diagram for KDReports::AutoTableElement:
Collaboration graph
[legend]

Public Types

using CellFormatFunc = std::function< void(int, QTextTableCellFormat &)>
 
enum  Role { DecorationAlignmentRole = 0x2D535FB1 , NonBreakableLinesRole = 0x2D535FB2 }
 

Public Member Functions

 AutoTableElement (const AutoTableElement &other)
 
 AutoTableElement (const QString &modelKey)
 
 AutoTableElement (QAbstractItemModel *tableModel)
 
 ~AutoTableElement () override
 
void build (ReportBuilder &) const override
 
Elementclone () const override
 
QBrush headerBackground () const
 
QSize iconSize () const
 
bool isHorizontalHeaderVisible () const
 
bool isVerticalHeaderVisible () const
 
AutoTableElementoperator= (const AutoTableElement &other)
 
void setHeaderBackground (const QBrush &brush)
 
void setHorizontalHeaderFormatFunction (const CellFormatFunc &func)
 Sets the function to call in order to customize the format of the cells created for the horizontal header.
 
void setHorizontalHeaderVisible (bool visible)
 
void setIconSize (QSize iconSize)
 
void setModelKey (const QString &modelKey)
 
void setTableModel (QAbstractItemModel *tableModel)
 
void setVerticalHeaderFormatFunction (const CellFormatFunc &func)
 Sets the function to call in order to customize the format of the cells created for the horizontal header.
 
void setVerticalHeaderVisible (bool visible)
 
QAbstractItemModeltableModel () const
 

Detailed Description

The KDReports::AutoTableElement class represents a table in the report, whose data is provided by a QAbstractItemModel. A header row is added if the QAbstractItemModel has horizontal header data, and a header column is added if the QAbstractItemModel has vertical header data. The header row is repeated on every page if the table is broken across page boundaries.

Definition at line 36 of file KDReportsAutoTableElement.h.

Member Typedef Documentation

◆ CellFormatFunc

Definition at line 124 of file KDReportsAutoTableElement.h.

Member Enumeration Documentation

◆ Role

Enumerator
DecorationAlignmentRole 

This model role allows to specify whether the icon should go before the text (Qt::AlignLeft) or after the text (Qt::AlignRight).

NonBreakableLinesRole 

This model role allows to specify that line-breaking is not allowed in this table cell.

Since
1.7.

Definition at line 169 of file KDReportsAutoTableElement.h.

Constructor & Destructor Documentation

◆ AutoTableElement() [1/3]

KDReports::AutoTableElement::AutoTableElement ( QAbstractItemModel tableModel)
explicit

Creates a table element from the given table model. Note that the argument isn't const because KDReports will call fetchMore() on it, if canFetchMore() returns true.

Definition at line 203 of file KDReportsAutoTableElement.cpp.

References tableModel().

◆ AutoTableElement() [2/3]

KDReports::AutoTableElement::AutoTableElement ( const QString modelKey)
explicit

Creates a table element that does not have an associated model yet. The association will be done later using the model key.

Definition at line 209 of file KDReportsAutoTableElement.cpp.

References KDReports::modelForKey().

◆ ~AutoTableElement()

KDReports::AutoTableElement::~AutoTableElement ( )
override

Destructor. Deletes internal data.

Definition at line 230 of file KDReportsAutoTableElement.cpp.

◆ AutoTableElement() [3/3]

KDReports::AutoTableElement::AutoTableElement ( const AutoTableElement other)

Copies a table element. The model and settings are copied over.

Definition at line 215 of file KDReportsAutoTableElement.cpp.

Member Function Documentation

◆ build()

void KDReports::AutoTableElement::build ( ReportBuilder builder) const
overridevirtual

◆ clone()

KDReports::Element * KDReports::AutoTableElement::clone ( ) const
overridevirtual

Implements KDReports::Element.

Definition at line 342 of file KDReportsAutoTableElement.cpp.

◆ headerBackground()

QBrush KDReports::AutoTableElement::headerBackground ( ) const
Returns
the background color of the headers
Since
1.4

Definition at line 398 of file KDReportsAutoTableElement.cpp.

Referenced by KDReports::MainTable::setAutoTableElement().

◆ iconSize()

QSize KDReports::AutoTableElement::iconSize ( ) const
Returns
the size passed to setIconSize
Since
1.3

Definition at line 378 of file KDReportsAutoTableElement.cpp.

Referenced by KDReports::MainTable::setAutoTableElement().

◆ isHorizontalHeaderVisible()

bool KDReports::AutoTableElement::isHorizontalHeaderVisible ( ) const
Returns
true if the horizontal header will be visible
Since
1.1

Definition at line 368 of file KDReportsAutoTableElement.cpp.

Referenced by KDReports::TableBreakingSettingsDialog::TableBreakingSettingsDialog(), and KDReports::MainTable::setAutoTableElement().

◆ isVerticalHeaderVisible()

bool KDReports::AutoTableElement::isVerticalHeaderVisible ( ) const
Returns
true if the vertical header will be visible
Since
1.1

Definition at line 363 of file KDReportsAutoTableElement.cpp.

Referenced by KDReports::TableBreakingSettingsDialog::TableBreakingSettingsDialog(), and KDReports::MainTable::setAutoTableElement().

◆ operator=()

KDReports::AutoTableElement & KDReports::AutoTableElement::operator= ( const AutoTableElement other)

Copies the model and settings from another table element.

Definition at line 221 of file KDReportsAutoTableElement.cpp.

◆ setHeaderBackground()

void KDReports::AutoTableElement::setHeaderBackground ( const QBrush brush)

Sets the background color of the headers The default color is gray. Call setHeaderBackground(QBrush()) to disable the background color and have transparent headers instead.

Definition at line 358 of file KDReportsAutoTableElement.cpp.

◆ setHorizontalHeaderFormatFunction()

void KDReports::AutoTableElement::setHorizontalHeaderFormatFunction ( const CellFormatFunc func)

Sets the function to call in order to customize the format of the cells created for the horizontal header.

This allows to set the width, style, and color of the 4 borders independently, customize the padding, etc.

Since
2.3

Definition at line 403 of file KDReportsAutoTableElement.cpp.

◆ setHorizontalHeaderVisible()

void KDReports::AutoTableElement::setHorizontalHeaderVisible ( bool  visible)

Sets whether to show a horizontal header, showing header data from the model. This is true by default, call setHorizontalHeaderVisible(false) to hide the horizontal header.

Definition at line 353 of file KDReportsAutoTableElement.cpp.

◆ setIconSize()

void KDReports::AutoTableElement::setIconSize ( QSize  iconSize)

Sets the size of the decoration icons, in pixels. This is used when setting the DecorationRole to a QIcon in the model. Note that the model can also set it to a QPixmap or QImage, in which case the size in the report will simply be the size of the pixmap or image.

Since
1.1

Definition at line 373 of file KDReportsAutoTableElement.cpp.

◆ setModelKey()

void KDReports::AutoTableElement::setModelKey ( const QString modelKey)

set the model key associated with this element

Since
1.4

Definition at line 393 of file KDReportsAutoTableElement.cpp.

References KDReports::modelForKey().

◆ setTableModel()

void KDReports::AutoTableElement::setTableModel ( QAbstractItemModel tableModel)

set the model associated with this element

Since
1.4

Definition at line 388 of file KDReportsAutoTableElement.cpp.

◆ setVerticalHeaderFormatFunction()

void KDReports::AutoTableElement::setVerticalHeaderFormatFunction ( const CellFormatFunc func)

Sets the function to call in order to customize the format of the cells created for the horizontal header.

This allows to set the width, style, and color of the 4 borders independently, customize the padding, etc.

Since
2.3

Definition at line 408 of file KDReportsAutoTableElement.cpp.

◆ setVerticalHeaderVisible()

void KDReports::AutoTableElement::setVerticalHeaderVisible ( bool  visible)

Sets whether to show a vertical header (showing header data from the model, or row numbers by default). This is true by default, call setVerticalHeaderVisible(false) to hide the vertical header.

Definition at line 348 of file KDReportsAutoTableElement.cpp.

◆ tableModel()

QAbstractItemModel * KDReports::AutoTableElement::tableModel ( ) const
Returns
the model associated with this element
Since
1.2

Definition at line 383 of file KDReportsAutoTableElement.cpp.

Referenced by AutoTableElement(), and KDReports::MainTable::setAutoTableElement().


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

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-reports/
Generated on Sun Apr 28 2024 00:03:09 for KD Reports API Documentation by doxygen 1.9.8