mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Conductor : remove "simple" conductor, and add option "visible" for text of multiwire conductor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3338 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -223,7 +223,8 @@ ConductorProperties::ConductorProperties() :
|
||||
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 @@ void ConductorProperties::toXml(QDomElement &e) const {
|
||||
}
|
||||
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 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
||||
// 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 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
||||
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 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
||||
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 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
||||
*/
|
||||
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 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const{
|
||||
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 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const{
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,7 @@ class ConductorProperties {
|
||||
* 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 @@ class ConductorProperties {
|
||||
/// 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;
|
||||
|
||||
|
||||
@@ -1281,33 +1281,45 @@ QString Conductor::text() const {
|
||||
}
|
||||
|
||||
/**
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,6 +72,7 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
|
||||
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 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
|
||||
*/
|
||||
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::initWidget() {
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>430</width>
|
||||
<height>571</height>
|
||||
<height>407</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -23,13 +23,6 @@
|
||||
<string>Type de conducteur</string>
|
||||
</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">
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user