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

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2037 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2013-02-11 18:35:18 +00:00
parent d69130f3aa
commit 2af5eb54b1
3 changed files with 22 additions and 10 deletions

View File

@@ -383,6 +383,7 @@ void ConductorProperties::readStyle(const QString &style_string) {
QString style_value = rx.cap(2); QString style_value = rx.cap(2);
if (style_name == "line-style") { if (style_name == "line-style") {
if (style_value == "dashed") style = Qt::DashLine; if (style_value == "dashed") style = Qt::DashLine;
else if (style_value == "dashdotted") style = Qt::DashDotLine;
else if (style_value == "normal") style = Qt::SolidLine; else if (style_value == "normal") style = Qt::SolidLine;
} }
} }
@@ -396,6 +397,8 @@ void ConductorProperties::readStyle(const QString &style_string) {
QString ConductorProperties::writeStyle() const { QString ConductorProperties::writeStyle() const {
if (style == Qt::DashLine) { if (style == Qt::DashLine) {
return("line-style: dashed;"); return("line-style: dashed;");
} else if (style == Qt::DashDotLine) {
return("line-style: dashdotted");
} else { } else {
return(QString()); return(QString());
} }

View File

@@ -113,13 +113,21 @@ void ConductorPropertiesWidget::buildInterface() {
QHBoxLayout *color_layout = new QHBoxLayout(); QHBoxLayout *color_layout = new QHBoxLayout();
QLabel *text1 = new QLabel(tr("Couleur :")); QLabel *text1 = new QLabel(tr("Couleur :"));
color_button = new QPushButton(""); color_button = new QPushButton("");
dashed_checkbox = new QCheckBox(tr("Trait en pointill\351s"));
color_layout -> addWidget(text1); color_layout -> addWidget(text1);
color_layout -> addWidget(color_button); 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); 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(simple);
groupbox_layout -> addWidget(multiline); groupbox_layout -> addWidget(multiline);
@@ -128,7 +136,7 @@ void ConductorPropertiesWidget::buildInterface() {
groupbox_layout -> addLayout(singleline_layout1); groupbox_layout -> addLayout(singleline_layout1);
groupbox2_layout -> addLayout(color_layout); groupbox2_layout -> addLayout(color_layout);
groupbox2_layout -> addWidget(dashed_checkbox); groupbox2_layout -> addLayout(style_layout);
radio_buttons = new QButtonGroup(this); radio_buttons = new QButtonGroup(this);
radio_buttons -> addButton(simple, ConductorProperties::Simple); radio_buttons -> addButton(simple, ConductorProperties::Simple);
@@ -150,7 +158,7 @@ void ConductorPropertiesWidget::buildConnections() {
connect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig())); connect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
connect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig())); connect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
connect(text_field, SIGNAL(textChanged(const QString &)), 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())); connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
} }
@@ -195,7 +203,7 @@ void ConductorPropertiesWidget::destroyConnections() {
disconnect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig())); disconnect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig())); disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
disconnect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor())); 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 /// Destructeur
@@ -206,7 +214,7 @@ ConductorPropertiesWidget::~ConductorPropertiesWidget() {
void ConductorPropertiesWidget::updateConfig() { void ConductorPropertiesWidget::updateConfig() {
properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId()); properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId());
properties_.color = colorButton(); 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_.text = text_field -> text();
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked(); properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked(); properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked();
@@ -222,7 +230,8 @@ void ConductorPropertiesWidget::updateDisplay() {
setConductorType(properties_.type); setConductorType(properties_.type);
setColorButton(properties_.color); 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); text_field -> setText(properties_.text);
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround); ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral); neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
@@ -308,7 +317,7 @@ void ConductorPropertiesWidget::setReadOnly(bool ro) {
neutral_checkbox -> setDisabled(ro); neutral_checkbox -> setDisabled(ro);
merge_checkbox -> setDisabled(ro); merge_checkbox -> setDisabled(ro);
color_button -> 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 the widget is not read-only, we still need to disable some widgets for consistency
if (!ro) { if (!ro) {
updateDisplay(); updateDisplay();

View File

@@ -70,7 +70,7 @@ class ConductorPropertiesWidget : public QWidget {
QCheckBox *neutral_checkbox; QCheckBox *neutral_checkbox;
QLabel *preview; QLabel *preview;
QPushButton *color_button; QPushButton *color_button;
QCheckBox *dashed_checkbox; QComboBox *line_style;
QCheckBox *merge_checkbox; QCheckBox *merge_checkbox;
ConductorProperties properties_; ConductorProperties properties_;