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

@@ -21,6 +21,8 @@
#include <QFontMetrics>
#include <QPainter>
static int no_model_height = 20;
static int no_model_width = 40;
/**
* @brief QetGraphicsHeaderItem::QetGraphicsHeaderItem
* @param parent
@@ -47,12 +49,18 @@ void QetGraphicsHeaderItem::setModel(QAbstractItemModel *model)
}
m_model = model;
connect(m_model, &QAbstractItemModel::headerDataChanged, this, &QetGraphicsHeaderItem::headerDataChanged);
connect(m_model, &QAbstractItemModel::modelReset, this, &QetGraphicsHeaderItem::modelReseted);
connect(m_model, &QAbstractItemModel::columnsInserted, this, &QetGraphicsHeaderItem::modelReseted);
setUpMinimumSectionsSize();
m_current_sections_width.clear();
m_current_sections_width.resize(m_sections_minimum_width.size());
if (m_model)
{
connect(m_model, &QAbstractItemModel::headerDataChanged, this, &QetGraphicsHeaderItem::headerDataChanged);
connect(m_model, &QAbstractItemModel::modelReset, this, &QetGraphicsHeaderItem::modelReseted);
connect(m_model, &QAbstractItemModel::columnsInserted, this, &QetGraphicsHeaderItem::modelReseted);
setUpMinimumSectionsSize();
m_current_sections_width.clear();
m_current_sections_width.resize(m_sections_minimum_width.size());
} else {
setUpMinimumSectionsSize();
}
adjustSize();
}
@@ -97,7 +105,6 @@ void QetGraphicsHeaderItem::paint(QPainter *painter, const QStyleOptionGraphicsI
painter->setBrush(brush);
painter->setPen(pen);
painter->setFont(m_model->headerData(0, Qt::Horizontal, Qt::FontRole).value<QFont>());
painter->drawRect(m_current_rect);
if (!m_model)
@@ -105,6 +112,7 @@ void QetGraphicsHeaderItem::paint(QPainter *painter, const QStyleOptionGraphicsI
painter->restore();
return;
}
painter->setFont(m_model->headerData(0, Qt::Horizontal, Qt::FontRole).value<QFont>());
//Draw vertical lines
auto offset= 0;
@@ -145,7 +153,20 @@ QRect QetGraphicsHeaderItem::rect() const {
* @param size
*/
void QetGraphicsHeaderItem::resizeSection(int logicalIndex, int size)
{
{
if (!m_model)
{
m_current_sections_width.clear();
m_current_sections_width.append(no_model_width);
m_sections_minimum_width.clear();
m_sections_minimum_width.append(no_model_width);
m_current_rect.setWidth(no_model_width);
setUpBoundingRect();
update();
emit sectionResized(0, no_model_width);
return;
}
if (logicalIndex >= m_current_sections_width.size() ||
m_current_sections_width.at(logicalIndex) == size) {
return;
@@ -195,7 +216,12 @@ void QetGraphicsHeaderItem::setMargins(const QMargins &margins)
*/
void QetGraphicsHeaderItem::setUpMinimumSectionsSize()
{
if (!m_model) {
if (!m_model)
{
m_minimum_section_height = no_model_height;
m_sections_minimum_width.clear();
m_sections_minimum_width.append(no_model_width);
m_minimum_width = no_model_width;
return;
}