mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-19 10:09:58 +01:00
Merge and clean Stromie patch : feature set xref slave position
This commit is contained in:
@@ -1287,11 +1287,7 @@ void DynamicElementTextItem::updateXref()
|
||||
}
|
||||
else
|
||||
m_slave_Xref_item->setPlainText(xref_label);
|
||||
|
||||
QRectF r = boundingRect();
|
||||
QPointF pos(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,
|
||||
r.bottom());
|
||||
m_slave_Xref_item->setPos(pos);
|
||||
setXref_item(xrp.getXrefPos());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1316,7 +1312,8 @@ void DynamicElementTextItem::setPlainText(const QString &text)
|
||||
{
|
||||
if (toPlainText() == text)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
bool update_alignment = true;
|
||||
if (diagram() && (diagram()->project()->state() == QETProject::ProjectParsingRunning))
|
||||
update_alignment = false;
|
||||
@@ -1352,10 +1349,9 @@ void DynamicElementTextItem::setPlainText(const QString &text)
|
||||
}
|
||||
else if (m_slave_Xref_item)
|
||||
{
|
||||
QRectF r = boundingRect();
|
||||
QPointF pos(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,
|
||||
r.bottom());
|
||||
m_slave_Xref_item->setPos(pos);
|
||||
|
||||
XRefProperties xrp = diagram()->project()->defaultXRefProperties(m_master_element.data()->kindInformations()["type"].toString());
|
||||
setXref_item(xrp.getXrefPos());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1365,3 +1361,49 @@ void DynamicElementTextItem::setTextWidth(qreal width)
|
||||
m_text_width = width;
|
||||
emit textWidthChanged(width);
|
||||
}
|
||||
|
||||
void DynamicElementTextItem::setXref_item(Qt::AlignmentFlag m_exHrefPos)
|
||||
{
|
||||
QRectF r = boundingRect();
|
||||
QPointF pos;
|
||||
//QPointF pos(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,r.top());
|
||||
if (m_exHrefPos == Qt::AlignBottom)
|
||||
{
|
||||
pos = QPointF(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,r.bottom());
|
||||
}
|
||||
else if (m_exHrefPos == Qt::AlignTop)
|
||||
{
|
||||
pos = QPointF(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,r.top() - m_slave_Xref_item->boundingRect().height());
|
||||
}
|
||||
else if (m_exHrefPos == Qt::AlignLeft) //
|
||||
{
|
||||
pos = QPointF(r.left() - m_slave_Xref_item->boundingRect().width(),r.center().y() - m_slave_Xref_item->boundingRect().height()/2);
|
||||
}
|
||||
else if (m_exHrefPos == Qt::AlignRight) //
|
||||
{
|
||||
pos = QPointF(r.right() ,r.center().y() - m_slave_Xref_item->boundingRect().height()/2);
|
||||
}
|
||||
else if (m_exHrefPos == Qt::AlignBaseline) //
|
||||
{
|
||||
if(this->alignment() &Qt::AlignBottom)
|
||||
{
|
||||
pos = QPointF(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,r.bottom());
|
||||
}
|
||||
else if(this->alignment() &Qt::AlignTop)
|
||||
{
|
||||
pos = QPointF(r.center().x() - m_slave_Xref_item->boundingRect().width()/2,r.top() - m_slave_Xref_item->boundingRect().height());
|
||||
}
|
||||
else if(this->alignment() &Qt::AlignLeft)
|
||||
{
|
||||
pos = QPointF(r.left() - m_slave_Xref_item->boundingRect().width(),r.center().y() - m_slave_Xref_item->boundingRect().height()/2);
|
||||
}
|
||||
else if(this->alignment() &Qt::AlignRight)
|
||||
{
|
||||
pos = QPointF(r.right() ,r.center().y() - m_slave_Xref_item->boundingRect().height()/2);
|
||||
}
|
||||
}
|
||||
m_slave_Xref_item->setPos(pos);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define DYNAMICELEMENTTEXTITEM_H
|
||||
|
||||
#include "diagramtextitem.h"
|
||||
#include "xrefproperties.h"
|
||||
#include "element.h"
|
||||
#include <QUuid>
|
||||
#include <QPointer>
|
||||
@@ -90,7 +91,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
QString text() const;
|
||||
void setText(const QString &text);
|
||||
static QString xmlTaggName() {return QString("dynamic_elmt_text");}
|
||||
static QString xmlTaggName() {return QString("dynamic_elmt_text");}
|
||||
void setInfoName(const QString &info_name);
|
||||
QString infoName() const;
|
||||
void setCompositeText(const QString &text);
|
||||
@@ -101,6 +102,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
void updateXref();
|
||||
void setPlainText(const QString &text);
|
||||
void setTextWidth(qreal width);
|
||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
Reference in New Issue
Block a user