mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-06 05:10:52 +01:00
Add widget to edit QetGraphicsTableItem and QetGraphicsHeaderItem
This commit is contained in:
@@ -26,8 +26,20 @@
|
||||
|
||||
class QAbstractItemModel;
|
||||
|
||||
/**
|
||||
* @brief The QetGraphicsHeaderItem class
|
||||
* The header 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 two last parameters are not settable directly with the header but trough the model to be displayed by the header.
|
||||
*/
|
||||
class QetGraphicsHeaderItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
|
||||
|
||||
public:
|
||||
QetGraphicsHeaderItem(QGraphicsItem *parent = nullptr);
|
||||
|
||||
@@ -36,28 +48,37 @@ class QetGraphicsHeaderItem : public QGraphicsObject
|
||||
|
||||
void setModel(QAbstractItemModel *model);
|
||||
QAbstractItemModel *model() const;
|
||||
void reset();
|
||||
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRect rect() const;
|
||||
void resizeSection(int logicalIndex, int size);
|
||||
int sectionSize(int logical_index) const;
|
||||
QMargins margins() const {return m_margin;}
|
||||
void setMargins(const QMargins &margins);
|
||||
QVector<int> minimumSectionWidth() const {return m_sections_minimum_width;}
|
||||
int minimumWidth() const {return m_minimum_width;}
|
||||
|
||||
signals:
|
||||
void sectionResized(int logicalIndex, int size);
|
||||
void heightResized();
|
||||
|
||||
private:
|
||||
void setUpMinimumSectionsSize();
|
||||
void setUpBoundingRect();
|
||||
void headerDataChanged(Qt::Orientations orientation, int first, int last);
|
||||
void adjustSize();
|
||||
|
||||
private:
|
||||
QRectF m_bounding_rect;
|
||||
QAbstractItemModel *m_model = nullptr;
|
||||
QFont m_font = QETApp::diagramTextsFont();
|
||||
QMargins m_margin;
|
||||
QVector<int> m_sections_minimum_width,
|
||||
m_current_sections_width;
|
||||
int m_section_height=1;
|
||||
QRect m_minimum_rect,
|
||||
m_current_rect;
|
||||
int m_section_height=1,
|
||||
m_minimum_section_height=1;
|
||||
int m_minimum_width=1;
|
||||
QRect m_current_rect;
|
||||
};
|
||||
|
||||
#endif // QETGRAPHICSHEADERITEM_H
|
||||
|
||||
Reference in New Issue
Block a user