QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetgraphicstableitem.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QetGraphicsTableItem_H
19#define QetGraphicsTableItem_H
20
21#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
22#include "../../qetapp.h"
23#include "../../qetgraphicsitem/qetgraphicsitem.h"
24
25#include <QFont>
26
27class QAbstractItemModel;
29
43{
44 Q_OBJECT
45
46 Q_PROPERTY(QSize size READ size WRITE setSize)
47 Q_PROPERTY(int displayNRow READ displayNRow WRITE setDisplayNRow)
48
49 public :
50 static void adjustTableToFolio(
52 QMargins margins = QMargins(20,20,20,0));
54 QetGraphicsTableItem *first_table);
55
56 QetGraphicsTableItem(QGraphicsItem *parent= nullptr);
57 virtual ~QetGraphicsTableItem() override;
58
59 enum { Type = UserType + 1300 };
60 int type() const override { return Type; }
61
62 void setModel(QAbstractItemModel *model = nullptr);
63 QAbstractItemModel *model() const;
64
65 virtual QRectF boundingRect() const override;
66 virtual void paint(
67 QPainter *painter,
68 const QStyleOptionGraphicsItem *option,
69 QWidget *widget) override;
72 void setSize(const QSize &size);
73 QSize size() const;
74 QSize minimumSize() const;
75 void setDisplayNRow(const int &number);
76 int displayNRow() const;
77 void setPreviousTable(QetGraphicsTableItem *table = nullptr);
78 void setNextTable(QetGraphicsTableItem *table = nullptr);
79 void setTableName(const QString &name);
80 QString tableName() const;
81 int displayNRowOffset() const;
82 int displayedRowCount() const;
83 QPointer<QetGraphicsTableItem> previousTable() const;
84 QPointer<QetGraphicsTableItem> nextTable() const;
85 void setToMinimumHeight();
86 void initLink();
87 QUuid uuid() const {return m_uuid;}
88 int minimumRowHeight() const;
89
90 QDomElement toXml(QDomDocument &dom_document) const;
91 void fromXml(const QDomElement &dom_element);
92 static QString xmlTagName() {return QString("graphics_table");}
93 virtual bool toDXF (const QString &filepath);
94
95 protected:
96 virtual void hoverEnterEvent(
97 QGraphicsSceneHoverEvent *event) override;
98 virtual void hoverLeaveEvent(
99 QGraphicsSceneHoverEvent *event) override;
100 virtual bool sceneEventFilter(
101 QGraphicsItem *watched,
102 QEvent *event) override;
103 virtual QVariant itemChange(
104 GraphicsItemChange change,
105 const QVariant &value) override;
106
107 private:
108 void modelReseted();
110 void setUpBoundingRect();
111 void adjustHandlerPos();
112 void setUpHandler();
113 void handlerMousePressEvent (QGraphicsSceneMouseEvent *event);
114 void handlerMouseMoveEvent (QGraphicsSceneMouseEvent *event);
115 void handlerMouseReleaseEvent (QGraphicsSceneMouseEvent *event);
116 void adjustColumnsWidth();
117 void dataChanged(
118 const QModelIndex &topLeft,
119 const QModelIndex &bottomRight,
120 const QVector<int> &roles);
122 void adjustSize();
124 void removeUselessNextTable(bool recursive = true);
125
126 QPointer<QAbstractItemModel> m_model;
127
129 int
133
134 QSize
138
140
143
144 QPointer<QetGraphicsTableItem> m_previous_table,
146
147 QString m_name;
148 QUuid
149 m_uuid = QUuid::createUuid(),
151};
152
153#endif // QetGraphicsTableItem_H
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37
The QetGraphicsHeaderItem class The header have a few parameters to edit her visual aspect....
Definition qetgraphicsheaderitem.h:41
Definition qetgraphicsitem.h:28
virtual QString name() const
Definition qetgraphicsitem.h:48
The QetGraphicsTableItem class This item display a table destined to represent the content of a QAbst...
Definition qetgraphicstableitem.h:43
static void checkInsufficientRowsCount(QetGraphicsTableItem *first_table)
QetGraphicsTableItem::checkInsufficientRowsCount Check if the number of rows of table + linked table ...
Definition qetgraphicstableitem.cpp:79
QetGraphicsHeaderItem * headerItem() const
Definition qetgraphicstableitem.h:70
void setNextTable(QetGraphicsTableItem *table=nullptr)
QetGraphicsTableItem::setNextTable Set the next table to table nullptr will remove an existing next t...
Definition qetgraphicstableitem.cpp:464
QPointer< QetGraphicsTableItem > nextTable() const
Definition qetgraphicstableitem.cpp:536
void setModel(QAbstractItemModel *model=nullptr)
QetGraphicsTableItem::setModel Set the model presented by this item. Since QetGraphicsTableItem don't...
Definition qetgraphicstableitem.cpp:178
QVector< int > m_minimum_column_width
Definition qetgraphicstableitem.h:128
void initLink()
Definition qetgraphicstableitem.cpp:553
void adjustSize()
QetGraphicsTableItem::adjustSize If needed, this function resize the current height and width of tabl...
Definition qetgraphicstableitem.cpp:1054
@ Type
Definition qetgraphicstableitem.h:59
void fromXml(const QDomElement &dom_element)
QetGraphicsTableItem::fromXml Restore the table from xml. Make this item is already in a diagram to.
Definition qetgraphicstableitem.cpp:621
int m_minimum_row_height
Definition qetgraphicstableitem.h:130
virtual QRectF boundingRect() const override
QetGraphicsTableItem::boundingRect Reimplemented from QGraphicsObject.
Definition qetgraphicstableitem.cpp:221
int minimumRowHeight() const
QetGraphicsTableItem::minimumRowHeight.
Definition qetgraphicstableitem.cpp:570
void modelReseted()
QetGraphicsTableItem::modelReseted.
Definition qetgraphicstableitem.cpp:847
void setDisplayNRow(const int &number)
QetGraphicsTableItem::setDisplayNRow Limit the number of row to display.
Definition qetgraphicstableitem.cpp:400
void previousTableDisplayRowChanged()
Definition qetgraphicstableitem.cpp:1082
QAbstractItemModel * model() const
QetGraphicsTableItem::model.
Definition qetgraphicstableitem.cpp:211
void setSize(const QSize &size)
QetGraphicsTableItem::setSize Set the current size of the table to size.
Definition qetgraphicstableitem.cpp:331
QPointer< QAbstractItemModel > m_model
Definition qetgraphicstableitem.h:126
void setUpBoundingRect()
QetGraphicsTableItem::setUpBoundingRect.
Definition qetgraphicstableitem.cpp:899
int displayNRow
Definition qetgraphicstableitem.h:47
QetGraphicsHeaderItem * m_header_item
Definition qetgraphicstableitem.h:142
QSize size
Definition qetgraphicstableitem.h:46
QPointer< QetGraphicsTableItem > m_next_table
Definition qetgraphicstableitem.h:145
void setUpColumnAndRowMinimumSize()
QetGraphicsTableItem::setUpColumnAndRowMinimumSize Calcule the minimum row height and the minimum col...
Definition qetgraphicstableitem.cpp:864
void setTableName(const QString &name)
Definition qetgraphicstableitem.cpp:485
static void adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins=QMargins(20, 20, 20, 0))
QetGraphicsTableItem::adjustTableToFolio Adjust the table to fit at best the folio.
Definition qetgraphicstableitem.cpp:44
QString tableName() const
Definition qetgraphicstableitem.cpp:490
void handlerMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition qetgraphicstableitem.cpp:958
QSize m_pending_size
Definition qetgraphicstableitem.h:137
int m_br_margin
Definition qetgraphicstableitem.h:132
QSize m_old_size
Definition qetgraphicstableitem.h:136
void handlerMousePressEvent(QGraphicsSceneMouseEvent *event)
Definition qetgraphicstableitem.cpp:932
int type() const override
Definition qetgraphicstableitem.h:60
QString m_name
Definition qetgraphicstableitem.h:147
QSize minimumSize() const
QetGraphicsTableItem::minimumSize.
Definition qetgraphicstableitem.cpp:366
int displayNRowOffset() const
QetGraphicsTableItem::displayNRowOffset.
Definition qetgraphicstableitem.cpp:500
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
QetGraphicsTableItem::paint Draw the table.
Definition qetgraphicstableitem.cpp:233
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Definition qetgraphicstableitem.cpp:1035
int m_number_of_row_to_display
Definition qetgraphicstableitem.h:131
QUuid uuid() const
Definition qetgraphicstableitem.h:87
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
QetGraphicsTableItem::hoverEnterEvent Reimplemented from QetGraphicsItem.
Definition qetgraphicstableitem.cpp:767
void handlerMouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition qetgraphicstableitem.cpp:941
QUuid m_uuid
Definition qetgraphicstableitem.h:149
void adjustColumnsWidth()
QetGraphicsTableItem::adjustColumnsWidth Adjust the size of each column according to the current tabl...
Definition qetgraphicstableitem.cpp:976
void removeUselessNextTable(bool recursive=true)
QetGraphicsTableItem::removeUselessNextTable Remove next table if useless, an useless table with 0 ro...
Definition qetgraphicstableitem.cpp:1096
QRectF m_bounding_rect
Definition qetgraphicstableitem.h:139
int displayedRowCount() const
QetGraphicsTableItem::displayedRowCount.
Definition qetgraphicstableitem.cpp:513
void setToMinimumHeight()
QetGraphicsTableItem::setToMinimumHeight Set the height to the the minimum. The width stay unchanged.
Definition qetgraphicstableitem.cpp:546
static QString xmlTagName()
Definition qetgraphicstableitem.h:92
QSize m_current_size
Definition qetgraphicstableitem.h:135
void adjustHandlerPos()
QetGraphicsTableItem::adjustHandlerPos Adjust the pos of the handler item.
Definition qetgraphicstableitem.cpp:918
QDomElement toXml(QDomDocument &dom_document) const
QetGraphicsTableItem::toXml Save the table to xml.
Definition qetgraphicstableitem.cpp:581
QPointer< QetGraphicsTableItem > previousTable() const
Definition qetgraphicstableitem.cpp:531
void setPreviousTable(QetGraphicsTableItem *table=nullptr)
QetGraphicsTableItem::setPreviousTable Set the previous table to table. If this table already have a ...
Definition qetgraphicstableitem.cpp:433
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
QetGraphicsTableItem::sceneEventFilter Reimplemented from QetGraphicsItem.
Definition qetgraphicstableitem.cpp:801
void setUpHandler()
QetGraphicsTableItem::setUpHandler.
Definition qetgraphicstableitem.cpp:926
QUuid m_pending_previous_table_uuid
Definition qetgraphicstableitem.h:150
QetGraphicsHandlerItem m_handler_item
Definition qetgraphicstableitem.h:141
virtual bool toDXF(const QString &filepath)
QetGraphicsTableItem::toDXF Draw this table to the dxf document.
Definition qetgraphicstableitem.cpp:683
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
QetGraphicsTableItem::hoverLeaveEvent Reimplemented from QetGraphicsItem.
Definition qetgraphicstableitem.cpp:784
QPointer< QetGraphicsTableItem > m_previous_table
Definition qetgraphicstableitem.h:144
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
QetGraphicsTableItem::itemChange.
Definition qetgraphicstableitem.cpp:831