mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Element text item group : add new property -> hold to bottom of the page
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5224 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -520,6 +520,11 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()), m_converted_text_from_xml_description.value(deti).x()) &&
|
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()), m_converted_text_from_xml_description.value(deti).x()) &&
|
||||||
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y()))
|
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y()))
|
||||||
{
|
{
|
||||||
|
//Once again this 'if', is only for retrocompatibility with old old old project
|
||||||
|
//when element text with tagg "label" is not null, but the element information "label" is.
|
||||||
|
if((deti->textFrom() == DynamicElementTextItem::ElementInfo) && (deti->infoName() == "label"))
|
||||||
|
m_element_informations.addValue("label", dom_input.attribute("text"));
|
||||||
|
|
||||||
deti->setText(dom_input.attribute("text"));
|
deti->setText(dom_input.attribute("text"));
|
||||||
|
|
||||||
qreal rotation = deti->rotation();
|
qreal rotation = deti->rotation();
|
||||||
@@ -605,6 +610,11 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
{
|
{
|
||||||
dc.addValue("formula", dc["label"]);
|
dc.addValue("formula", dc["label"]);
|
||||||
}
|
}
|
||||||
|
//retrocompatibility with older version
|
||||||
|
if(dc.value("label").toString().isEmpty() &&
|
||||||
|
!m_element_informations.value("label").toString().isEmpty())
|
||||||
|
dc.addValue("label", m_element_informations.value("label"));
|
||||||
|
|
||||||
setElementInformations(dc);
|
setElementInformations(dc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -648,54 +658,112 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
bool la = m_element_informations.keyMustShow("label");
|
bool la = m_element_informations.keyMustShow("label");
|
||||||
bool c = m_element_informations.keyMustShow("comment");
|
bool c = m_element_informations.keyMustShow("comment");
|
||||||
bool lo = m_element_informations.keyMustShow("location");
|
bool lo = m_element_informations.keyMustShow("location");
|
||||||
if(!label.isEmpty() && la &&
|
|
||||||
((!comment.isEmpty() && c) || (!location.isEmpty() && lo)))
|
if((m_link_type != Master) ||
|
||||||
|
((m_link_type == Master) &&
|
||||||
|
(diagram()->project()->defaultXRefProperties(m_kind_informations["type"].toString()).snapTo() == XRefProperties::Label))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//#2 in the converted list one text must have text from = element info and info name = label
|
if(!label.isEmpty() && la &&
|
||||||
for(DynamicElementTextItem *deti : successfully_converted)
|
((!comment.isEmpty() && c) || (!location.isEmpty() && lo)))
|
||||||
{
|
{
|
||||||
if(deti->textFrom() == DynamicElementTextItem::ElementInfo && deti->infoName() == "label")
|
//#2 in the converted list one text must have text from = element info and info name = label
|
||||||
|
for(DynamicElementTextItem *deti : successfully_converted)
|
||||||
{
|
{
|
||||||
//Create the comment item
|
if(deti->textFrom() == DynamicElementTextItem::ElementInfo && deti->infoName() == "label")
|
||||||
DynamicElementTextItem *comment_text = nullptr;
|
|
||||||
if(!comment.isEmpty() && c)
|
|
||||||
{
|
{
|
||||||
comment_text = new DynamicElementTextItem(this);
|
qreal rotation = deti->rotation();
|
||||||
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
|
||||||
comment_text->setInfoName("comment");
|
|
||||||
comment_text->setFontSize(6);
|
|
||||||
comment_text->setFrame(true);
|
|
||||||
comment_text->setTextWidth(70);
|
|
||||||
comment_text->setPos(deti->x(), deti->y()+10); //+10 is arbitrary, comment_text must be below deti
|
|
||||||
addDynamicTextItem(comment_text);
|
|
||||||
}
|
|
||||||
//create the location item
|
|
||||||
DynamicElementTextItem *location_text = nullptr;
|
|
||||||
if(!location.isEmpty() && lo)
|
|
||||||
{
|
|
||||||
location_text = new DynamicElementTextItem(this);
|
|
||||||
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
|
||||||
location_text->setInfoName("location");
|
|
||||||
location_text->setFontSize(6);
|
|
||||||
location_text->setTextWidth(70);
|
|
||||||
location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
|
|
||||||
addDynamicTextItem(location_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create the group
|
//Create the comment item
|
||||||
ElementTextItemGroup *group = addTextGroup(tr("Label + commentaire"));
|
DynamicElementTextItem *comment_text = nullptr;
|
||||||
addTextToGroup(deti, group);
|
if(!comment.isEmpty() && c)
|
||||||
if(comment_text)
|
{
|
||||||
addTextToGroup(comment_text, group);
|
comment_text = new DynamicElementTextItem(this);
|
||||||
if(location_text)
|
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||||
addTextToGroup(location_text, group);
|
comment_text->setInfoName("comment");
|
||||||
group->setAlignment(Qt::AlignVCenter);
|
comment_text->setFontSize(6);
|
||||||
group->setVerticalAdjustment(-4);
|
comment_text->setFrame(true);
|
||||||
|
if(comment_text->toPlainText().count() > 17)
|
||||||
|
comment_text->setTextWidth(80);
|
||||||
|
comment_text->setPos(deti->x(), deti->y()+10); //+10 is arbitrary, comment_text must be below deti
|
||||||
|
addDynamicTextItem(comment_text);
|
||||||
|
}
|
||||||
|
//create the location item
|
||||||
|
DynamicElementTextItem *location_text = nullptr;
|
||||||
|
if(!location.isEmpty() && lo)
|
||||||
|
{
|
||||||
|
location_text = new DynamicElementTextItem(this);
|
||||||
|
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||||
|
location_text->setInfoName("location");
|
||||||
|
location_text->setFontSize(6);
|
||||||
|
if(comment_text->toPlainText().count() > 17)
|
||||||
|
location_text->setTextWidth(80);
|
||||||
|
location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
|
||||||
|
addDynamicTextItem(location_text);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
QPointF pos = deti->pos();
|
||||||
|
//Create the group
|
||||||
|
ElementTextItemGroup *group = addTextGroup(tr("Label + commentaire"));
|
||||||
|
addTextToGroup(deti, group);
|
||||||
|
if(comment_text)
|
||||||
|
addTextToGroup(comment_text, group);
|
||||||
|
if(location_text)
|
||||||
|
addTextToGroup(location_text, group);
|
||||||
|
group->setAlignment(Qt::AlignVCenter);
|
||||||
|
group->setVerticalAdjustment(-4);
|
||||||
|
group->setRotation(rotation);
|
||||||
|
//Change the position of the group, so that the text "label" stay in the same
|
||||||
|
//position in scene coordinate
|
||||||
|
group->setPos(pos - deti->pos());
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//This element is supposed to be a master and Xref property snap to bottom
|
||||||
|
if((!comment.isEmpty() && c) || (!location.isEmpty() && lo))
|
||||||
|
{
|
||||||
|
//Create the comment item
|
||||||
|
DynamicElementTextItem *comment_text = nullptr;
|
||||||
|
if(!comment.isEmpty() && c)
|
||||||
|
{
|
||||||
|
comment_text = new DynamicElementTextItem(this);
|
||||||
|
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||||
|
comment_text->setInfoName("comment");
|
||||||
|
comment_text->setFontSize(6);
|
||||||
|
comment_text->setFrame(true);
|
||||||
|
comment_text->setTextWidth(80);
|
||||||
|
addDynamicTextItem(comment_text);
|
||||||
|
}
|
||||||
|
//create the location item
|
||||||
|
DynamicElementTextItem *location_text = nullptr;
|
||||||
|
if(!location.isEmpty() && lo)
|
||||||
|
{
|
||||||
|
location_text = new DynamicElementTextItem(this);
|
||||||
|
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||||
|
location_text->setInfoName("location");
|
||||||
|
location_text->setFontSize(6);
|
||||||
|
location_text->setTextWidth(80);
|
||||||
|
if(comment_text)
|
||||||
|
location_text->setPos(comment_text->x(), comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment
|
||||||
|
addDynamicTextItem(location_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the group
|
||||||
|
ElementTextItemGroup *group = addTextGroup(tr("Label + commentaire"));
|
||||||
|
if(comment_text)
|
||||||
|
addTextToGroup(comment_text, group);
|
||||||
|
if(location_text)
|
||||||
|
addTextToGroup(location_text, group);
|
||||||
|
group->setAlignment(Qt::AlignVCenter);
|
||||||
|
group->setVerticalAdjustment(-4);
|
||||||
|
group->setHoldToBottomPage(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@@ -794,6 +862,7 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
//Dynamic texts owned by groups
|
//Dynamic texts owned by groups
|
||||||
for(ElementTextItemGroup *group : m_texts_group)
|
for(ElementTextItemGroup *group : m_texts_group)
|
||||||
{
|
{
|
||||||
|
group->blockAlignmentUpdate(true);
|
||||||
//temporarily remove the texts from group to get the pos relative to element and not group.
|
//temporarily remove the texts from group to get the pos relative to element and not group.
|
||||||
//Set the alignment to top, because top is not used by groupand so,
|
//Set the alignment to top, because top is not used by groupand so,
|
||||||
//each time a text is removed from the group, the alignement is not updated
|
//each time a text is removed from the group, the alignement is not updated
|
||||||
@@ -818,6 +887,7 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
|
|
||||||
//Save the group to xml
|
//Save the group to xml
|
||||||
texts_group.appendChild(group->toXml(document));
|
texts_group.appendChild(group->toXml(document));
|
||||||
|
group->blockAlignmentUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Append the dynamic texts to element
|
//Append the dynamic texts to element
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
#include "crossrefitem.h"
|
#include "crossrefitem.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
#include "masterelement.h"
|
||||||
|
#include "qgraphicsitemutility.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
@@ -56,18 +58,13 @@ void ElementTextItemGroup::addToGroup(QGraphicsItem *item)
|
|||||||
{
|
{
|
||||||
if(item->type() == DynamicElementTextItem::Type)
|
if(item->type() == DynamicElementTextItem::Type)
|
||||||
{
|
{
|
||||||
//Befor add text to group we must to set the text and the group to the same rotation
|
//Befor add text to this group we must to set the text at the same rotation of this group
|
||||||
item->setRotation(0);
|
if((item->rotation() != rotation()) && !m_block_alignment_update)
|
||||||
item->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
item->setRotation(rotation());
|
||||||
|
|
||||||
qreal rot = this->rotation();
|
|
||||||
this->setRotation(0);
|
|
||||||
|
|
||||||
QGraphicsItemGroup::addToGroup(item);
|
QGraphicsItemGroup::addToGroup(item);
|
||||||
updateAlignment();
|
updateAlignment();
|
||||||
|
|
||||||
this->setRotation(rot);
|
|
||||||
|
|
||||||
DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item);
|
DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item);
|
||||||
connect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment);
|
connect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||||
connect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment);
|
connect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||||
@@ -115,6 +112,17 @@ void ElementTextItemGroup::removeFromGroup(QGraphicsItem *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementTextItemGroup::blockAlignmentUpdate
|
||||||
|
* If true, the texts in this group are never aligned, moved, rotated etc...
|
||||||
|
* the texts stay as it was, until blockAlignmentUpdate is set to false.
|
||||||
|
* @param block
|
||||||
|
*/
|
||||||
|
void ElementTextItemGroup::blockAlignmentUpdate(bool block)
|
||||||
|
{
|
||||||
|
m_block_alignment_update = block;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementTextItemGroup::setAlignement
|
* @brief ElementTextItemGroup::setAlignement
|
||||||
* Set the alignement of this group
|
* Set the alignement of this group
|
||||||
@@ -140,13 +148,42 @@ Qt::Alignment ElementTextItemGroup::alignment() const
|
|||||||
*/
|
*/
|
||||||
void ElementTextItemGroup::updateAlignment()
|
void ElementTextItemGroup::updateAlignment()
|
||||||
{
|
{
|
||||||
|
if(m_block_alignment_update)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
QList <DynamicElementTextItem *> texts = this->texts();
|
QList <DynamicElementTextItem *> texts = this->texts();
|
||||||
|
|
||||||
if (texts.size() > 1)
|
qreal rotation_ = rotation();
|
||||||
|
|
||||||
|
//Set the rotation of this group to 0° relative to the scene
|
||||||
|
qreal rot = rotation();
|
||||||
|
QGraphicsItem *parent = parentItem();
|
||||||
|
while (parent) {
|
||||||
|
rot += parent->rotation();
|
||||||
|
parent = parent->parentItem();
|
||||||
|
}
|
||||||
|
if(rot != 0)
|
||||||
|
setRotation(rotation() - rot);
|
||||||
|
|
||||||
|
|
||||||
|
if(texts.size() == 1)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
QGraphicsItem *first = texts.first();
|
||||||
|
setPos(mapFromScene(first->mapToScene(pos())));
|
||||||
|
first->setPos(0,0);
|
||||||
|
}
|
||||||
|
else if (texts.size() > 1)
|
||||||
|
{
|
||||||
|
qreal width = 0;
|
||||||
|
for(QGraphicsItem *item : texts)
|
||||||
|
if(item->boundingRect().width() > width)
|
||||||
|
width = item->boundingRect().width();
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
std::sort(texts.begin(), texts.end(), sorting);
|
std::sort(texts.begin(), texts.end(), sorting);
|
||||||
|
|
||||||
qreal y_offset = 0;
|
qreal y_offset = 0;
|
||||||
@@ -157,14 +194,13 @@ void ElementTextItemGroup::updateAlignment()
|
|||||||
|
|
||||||
for(QGraphicsItem *item : texts)
|
for(QGraphicsItem *item : texts)
|
||||||
{
|
{
|
||||||
item->setPos(ref.x(), ref.y()+y_offset);
|
item->setPos(0, ref.y()+y_offset);
|
||||||
y_offset+=item->boundingRect().height() + m_vertical_adjustment;
|
y_offset+=item->boundingRect().height() + m_vertical_adjustment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(m_alignment == Qt::AlignVCenter)
|
else if(m_alignment == Qt::AlignVCenter)
|
||||||
{
|
{
|
||||||
QPointF ref(texts.first()->pos().x() + texts.first()->boundingRect().width()/2,
|
QPointF ref(width/2,0);
|
||||||
texts.first()->pos().y());
|
|
||||||
|
|
||||||
for(QGraphicsItem *item : texts)
|
for(QGraphicsItem *item : texts)
|
||||||
{
|
{
|
||||||
@@ -175,8 +211,7 @@ void ElementTextItemGroup::updateAlignment()
|
|||||||
}
|
}
|
||||||
else if (m_alignment == Qt::AlignRight)
|
else if (m_alignment == Qt::AlignRight)
|
||||||
{
|
{
|
||||||
QPointF ref(texts.first()->pos().x() + texts.first()->boundingRect().width(),
|
QPointF ref(width,0);
|
||||||
texts.first()->pos().y());
|
|
||||||
|
|
||||||
for(QGraphicsItem *item : texts)
|
for(QGraphicsItem *item : texts)
|
||||||
{
|
{
|
||||||
@@ -185,14 +220,17 @@ void ElementTextItemGroup::updateAlignment()
|
|||||||
y_offset+=item->boundingRect().height() + m_vertical_adjustment;
|
y_offset+=item->boundingRect().height() + m_vertical_adjustment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTransformOriginPoint(boundingRect().topLeft());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Restor the rotation
|
||||||
|
setRotation(rotation_);
|
||||||
|
|
||||||
if(m_Xref_item)
|
if(m_Xref_item)
|
||||||
m_Xref_item->autoPos();
|
m_Xref_item->autoPos();
|
||||||
if(m_slave_Xref_item)
|
if(m_slave_Xref_item)
|
||||||
adjustSlaveXrefPos();
|
adjustSlaveXrefPos();
|
||||||
|
if(m_hold_to_bottom_of_page)
|
||||||
|
autoPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,6 +257,47 @@ void ElementTextItemGroup::setName(QString name)
|
|||||||
emit nameChanged(m_name);
|
emit nameChanged(m_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ElementTextItemGroup::setHoldToBottomPage(bool hold)
|
||||||
|
{
|
||||||
|
if(m_hold_to_bottom_of_page == hold)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_hold_to_bottom_of_page = hold;
|
||||||
|
if(m_hold_to_bottom_of_page)
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
|
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
|
connect(m_parent_element, &Element::yChanged, this, &ElementTextItemGroup::autoPos);
|
||||||
|
connect(m_parent_element, &Element::rotationChanged, this, &ElementTextItemGroup::autoPos);
|
||||||
|
if(m_parent_element->linkType() == Element::Master)
|
||||||
|
{
|
||||||
|
//We use timer to let the time of the parent element xref to be updated, befor update the position of this group
|
||||||
|
//because the position of this group is related to the size of the parent element Xref
|
||||||
|
m_linked_changed_timer = connect(m_parent_element, &Element::linkedElementChanged,
|
||||||
|
[this]() {QTimer::singleShot(200, this, &ElementTextItemGroup::autoPos);});
|
||||||
|
if(m_parent_element->diagram())
|
||||||
|
m_XrefChanged_timer = connect(m_parent_element->diagram()->project(), &QETProject::XRefPropertiesChanged,
|
||||||
|
[this]() {QTimer::singleShot(200, this, &ElementTextItemGroup::autoPos);});
|
||||||
|
}
|
||||||
|
autoPos();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
disconnect(m_parent_element, &Element::yChanged, this, &ElementTextItemGroup::autoPos);
|
||||||
|
disconnect(m_parent_element, &Element::rotationChanged, this, &ElementTextItemGroup::autoPos);
|
||||||
|
if(m_parent_element->linkType() == Element::Master)
|
||||||
|
{
|
||||||
|
disconnect(m_linked_changed_timer);
|
||||||
|
if(m_XrefChanged_timer)
|
||||||
|
disconnect(m_XrefChanged_timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit holdToBottomPageChanged(hold);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementTextItemGroup::texts
|
* @brief ElementTextItemGroup::texts
|
||||||
* @return Every texts in this group
|
* @return Every texts in this group
|
||||||
@@ -269,12 +348,17 @@ QDomElement ElementTextItemGroup::toXml(QDomDocument &dom_document) const
|
|||||||
QDomElement dom_element = dom_document.createElement(this->xmlTaggName());
|
QDomElement dom_element = dom_document.createElement(this->xmlTaggName());
|
||||||
dom_element.setAttribute("name", m_name);
|
dom_element.setAttribute("name", m_name);
|
||||||
|
|
||||||
|
dom_element.setAttribute("x", QString::number(pos().x()));
|
||||||
|
dom_element.setAttribute("y", QString::number(pos().y()));
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
dom_element.setAttribute("alignment", me.valueToKey(m_alignment));
|
dom_element.setAttribute("alignment", me.valueToKey(m_alignment));
|
||||||
|
|
||||||
dom_element.setAttribute("rotation", this->rotation());
|
dom_element.setAttribute("rotation", this->rotation());
|
||||||
dom_element.setAttribute("vertical_adjustment", m_vertical_adjustment);
|
dom_element.setAttribute("vertical_adjustment", m_vertical_adjustment);
|
||||||
|
|
||||||
|
dom_element.setAttribute("hold_to_bottom_page", m_hold_to_bottom_of_page == true ? "true" : "false");
|
||||||
|
|
||||||
QDomElement dom_texts = dom_document.createElement("texts");
|
QDomElement dom_texts = dom_document.createElement("texts");
|
||||||
for(DynamicElementTextItem *deti : texts())
|
for(DynamicElementTextItem *deti : texts())
|
||||||
{
|
{
|
||||||
@@ -303,11 +387,18 @@ void ElementTextItemGroup::fromXml(QDomElement &dom_element)
|
|||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
setAlignment(Qt::Alignment(me.keyToValue(dom_element.attribute("alignment").toStdString().data())));
|
setAlignment(Qt::Alignment(me.keyToValue(dom_element.attribute("alignment").toStdString().data())));
|
||||||
|
|
||||||
|
setPos(dom_element.attribute("x", QString::number(0)).toDouble(),
|
||||||
|
dom_element.attribute("y", QString::number(0)).toDouble());
|
||||||
|
|
||||||
setRotation(dom_element.attribute("rotation", QString::number(0)).toDouble());
|
setRotation(dom_element.attribute("rotation", QString::number(0)).toDouble());
|
||||||
setVerticalAdjustment(dom_element.attribute("vertical_adjustment").toInt());
|
setVerticalAdjustment(dom_element.attribute("vertical_adjustment").toInt());
|
||||||
|
|
||||||
|
QString hold = dom_element.attribute("hold_to_bottom_page", "false");
|
||||||
|
setHoldToBottomPage(hold == "true" ? true : false);
|
||||||
|
|
||||||
if(parentElement())
|
if(parentElement())
|
||||||
{
|
{
|
||||||
|
m_block_alignment_update = true;
|
||||||
for(QDomElement text : QET::findInDomElement(dom_element, "texts", "text"))
|
for(QDomElement text : QET::findInDomElement(dom_element, "texts", "text"))
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = nullptr;
|
DynamicElementTextItem *deti = nullptr;
|
||||||
@@ -320,6 +411,7 @@ void ElementTextItemGroup::fromXml(QDomElement &dom_element)
|
|||||||
if (deti)
|
if (deti)
|
||||||
parentElement()->addTextToGroup(deti, this);
|
parentElement()->addTextToGroup(deti, this);
|
||||||
}
|
}
|
||||||
|
m_block_alignment_update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,6 +434,7 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
|||||||
t.setCosmetic(true);
|
t.setCosmetic(true);
|
||||||
painter->setPen(t);
|
painter->setPen(t);
|
||||||
painter->drawRoundRect(boundingRect().adjusted(1, 1, -1, -1), 10, 10);
|
painter->drawRoundRect(boundingRect().adjusted(1, 1, -1, -1), 10, 10);
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -614,3 +707,31 @@ void ElementTextItemGroup::adjustSlaveXrefPos()
|
|||||||
m_slave_Xref_item->setPos(pos);
|
m_slave_Xref_item->setPos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ElementTextItemGroup::autoPos()
|
||||||
|
{
|
||||||
|
int offset = 5;
|
||||||
|
|
||||||
|
if(m_parent_element->linkType() == Element::Master)
|
||||||
|
{
|
||||||
|
if(!diagram())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MasterElement *master = static_cast<MasterElement *>(m_parent_element);
|
||||||
|
XRefProperties xrp = diagram()->project()->defaultXRefProperties(master->kindInformations()["type"].toString());
|
||||||
|
if(xrp.snapTo() == XRefProperties::Bottom)
|
||||||
|
{
|
||||||
|
QRectF rectXref = master->XrefBoundingRect();
|
||||||
|
offset = xrp.offset() <= 40 ? 5 : xrp.offset();
|
||||||
|
|
||||||
|
offset += (int)rectXref.height();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qreal r = rotation();
|
||||||
|
centerToBottomDiagram(this, m_parent_element, offset);
|
||||||
|
//centerToBottomDiagram change the rotation of this group if needed,
|
||||||
|
//but setRotation is not a virtual function of QGraphicsItem, and the function centerToBottomDiagram
|
||||||
|
//work with a QGraphicsItem. So we emit the signal if rotation changed
|
||||||
|
if(rotation() != r)
|
||||||
|
emit rotationChanged(rotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2017 The QElectroTech Team
|
Copyright 2006-2017 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
|||||||
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||||
|
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
signals:
|
signals:
|
||||||
@@ -48,12 +49,14 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
|||||||
void verticalAdjustmentChanged(int);
|
void verticalAdjustmentChanged(int);
|
||||||
void alignmentChanged(Qt::Alignment);
|
void alignmentChanged(Qt::Alignment);
|
||||||
void nameChanged(QString);
|
void nameChanged(QString);
|
||||||
|
void holdToBottomPageChanged(bool);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementTextItemGroup(const QString &name, Element *parent);
|
ElementTextItemGroup(const QString &name, Element *parent);
|
||||||
~ElementTextItemGroup() override;
|
~ElementTextItemGroup() override;
|
||||||
void addToGroup(QGraphicsItem *item);
|
void addToGroup(QGraphicsItem *item);
|
||||||
void removeFromGroup(QGraphicsItem *item);
|
void removeFromGroup(QGraphicsItem *item);
|
||||||
|
void blockAlignmentUpdate(bool block);
|
||||||
|
|
||||||
void setAlignment(Qt::Alignment alignement);
|
void setAlignment(Qt::Alignment alignement);
|
||||||
Qt::Alignment alignment() const;
|
Qt::Alignment alignment() const;
|
||||||
@@ -62,6 +65,8 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
|||||||
void setVerticalAdjustment(int v);
|
void setVerticalAdjustment(int v);
|
||||||
void setName(QString name);
|
void setName(QString name);
|
||||||
QString name() const {return m_name;}
|
QString name() const {return m_name;}
|
||||||
|
void setHoldToBottomPage(bool hold);
|
||||||
|
bool holdToBottomPage() const {return m_hold_to_bottom_of_page;}
|
||||||
QList<DynamicElementTextItem *> texts() const;
|
QList<DynamicElementTextItem *> texts() const;
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
@@ -86,17 +91,22 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
|||||||
private:
|
private:
|
||||||
void updateXref();
|
void updateXref();
|
||||||
void adjustSlaveXrefPos();
|
void adjustSlaveXrefPos();
|
||||||
|
void autoPos();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Alignment m_alignment = Qt::AlignJustify;
|
Qt::Alignment m_alignment = Qt::AlignJustify;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
bool m_first_move = true;
|
bool m_first_move = true,
|
||||||
|
m_hold_to_bottom_of_page = false,
|
||||||
|
m_block_alignment_update = false;
|
||||||
QPointF m_initial_position;
|
QPointF m_initial_position;
|
||||||
int m_vertical_adjustment = 0;
|
int m_vertical_adjustment = 0;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
Element *m_parent_element = nullptr;
|
Element *m_parent_element = nullptr;
|
||||||
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
||||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||||
|
QMetaObject::Connection m_XrefChanged_timer,
|
||||||
|
m_linked_changed_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELEMENTTEXTITEMGROUP_H
|
#endif // ELEMENTTEXTITEMGROUP_H
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ bool centerToParentBottom(QGraphicsItem *item) {
|
|||||||
* @param offset
|
* @param offset
|
||||||
* @return true if element is centered else false (element_to_follow have not diagram)
|
* @return true if element is centered else false (element_to_follow have not diagram)
|
||||||
*/
|
*/
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, int offset) {
|
#include "elementtextitemgroup.h"
|
||||||
|
#include "crossrefitem.h"
|
||||||
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset) {
|
||||||
if (! element_to_follow -> diagram()) {
|
if (! element_to_follow -> diagram()) {
|
||||||
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
||||||
return false;
|
return false;
|
||||||
@@ -59,18 +61,26 @@ bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_f
|
|||||||
QPointF point = element_to_follow -> sceneBoundingRect().center();
|
QPointF point = element_to_follow -> sceneBoundingRect().center();
|
||||||
|
|
||||||
point.setY(border.bottom() - item_to_center -> boundingRect().height() - offset );
|
point.setY(border.bottom() - item_to_center -> boundingRect().height() - offset );
|
||||||
point.rx() -= (item_to_center -> boundingRect().width()/2 +
|
point.rx() -= (item_to_center -> boundingRect().width()/2);
|
||||||
item_to_center -> boundingRect().left()); //< we add boundingrect.left because this value can be négative
|
|
||||||
|
//Apply the difference between the pos() of item and his bounding rect
|
||||||
|
QPointF tl = item_to_center->boundingRect().topLeft();
|
||||||
|
point.rx() -= tl.x();
|
||||||
|
point.ry() -= tl.y();
|
||||||
|
|
||||||
item_to_center -> setPos(0,0); //Due to a weird behavior or bug, before set the new position and rotation,
|
item_to_center -> setPos(0,0); //Due to a weird behavior or bug, before set the new position and rotation,
|
||||||
item_to_center -> setRotation(0); //we must to set the position and rotation at 0.
|
item_to_center -> setRotation(0); //we must to set the position and rotation at 0.
|
||||||
|
|
||||||
item_to_center -> setPos(item_to_center -> mapFromScene(point));
|
item_to_center->setPos(item_to_center->mapFromScene(point));
|
||||||
|
|
||||||
if (item_to_center -> rotation() != - element_to_follow -> rotation()) {
|
qreal rot = item_to_center->rotation();
|
||||||
item_to_center -> setRotation(0);
|
QGraphicsItem *parent = item_to_center->parentItem();
|
||||||
item_to_center -> setRotation(- element_to_follow -> rotation());
|
while (parent) {
|
||||||
|
rot += parent->rotation();
|
||||||
|
parent = parent->parentItem();
|
||||||
}
|
}
|
||||||
|
if(rot != 0)
|
||||||
|
item_to_center->setRotation(item_to_center->rotation() - rot);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef QGRAPHICSITEMUTILITY_H
|
#ifndef QGRAPHICSITEMUTILITY_H
|
||||||
#define QGRAPHICSITEMUTILITY_H
|
#define QGRAPHICSITEMUTILITY_H
|
||||||
|
#include <QtGlobal>
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
bool centerToParentBottom (QGraphicsItem *item);
|
bool centerToParentBottom (QGraphicsItem *item);
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, int offset = 0 );
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
||||||
|
|
||||||
#endif // QGRAPHICSITEMUTILITY_H
|
#endif // QGRAPHICSITEMUTILITY_H
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ int rot_txt_row = 10;
|
|||||||
int align_grp_row = 0;
|
int align_grp_row = 0;
|
||||||
int rot_grp_row = 1;
|
int rot_grp_row = 1;
|
||||||
int adjust_grp_row = 2;
|
int adjust_grp_row = 2;
|
||||||
|
int hold_to_bottom_grp_row = 3;
|
||||||
|
|
||||||
DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *parent) :
|
DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *parent) :
|
||||||
QStandardItemModel(parent),
|
QStandardItemModel(parent),
|
||||||
@@ -545,6 +546,10 @@ QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *
|
|||||||
if(group->name() != name)
|
if(group->name() != name)
|
||||||
new QPropertyUndoCommand(group, "name", QVariant(group->name()), QVariant(name), undo);
|
new QPropertyUndoCommand(group, "name", QVariant(group->name()), QVariant(name), undo);
|
||||||
|
|
||||||
|
bool hold_to_bottom = group_qsi->child(hold_to_bottom_grp_row, 1)->checkState() == Qt::Checked? true : false;
|
||||||
|
if(group->holdToBottomPage() != hold_to_bottom)
|
||||||
|
new QPropertyUndoCommand(group, "holdToBottomPage", QVariant(group->holdToBottomPage()), QVariant(hold_to_bottom), undo);
|
||||||
|
|
||||||
|
|
||||||
return undo;
|
return undo;
|
||||||
}
|
}
|
||||||
@@ -585,7 +590,7 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
|
|||||||
default: break;}
|
default: break;}
|
||||||
|
|
||||||
QStandardItem *alignment_a = new QStandardItem(text);
|
QStandardItem *alignment_a = new QStandardItem(text);
|
||||||
alignment_a->setData(DynamicElementTextModel::grp_alignment, Qt::UserRole+1);
|
alignment_a->setData(DynamicElementTextModel::grpAlignment, Qt::UserRole+1);
|
||||||
alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||||
qsi_list.clear();
|
qsi_list.clear();
|
||||||
qsi_list << alignment << alignment_a;
|
qsi_list << alignment << alignment_a;
|
||||||
@@ -597,7 +602,7 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
|
|||||||
|
|
||||||
QStandardItem *rot_a = new QStandardItem;
|
QStandardItem *rot_a = new QStandardItem;
|
||||||
rot_a->setData(group->rotation(), Qt::EditRole);
|
rot_a->setData(group->rotation(), Qt::EditRole);
|
||||||
rot_a->setData(DynamicElementTextModel::grp_rotation, Qt::UserRole+1);
|
rot_a->setData(DynamicElementTextModel::grpRotation, Qt::UserRole+1);
|
||||||
rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||||
qsi_list.clear();
|
qsi_list.clear();
|
||||||
qsi_list << rot << rot_a;
|
qsi_list << rot << rot_a;
|
||||||
@@ -609,12 +614,25 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
|
|||||||
|
|
||||||
QStandardItem *v_adj_a = new QStandardItem;
|
QStandardItem *v_adj_a = new QStandardItem;
|
||||||
v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole);
|
v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole);
|
||||||
v_adj_a->setData(DynamicElementTextModel::grp_v_adjust, Qt::UserRole+1);
|
v_adj_a->setData(DynamicElementTextModel::grpVAdjust, Qt::UserRole+1);
|
||||||
v_adj_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
v_adj_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||||
qsi_list.clear();
|
qsi_list.clear();
|
||||||
qsi_list << v_adj << v_adj_a;
|
qsi_list << v_adj << v_adj_a;
|
||||||
grp->appendRow(qsi_list);
|
grp->appendRow(qsi_list);
|
||||||
|
|
||||||
|
//Hold to the bottom of the page
|
||||||
|
QStandardItem *hold_bottom = new QStandardItem(tr("Maintenir en bas de page"));
|
||||||
|
hold_bottom->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
|
||||||
|
QStandardItem *hold_bottom_a = new QStandardItem();
|
||||||
|
hold_bottom_a->setCheckable(true);
|
||||||
|
hold_bottom_a->setCheckState(group->holdToBottomPage() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, Qt::UserRole+1);
|
||||||
|
hold_bottom_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
|
||||||
|
qsi_list.clear();
|
||||||
|
qsi_list << hold_bottom << hold_bottom_a;
|
||||||
|
grp->appendRow(qsi_list);
|
||||||
|
|
||||||
|
|
||||||
//Add the texts of the group
|
//Add the texts of the group
|
||||||
for(DynamicElementTextItem *deti : group->texts())
|
for(DynamicElementTextItem *deti : group->texts())
|
||||||
@@ -623,6 +641,7 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
|
|||||||
group_item->appendRow(itemsForText(deti));
|
group_item->appendRow(itemsForText(deti));
|
||||||
}
|
}
|
||||||
setConnection(group, true);
|
setConnection(group, true);
|
||||||
|
enableGroupRotation(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -990,6 +1009,30 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn
|
|||||||
qsi->child(compo_txt_row,1)->setEnabled(compo);
|
qsi->child(compo_txt_row,1)->setEnabled(compo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DynamicElementTextModel::enableGroupRotation
|
||||||
|
* Enable/disable the item "group rotation" according the option hold to bottom
|
||||||
|
* @param group
|
||||||
|
*/
|
||||||
|
void DynamicElementTextModel::enableGroupRotation(ElementTextItemGroup *group)
|
||||||
|
{
|
||||||
|
if(!m_groups_list.contains(group))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QStandardItem *qsi = m_groups_list.value(group);
|
||||||
|
|
||||||
|
if(group->holdToBottomPage())
|
||||||
|
{
|
||||||
|
qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable);
|
||||||
|
qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
|
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = textFromItem(qsi);
|
DynamicElementTextItem *deti = textFromItem(qsi);
|
||||||
@@ -1107,10 +1150,11 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QMetaObject::Connection> connection_list;
|
QList<QMetaObject::Connection> connection_list;
|
||||||
connection_list << connect(group, &ElementTextItemGroup::alignmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_alignment);});
|
connection_list << connect(group, &ElementTextItemGroup::alignmentChanged, [group, this]() {this->updateDataFromGroup(group, grpAlignment);});
|
||||||
connection_list << connect(group, &ElementTextItemGroup::rotationChanged, [group, this]() {this->updateDataFromGroup(group, grp_rotation);});
|
connection_list << connect(group, &ElementTextItemGroup::rotationChanged, [group, this]() {this->updateDataFromGroup(group, grpRotation);});
|
||||||
connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_v_adjust);});
|
connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grpVAdjust);});
|
||||||
connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_name);});
|
connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grpName);});
|
||||||
|
connection_list << connect(group, &ElementTextItemGroup::holdToBottomPageChanged, [group, this]() {this->updateDataFromGroup(group, grpHoldBottom);});
|
||||||
|
|
||||||
m_hash_group_connect.insert(group, connection_list);
|
m_hash_group_connect.insert(group, connection_list);
|
||||||
}
|
}
|
||||||
@@ -1219,7 +1263,7 @@ void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, D
|
|||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case grp_alignment:
|
case grpAlignment:
|
||||||
{
|
{
|
||||||
switch (group->alignment())
|
switch (group->alignment())
|
||||||
{
|
{
|
||||||
@@ -1230,15 +1274,21 @@ void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, D
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case grp_rotation:
|
case grpRotation:
|
||||||
qsi->child(rot_grp_row,1)->setData(group->rotation(), Qt::EditRole);
|
qsi->child(rot_grp_row,1)->setData(group->rotation(), Qt::EditRole);
|
||||||
break;
|
break;
|
||||||
case grp_v_adjust:
|
case grpVAdjust:
|
||||||
qsi->child(adjust_grp_row,1)->setData(group->verticalAdjustment(), Qt::EditRole);
|
qsi->child(adjust_grp_row,1)->setData(group->verticalAdjustment(), Qt::EditRole);
|
||||||
break;
|
break;
|
||||||
case grp_name:
|
case grpName:
|
||||||
qsi->setData(group->name(), Qt::DisplayRole);
|
qsi->setData(group->name(), Qt::DisplayRole);
|
||||||
break;
|
break;
|
||||||
|
case grpHoldBottom:
|
||||||
|
{
|
||||||
|
qsi->child(hold_to_bottom_grp_row,1)->setCheckState(group->holdToBottomPage()? Qt::Checked : Qt::Unchecked);
|
||||||
|
enableGroupRotation(group);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_block_dataChanged = false;
|
m_block_dataChanged = false;
|
||||||
@@ -1350,7 +1400,7 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
|||||||
sb->setSuffix(" px");
|
sb->setSuffix(" px");
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
case DynamicElementTextModel::grp_alignment:
|
case DynamicElementTextModel::grpAlignment:
|
||||||
{
|
{
|
||||||
QComboBox *qcb = new QComboBox(parent);
|
QComboBox *qcb = new QComboBox(parent);
|
||||||
qcb->setFrame(false);
|
qcb->setFrame(false);
|
||||||
@@ -1360,7 +1410,7 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
|||||||
qcb->addItem(tr("Droite"));
|
qcb->addItem(tr("Droite"));
|
||||||
return qcb;
|
return qcb;
|
||||||
}
|
}
|
||||||
case DynamicElementTextModel::grp_rotation:
|
case DynamicElementTextModel::grpRotation:
|
||||||
{
|
{
|
||||||
QSpinBox *sb = new QSpinBox(parent);
|
QSpinBox *sb = new QSpinBox(parent);
|
||||||
sb->setObjectName("group_rotation");
|
sb->setObjectName("group_rotation");
|
||||||
@@ -1370,7 +1420,7 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
|||||||
sb->setSuffix(" °");
|
sb->setSuffix(" °");
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
case DynamicElementTextModel::grp_v_adjust:
|
case DynamicElementTextModel::grpVAdjust:
|
||||||
{
|
{
|
||||||
QSpinBox *sb = new QSpinBox(parent);
|
QSpinBox *sb = new QSpinBox(parent);
|
||||||
sb->setObjectName("group_v_adjustment");
|
sb->setObjectName("group_v_adjustment");
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
frame,
|
frame,
|
||||||
rotation,
|
rotation,
|
||||||
textWidth,
|
textWidth,
|
||||||
grp_alignment,
|
grpAlignment,
|
||||||
grp_rotation,
|
grpRotation,
|
||||||
grp_v_adjust,
|
grpVAdjust,
|
||||||
grp_name
|
grpName,
|
||||||
|
grpHoldBottom
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
||||||
@@ -87,6 +88,7 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||||
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||||
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
|
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
|
||||||
|
void enableGroupRotation(ElementTextItemGroup *group);
|
||||||
void itemDataChanged(QStandardItem *qsi);
|
void itemDataChanged(QStandardItem *qsi);
|
||||||
void setConnection(DynamicElementTextItem *deti, bool set);
|
void setConnection(DynamicElementTextItem *deti, bool set);
|
||||||
void setConnection(ElementTextItemGroup *group, bool set);
|
void setConnection(ElementTextItemGroup *group, bool set);
|
||||||
|
|||||||
@@ -361,9 +361,9 @@ QWidget *ElementPropertiesWidget::generalWidget()
|
|||||||
description_string += QString(tr("Folio : %1\n")).arg(folio_index + 1);
|
description_string += QString(tr("Folio : %1\n")).arg(folio_index + 1);
|
||||||
}
|
}
|
||||||
description_string += QString(tr("Position : %1\n")).arg(m_diagram -> convertPosition(m_element -> scenePos()).toString());
|
description_string += QString(tr("Position : %1\n")).arg(m_diagram -> convertPosition(m_element -> scenePos()).toString());
|
||||||
|
description_string += QString(tr("Rotation : %1°\n")).arg(m_element.data()->rotation());
|
||||||
description_string += QString(tr("Dimensions : %1*%2\n")).arg(m_element -> size().width()).arg(m_element -> size().height());
|
description_string += QString(tr("Dimensions : %1*%2\n")).arg(m_element -> size().width()).arg(m_element -> size().height());
|
||||||
description_string += QString(tr("Bornes : %1\n")).arg(m_element -> terminals().count());
|
description_string += QString(tr("Bornes : %1\n")).arg(m_element -> terminals().count());
|
||||||
description_string += QString(tr("Champs de texte : %1\n")).arg(m_element -> texts().count());
|
|
||||||
|
|
||||||
if (custom_element) {
|
if (custom_element) {
|
||||||
description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
|
description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user