mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Xref: Change Vertical Offset of Cross References
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4547 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -30,6 +30,7 @@ XRefProperties::XRefProperties()
|
||||
m_prefix_keys << "power" << "delay" << "switch";
|
||||
m_master_label = "%f-%l%c";
|
||||
m_slave_label = "(%f-%l%c)";
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,8 @@ void XRefProperties::toSettings(QSettings &settings, const QString prefix) const
|
||||
settings.setValue(prefix + "displayhas", display);
|
||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||
settings.setValue(prefix + "snapto", snap);
|
||||
int offset = m_offset;
|
||||
settings.setValue(prefix + "offset", offset);
|
||||
QString master_label = m_master_label;
|
||||
settings.setValue(prefix + "master_label", master_label);
|
||||
QString slave_label = m_slave_label;
|
||||
@@ -65,6 +68,7 @@ void XRefProperties::fromSettings(const QSettings &settings, const QString prefi
|
||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||
QString snap = settings.value(prefix + "snapto", "label").toString();
|
||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||
m_offset = settings.value(prefix + "offset", "0").toInt();
|
||||
m_master_label = settings.value(prefix + "master_label", "%f-%l%c").toString();
|
||||
m_slave_label = settings.value(prefix + "slave_label", "(%f-%l%c)").toString();
|
||||
foreach (QString key, m_prefix_keys) {
|
||||
@@ -83,6 +87,8 @@ void XRefProperties::toXml(QDomElement &xml_element) const {
|
||||
xml_element.setAttribute("displayhas", display);
|
||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||
xml_element.setAttribute("snapto", snap);
|
||||
int offset = m_offset;
|
||||
xml_element.setAttribute("offset", offset);
|
||||
QString master_label = m_master_label;
|
||||
xml_element.setAttribute("master_label", master_label);
|
||||
QString slave_label = m_slave_label;
|
||||
@@ -103,6 +109,7 @@ void XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||
QString snap = xml_element.attribute("snapto", "label");
|
||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||
m_offset = xml_element.attribute("offset", "0").toInt();
|
||||
m_master_label = xml_element.attribute("master_label", "%f-%l%c");
|
||||
m_slave_label = xml_element.attribute("slave_label","(%f-%l%c)");
|
||||
foreach (QString key, m_prefix_keys) {
|
||||
@@ -142,7 +149,8 @@ bool XRefProperties::operator ==(const XRefProperties &xrp) const{
|
||||
m_snap_to == xrp.m_snap_to &&
|
||||
m_prefix == xrp.m_prefix &&
|
||||
m_master_label == xrp.m_master_label &&
|
||||
m_slave_label == xrp.m_slave_label);
|
||||
m_slave_label == xrp.m_slave_label &&
|
||||
m_offset == xrp.m_offset);
|
||||
}
|
||||
|
||||
bool XRefProperties::operator !=(const XRefProperties &xrp) const {
|
||||
|
||||
@@ -68,6 +68,9 @@ class XRefProperties : public PropertiesInterface
|
||||
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
|
||||
QString slaveLabel () const {return m_slave_label;}
|
||||
|
||||
void setOffset(const int offset) {m_offset = offset;}
|
||||
int offset() const {return m_offset;}
|
||||
|
||||
private:
|
||||
bool m_show_power_ctc;
|
||||
DisplayHas m_display;
|
||||
@@ -76,6 +79,7 @@ class XRefProperties : public PropertiesInterface
|
||||
QStringList m_prefix_keys;
|
||||
QString m_master_label;
|
||||
QString m_slave_label;
|
||||
int m_offset;
|
||||
};
|
||||
|
||||
#endif // XREFPROPERTIES_H
|
||||
|
||||
@@ -57,8 +57,10 @@ QRectF CommentItem::boundingRect() const {
|
||||
void CommentItem::autoPos() {
|
||||
if (m_text_parent)
|
||||
centerToParentBottom(this);
|
||||
else
|
||||
centerToBottomDiagram(this, m_element);
|
||||
else {
|
||||
XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
|
||||
centerToBottomDiagram(this, m_element, xrp.offset());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -217,7 +217,7 @@ void CrossRefItem::updateLabel() {
|
||||
void CrossRefItem::autoPos() {
|
||||
//We calcul the position according to the @snapTo of the xrefproperties
|
||||
if (m_properties.snapTo() == XRefProperties::Bottom)
|
||||
centerToBottomDiagram(this, m_element);
|
||||
centerToBottomDiagram(this, m_element, m_properties.offset());
|
||||
else
|
||||
centerToParentBottom(this);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ bool centerToParentBottom(QGraphicsItem *item) {
|
||||
* @param element_to_follow
|
||||
* @return true if element is centered else false (element_to_follow have not diagram)
|
||||
*/
|
||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow) {
|
||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, int offset) {
|
||||
if (! element_to_follow -> diagram()) {
|
||||
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
||||
return false;
|
||||
@@ -57,8 +57,10 @@ bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_f
|
||||
QRectF border = element_to_follow -> diagram() -> border_and_titleblock.insideBorderRect();
|
||||
QPointF point = element_to_follow -> sceneBoundingRect().center();
|
||||
|
||||
if (offset >= 50) //applies offset
|
||||
point.setY(border.bottom() - offset );
|
||||
else //applies default
|
||||
point.setY(border.bottom() - item_to_center -> boundingRect().height() - 5);
|
||||
|
||||
point.rx() -= (item_to_center -> boundingRect().width()/2 +
|
||||
item_to_center -> boundingRect().left()); //< we add boundingrect.left because this value can be négative
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ class QGraphicsItem;
|
||||
class Element;
|
||||
|
||||
bool centerToParentBottom (QGraphicsItem *item);
|
||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow);
|
||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, int offset );
|
||||
|
||||
#endif // QGRAPHICSITEMUTILITY_H
|
||||
|
||||
@@ -119,6 +119,7 @@ void XRefPropertiesWidget::saveProperties(int index) {
|
||||
xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
|
||||
xrp.setMasterLabel(ui->m_master_le->text());
|
||||
xrp.setSlaveLabel(ui->m_slave_le->text());
|
||||
xrp.setOffset(ui->m_offset_sb->value());
|
||||
|
||||
m_properties.insert(type, xrp);
|
||||
}
|
||||
@@ -145,6 +146,9 @@ void XRefPropertiesWidget::updateDisplay() {
|
||||
QString slave = xrp.slaveLabel();
|
||||
ui->m_slave_le->setText(slave);
|
||||
|
||||
int offset = xrp.offset();
|
||||
ui->m_offset_sb->setValue(offset);
|
||||
|
||||
if (xrp.snapTo() == XRefProperties::Bottom)
|
||||
ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));
|
||||
else ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("label"));
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>484</width>
|
||||
<width>507</width>
|
||||
<height>649</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -48,6 +48,48 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>XRef Vertical Offset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_offset_sb">
|
||||
<property name="toolTip">
|
||||
<string>10px corresponds to 1 tile displacement</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Set Vertical Offset for the Cross References. 10px corresponds to 1 tile displacement.</string>
|
||||
</property>
|
||||
<property name="specialValueText">
|
||||
<string>Default - Fit to XRef height</string>
|
||||
</property>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true">px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>40</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>300</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user