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

@@ -23,6 +23,7 @@
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "itemmodelcommand.h"
#include "propertieseditorfactory.h"
#include "elementprovider.h"
#include <QAbstractItemModel>
#include <QFontDialog>
@@ -74,6 +75,7 @@ void GraphicsTablePropertiesEditor::setTable(QetGraphicsTableItem *table)
{
ui->m_content_layout->removeWidget(m_current_model_editor);
m_current_model_editor->deleteLater();
m_current_model_editor = nullptr;
}
}
@@ -129,6 +131,12 @@ QUndoCommand *GraphicsTablePropertiesEditor::associatedUndo() const
return undo;
}
if (ui->m_display_n_row_sb->value() != m_table_item->displayNRow()) {
auto undo = new QPropertyUndoCommand(m_table_item.data(), "displayNRow", m_table_item->displayNRow(), ui->m_display_n_row_sb->value());
undo->setText(tr("Modifier le nombre de ligne affiché par un tableau"));
return undo;
}
QMargins header_margins(ui->m_header_left_margin->value(),
ui->m_header_top_margin->value(),
ui->m_header_right_margin->value(),
@@ -241,8 +249,33 @@ void GraphicsTablePropertiesEditor::updateUi()
}
m_edit_connection.clear();
ui->m_table_name_le->setText(m_table_item->tableName());
ui->m_x_pos->setValue(m_table_item->pos().x());
ui->m_y_pos->setValue(m_table_item->pos().y());
ui->m_display_n_row_sb->setValue(m_table_item->displayNRow());
ui->m_previous_table_cb->clear();
m_other_table_vector.clear();
ui->m_previous_table_cb->addItem(tr("Aucun")); //Add no previous table
if (auto item_ = m_table_item->previousTable()) //Add the current previous table
{
m_other_table_vector.append(item_);
ui->m_previous_table_cb->addItem(item_->tableName(), m_other_table_vector.indexOf(item_));
ui->m_previous_table_cb->setCurrentIndex(ui->m_previous_table_cb->findData(m_other_table_vector.indexOf(item_)));
}
ElementProvider ep(m_table_item->diagram()->project());
for (auto item_ : ep.table(m_table_item, m_table_item->model())) //Add available tables
{
if (item_ != m_table_item &&
item_->nextTable() == nullptr)
{
m_other_table_vector.append(item_);
ui->m_previous_table_cb->addItem(item_->tableName(), m_other_table_vector.indexOf(item_));
}
}
auto margin = m_table_item->headerItem()->margins();
ui->m_header_top_margin ->setValue(margin.top());
@@ -294,5 +327,19 @@ void GraphicsTablePropertiesEditor::setUpEditConnection()
m_edit_connection << connect(ui->m_table_bottom_margin, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::apply);
}
}
void GraphicsTablePropertiesEditor::on_m_table_name_le_textEdited(const QString &arg1) {
m_table_item->setTableName(arg1);
}
void GraphicsTablePropertiesEditor::on_m_previous_table_cb_activated(int index)
{
if (index == 0) {
m_table_item->setPreviousTable();
} else {
m_table_item->setPreviousTable(m_other_table_vector.at(ui->m_previous_table_cb->currentData().toInt()));
}
}