QElectroTech  0.8-dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
QetGraphicsTableItem Class Reference

The QetGraphicsTableItem class This item display a table destined to represent the content of a QAbstractItemModel The table have a few parameters to edit her visual aspect. Margins, to edit the margin between the cell and the text. Text font. Text alignment in the cell These three parameters are not settable directly with the table but trough the model to be displayed by the table. The table search these parameters only in the index(0,0) for all the table. By consequence, set data in other index than 0,0 is useless also these parameter can't be set individually for each cell. The margins is stored in the model in index Qt::UserRole+1 and for value a QString. See QETUtils::marginsFromString and QETUtils::marginsToString. More...

#include <qetgraphicstableitem.h>

Inheritance diagram for QetGraphicsTableItem:
Inheritance graph
Collaboration diagram for QetGraphicsTableItem:
Collaboration graph

Public Types

enum  { Type = UserType + 1300 }
 

Public Member Functions

 QetGraphicsTableItem (QGraphicsItem *parent=nullptr)
 QetGraphicsTableItem::QetGraphicsTableItem Default constructor. More...
 
virtual ~QetGraphicsTableItem () override
 
int type () const override
 
void setModel (QAbstractItemModel *model=nullptr)
 QetGraphicsTableItem::setModel Set the model presented by this item. Since QetGraphicsTableItem don't take ownership of model, if item already have a model, it's your responsibility to delete it. More...
 
QAbstractItemModel * model () const
 QetGraphicsTableItem::model. More...
 
virtual QRectF boundingRect () const override
 QetGraphicsTableItem::boundingRect Reimplemented from QGraphicsObject. More...
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 QetGraphicsTableItem::paint Draw the table. More...
 
QetGraphicsHeaderItemheaderItem () const
 
void setSize (const QSize &size)
 QetGraphicsTableItem::setSize Set the current size of the table to size. More...
 
QSize size () const
 QetGraphicsTableItem::size. More...
 
QSize minimumSize () const
 QetGraphicsTableItem::minimumSize. More...
 
void setDisplayNRow (const int &number)
 QetGraphicsTableItem::setDisplayNRow Limit the number of row to display. More...
 
int displayNRow () const
 QetGraphicsTableItem::displayNRow. More...
 
void setPreviousTable (QetGraphicsTableItem *table=nullptr)
 QetGraphicsTableItem::setPreviousTable Set the previous table to table. If this table already have a previous table, the previous table will be replaced. Set new table to nullptr to remove an existing previous table. The table uses the model of the new previous table. Since the table does not take ownership of the model, it is your responsibility to manage the old model. Linked tables (table with next and/or previous table) share the same model, a table always take the model of the previous table. When remove a previous table (set to nullptr) from a table, the model is also removed, you need to set a new model. More...
 
void setNextTable (QetGraphicsTableItem *table=nullptr)
 QetGraphicsTableItem::setNextTable Set the next table to table nullptr will remove an existing next table. More...
 
void setTableName (const QString &name)
 
QString tableName () const
 
int displayNRowOffset () const
 QetGraphicsTableItem::displayNRowOffset. More...
 
QetGraphicsTableItempreviousTable () const
 
QetGraphicsTableItemnextTable () const
 
void setToMinimumHeight ()
 QetGraphicsTableItem::setToMinimumHeight Set the height to the the minimum. The width stay unchanged. More...
 
void initLink ()
 
QUuid uuid () const
 
int minimumRowHeigth () const
 QetGraphicsTableItem::minimumRowHeigth. More...
 
QDomElement toXml (QDomDocument &dom_document) const
 QetGraphicsTableItem::toXml Save the table to xml. More...
 
void fromXml (const QDomElement &dom_element)
 QetGraphicsTableItem::fromXml Restore the table from xml. Make this item is already in a diagram to. More...
 
- Public Member Functions inherited from QetGraphicsItem
 QetGraphicsItem (QGraphicsItem *parent=nullptr)
 QetGraphicsItem::QetGraphicsItem Default constructor. More...
 
 ~QetGraphicsItem () override=0
 
Diagramdiagram () const
 
virtual void setPos (const QPointF &p)
 
virtual void setPos (qreal x, qreal y)
 
virtual bool isMovable () const
 
virtual void setMovable (bool movable)
 
virtual void editProperty ()
 
virtual QString name () const
 
QET::GraphicsItemState state () const
 QetGraphicsItem::state. More...
 

Static Public Member Functions

static void adjustTableToFolio (QetGraphicsTableItem *table, QMargins margins=QMargins(20, 20, 20, 0))
 QetGraphicsTableItem::adjustTableToFolio Adjust the table to fit at best the folio. More...
 
static void checkInsufficientRowsCount (QetGraphicsTableItem *first_table)
 QetGraphicsTableItem::checkInsufficientRowsCount Check if the number of rows of table + linked table is enough to display all content of the model, if not open a dialog to advise user what to do. More...
 
static QString xmlTagName ()
 

Protected Member Functions

virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 QetGraphicsTableItem::hoverEnterEvent Reimplemented from QetGraphicsItem. More...
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 QetGraphicsTableItem::hoverLeaveEvent Reimplemented from QetGraphicsItem. More...
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event) override
 QetGraphicsTableItem::sceneEventFilter Reimplemented from QetGraphicsItem. More...
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 QetGraphicsTableItem::itemChange. More...
 
- Protected Member Functions inherited from QetGraphicsItem
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 QetGraphicsItem::mouseReleaseEvent handle mouse release click. More...
 

Properties

QSize size
 
int displayNRow
 

Private Member Functions

void modelReseted ()
 
void setUpColumnAndRowMinimumSize ()
 QetGraphicsTableItem::setUpColumnAndRowMinimumSize Calcule the minimum row height and the minimum column width for each columns this function doesn't change the geometry of the table. More...
 
void setUpBoundingRect ()
 QetGraphicsTableItem::setUpBoundingRect. More...
 
void adjustHandlerPos ()
 QetGraphicsTableItem::adjustHandlerPos Adjust the pos of the handler item. More...
 
void setUpHandler ()
 QetGraphicsTableItem::setUpHandler. More...
 
void handlerMousePressEvent (QGraphicsSceneMouseEvent *event)
 
void handlerMouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void handlerMouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
void adjustColumnsWidth ()
 QetGraphicsTableItem::adjustColumnsWidth Adjust the size of each column according to the current table width by setting the sectionSize of the header item. More...
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
 
void headerSectionResized ()
 QetGraphicsTableItem::headerSectionResized Connected to the header signal QetGraphicsTableItem sectionResized. More...
 
void adjustSize ()
 QetGraphicsTableItem::adjustSize If needed, this function resize the current height and width of table and/or the size of columns. according to there minimum. More...
 
void previousTableDisplayRowChanged ()
 

Private Attributes

QAbstractItemModel * m_model = nullptr
 
QVector< int > m_minimum_column_width
 
int m_minimum_row_height
 
int m_number_of_displayed_row = 0
 
QSize m_current_size
 
QSize m_old_size
 
QSize m_pending_size
 
int m_br_margin = 10
 
QRectF m_bounding_rect
 
QetGraphicsHandlerItem m_handler_item
 
QetGraphicsHeaderItemm_header_item = nullptr
 
QetGraphicsTableItemm_previous_table = nullptr
 
QetGraphicsTableItemm_next_table = nullptr
 
QString m_name
 
QUuid m_uuid = QUuid::createUuid()
 
QUuid m_pending_previous_table_uuid
 

Additional Inherited Members

- Protected Attributes inherited from QetGraphicsItem
bool is_movable_
 
bool m_first_move
 
bool snap_to_grid_
 
QPointF m_mouse_to_origin_movement
 
QET::GraphicsItemState m_state = QET:: GIOK
 

Detailed Description

The QetGraphicsTableItem class This item display a table destined to represent the content of a QAbstractItemModel The table have a few parameters to edit her visual aspect. Margins, to edit the margin between the cell and the text. Text font. Text alignment in the cell These three parameters are not settable directly with the table but trough the model to be displayed by the table. The table search these parameters only in the index(0,0) for all the table. By consequence, set data in other index than 0,0 is useless also these parameter can't be set individually for each cell. The margins is stored in the model in index Qt::UserRole+1 and for value a QString. See QETUtils::marginsFromString and QETUtils::marginsToString.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ QetGraphicsTableItem()

QetGraphicsTableItem::QetGraphicsTableItem ( QGraphicsItem *  parent = nullptr)

QetGraphicsTableItem::QetGraphicsTableItem Default constructor.

Parameters
parent
Here is the call graph for this function:

◆ ~QetGraphicsTableItem()

QetGraphicsTableItem::~QetGraphicsTableItem ( )
overridevirtual

Member Function Documentation

◆ adjustColumnsWidth()

void QetGraphicsTableItem::adjustColumnsWidth ( )
private

QetGraphicsTableItem::adjustColumnsWidth Adjust the size of each column according to the current table width by setting the sectionSize of the header item.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustHandlerPos()

void QetGraphicsTableItem::adjustHandlerPos ( )
private

QetGraphicsTableItem::adjustHandlerPos Adjust the pos of the handler item.

Here is the caller graph for this function:

◆ adjustSize()

void QetGraphicsTableItem::adjustSize ( )
private

QetGraphicsTableItem::adjustSize If needed, this function resize the current height and width of table and/or the size of columns. according to there minimum.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustTableToFolio()

void QetGraphicsTableItem::adjustTableToFolio ( QetGraphicsTableItem table,
QMargins  margins = QMargins(20,20,20,0) 
)
static

QetGraphicsTableItem::adjustTableToFolio Adjust the table to fit at best the folio.

Parameters
table: table to adjust
margins: margins between table and folio.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boundingRect()

QRectF QetGraphicsTableItem::boundingRect ( ) const
overridevirtual

QetGraphicsTableItem::boundingRect Reimplemented from QGraphicsObject.

Returns

◆ checkInsufficientRowsCount()

void QetGraphicsTableItem::checkInsufficientRowsCount ( QetGraphicsTableItem table)
static

QetGraphicsTableItem::checkInsufficientRowsCount Check if the number of rows of table + linked table is enough to display all content of the model, if not open a dialog to advise user what to do.

Parameters
table
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dataChanged()

void QetGraphicsTableItem::dataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight,
const QVector< int > &  roles 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayNRow()

int QetGraphicsTableItem::displayNRow ( ) const

QetGraphicsTableItem::displayNRow.

Returns
the number of row displayed. A value of 0 or less mean there is no limit

◆ displayNRowOffset()

int QetGraphicsTableItem::displayNRowOffset ( ) const

QetGraphicsTableItem::displayNRowOffset.

Returns
the offset (aka the last displayed row) of displayed row. If this item have a previous table, the previous offset is added.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromXml()

void QetGraphicsTableItem::fromXml ( const QDomElement &  dom_element)

QetGraphicsTableItem::fromXml Restore the table from xml. Make this item is already in a diagram to.

Parameters
dom_element
Here is the call graph for this function:

◆ handlerMouseMoveEvent()

void QetGraphicsTableItem::handlerMouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handlerMousePressEvent()

void QetGraphicsTableItem::handlerMousePressEvent ( QGraphicsSceneMouseEvent *  event)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handlerMouseReleaseEvent()

void QetGraphicsTableItem::handlerMouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ headerItem()

QetGraphicsHeaderItem* QetGraphicsTableItem::headerItem ( ) const
inline
Here is the caller graph for this function:

◆ headerSectionResized()

void QetGraphicsTableItem::headerSectionResized ( )
private

QetGraphicsTableItem::headerSectionResized Connected to the header signal QetGraphicsTableItem sectionResized.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverEnterEvent()

void QetGraphicsTableItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotectedvirtual

QetGraphicsTableItem::hoverEnterEvent Reimplemented from QetGraphicsItem.

Parameters
event
Here is the call graph for this function:

◆ hoverLeaveEvent()

void QetGraphicsTableItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotectedvirtual

QetGraphicsTableItem::hoverLeaveEvent Reimplemented from QetGraphicsItem.

Parameters
event

◆ initLink()

void QetGraphicsTableItem::initLink ( )
Here is the call graph for this function:

◆ itemChange()

QVariant QetGraphicsTableItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
overrideprotectedvirtual

QetGraphicsTableItem::itemChange.

Parameters
change
value
Returns

◆ minimumRowHeigth()

int QetGraphicsTableItem::minimumRowHeigth ( ) const

QetGraphicsTableItem::minimumRowHeigth.

Returns
the minimum height of a row
Here is the caller graph for this function:

◆ minimumSize()

QSize QetGraphicsTableItem::minimumSize ( ) const

QetGraphicsTableItem::minimumSize.

Returns
the minimum size the table can be The returned size take care of the table's minimum width, but also the header item's minimum width
Here is the caller graph for this function:

◆ model()

QAbstractItemModel * QetGraphicsTableItem::model ( ) const

QetGraphicsTableItem::model.

Returns
The model that this item is presenting
Here is the caller graph for this function:

◆ modelReseted()

void QetGraphicsTableItem::modelReseted ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextTable()

QetGraphicsTableItem * QetGraphicsTableItem::nextTable ( ) const

◆ paint()

void QetGraphicsTableItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
overridevirtual

QetGraphicsTableItem::paint Draw the table.

Parameters
painter
option
widget
Here is the call graph for this function:

◆ previousTable()

QetGraphicsTableItem * QetGraphicsTableItem::previousTable ( ) const
Here is the caller graph for this function:

◆ previousTableDisplayRowChanged()

void QetGraphicsTableItem::previousTableDisplayRowChanged ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sceneEventFilter()

bool QetGraphicsTableItem::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
)
overrideprotectedvirtual

QetGraphicsTableItem::sceneEventFilter Reimplemented from QetGraphicsItem.

Parameters
watched
event
Returns
Here is the call graph for this function:

◆ setDisplayNRow()

void QetGraphicsTableItem::setDisplayNRow ( const int &  number)

QetGraphicsTableItem::setDisplayNRow Limit the number of row to display.

Parameters
number: set to 0 or less to disabled the limit of row to display
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setModel()

void QetGraphicsTableItem::setModel ( QAbstractItemModel *  model = nullptr)

QetGraphicsTableItem::setModel Set the model presented by this item. Since QetGraphicsTableItem don't take ownership of model, if item already have a model, it's your responsibility to delete it.

Parameters
model
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNextTable()

void QetGraphicsTableItem::setNextTable ( QetGraphicsTableItem table = nullptr)

QetGraphicsTableItem::setNextTable Set the next table to table nullptr will remove an existing next table.

Parameters
table
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPreviousTable()

void QetGraphicsTableItem::setPreviousTable ( QetGraphicsTableItem table = nullptr)

QetGraphicsTableItem::setPreviousTable Set the previous table to table. If this table already have a previous table, the previous table will be replaced. Set new table to nullptr to remove an existing previous table. The table uses the model of the new previous table. Since the table does not take ownership of the model, it is your responsibility to manage the old model. Linked tables (table with next and/or previous table) share the same model, a table always take the model of the previous table. When remove a previous table (set to nullptr) from a table, the model is also removed, you need to set a new model.

Parameters
table
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSize()

void QetGraphicsTableItem::setSize ( const QSize &  size)

QetGraphicsTableItem::setSize Set the current size of the table to size.

Parameters
size
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTableName()

void QetGraphicsTableItem::setTableName ( const QString &  name)
Here is the call graph for this function:

◆ setToMinimumHeight()

void QetGraphicsTableItem::setToMinimumHeight ( )

QetGraphicsTableItem::setToMinimumHeight Set the height to the the minimum. The width stay unchanged.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpBoundingRect()

void QetGraphicsTableItem::setUpBoundingRect ( )
private

QetGraphicsTableItem::setUpBoundingRect.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpColumnAndRowMinimumSize()

void QetGraphicsTableItem::setUpColumnAndRowMinimumSize ( )
private

QetGraphicsTableItem::setUpColumnAndRowMinimumSize Calcule the minimum row height and the minimum column width for each columns this function doesn't change the geometry of the table.

Here is the caller graph for this function:

◆ setUpHandler()

void QetGraphicsTableItem::setUpHandler ( )
private

QetGraphicsTableItem::setUpHandler.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

QSize QetGraphicsTableItem::size ( ) const

QetGraphicsTableItem::size.

Returns
The current size of the table
Here is the call graph for this function:

◆ tableName()

QString QetGraphicsTableItem::tableName ( ) const

◆ toXml()

QDomElement QetGraphicsTableItem::toXml ( QDomDocument &  dom_document) const

QetGraphicsTableItem::toXml Save the table to xml.

Parameters
dom_document: parent document
Returns
the dom_element that describe the table
Here is the call graph for this function:

◆ type()

int QetGraphicsTableItem::type ( ) const
inlineoverride

◆ uuid()

QUuid QetGraphicsTableItem::uuid ( ) const
inline

◆ xmlTagName()

static QString QetGraphicsTableItem::xmlTagName ( )
inlinestatic
Here is the caller graph for this function:

Member Data Documentation

◆ m_bounding_rect

QRectF QetGraphicsTableItem::m_bounding_rect
private

◆ m_br_margin

int QetGraphicsTableItem::m_br_margin = 10
private

◆ m_current_size

QSize QetGraphicsTableItem::m_current_size
private

◆ m_handler_item

QetGraphicsHandlerItem QetGraphicsTableItem::m_handler_item
private

◆ m_header_item

QetGraphicsHeaderItem* QetGraphicsTableItem::m_header_item = nullptr
private

◆ m_minimum_column_width

QVector<int> QetGraphicsTableItem::m_minimum_column_width
private

◆ m_minimum_row_height

int QetGraphicsTableItem::m_minimum_row_height
private

◆ m_model

QAbstractItemModel* QetGraphicsTableItem::m_model = nullptr
private

◆ m_name

QString QetGraphicsTableItem::m_name
private

◆ m_next_table

QetGraphicsTableItem * QetGraphicsTableItem::m_next_table = nullptr
private

◆ m_number_of_displayed_row

int QetGraphicsTableItem::m_number_of_displayed_row = 0
private

◆ m_old_size

QSize QetGraphicsTableItem::m_old_size
private

◆ m_pending_previous_table_uuid

QUuid QetGraphicsTableItem::m_pending_previous_table_uuid
private

◆ m_pending_size

QSize QetGraphicsTableItem::m_pending_size
private

◆ m_previous_table

QetGraphicsTableItem* QetGraphicsTableItem::m_previous_table = nullptr
private

◆ m_uuid

QUuid QetGraphicsTableItem::m_uuid = QUuid::createUuid()
private

Property Documentation

◆ displayNRow

int QetGraphicsTableItem::displayNRow
readwrite

◆ size

QSize QetGraphicsTableItem::size
readwrite

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