[qet] [3338] Conductor : remove "simple" conductor, and add option "visible" for text of multiwire conductor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3338
Author: blacksun
Date: 2014-09-28 11:47:06 +0200 (Sun, 28 Sep 2014)
Log Message:
-----------
Conductor : remove "simple" conductor, and add option "visible" for text of multiwire conductor
Modified Paths:
--------------
trunk/sources/conductorproperties.cpp
trunk/sources/conductorproperties.h
trunk/sources/qetgraphicsitem/conductor.cpp
trunk/sources/ui/conductorpropertieswidget.cpp
trunk/sources/ui/conductorpropertieswidget.ui
Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp 2014-09-27 18:18:32 UTC (rev 3337)
+++ trunk/sources/conductorproperties.cpp 2014-09-28 09:47:06 UTC (rev 3338)
@@ -223,7 +223,8 @@
text_size(9),
verti_rotate_text(270),
horiz_rotate_text(0),
- style(Qt::SolidLine)
+ style(Qt::SolidLine),
+ m_show_text(true)
{
}
@@ -252,6 +253,7 @@
}
e.setAttribute("num", text);
e.setAttribute("numsize", text_size);
+ e.setAttribute("displaytext", m_show_text);
e.setAttribute("vertirotatetext", verti_rotate_text);
e.setAttribute("horizrotatetext", horiz_rotate_text);
@@ -283,17 +285,19 @@
// get specific properties for single conductor
singleLineProperties.fromXml(e);
type = Single;
- } else if (e.attribute("type") == typeToString(Simple)) {
- type = Simple;
} else {
type = Multi;
}
// get text field
text = e.attribute("num");
text_size = e.attribute("numsize", QString::number(9)).toInt();
+ m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
+ //Keep retrocompatible with version older than 0,4
+ //If the propertie @type is simple (removed since QET 0,4), we set text no visible.
+ if (e.attribute("type") == "simple") m_show_text = false;
}
/**
@@ -306,6 +310,7 @@
settings.setValue(prefix + "type", typeToString(type));
settings.setValue(prefix + "text", text);
settings.setValue(prefix + "textsize", QString::number(text_size));
+ settings.setValue(prefix + "displaytext", m_show_text);
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
singleLineProperties.toSettings(settings, prefix);
@@ -327,14 +332,13 @@
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
if (setting_type == typeToString(Single)) {
type = Single;
- } else if (setting_type == typeToString(Simple)) {
- type = Simple;
} else {
type = Multi;
}
singleLineProperties.fromSettings(settings, prefix);
text = settings.value(prefix + "text", "_").toString();
text_size = settings.value(prefix + "textsize", "7").toInt();
+ m_show_text = settings.value(prefix + "displaytext", true).toBool();
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
@@ -347,7 +351,6 @@
*/
QString ConductorProperties::typeToString(ConductorType t) {
switch(t) {
- case Simple: return("simple");
case Single: return("single");
case Multi: return("multi");
default: return(QString());
@@ -364,6 +367,7 @@
other.color == color &&\
other.style == style &&\
other.text == text &&\
+ other.m_show_text == m_show_text &&\
other.text_size == text_size &&\
other.verti_rotate_text == verti_rotate_text &&\
other.horiz_rotate_text == horiz_rotate_text &&\
@@ -376,16 +380,7 @@
@return true si les deux ensembles de proprietes sont differents, false sinon
*/
bool ConductorProperties::operator!=(const ConductorProperties &other) const{
- return(
- other.type != type ||\
- other.color != color ||\
- other.style != style ||\
- other.text != text ||\
- other.text_size != text_size ||\
- other.verti_rotate_text != verti_rotate_text ||\
- other.horiz_rotate_text != horiz_rotate_text ||\
- other.singleLineProperties != singleLineProperties
- );
+ return(!(*this == other));
}
/**
Modified: trunk/sources/conductorproperties.h
===================================================================
--- trunk/sources/conductorproperties.h 2014-09-27 18:18:32 UTC (rev 3337)
+++ trunk/sources/conductorproperties.h 2014-09-28 09:47:06 UTC (rev 3338)
@@ -70,7 +70,7 @@
* Single: singleline symbols, no text input
* Multi: text input, no symbol
*/
- enum ConductorType { Simple, Single, Multi };
+ enum ConductorType { Single, Multi };
// attributes
/// Conductor type
@@ -84,6 +84,7 @@
/// rotation angle texte
double verti_rotate_text;
double horiz_rotate_text;
+ bool m_show_text;
/// conducteur style (Qt::SolidLine or Qt::DashLine)
Qt::PenStyle style;
Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp 2014-09-27 18:18:32 UTC (rev 3337)
+++ trunk/sources/qetgraphicsitem/conductor.cpp 2014-09-28 09:47:06 UTC (rev 3338)
@@ -1281,33 +1281,45 @@
}
/**
- @param t Nouveau texte du conducteur
-*/
+ * @brief Conductor::setText
+ * The text of this conductor
+ * @param t
+ */
void Conductor::setText(const QString &t) {
- text_item -> setFontSize(properties_.text_size);
text_item -> setPlainText(t);
-
}
-/// @param p les proprietes de ce conducteur
+/**
+ * @brief Conductor::setProperties
+ * Set new properties for this conductor
+ * @param p : properties
+ */
void Conductor::setProperties(const ConductorProperties &p) {
properties_ = p;
readProperties();
}
-/// @return les proprietes de ce conducteur
+/**
+ * @brief Conductor::properties
+ * @return the properties of this Conductor
+ */
ConductorProperties Conductor::properties() const {
return(properties_);
}
/**
- Relit les proprietes et les applique
-*/
+ * @brief Conductor::readProperties
+ * Read and apply properties
+ */
void Conductor::readProperties() {
- // la couleur n'est vraiment applicable que lors du rendu du conducteur
setText(properties_.text);
+ text_item -> setFontSize(properties_.text_size);
+ if (properties_.type != ConductorProperties::Multi) {
+ text_item -> setVisible(false);
+ } else {
+ text_item -> setVisible(properties_.m_show_text);
+ }
calculateTextItemPosition();
- text_item -> setVisible(properties_.type == ConductorProperties::Multi);
}
/**
Modified: trunk/sources/ui/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.cpp 2014-09-27 18:18:32 UTC (rev 3337)
+++ trunk/sources/ui/conductorpropertieswidget.cpp 2014-09-28 09:47:06 UTC (rev 3338)
@@ -72,6 +72,7 @@
if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index);
ui -> m_text_le -> setText (m_properties.text);
ui -> m_text_size_sb -> setValue (m_properties.text_size);
+ ui -> m_show_text_cb -> setChecked (m_properties.m_show_text);
ui -> m_earth_cb -> setChecked (m_properties.singleLineProperties.hasGround);
ui -> m_neutral_cb -> setChecked (m_properties.singleLineProperties.hasNeutral);
ui -> m_pen_cb -> setChecked (m_properties.singleLineProperties.isPen());
@@ -90,13 +91,13 @@
*/
ConductorProperties ConductorPropertiesWidget::properties() const {
ConductorProperties properties_;
- if (ui -> m_simple_rb -> isChecked()) properties_.type = ConductorProperties::Simple;
- else if (ui -> m_multi_rb -> isChecked()) properties_.type = ConductorProperties::Multi;
+ if (ui -> m_multi_rb -> isChecked()) properties_.type = ConductorProperties::Multi;
else if (ui -> m_single_rb -> isChecked()) properties_.type = ConductorProperties::Single;
properties_.color = ui->m_color_pb->palette().color(QPalette::Button);
properties_.style = static_cast<Qt::PenStyle>(ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).toInt());
properties_.text = ui -> m_text_le -> text();
properties_.text_size = ui -> m_text_size_sb -> value();
+ properties_.m_show_text = ui -> m_show_text_cb -> isChecked();
properties_.verti_rotate_text = m_verti_select -> value();
properties_.horiz_rotate_text = m_horiz_select -> value();
properties_.singleLineProperties.hasGround = ui -> m_earth_cb -> isChecked();
@@ -145,9 +146,6 @@
*/
void ConductorPropertiesWidget::setConductorType(ConductorProperties::ConductorType type) {
switch (type) {
- case ConductorProperties::Simple:
- ui -> m_simple_rb -> setChecked(true);
- break;
case ConductorProperties::Multi:
ui -> m_multi_rb -> setChecked(true);
break;
Modified: trunk/sources/ui/conductorpropertieswidget.ui
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.ui 2014-09-27 18:18:32 UTC (rev 3337)
+++ trunk/sources/ui/conductorpropertieswidget.ui 2014-09-28 09:47:06 UTC (rev 3338)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>430</width>
- <height>571</height>
+ <height>407</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,13 +24,6 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QRadioButton" name="m_simple_rb">
- <property name="text">
- <string>Simple</string>
- </property>
- </widget>
- </item>
- <item>
<widget class="QRadioButton" name="m_multi_rb">
<property name="text">
<string>Multifilaire</string>
@@ -57,12 +50,16 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
- <string>Texte par defaut :</string>
+ <string>Texte :</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="m_text_le"/>
+ <widget class="QLineEdit" name="m_text_le">
+ <property name="toolTip">
+ <string>Texte</string>
+ </property>
+ </widget>
</item>
<item>
<widget class="QLabel" name="label_2">
@@ -73,6 +70,9 @@
</item>
<item>
<widget class="QSpinBox" name="m_text_size_sb">
+ <property name="toolTip">
+ <string>taille</string>
+ </property>
<property name="minimum">
<number>5</number>
</property>
@@ -81,6 +81,16 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="m_show_text_cb">
+ <property name="text">
+ <string>Visible</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
@@ -256,24 +266,24 @@
<string>Apparence du conducteur</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="2" column="1">
+ <item row="3" column="2">
<widget class="QComboBox" name="m_line_style_cb"/>
</item>
- <item row="0" column="0">
+ <item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Couleur :</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="1" column="2">
<widget class="QPushButton" name="m_color_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="2" column="0">
+ <item row="3" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Style :</string>