Added Cross Reference Labels for Master and Slave Element. Removed View Mode

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4511 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-05-23 22:01:22 +00:00
parent 7229109ff4
commit ada71484e8
8 changed files with 122 additions and 70 deletions

View File

@@ -27,8 +27,9 @@ XRefProperties::XRefProperties()
m_show_power_ctc = true; m_show_power_ctc = true;
m_display = Cross; m_display = Cross;
m_snap_to = Bottom; m_snap_to = Bottom;
m_view_mode = Index;
m_prefix_keys << "power" << "delay" << "switch"; m_prefix_keys << "power" << "delay" << "switch";
m_master_label = "%f-%l%c";
m_slave_label = "(%f-%l%c)";
} }
/** /**
@@ -41,10 +42,12 @@ void XRefProperties::toSettings(QSettings &settings, const QString prefix) const
settings.setValue(prefix + "showpowerctc", m_show_power_ctc); settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
QString display = m_display == Cross? "cross" : "contacts"; QString display = m_display == Cross? "cross" : "contacts";
settings.setValue(prefix + "displayhas", display); settings.setValue(prefix + "displayhas", display);
QString view_mode = m_view_mode == Index? "index" : "foliolabel";
settings.setValue(prefix + "viewmode", view_mode);
QString snap = m_snap_to == Bottom? "bottom" : "label"; QString snap = m_snap_to == Bottom? "bottom" : "label";
settings.setValue(prefix + "snapto", snap); settings.setValue(prefix + "snapto", snap);
QString master_label = m_master_label;
settings.setValue(prefix + "master_label", master_label);
QString slave_label = m_slave_label;
settings.setValue(prefix + "slave_label", slave_label);
foreach (QString key, m_prefix.keys()) { foreach (QString key, m_prefix.keys()) {
settings.setValue(prefix + key + "prefix", m_prefix.value(key)); settings.setValue(prefix + key + "prefix", m_prefix.value(key));
} }
@@ -60,10 +63,10 @@ void XRefProperties::fromSettings(const QSettings &settings, const QString prefi
m_show_power_ctc = settings.value(prefix + "showpowerctc", false).toBool(); m_show_power_ctc = settings.value(prefix + "showpowerctc", false).toBool();
QString display = settings.value(prefix + "displayhas", "cross").toString(); QString display = settings.value(prefix + "displayhas", "cross").toString();
display == "cross"? m_display = Cross : m_display = Contacts; display == "cross"? m_display = Cross : m_display = Contacts;
QString view_mode = settings.value(prefix + "viewmode", "index").toString();
view_mode == "index"? m_view_mode = Index : m_view_mode = FolioLabel;
QString snap = settings.value(prefix + "snapto", "label").toString(); QString snap = settings.value(prefix + "snapto", "label").toString();
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label; snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
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) { foreach (QString key, m_prefix_keys) {
m_prefix.insert(key, settings.value(prefix + key + "prefix").toString()); m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
} }
@@ -78,10 +81,12 @@ void XRefProperties::toXml(QDomElement &xml_element) const {
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false"); xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
QString display = m_display == Cross? "cross" : "contacts"; QString display = m_display == Cross? "cross" : "contacts";
xml_element.setAttribute("displayhas", display); xml_element.setAttribute("displayhas", display);
QString view_mode = m_view_mode == Index? "index" : "foliolabel";
xml_element.setAttribute("viewmode", view_mode);
QString snap = m_snap_to == Bottom? "bottom" : "label"; QString snap = m_snap_to == Bottom? "bottom" : "label";
xml_element.setAttribute("snapto", snap); xml_element.setAttribute("snapto", snap);
QString master_label = m_master_label;
xml_element.setAttribute("master_label", master_label);
QString slave_label = m_slave_label;
xml_element.setAttribute("slave_label", slave_label);
foreach (QString key, m_prefix.keys()) { foreach (QString key, m_prefix.keys()) {
xml_element.setAttribute(key + "prefix", m_prefix.value(key)); xml_element.setAttribute(key + "prefix", m_prefix.value(key));
} }
@@ -96,10 +101,10 @@ void XRefProperties::fromXml(const QDomElement &xml_element) {
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true"; m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
QString display = xml_element.attribute("displayhas", "cross"); QString display = xml_element.attribute("displayhas", "cross");
display == "cross"? m_display = Cross : m_display = Contacts; display == "cross"? m_display = Cross : m_display = Contacts;
QString view_mode = xml_element.attribute("viewmode", "index");
view_mode == "index"? m_view_mode = Index : m_view_mode = FolioLabel;
QString snap = xml_element.attribute("snapto", "label"); QString snap = xml_element.attribute("snapto", "label");
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label; snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
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) { foreach (QString key, m_prefix_keys) {
m_prefix.insert(key, xml_element.attribute(key + "prefix")); m_prefix.insert(key, xml_element.attribute(key + "prefix"));
} }
@@ -134,9 +139,10 @@ QHash<QString, XRefProperties> XRefProperties::defaultProperties()
bool XRefProperties::operator ==(const XRefProperties &xrp) const{ bool XRefProperties::operator ==(const XRefProperties &xrp) const{
return (m_show_power_ctc == xrp.m_show_power_ctc && return (m_show_power_ctc == xrp.m_show_power_ctc &&
m_display == xrp.m_display && m_display == xrp.m_display &&
m_view_mode == xrp.m_view_mode &&
m_snap_to == xrp.m_snap_to && m_snap_to == xrp.m_snap_to &&
m_prefix == xrp.m_prefix); m_prefix == xrp.m_prefix &&
m_master_label == xrp.m_master_label &&
m_slave_label == xrp.m_slave_label);
} }
bool XRefProperties::operator !=(const XRefProperties &xrp) const { bool XRefProperties::operator !=(const XRefProperties &xrp) const {

View File

@@ -35,11 +35,6 @@ class XRefProperties : public PropertiesInterface
Contacts Contacts
}; };
enum ViewMode {
Index,
FolioLabel
};
enum SnapTo { enum SnapTo {
Bottom, Bottom,
Label Label
@@ -61,22 +56,26 @@ class XRefProperties : public PropertiesInterface
void setDisplayHas (const DisplayHas dh) {m_display = dh;} void setDisplayHas (const DisplayHas dh) {m_display = dh;}
DisplayHas displayHas () const {return m_display;} DisplayHas displayHas () const {return m_display;}
void setViewMode (const ViewMode vm) {m_view_mode = vm;}
ViewMode viewMode () const {return m_view_mode;}
void setSnapTo (const SnapTo st) {m_snap_to = st;} void setSnapTo (const SnapTo st) {m_snap_to = st;}
SnapTo snapTo () const {return m_snap_to;} SnapTo snapTo () const {return m_snap_to;}
void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);} void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);}
QString prefix (const QString &key) const {return m_prefix.value(key);} QString prefix (const QString &key) const {return m_prefix.value(key);}
void setMasterLabel (const QString master) {m_master_label = master;}
QString masterLabel () const {return m_master_label;}
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
QString slaveLabel () const {return m_slave_label;}
private: private:
bool m_show_power_ctc; bool m_show_power_ctc;
DisplayHas m_display; DisplayHas m_display;
ViewMode m_view_mode;
SnapTo m_snap_to; SnapTo m_snap_to;
QHash <QString, QString> m_prefix; QHash <QString, QString> m_prefix;
QStringList m_prefix_keys; QStringList m_prefix_keys;
QString m_master_label;
QString m_slave_label;
}; };
#endif // XREFPROPERTIES_H #endif // XREFPROPERTIES_H

View File

@@ -91,16 +91,13 @@ QPainterPath CrossRefItem::shape() const{
QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_prefix) const{ QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_prefix) const{
QString txt; QString txt;
XRefProperties::ViewMode vw = m_properties.viewMode(); XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
if (vw == XRefProperties::Index) txt = xrp.masterLabel();
{ txt.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
txt += QString::number(elmt->diagram()->folioIndex() + 1); txt.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
} txt.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
else if (vw == XRefProperties::FolioLabel){ txt.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
txt += elmt->diagram()->border_and_titleblock.folio();
}
txt += "-";
txt += elmt->diagram()->convertPosition(elmt -> scenePos()).toString();
if (add_prefix) { if (add_prefix) {
if (elmt->kindInformations()["type"].toString() == "power") txt.prepend(m_properties.prefix("power")); if (elmt->kindInformations()["type"].toString() == "power") txt.prepend(m_properties.prefix("power"));
else if (elmt->kindInformations()["type"].toString().contains("delay")) txt.prepend(m_properties.prefix("delay")); else if (elmt->kindInformations()["type"].toString().contains("delay")) txt.prepend(m_properties.prefix("delay"));

View File

@@ -62,6 +62,8 @@ class CrossRefItem : public QGraphicsObject
virtual QPainterPath shape () const; virtual QPainterPath shape () const;
QString elementPositionText (const Element *elmt, const bool &add_prefix = false) const; QString elementPositionText (const Element *elmt, const bool &add_prefix = false) const;
void allElementsPositionText (QString &no_str, QString &nc_str,const bool &add_prefix = false) const; void allElementsPositionText (QString &no_str, QString &nc_str,const bool &add_prefix = false) const;
void setTextLabel(QString label);
signals: signals:

View File

@@ -122,6 +122,7 @@ void SlaveElement::unlinkElement(Element *elmt)
* and add a qgraphicstextitem for show the position of the master * and add a qgraphicstextitem for show the position of the master
*/ */
void SlaveElement::updateLabel() { void SlaveElement::updateLabel() {
QString label("_"); QString label("_");
QString Xreflabel; QString Xreflabel;
bool no_editable = false; bool no_editable = false;
@@ -131,19 +132,12 @@ void SlaveElement::updateLabel() {
no_editable = true; no_editable = true;
Element *elmt = linkedElements().first(); Element *elmt = linkedElements().first();
label = elmt -> elementInformations()["label"].toString(); label = elmt -> elementInformations()["label"].toString();
XRefProperties m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString()); XRefProperties xrp = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
Xreflabel = "("; Xreflabel = xrp.slaveLabel();
XRefProperties::ViewMode vw = m_properties.viewMode(); Xreflabel.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
if (vw == XRefProperties::Index) Xreflabel.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
{ Xreflabel.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
Xreflabel += QString::number(elmt->diagram()->folioIndex()+1); Xreflabel.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
}
else if (vw == XRefProperties::FolioLabel){
Xreflabel += elmt->diagram()->border_and_titleblock.folio();
}
Xreflabel += "-";
Xreflabel += elmt->diagram() -> convertPosition(elmt -> scenePos()).toString();
Xreflabel += ")";
} }
// set the new label // set the new label

View File

@@ -38,8 +38,6 @@ class SlaveElement : public CustomElement
private: private:
QGraphicsTextItem *Xref_item; QGraphicsTextItem *Xref_item;
//XRefProperties m_properties;
}; };
#endif // SLAVEELEMENT_H #endif // SLAVEELEMENT_H

View File

@@ -110,8 +110,6 @@ void XRefPropertiesWidget::saveProperties(int index) {
if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross); if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross);
else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts); else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts);
if (ui->m_display_folio_index_rb->isChecked()) xrp.setViewMode (XRefProperties::Index);
else if (ui->m_display_folio_label_rb->isChecked()) xrp.setViewMode (XRefProperties::FolioLabel);
if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom") if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
xrp.setSnapTo(XRefProperties::Bottom); xrp.setSnapTo(XRefProperties::Bottom);
else xrp.setSnapTo(XRefProperties::Label); else xrp.setSnapTo(XRefProperties::Label);
@@ -119,6 +117,8 @@ void XRefPropertiesWidget::saveProperties(int index) {
xrp.setPrefix("power", ui->m_power_prefix_le->text()); xrp.setPrefix("power", ui->m_power_prefix_le->text());
xrp.setPrefix("delay", ui->m_delay_prefix_le->text()); xrp.setPrefix("delay", ui->m_delay_prefix_le->text());
xrp.setPrefix("switch", ui->m_switch_prefix_le->text()); xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
xrp.setMasterLabel(ui->m_master_le->text());
xrp.setSlaveLabel(ui->m_slave_le->text());
m_properties.insert(type, xrp); m_properties.insert(type, xrp);
} }
@@ -139,13 +139,11 @@ void XRefPropertiesWidget::updateDisplay() {
ui->m_display_has_contacts_rb->setChecked(true); ui->m_display_has_contacts_rb->setChecked(true);
} }
XRefProperties::ViewMode vw = xrp.viewMode(); QString master = xrp.masterLabel();
if (vw == XRefProperties::Index) { ui->m_master_le->setText(master);
ui->m_display_folio_index_rb->setChecked(true);
} QString slave = xrp.slaveLabel();
else if (vw == XRefProperties::FolioLabel) { ui->m_slave_le->setText(slave);
ui->m_display_folio_label_rb->setChecked(true);
}
if (xrp.snapTo() == XRefProperties::Bottom) if (xrp.snapTo() == XRefProperties::Bottom)
ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom")); ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>484</width> <width>484</width>
<height>475</height> <height>649</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -75,26 +75,84 @@
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Mode d'affichage</string> <string>Cross Reference Labels</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QRadioButton" name="m_display_folio_label_rb"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="text"> <item>
<string> Label de Folio</string> <widget class="QLabel" name="label_6">
</property> <property name="sizePolicy">
<property name="autoExclusive"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<bool>true</bool> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
</widget> </sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Master</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_master_le">
<property name="inputMask">
<string/>
</property>
<property name="text">
<string>%f-%l%c</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="m_display_folio_index_rb"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Slave</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_slave_le">
<property name="text">
<string>(%f-%l%c)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Index de Folio </string> <string>You can use variables for the displayed label of XRef:
</property> The variables are:
<property name="autoExclusive"> %f: Folio Index
<bool>true</bool> %F: Folio label
%l: Line
%c: Colunm</string>
</property> </property>
</widget> </widget>
</item> </item>