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

@@ -19,6 +19,8 @@
#include "qetproject.h"
#include "diagram.h"
#include "qetgraphicsitem/element.h"
#include "qetgraphicstableitem.h"
#include <QAbstractItemModel>
/**
* @brief ElementProvider::ElementProvider Constructor
@@ -27,8 +29,8 @@
*/
ElementProvider::ElementProvider(QETProject *prj, Diagram *diagram)
{
diag_list = prj->diagrams();
diag_list.removeOne(diagram);
m_diagram_list = prj->diagrams();
m_diagram_list.removeOne(diagram);
}
/**
@@ -36,7 +38,7 @@ ElementProvider::ElementProvider(QETProject *prj, Diagram *diagram)
* @param diag Diagram to search
*/
ElementProvider::ElementProvider(Diagram *diag) {
diag_list << diag;
m_diagram_list << diag;
}
/**
@@ -52,7 +54,7 @@ QList <Element *> ElementProvider::freeElement(const int filter) const{
QList <Element *> free_elmt;
//serch in all diagram
foreach (Diagram *d, diag_list) {
foreach (Diagram *d, m_diagram_list) {
//get all element in diagram d
QList <Element *> elmt_list;
elmt_list = d->elements();
@@ -72,7 +74,7 @@ QList <Element *> ElementProvider::freeElement(const int filter) const{
QList <Element *> ElementProvider::fromUuids(QList<QUuid> uuid_list) const {
QList <Element *> found_element;
foreach (Diagram *d, diag_list) {
foreach (Diagram *d, m_diagram_list) {
foreach(Element *elmt, d->elements()) {
if (uuid_list.contains(elmt->uuid())) {
found_element << elmt;
@@ -94,7 +96,7 @@ QList <Element *> ElementProvider::find(const int filter) const {
QList <Element *> elmt_;
//serch in all diagram
foreach (Diagram *d, diag_list) {
foreach (Diagram *d, m_diagram_list) {
//get all element in diagram d
QList <Element *> elmt_list;
elmt_list = d->elements();
@@ -105,3 +107,52 @@ QList <Element *> ElementProvider::find(const int filter) const {
}
return (elmt_);
}
/**
* @brief ElementProvider::table
* @param table
* @param model
* @return All tables wich display the derivated class of @model (if set) and not already in all the chain of next/previous table of @table (if set)
* If table and model are nullptr, return every tables
*/
QVector<QetGraphicsTableItem *> ElementProvider::table(QetGraphicsTableItem *table, QAbstractItemModel *model)
{
QVector<QetGraphicsTableItem *> v_;
QVector<QetGraphicsTableItem *> linked_vector;
if (table)
{
auto linked_table = table->previousTable() ? table->previousTable() : table->nextTable(); //table can be inside a chain, at the head of a chain or alone
while (linked_table) { //Go to the first table
if (linked_table->previousTable())
linked_table = linked_table->previousTable();
else
break;
}
while (linked_table) { //Store each linked table in linked_vector
linked_vector.append(linked_table);
linked_table = linked_table->nextTable();
}
}
for (auto d : m_diagram_list) {
for (auto item_ : d->items())
{
if(item_->type() == QetGraphicsTableItem::Type)
{
auto found_table = static_cast<QetGraphicsTableItem *>(item_);
if (linked_vector.contains(found_table)) {
continue;
}
if (!model ||
(found_table->model() &&
model->metaObject()->className() == found_table->model()->metaObject()->className()))
{v_.append(found_table);}
}
}
}
return v_;
}

View File

@@ -20,10 +20,12 @@
#include <QUuid>
#include <QList>
#include <QAbstractTableModel>
class QETProject;
class Diagram;
class Element;
class QetGraphicsTableItem;
/**
this class can search in the given diagram or project some kind of element
@@ -34,14 +36,15 @@ class Element;
class ElementProvider
{
public:
ElementProvider(QETProject *prj, Diagram *diagram=nullptr);
ElementProvider(Diagram *diag);
QList <Element *> freeElement(const int filter) const;
QList <Element *> fromUuids(QList <QUuid>) const;
QList <Element *> find(const int filter) const;
ElementProvider(QETProject *prj, Diagram *diagram=nullptr);
ElementProvider(Diagram *diag);
QList <Element *> freeElement(const int filter) const;
QList <Element *> fromUuids(QList <QUuid>) const;
QList <Element *> find(const int filter) const;
QVector <QetGraphicsTableItem *> table(QetGraphicsTableItem *table = nullptr, QAbstractItemModel *model = nullptr);
private:
QList <Diagram *> diag_list;
QList <Diagram *> m_diagram_list;
};
#endif // ELEMENTPROVIDER_H

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

View File

@@ -46,7 +46,7 @@ class QetGraphicsHeaderItem : public QGraphicsObject
enum { Type = UserType + 1301 };
int type() const override { return Type; }
void setModel(QAbstractItemModel *model);
void setModel(QAbstractItemModel *model = nullptr);
QAbstractItemModel *model() const;
virtual QRectF boundingRect() const override;

View File

@@ -26,6 +26,9 @@
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
static int no_model_height = 20;
static int no_model_width = 40;
/**
* @brief QetGraphicsTableItem::QetGraphicsTableItem
* Default constructor
@@ -78,8 +81,11 @@ void QetGraphicsTableItem::setModel(QAbstractItemModel *model)
adjustSize();
m_header_item->setPos(0, -m_header_item->rect().height());
connect(m_model, &QAbstractItemModel::dataChanged, this, &QetGraphicsTableItem::dataChanged);
connect(m_model, &QAbstractItemModel::modelReset, this, &QetGraphicsTableItem::modelReseted);
if (m_model)
{
connect(m_model, &QAbstractItemModel::dataChanged, this, &QetGraphicsTableItem::dataChanged);
connect(m_model, &QAbstractItemModel::modelReset, this, &QetGraphicsTableItem::modelReseted);
}
}
/**
@@ -117,15 +123,25 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
pen.setWidthF(0.7);
pen.setColor(Qt::black);
painter->setPen(pen);
painter->setFont(m_model->data(model()->index(0,0), Qt::FontRole).value<QFont>());
painter->drawRect(0,0, m_header_item->rect().width(), m_current_size.height());
if (isSelected())
{
painter->save();
QColor color(Qt::darkBlue);
color.setAlpha(20);
painter->setBrush(QBrush (color));
painter->setPen(Qt::NoPen);
painter->drawRect(0,0, m_header_item->rect().width(), m_current_size.height());
painter->restore();
}
if(!m_model)
{
painter->restore();
return;
}
painter->setFont(m_model->data(model()->index(0,0), Qt::FontRole).value<QFont>());
//Draw vertical lines
auto offset= 0;
@@ -137,9 +153,18 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
offset += m_header_item->sectionSize(i);
}
//Calcule the number of rows to display.
auto row_count = m_model->rowCount();
if (m_previous_table) //Remove the number of row already displayed by previous tables
row_count -= m_previous_table->displayNRowOffset();
if (m_number_of_displayed_row > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_displayed_row);
//Draw horizontal lines
auto cell_height = static_cast<double>(m_current_size.height())/static_cast<double>(m_model->rowCount());
for(auto i= 1 ; i-1<m_model->rowCount() ; ++i)
auto cell_height = static_cast<double>(m_current_size.height())/static_cast<double>(row_count);
for(auto i= 1 ; i-1<row_count ; ++i)
{
QPointF p1(m_header_item->rect().left(), cell_height*i);
QPointF p2(m_header_item->rect().right(), cell_height*i);
@@ -147,7 +172,7 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
}
//Write text of each cell
for (auto i= 0 ; i<m_model->rowCount() ; ++i)
for (auto i=0 ; i<row_count ; ++i)
{
QPointF top_left(m_margin.left(), i==0? m_margin.top() : cell_height*i + m_margin.top());
@@ -159,9 +184,10 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
}
QSize size(m_header_item->sectionSize(j) - m_margin.left() - m_margin.right(),
static_cast<int>(cell_height) - m_margin.top() - m_margin.bottom());
auto index_row = m_previous_table ? i + m_previous_table->displayNRowOffset() : i;
painter->drawText(QRectF(top_left, size),
m_model->data(m_model->index(0,0), Qt::TextAlignmentRole).toInt(),
m_model->index(i, j).data().toString());
m_model->index(index_row, j).data().toString());
}
}
@@ -218,10 +244,155 @@ QSize QetGraphicsTableItem::size() const
*/
QSize QetGraphicsTableItem::minimumSize() const
{
QSize s(std::accumulate(m_minimum_column_width.begin(), m_minimum_column_width.end(), 0), m_minimum_row_height*m_model->rowCount());
if (!m_model) {
return QSize(no_model_width, no_model_height);
}
auto row_count = m_model->rowCount();
if (m_previous_table) {
row_count -= m_previous_table->displayNRowOffset();
}
if (m_number_of_displayed_row > 0)
row_count = std::min(row_count, m_number_of_displayed_row);
QSize s(std::accumulate(m_minimum_column_width.begin(), m_minimum_column_width.end(), 0), m_minimum_row_height*row_count);
return s;
}
/**
* @brief QetGraphicsTableItem::setDisplayNRow
* Limit the number of row to display
* @param number : set to 0 or less to disabled the limit of row to display
*/
void QetGraphicsTableItem::setDisplayNRow(const int &number) {
m_number_of_displayed_row = number;
setToMinimumHeight();
if (m_next_table)
m_next_table->previousTableDisplayRowChanged();
}
/**
* @brief QetGraphicsTableItem::displayNRow
* @return the number of row displayed.
* A value of 0 or less mean there is no limit
*/
int QetGraphicsTableItem::displayNRow() const {
return m_number_of_displayed_row;
}
/**
* @brief QetGraphicsTableItem::setPreviousTable
* Set the previous table to @table.
* If this table already have a previous table, the previous table will be replaced.
* Set new table to nullptr to remove an existing previous table.
* The table uses the model of the new previous table.
* Since the table does not take ownership of the model, it is your responsibility to manage the old model.
* Linked tables (table with next and/or previous table) share the same model, a table always take the model of the previous table..
* When remove a previous table (set to nullptr) from a table, the model is also removed, you need to set a new model
* @param table
*/
void QetGraphicsTableItem::setPreviousTable(QetGraphicsTableItem *table)
{
if (m_previous_table == table) {
return;
}
auto old_previous_table = m_previous_table;
m_previous_table = table;
if (m_previous_table) //set previous table and get her model
{
m_previous_table->setNextTable(this);
setModel(m_previous_table->m_model);
}
else //Remove model
{
setModel(nullptr);
}
if (old_previous_table &&
old_previous_table->nextTable() == this) {
old_previous_table->setNextTable(nullptr);
}
//Set the m_model to every next table
auto next_ = m_next_table;
while (next_) {
next_->setModel(m_model);
next_ = next_->nextTable();
}
}
/**
* @brief QetGraphicsTableItem::setNextTable
* Set the next table to @table
* nullptr will remove an existing next table.
* @param table
*/
void QetGraphicsTableItem::setNextTable(QetGraphicsTableItem *table)
{
if (m_next_table == table) {
return;
}
auto old_next_table = m_next_table;
m_next_table = table;
if (m_next_table) {
m_next_table->setPreviousTable(this);
}
if (old_next_table &&
old_next_table->previousTable() == this) {
old_next_table->setPreviousTable(nullptr);
}
}
void QetGraphicsTableItem::setTableName(const QString &name) {
m_name = name;
}
QString QetGraphicsTableItem::tableName() const {
return m_name;
}
/**
* @brief QetGraphicsTableItem::displayNRowOffset
* @return the offset (aka the last displayed row) of displayed row.
* If this item have a previous table, the previous offset is added.
*/
int QetGraphicsTableItem::displayNRowOffset() const
{
auto offset_ = m_number_of_displayed_row;
if(m_previous_table)
offset_ += m_previous_table->displayNRowOffset();
return offset_;
}
QetGraphicsTableItem *QetGraphicsTableItem::previousTable() const {
return m_previous_table;
}
QetGraphicsTableItem *QetGraphicsTableItem::nextTable() const {
return m_next_table;
}
/**
* @brief QetGraphicsTableItem::setToMinimumHeight
* Set the height to the the minimum.
* The width stay unchanged.
*/
void QetGraphicsTableItem::setToMinimumHeight()
{
auto size_ = size();
size_.setHeight(1);
setSize(size_);
}
/**
* @brief QetGraphicsTableItem::hoverEnterEvent
* Reimplemented from QetGraphicsItem
@@ -229,9 +400,12 @@ QSize QetGraphicsTableItem::minimumSize() const
*/
void QetGraphicsTableItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
adjustHandlerPos();
this->scene()->addItem(&m_handler_item);
m_handler_item.installSceneEventFilter(this);
if (m_model)
{
adjustHandlerPos();
this->scene()->addItem(&m_handler_item);
m_handler_item.installSceneEventFilter(this);
}
QGraphicsObject::hoverEnterEvent(event);
}
@@ -242,7 +416,9 @@ void QetGraphicsTableItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
*/
void QetGraphicsTableItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
m_handler_item.scene()->removeItem(&m_handler_item);
if (m_model) {
m_handler_item.scene()->removeItem(&m_handler_item);
}
QGraphicsObject::hoverLeaveEvent(event);
}
@@ -279,6 +455,7 @@ bool QetGraphicsTableItem::sceneEventFilter(QGraphicsItem *watched, QEvent *even
void QetGraphicsTableItem::modelReseted() {
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
setToMinimumHeight();
}
/**
@@ -288,7 +465,10 @@ void QetGraphicsTableItem::modelReseted() {
*/
void QetGraphicsTableItem::setUpColumnAndRowMinimumSize()
{
if (!m_model) {
if (!m_model)
{
m_minimum_row_height = no_model_height;
m_minimum_column_width = m_header_item->minimumSectionWidth();
return;
}
@@ -340,6 +520,8 @@ void QetGraphicsTableItem::setUpHandler()
void QetGraphicsTableItem::handlerMousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
diagram()->clearSelection();
this->setSelected(true);
m_old_size = size();
//User start to resize the table, disconnect the signal to avoid double paint.
disconnect(m_header_item, &QetGraphicsHeaderItem::sectionResized, this, &QetGraphicsTableItem::headerSectionResized);
@@ -380,6 +562,15 @@ void QetGraphicsTableItem::handlerMouseReleaseEvent(QGraphicsSceneMouseEvent *ev
*/
void QetGraphicsTableItem::adjustColumnsWidth()
{
if (!m_model)
{
auto h_ = m_header_item->minimumSectionWidth();
for (auto i=0 ; i<h_.size() ; ++i) {
m_header_item->resizeSection(i, h_.at(i));
}
return;
}
auto a = m_current_size.width() - minimumSize().width();
auto b = a/std::max(1,m_model->columnCount()); //avoid divide by 0
@@ -423,6 +614,12 @@ void QetGraphicsTableItem::headerSectionResized()
*/
void QetGraphicsTableItem::adjustSize()
{
//If there is no model, set the size to minimum
if (!m_model) {
setSize(minimumSize());
return;
}
if (m_current_size.height() < minimumSize().height())
{
prepareGeometryChange();
@@ -440,3 +637,10 @@ void QetGraphicsTableItem::adjustSize()
update();
}
}
void QetGraphicsTableItem::previousTableDisplayRowChanged() {
setToMinimumHeight();
if (m_next_table) {
m_next_table->previousTableDisplayRowChanged();
}
}

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

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);
}
/**