Table can be splitted and and row number limited

1.Table can have a name.
2.User can define the maximum row to display.
3.Table can be linked together, this is useful when there is a large
data to display in a single table.

Point 1, 2 and 3 work like this :

-Name a table (point 1).
-Limit the number of row to display to fit the table into a diagram
(point 2).
-Create a second table in a new folio.
-Link the second table to first table, you can search by table name
(point 3).
-the new table start to display where the first table end.
The number of linked table is unlimited.
This commit is contained in:
Claveau Joshua
2020-04-10 21:27:47 +02:00
parent 4d27728773
commit 871b0d9ee9
10 changed files with 685 additions and 78 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
Copyright 2006-2020 QElectroTech Team
This file is part of QElectroTech.
@@ -44,6 +44,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
Q_PROPERTY(QSize size READ size WRITE setSize)
Q_PROPERTY(int displayNRow READ displayNRow WRITE setDisplayNRow)
public:
QetGraphicsTableItem(QGraphicsItem *parent= nullptr);
@@ -52,7 +53,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
enum { Type = UserType + 1300 };
int type() const override { return Type; }
void setModel(QAbstractItemModel *model);
void setModel(QAbstractItemModel *model = nullptr);
QAbstractItemModel *model() const;
virtual QRectF boundingRect() const override;
@@ -63,6 +64,16 @@ class QetGraphicsTableItem : public QetGraphicsItem
void setSize(const QSize &size);
QSize size() const;
QSize minimumSize() const;
void setDisplayNRow(const int &number);
int displayNRow() const;
void setPreviousTable(QetGraphicsTableItem *table = nullptr);
void setNextTable(QetGraphicsTableItem *table = nullptr);
void setTableName(const QString &name);
QString tableName() const;
int displayNRowOffset() const;
QetGraphicsTableItem *previousTable() const;
QetGraphicsTableItem *nextTable() const;
void setToMinimumHeight();
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
@@ -82,6 +93,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
void headerSectionResized();
void adjustSize();
void previousTableDisplayRowChanged();
private:
QAbstractItemModel *m_model= nullptr;
@@ -89,6 +101,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
QMargins m_margin;
QVector<int> m_minimum_column_width;
int m_minimum_row_height;
int m_number_of_displayed_row = 0;
QSize m_current_size,
m_old_size;
@@ -97,6 +110,11 @@ class QetGraphicsTableItem : public QetGraphicsItem
QetGraphicsHandlerItem m_handler_item;
QetGraphicsHeaderItem *m_header_item = nullptr;
QetGraphicsTableItem *m_previous_table = nullptr,
*m_next_table = nullptr;
QString m_name;
};
#endif // QetGraphicsTableItem_H