mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Nomenclature : enable option "fit to diagram"
This commit is contained in:
@@ -59,5 +59,24 @@ void QetGraphicsTableFactory::createAndAddNomenclature(Diagram *diagram)
|
|||||||
table->setModel(model);
|
table->setModel(model);
|
||||||
diagram->addItem(table);
|
diagram->addItem(table);
|
||||||
table->setPos(50,50);
|
table->setPos(50,50);
|
||||||
|
|
||||||
|
|
||||||
|
if (d->adjustTableToFolio())
|
||||||
|
{
|
||||||
|
auto drawable_rect = diagram->border_and_titleblock.insideBorderRect();
|
||||||
|
table->setPos(drawable_rect.topLeft().x() + 20, drawable_rect.topLeft().y() + 20 + table->headerItem()->rect().height());
|
||||||
|
|
||||||
|
auto size_ = table->size();
|
||||||
|
size_.setWidth(int(drawable_rect.width() - 40));
|
||||||
|
//Size must be a multiple of 10, because the table adjust itself by step of 10.
|
||||||
|
while (size_.width()%10) {
|
||||||
|
--size_.rwidth(); }
|
||||||
|
table->setSize(size_);
|
||||||
|
|
||||||
|
//Calcul the maximum row to display to fit the nomenclature into diagram
|
||||||
|
auto available_height = drawable_rect.height() - table->pos().y();
|
||||||
|
auto min_row_height = table->minimumRowHeigth();
|
||||||
|
table->setDisplayNRow(int(floor(available_height/min_row_height))); //Convert a double to int, but max_row_to_display is already rounded an integer so we assume everything is ok
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="m_adjust_table_size_cb">
|
<widget class="QCheckBox" name="m_adjust_table_size_cb">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ajuster la taille du tableau au folio</string>
|
<string>Ajuster la taille du tableau au folio</string>
|
||||||
|
|||||||
@@ -406,6 +406,14 @@ void QetGraphicsTableItem::initLink()
|
|||||||
setSize(m_pending_size);
|
setSize(m_pending_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QetGraphicsTableItem::minimumRowHeigth
|
||||||
|
* @return the minimum height of a row
|
||||||
|
*/
|
||||||
|
int QetGraphicsTableItem::minimumRowHeigth() const {
|
||||||
|
return m_minimum_row_height;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QetGraphicsTableItem::toXml
|
* @brief QetGraphicsTableItem::toXml
|
||||||
* Save the table to xml
|
* Save the table to xml
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
|
|||||||
void setToMinimumHeight();
|
void setToMinimumHeight();
|
||||||
void initLink();
|
void initLink();
|
||||||
QUuid uuid() const {return m_uuid;}
|
QUuid uuid() const {return m_uuid;}
|
||||||
|
int minimumRowHeigth() const;
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &dom_document) const;
|
QDomElement toXml(QDomDocument &dom_document) const;
|
||||||
void fromXml(const QDomElement &dom_element);
|
void fromXml(const QDomElement &dom_element);
|
||||||
|
|||||||
Reference in New Issue
Block a user