QElectroTech 0.100.0-dev
|
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>
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. | |
QetGraphicsHeaderItem * | headerItem () 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< QetGraphicsTableItem > | previousTable () const |
QPointer< QetGraphicsTableItem > | nextTable () 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 | |
Diagram * | diagram () 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 |
QetGraphicsHeaderItem * | m_header_item = nullptr |
QPointer< QetGraphicsTableItem > | m_previous_table |
QPointer< QetGraphicsTableItem > | m_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 |
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.
QetGraphicsTableItem::QetGraphicsTableItem | ( | QGraphicsItem * | parent = nullptr | ) |
QetGraphicsTableItem::QetGraphicsTableItem Default constructor.
parent |
|
overridevirtual |
|
private |
QetGraphicsTableItem::adjustColumnsWidth Adjust the size of each column according to the current table width by setting the sectionSize of the header item.
|
private |
QetGraphicsTableItem::adjustHandlerPos Adjust the pos of the handler item.
|
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.
|
static |
QetGraphicsTableItem::adjustTableToFolio Adjust the table to fit at best the folio.
table | : table to adjust |
margins | : margins between table and folio. |
|
overridevirtual |
QetGraphicsTableItem::boundingRect Reimplemented from QGraphicsObject.
|
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.
table |
|
private |
int QetGraphicsTableItem::displayedRowCount | ( | ) | const |
QetGraphicsTableItem::displayedRowCount.
int QetGraphicsTableItem::displayNRow | ( | ) | const |
QetGraphicsTableItem::displayNRow.
int QetGraphicsTableItem::displayNRowOffset | ( | ) | const |
QetGraphicsTableItem::displayNRowOffset.
void QetGraphicsTableItem::fromXml | ( | const QDomElement & | dom_element | ) |
QetGraphicsTableItem::fromXml Restore the table from xml. Make this item is already in a diagram to.
dom_element |
|
private |
|
private |
|
private |
|
inline |
|
private |
|
overrideprotectedvirtual |
QetGraphicsTableItem::hoverEnterEvent Reimplemented from QetGraphicsItem.
event |
|
overrideprotectedvirtual |
QetGraphicsTableItem::hoverLeaveEvent Reimplemented from QetGraphicsItem.
event |
void QetGraphicsTableItem::initLink | ( | ) |
|
overrideprotectedvirtual |
int QetGraphicsTableItem::minimumRowHeight | ( | ) | const |
QetGraphicsTableItem::minimumRowHeight.
QSize QetGraphicsTableItem::minimumSize | ( | ) | const |
QetGraphicsTableItem::minimumSize.
QAbstractItemModel * QetGraphicsTableItem::model | ( | ) | const |
|
private |
QetGraphicsTableItem::modelReseted.
QPointer< QetGraphicsTableItem > QetGraphicsTableItem::nextTable | ( | ) | const |
|
overridevirtual |
QetGraphicsTableItem::paint Draw the table.
painter | |
option | |
widget |
QPointer< QetGraphicsTableItem > QetGraphicsTableItem::previousTable | ( | ) | const |
|
private |
|
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.
recursive |
|
overrideprotectedvirtual |
QetGraphicsTableItem::sceneEventFilter Reimplemented from QetGraphicsItem.
watched | |
event |
void QetGraphicsTableItem::setDisplayNRow | ( | const int & | number | ) |
QetGraphicsTableItem::setDisplayNRow Limit the number of row to display.
number | : set to 0 or less to disabled the limit of row to display |
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.
model |
void QetGraphicsTableItem::setNextTable | ( | QetGraphicsTableItem * | table = nullptr | ) |
QetGraphicsTableItem::setNextTable Set the next table to table nullptr will remove an existing next table.
table |
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.
table |
void QetGraphicsTableItem::setSize | ( | const QSize & | size | ) |
QetGraphicsTableItem::setSize Set the current size of the table to size.
size |
void QetGraphicsTableItem::setTableName | ( | const QString & | name | ) |
void QetGraphicsTableItem::setToMinimumHeight | ( | ) |
QetGraphicsTableItem::setToMinimumHeight Set the height to the the minimum. The width stay unchanged.
|
private |
QetGraphicsTableItem::setUpBoundingRect.
|
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.
|
private |
QetGraphicsTableItem::setUpHandler.
QSize QetGraphicsTableItem::size | ( | ) | const |
QString QetGraphicsTableItem::tableName | ( | ) | const |
|
virtual |
QetGraphicsTableItem::toDXF Draw this table to the dxf document.
filepath | file path of the the dxf document |
QDomElement QetGraphicsTableItem::toXml | ( | QDomDocument & | dom_document | ) | const |
QetGraphicsTableItem::toXml Save the table to xml.
dom_document | : parent document |
|
inlineoverride |
|
inline |
|
inlinestatic |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
readwrite |
|
readwrite |