QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetgraphicsheaderitem.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 QETGRAPHICSHEADERITEM_H
19#define QETGRAPHICSHEADERITEM_H
20
21#include "../../qetapp.h"
22
23#include <QFont>
24#include <QGraphicsObject>
25#include <QMargins>
26
27class QAbstractItemModel;
28
40class QetGraphicsHeaderItem : public QGraphicsObject
41{
42 Q_OBJECT
43
44 public:
45 QetGraphicsHeaderItem(QGraphicsItem *parent = nullptr);
46
47 enum { Type = UserType + 1301 };
48 int type() const override { return Type; }
49
50 void setModel(QAbstractItemModel *model = nullptr);
51 QAbstractItemModel *model() const;
52
53 virtual QRectF boundingRect() const override;
54 virtual void paint(
55 QPainter *painter,
56 const QStyleOptionGraphicsItem *option,
57 QWidget *widget) override;
58 QRect rect() const;
59 void resizeSection(int logicalIndex, int size);
60 int sectionSize(int logical_index) const;
61 QVector<int> minimumSectionWidth() const
63 int minimumWidth() const
64 {return m_minimum_width;}
65
66 QDomElement toXml (QDomDocument &document) const;
67 void fromXml(const QDomElement &element);
68 static QString xmlTagName() {return QString("graphics_header");}
69 virtual bool toDXF (const QString &filepath);
70
71 signals:
72 void sectionResized(int logicalIndex, int size);
74
75 private:
77 void setUpBoundingRect();
79 Qt::Orientations orientation,
80 int first,
81 int last);
82 void adjustSize();
83 void modelReseted();
84
87 QPointer<QAbstractItemModel> m_model;
88
89 QVector<int>
92
93 int
97};
98
99#endif // QETGRAPHICSHEADERITEM_H
The QetGraphicsHeaderItem class The header have a few parameters to edit her visual aspect....
Definition qetgraphicsheaderitem.h:41
QVector< int > m_sections_minimum_width
Definition qetgraphicsheaderitem.h:90
void setUpBoundingRect()
QetGraphicsHeaderItem::setUpBoundingRect Setup the bounding rect of the item.
Definition qetgraphicsheaderitem.cpp:401
QPointer< QAbstractItemModel > m_model
Definition qetgraphicsheaderitem.h:87
int type() const override
Definition qetgraphicsheaderitem.h:48
int m_section_height
Definition qetgraphicsheaderitem.h:94
void adjustSize()
QetGraphicsHeaderItem::adjustSize If needed, this function resize the current height and section acco...
Definition qetgraphicsheaderitem.cpp:430
int m_minimum_section_height
Definition qetgraphicsheaderitem.h:95
void fromXml(const QDomElement &element)
QetGraphicsHeaderItem::fromXml Restore the header from xml.
Definition qetgraphicsheaderitem.cpp:330
void resizeSection(int logicalIndex, int size)
QetGraphicsHeaderItem::resizeSection.
Definition qetgraphicsheaderitem.cpp:251
void setModel(QAbstractItemModel *model=nullptr)
QetGraphicsHeaderItem::setModel Set the model presented by this item Since QetGraphicsHeaderItem don'...
Definition qetgraphicsheaderitem.cpp:45
virtual bool toDXF(const QString &filepath)
QetGraphicsHeaderItem::toDXF Draw this table to the dxf document.
Definition qetgraphicsheaderitem.cpp:183
QRect rect() const
QetGraphicsHeaderItem::rect.
Definition qetgraphicsheaderitem.cpp:241
QDomElement toXml(QDomDocument &document) const
QetGraphicsHeaderItem::toXml save the header to xml.
Definition qetgraphicsheaderitem.cpp:308
virtual QRectF boundingRect() const override
QetGraphicsHeaderItem::boundingRect Reimplemented from QGraphicsObject::boundingRect() const;.
Definition qetgraphicsheaderitem.cpp:89
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
QetGraphicsHeaderItem::paint Reimplemented from QGraphicsObject::paint(QPainter *painter,...
Definition qetgraphicsheaderitem.cpp:101
QRectF m_bounding_rect
Definition qetgraphicsheaderitem.h:86
void sectionResized(int logicalIndex, int size)
int sectionSize(int logical_index) const
QetGraphicsHeaderItem::sectionSize.
Definition qetgraphicsheaderitem.cpp:293
void modelReseted()
Definition qetgraphicsheaderitem.cpp:442
static QString xmlTagName()
Definition qetgraphicsheaderitem.h:68
void setUpMinimumSectionsSize()
QetGraphicsHeaderItem::setUpMinimumSectionsSize Setup the minimum section size and height of the item...
Definition qetgraphicsheaderitem.cpp:353
QAbstractItemModel * model() const
QetGraphicsHeaderItem::model.
Definition qetgraphicsheaderitem.cpp:79
QVector< int > m_current_sections_width
Definition qetgraphicsheaderitem.h:91
int minimumWidth() const
Definition qetgraphicsheaderitem.h:63
int m_minimum_width
Definition qetgraphicsheaderitem.h:96
QVector< int > minimumSectionWidth() const
Definition qetgraphicsheaderitem.h:61
@ Type
Definition qetgraphicsheaderitem.h:47
QRect m_current_rect
Definition qetgraphicsheaderitem.h:85
void headerDataChanged(Qt::Orientations orientation, int first, int last)
QetGraphicsHeaderItem::headerDataChanged Update the header when data of displayed model change.
Definition qetgraphicsheaderitem.cpp:413