[qet] [2037] Diagram editor: conductors can now be rendered with a solid, dashed or dashed-and-dotted style.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2037
Author:   xavier
Date:     2013-02-11 19:35:18 +0100 (Mon, 11 Feb 2013)
Log Message:
-----------
Diagram editor: conductors can now be rendered with a solid, dashed or dashed-and-dotted style.

Modified Paths:
--------------
    trunk/sources/conductorproperties.cpp
    trunk/sources/conductorpropertieswidget.cpp
    trunk/sources/conductorpropertieswidget.h

Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp	2013-02-11 18:35:16 UTC (rev 2036)
+++ trunk/sources/conductorproperties.cpp	2013-02-11 18:35:18 UTC (rev 2037)
@@ -383,6 +383,7 @@
 			QString style_value = rx.cap(2);
 			if (style_name == "line-style") {
 				if (style_value == "dashed") style = Qt::DashLine;
+				else if (style_value == "dashdotted") style = Qt::DashDotLine;
 				else if (style_value == "normal") style = Qt::SolidLine;
 			}
 		}
@@ -396,6 +397,8 @@
 QString ConductorProperties::writeStyle() const {
 	if (style == Qt::DashLine) {
 		return("line-style: dashed;");
+	} else if (style == Qt::DashDotLine) {
+		return("line-style: dashdotted");
 	} else {
 		return(QString());
 	}

Modified: trunk/sources/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/conductorpropertieswidget.cpp	2013-02-11 18:35:16 UTC (rev 2036)
+++ trunk/sources/conductorpropertieswidget.cpp	2013-02-11 18:35:18 UTC (rev 2037)
@@ -113,13 +113,21 @@
 	QHBoxLayout *color_layout = new QHBoxLayout();
 	QLabel *text1 = new QLabel(tr("Couleur :"));
 	color_button = new QPushButton("");
-	dashed_checkbox = new QCheckBox(tr("Trait en pointill\351s"));
-	
 	color_layout -> addWidget(text1);
 	color_layout -> addWidget(color_button);
 	
+	QHBoxLayout *style_layout = new QHBoxLayout();
+	QLabel *text2 = new QLabel(tr("Style :", "conductor line style"));
+	line_style = new QComboBox();
+	line_style -> addItem(tr("Trait plein", "conductor style: solid line"), Qt::SolidLine);
+	line_style -> addItem(tr("Trait en pointill\351s", "conductor style: dashed line"), Qt::DashLine);
+	line_style -> addItem(tr("Traits et points", "conductor style: dashed and dotted line"), Qt::DashDotLine);
+	style_layout -> addWidget(text2);
+	style_layout -> addWidget(line_style);
+	
 	setColorButton(properties_.color);
-	dashed_checkbox -> setChecked(properties_.style == Qt::DashLine);
+	int index = line_style -> findData(properties_.style);
+	if (index != -1) line_style -> setCurrentIndex(index);
 	
 	groupbox_layout -> addWidget(simple);
 	groupbox_layout -> addWidget(multiline);
@@ -128,7 +136,7 @@
 	groupbox_layout -> addLayout(singleline_layout1);
 	
 	groupbox2_layout -> addLayout(color_layout);
-	groupbox2_layout -> addWidget(dashed_checkbox);
+	groupbox2_layout -> addLayout(style_layout);
 	
 	radio_buttons = new QButtonGroup(this);
 	radio_buttons -> addButton(simple,     ConductorProperties::Simple);
@@ -150,7 +158,7 @@
 	connect(phase_slider,      SIGNAL(valueChanged(int)),            this,          SLOT(updateConfig()));
 	connect(radio_buttons,     SIGNAL(buttonClicked(int)),           this,          SLOT(updateConfig()));
 	connect(text_field,        SIGNAL(textChanged(const QString &)), this,          SLOT(updateConfig()));
-	connect(dashed_checkbox,   SIGNAL(toggled(bool)),                this,          SLOT(updateConfig()));
+	connect(line_style,        SIGNAL(currentIndexChanged(int)),     this,          SLOT(updateConfig()));
 	connect(color_button,      SIGNAL(clicked()),                    this,          SLOT(chooseColor()));
 }
 
@@ -195,7 +203,7 @@
 	disconnect(radio_buttons,     SIGNAL(buttonClicked(int)),           this,          SLOT(updateConfig()));
 	disconnect(text_field,        SIGNAL(textChanged(const QString &)), this,          SLOT(updateConfig()));
 	disconnect(color_button,      SIGNAL(clicked()),                    this,          SLOT(chooseColor()));
-	disconnect(dashed_checkbox,   SIGNAL(toggled(bool)),                this,          SLOT(updateConfig()));
+	disconnect(line_style,        SIGNAL(currentIndexChanged(int)),     this,          SLOT(updateConfig()));
 }
 
 /// Destructeur
@@ -206,7 +214,7 @@
 void ConductorPropertiesWidget::updateConfig() {
 	properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId());
 	properties_.color = colorButton();
-	properties_.style = dashed_checkbox -> isChecked() ? Qt::DashLine : Qt::SolidLine;
+	properties_.style = static_cast<Qt::PenStyle>(line_style -> itemData(line_style -> currentIndex()).toInt());
 	properties_.text = text_field -> text();
 	properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
 	properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked();
@@ -222,7 +230,8 @@
 	
 	setConductorType(properties_.type);
 	setColorButton(properties_.color);
-	dashed_checkbox -> setChecked(properties_.style == Qt::DashLine);
+	int index = line_style -> findData(properties_.style);
+	if (index != -1) line_style -> setCurrentIndex(index);
 	text_field -> setText(properties_.text);
 	ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
 	neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
@@ -308,7 +317,7 @@
 	neutral_checkbox -> setDisabled(ro);
 	merge_checkbox -> setDisabled(ro);
 	color_button -> setDisabled(ro);
-	dashed_checkbox -> setDisabled(ro);
+	line_style -> setDisabled(ro);
 	// if the widget is not read-only, we still need to disable some widgets for consistency
 	if (!ro) {
 		updateDisplay();

Modified: trunk/sources/conductorpropertieswidget.h
===================================================================
--- trunk/sources/conductorpropertieswidget.h	2013-02-11 18:35:16 UTC (rev 2036)
+++ trunk/sources/conductorpropertieswidget.h	2013-02-11 18:35:18 UTC (rev 2037)
@@ -70,7 +70,7 @@
 	QCheckBox *neutral_checkbox;
 	QLabel *preview;
 	QPushButton *color_button;
-	QCheckBox *dashed_checkbox;
+	QComboBox *line_style;
 	QCheckBox *merge_checkbox;
 	
 	ConductorProperties properties_;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/