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()));
}
}

View File

@@ -1,4 +1,4 @@
/*
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
@@ -51,8 +51,10 @@ class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
void on_m_header_font_pb_clicked();
void on_m_table_font_pb_clicked();
virtual void updateUi() override;
void on_m_table_name_le_textEdited(const QString &arg1);
void on_m_previous_table_cb_activated(int index);
private:
private:
void setUpEditConnection();
private:
@@ -63,6 +65,7 @@ class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
QButtonGroup *m_header_button_group = nullptr,
*m_table_button_group = nullptr;
QWidget *m_current_model_editor = nullptr;
QVector<QetGraphicsTableItem *> m_other_table_vector;
};
Q_DECLARE_METATYPE(QMargins)

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>353</width>
<height>534</height>
<width>467</width>
<height>672</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,30 +24,55 @@
<string>Affichage</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLineEdit" name="m_table_name_le">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Nom du tableau</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Position</string>
<string>Position et lignes</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_8">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="4" colspan="2">
<widget class="QComboBox" name="m_previous_table_cb">
<property name="insertPolicy">
<enum>QComboBox::InsertAtBottom</enum>
</property>
<item>
<property name="text">
<string>Aucun</string>
</property>
</item>
</widget>
</item>
<item row="0" column="6" colspan="2">
<widget class="QSpinBox" name="m_display_n_row_sb">
<property name="specialValueText">
<string>Toutes</string>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="label">
<property name="text">
<string>X :</string>
<string>Lignes à afficher :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_x_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item>
<item row="0" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Y :</string>
@@ -57,13 +82,124 @@
</property>
</widget>
</item>
<item>
<item row="1" column="7">
<widget class="QPushButton" name="m_next_pb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Tableau suivant</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-right.png</normaloff>:/ico/16x16/arrow-right.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>X :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_previous_cb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Tableau précédent</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-left.png</normaloff>:/ico/16x16/arrow-left.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="m_x_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="2" column="1" colspan="7">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="m_y_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="8">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tableau précédent :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -75,16 +211,33 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QSpinBox" name="m_header_left_margin"/>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="m_header_bottom_margin"/>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_header_top_margin"/>
<item row="2" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="m_header_left_margin">
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_header_top_margin"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Marge</string>
@@ -94,9 +247,25 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="2" column="3">
<widget class="QSpinBox" name="m_header_right_margin"/>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="m_header_bottom_margin"/>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
@@ -114,6 +283,19 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
@@ -142,6 +324,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@@ -150,6 +345,9 @@
<property name="text">
<string>Police</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
@@ -163,19 +361,32 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="2">
<widget class="QSpinBox" name="m_table_right_margin"/>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="m_table_top_margin"/>
</item>
<item row="2" column="1">
<item row="2" column="2">
<widget class="QSpinBox" name="m_table_bottom_margin"/>
</item>
<item row="1" column="0">
<item row="1" column="1">
<widget class="QSpinBox" name="m_table_left_margin"/>
</item>
<item row="1" column="1">
<item row="0" column="2">
<widget class="QSpinBox" name="m_table_top_margin"/>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="m_table_right_margin"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Marge</string>
@@ -185,6 +396,19 @@
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
@@ -202,6 +426,19 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
@@ -230,6 +467,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@@ -238,6 +488,9 @@
<property name="text">
<string>Police</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
@@ -282,6 +535,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -33,9 +33,7 @@ NomenclatureModelPropertiesWidget::NomenclatureModelPropertiesWidget(Nomenclatur
ui(new Ui::NomenclatureModelPropertiesWidget)
{
ui->setupUi(this);
if (model) {
setModel(model);
}
setModel(model);
}
/**
@@ -51,6 +49,8 @@ NomenclatureModelPropertiesWidget::~NomenclatureModelPropertiesWidget() {
*/
void NomenclatureModelPropertiesWidget::setModel(NomenclatureModel *model) {
m_model = model;
ui->m_edit_query_pb->setEnabled(m_model);
ui->m_refresh_pb->setEnabled(m_model);
}
/**