mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 08:40:53 +01:00
Minor fix : QetGraphicsTableItem keep his size when model is reseted or when open from xml.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -435,25 +435,11 @@ void QetGraphicsHeaderItem::adjustSize()
|
|||||||
emit heightResized();
|
emit heightResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_current_sections_width.size() == m_sections_minimum_width.size())
|
|
||||||
{
|
|
||||||
auto old_sections_width = m_current_sections_width;
|
|
||||||
|
|
||||||
for (int i=0 ; i<m_current_sections_width.size() ; ++i)
|
|
||||||
{
|
|
||||||
if (old_sections_width.at(i) < m_sections_minimum_width.at(i)) {
|
|
||||||
resizeSection(i, m_sections_minimum_width.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QetGraphicsHeaderItem::modelReseted()
|
void QetGraphicsHeaderItem::modelReseted()
|
||||||
{
|
{
|
||||||
setUpMinimumSectionsSize();
|
setUpMinimumSectionsSize();
|
||||||
m_current_sections_width.clear();
|
|
||||||
m_current_sections_width.resize(m_sections_minimum_width.size());
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,8 +145,6 @@ QetGraphicsTableItem::QetGraphicsTableItem(QGraphicsItem *parent) :
|
|||||||
this, &QetGraphicsTableItem::adjustHandlerPos);
|
this, &QetGraphicsTableItem::adjustHandlerPos);
|
||||||
|
|
||||||
m_header_item = new QetGraphicsHeaderItem(this);
|
m_header_item = new QetGraphicsHeaderItem(this);
|
||||||
connect(m_header_item, &QetGraphicsHeaderItem::sectionResized,
|
|
||||||
this, &QetGraphicsTableItem::headerSectionResized);
|
|
||||||
connect(m_header_item, &QetGraphicsHeaderItem::heightResized,
|
connect(m_header_item, &QetGraphicsHeaderItem::heightResized,
|
||||||
this, [this]()
|
this, [this]()
|
||||||
{
|
{
|
||||||
@@ -897,12 +895,6 @@ void QetGraphicsTableItem::handlerMousePressEvent(
|
|||||||
diagram()->clearSelection();
|
diagram()->clearSelection();
|
||||||
this->setSelected(true);
|
this->setSelected(true);
|
||||||
m_old_size = size();
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QetGraphicsTableItem::handlerMouseMoveEvent(
|
void QetGraphicsTableItem::handlerMouseMoveEvent(
|
||||||
@@ -933,12 +925,6 @@ void QetGraphicsTableItem::handlerMouseReleaseEvent(
|
|||||||
undo->setText(tr("Modifier la géometrie d'un tableau"));
|
undo->setText(tr("Modifier la géometrie d'un tableau"));
|
||||||
diagram()->undoStack().push(undo);
|
diagram()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
//User finish to resize the table, we can reconnect now
|
|
||||||
connect(
|
|
||||||
m_header_item,
|
|
||||||
&QetGraphicsHeaderItem::sectionResized,
|
|
||||||
this,
|
|
||||||
&QetGraphicsTableItem::headerSectionResized);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -960,13 +946,6 @@ void QetGraphicsTableItem::adjustColumnsWidth()
|
|||||||
auto a = m_current_size.width() - minimumSize().width();
|
auto a = m_current_size.width() - minimumSize().width();
|
||||||
auto b = a/std::max(1,m_model->columnCount()); //avoid divide by 0
|
auto b = a/std::max(1,m_model->columnCount()); //avoid divide by 0
|
||||||
|
|
||||||
//Avoid to resize
|
|
||||||
disconnect(
|
|
||||||
m_header_item,
|
|
||||||
&QetGraphicsHeaderItem::sectionResized,
|
|
||||||
this,
|
|
||||||
&QetGraphicsTableItem::headerSectionResized);
|
|
||||||
|
|
||||||
int sum_=0;
|
int sum_=0;
|
||||||
for(auto i= 0 ; i<m_model->columnCount() ; ++i)
|
for(auto i= 0 ; i<m_model->columnCount() ; ++i)
|
||||||
{
|
{
|
||||||
@@ -1008,11 +987,7 @@ void QetGraphicsTableItem::adjustColumnsWidth()
|
|||||||
m_header_item->sectionSize(last_section)
|
m_header_item->sectionSize(last_section)
|
||||||
+ ((m_current_size.width()-sum_)%m_model->columnCount()));
|
+ ((m_current_size.width()-sum_)%m_model->columnCount()));
|
||||||
}
|
}
|
||||||
connect(
|
|
||||||
m_header_item,
|
|
||||||
&QetGraphicsHeaderItem::sectionResized,
|
|
||||||
this,
|
|
||||||
&QetGraphicsTableItem::headerSectionResized);
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1030,21 +1005,6 @@ void QetGraphicsTableItem::dataChanged(
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief QetGraphicsTableItem::headerSectionResized
|
|
||||||
Connected to the header signal QetGraphicsTableItem sectionResized
|
|
||||||
*/
|
|
||||||
void QetGraphicsTableItem::headerSectionResized()
|
|
||||||
{
|
|
||||||
auto header_size = m_header_item->rect().size();
|
|
||||||
auto size_ = size();
|
|
||||||
size_.setWidth(header_size.width());
|
|
||||||
|
|
||||||
m_current_size = size_;
|
|
||||||
prepareGeometryChange();
|
|
||||||
setUpBoundingRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsTableItem::adjustSize
|
@brief QetGraphicsTableItem::adjustSize
|
||||||
If needed, this function resize the current height and width of table and/or the size of columns.
|
If needed, this function resize the current height and width of table and/or the size of columns.
|
||||||
|
|||||||
Reference in New Issue
Block a user