QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
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 through 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.
 
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.
 
QAbstractItemModel * model () const
 QetGraphicsTableItem::model.
 
virtual QRectF boundingRect () const override
 QetGraphicsTableItem::boundingRect Reimplemented from QGraphicsObject.
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 QetGraphicsTableItem::paint Draw the table.
 
QetGraphicsHeaderItemheaderItem () const
 
void setSize (const QSize &size)
 QetGraphicsTableItem::setSize Set the current size of the table to size.
 
QSize size () const
 QetGraphicsTableItem::size.
 
QSize minimumSize () const
 QetGraphicsTableItem::minimumSize.
 
void setDisplayNRow (const int &number)
 QetGraphicsTableItem::setDisplayNRow Limit the number of row to display.
 
int displayNRow () const
 QetGraphicsTableItem::displayNRow.
 
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.
 
void setNextTable (QetGraphicsTableItem *table=nullptr)
 QetGraphicsTableItem::setNextTable Set the next table to table nullptr will remove an existing next table.
 
void setTableName (const QString &name)
 
QString tableName () const
 
int displayNRowOffset () const
 QetGraphicsTableItem::displayNRowOffset.
 
int displayedRowCount () const
 QetGraphicsTableItem::displayedRowCount.
 
QPointer< QetGraphicsTableItempreviousTable () const
 
QPointer< QetGraphicsTableItemnextTable () const
 
void setToMinimumHeight ()
 QetGraphicsTableItem::setToMinimumHeight Set the height to the the minimum. The width stay unchanged.
 
void initLink ()
 
QUuid uuid () const
 
int minimumRowHeight () const
 QetGraphicsTableItem::minimumRowHeight.
 
QDomElement toXml (QDomDocument &dom_document) const
 QetGraphicsTableItem::toXml Save the table to xml.
 
void fromXml (const QDomElement &dom_element)
 QetGraphicsTableItem::fromXml Restore the table from xml. Make this item is already in a diagram to.
 
virtual bool toDXF (const QString &filepath)
 QetGraphicsTableItem::toDXF Draw this table to the dxf document.
 
- Public Member Functions inherited from QetGraphicsItem
 QetGraphicsItem (QGraphicsItem *parent=nullptr)
 QetGraphicsItem::QetGraphicsItem Default constructor.
 
 ~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)
 
bool isHovered () const
 
virtual void editProperty ()
 
virtual QString name () const
 
QET::GraphicsItemState state () const
 QetGraphicsItem::state.
 

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.
 
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.
 
static QString xmlTagName ()
 

Protected Member Functions

virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 QetGraphicsTableItem::hoverEnterEvent Reimplemented from QetGraphicsItem.
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 QetGraphicsTableItem::hoverLeaveEvent Reimplemented from QetGraphicsItem.
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event) override
 QetGraphicsTableItem::sceneEventFilter Reimplemented from QetGraphicsItem.
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 QetGraphicsTableItem::itemChange.
 
- 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.
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 

Properties

QSize size
 
int displayNRow
 

Private Member Functions

void modelReseted ()
 QetGraphicsTableItem::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.
 
void setUpBoundingRect ()
 QetGraphicsTableItem::setUpBoundingRect.
 
void adjustHandlerPos ()
 QetGraphicsTableItem::adjustHandlerPos Adjust the pos of the handler item.
 
void setUpHandler ()
 QetGraphicsTableItem::setUpHandler.
 
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.
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
 
void headerSectionResized ()
 
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.
 
void previousTableDisplayRowChanged ()
 
void removeUselessNextTable (bool recursive=true)
 QetGraphicsTableItem::removeUselessNextTable Remove next table if useless, an useless table with 0 row displayed. If recursive is true check and remove for all sub next table.
 

Private Attributes

QPointer< QAbstractItemModel > m_model
 
QVector< int > m_minimum_column_width
 
int m_minimum_row_height
 
int m_number_of_row_to_display = 0
 
int m_br_margin = 10
 
QSize m_current_size
 
QSize m_old_size
 
QSize m_pending_size
 
QRectF m_bounding_rect
 
QetGraphicsHandlerItem m_handler_item
 
QetGraphicsHeaderItemm_header_item = nullptr
 
QPointer< QetGraphicsTableItemm_previous_table
 
QPointer< QetGraphicsTableItemm_next_table
 
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 through 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:

◆ displayedRowCount()

int QetGraphicsTableItem::displayedRowCount ( ) const

QetGraphicsTableItem::displayedRowCount.

Returns
the number of row displayed by this table

◆ 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.

◆ 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

◆ 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

◆ minimumRowHeight()

int QetGraphicsTableItem::minimumRowHeight ( ) const

QetGraphicsTableItem::minimumRowHeight.

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

QetGraphicsTableItem::modelReseted.

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

◆ nextTable()

QPointer< 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()

QPointer< 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:

◆ removeUselessNextTable()

void QetGraphicsTableItem::removeUselessNextTable ( bool  recursive = true)
private

QetGraphicsTableItem::removeUselessNextTable Remove next table if useless, an useless table with 0 row displayed. If recursive is true check and remove for all sub next table.

Parameters
recursive
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 call graph for this function:
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

◆ toDXF()

bool QetGraphicsTableItem::toDXF ( const QString &  filepath)
virtual

QetGraphicsTableItem::toDXF Draw this table to the dxf document.

Parameters
filepathfile path of the the dxf document
Returns
true if draw success
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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

QPointer<QAbstractItemModel> QetGraphicsTableItem::m_model
private

◆ m_name

QString QetGraphicsTableItem::m_name
private

◆ m_next_table

QPointer<QetGraphicsTableItem> QetGraphicsTableItem::m_next_table
private

◆ m_number_of_row_to_display

int QetGraphicsTableItem::m_number_of_row_to_display = 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

QPointer<QetGraphicsTableItem> QetGraphicsTableItem::m_previous_table
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: