mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
add widget for change size of conductor text item
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2647 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -220,6 +220,7 @@ ConductorProperties::ConductorProperties() :
|
|||||||
type(Multi),
|
type(Multi),
|
||||||
color(Qt::black),
|
color(Qt::black),
|
||||||
text("_"),
|
text("_"),
|
||||||
|
text_size(9),
|
||||||
verti_rotate_text(270),
|
verti_rotate_text(270),
|
||||||
horiz_rotate_text(0),
|
horiz_rotate_text(0),
|
||||||
style(Qt::SolidLine)
|
style(Qt::SolidLine)
|
||||||
@@ -248,6 +249,7 @@ void ConductorProperties::toXml(QDomElement &e) const {
|
|||||||
singleLineProperties.toXml(e);
|
singleLineProperties.toXml(e);
|
||||||
} else if (type == Multi) {
|
} else if (type == Multi) {
|
||||||
e.setAttribute("num", text);
|
e.setAttribute("num", text);
|
||||||
|
e.setAttribute("numsize", text_size);
|
||||||
e.setAttribute("vertirotatetext", verti_rotate_text);
|
e.setAttribute("vertirotatetext", verti_rotate_text);
|
||||||
e.setAttribute("horizrotatetext", horiz_rotate_text);
|
e.setAttribute("horizrotatetext", horiz_rotate_text);
|
||||||
}
|
}
|
||||||
@@ -284,6 +286,7 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
|||||||
} else {
|
} else {
|
||||||
// recupere le champ de texte
|
// recupere le champ de texte
|
||||||
text = e.attribute("num");
|
text = e.attribute("num");
|
||||||
|
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
||||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
||||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
||||||
type = Multi;
|
type = Multi;
|
||||||
@@ -299,6 +302,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
|||||||
settings.setValue(prefix + "style", writeStyle());
|
settings.setValue(prefix + "style", writeStyle());
|
||||||
settings.setValue(prefix + "type", typeToString(type));
|
settings.setValue(prefix + "type", typeToString(type));
|
||||||
settings.setValue(prefix + "text", text);
|
settings.setValue(prefix + "text", text);
|
||||||
|
settings.setValue(prefix + "textsize", QString::number(text_size));
|
||||||
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
||||||
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
||||||
singleLineProperties.toSettings(settings, prefix);
|
singleLineProperties.toSettings(settings, prefix);
|
||||||
@@ -327,6 +331,7 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
}
|
}
|
||||||
singleLineProperties.fromSettings(settings, prefix);
|
singleLineProperties.fromSettings(settings, prefix);
|
||||||
text = settings.value(prefix + "text", "_").toString();
|
text = settings.value(prefix + "text", "_").toString();
|
||||||
|
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||||
|
|
||||||
@@ -350,12 +355,13 @@ QString ConductorProperties::typeToString(ConductorType t) {
|
|||||||
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
||||||
@return true si les deux ensembles de proprietes sont identiques, false sinon
|
@return true si les deux ensembles de proprietes sont identiques, false sinon
|
||||||
*/
|
*/
|
||||||
int ConductorProperties::operator==(const ConductorProperties &other) {
|
bool ConductorProperties::operator==(const ConductorProperties &other) const{
|
||||||
return(
|
return(
|
||||||
other.type == type &&\
|
other.type == type &&\
|
||||||
other.color == color &&\
|
other.color == color &&\
|
||||||
other.style == style &&\
|
other.style == style &&\
|
||||||
other.text == text &&\
|
other.text == text &&\
|
||||||
|
other.text_size == text_size &&\
|
||||||
other.verti_rotate_text == verti_rotate_text &&\
|
other.verti_rotate_text == verti_rotate_text &&\
|
||||||
other.horiz_rotate_text == horiz_rotate_text &&\
|
other.horiz_rotate_text == horiz_rotate_text &&\
|
||||||
other.singleLineProperties == singleLineProperties
|
other.singleLineProperties == singleLineProperties
|
||||||
@@ -366,12 +372,13 @@ int ConductorProperties::operator==(const ConductorProperties &other) {
|
|||||||
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
||||||
@return true si les deux ensembles de proprietes sont differents, false sinon
|
@return true si les deux ensembles de proprietes sont differents, false sinon
|
||||||
*/
|
*/
|
||||||
int ConductorProperties::operator!=(const ConductorProperties &other) {
|
bool ConductorProperties::operator!=(const ConductorProperties &other) const{
|
||||||
return(
|
return(
|
||||||
other.type != type ||\
|
other.type != type ||\
|
||||||
other.color != color ||\
|
other.color != color ||\
|
||||||
other.style != style ||\
|
other.style != style ||\
|
||||||
other.text != text ||\
|
other.text != text ||\
|
||||||
|
other.text_size != text_size ||\
|
||||||
other.verti_rotate_text != verti_rotate_text ||\
|
other.verti_rotate_text != verti_rotate_text ||\
|
||||||
other.horiz_rotate_text != horiz_rotate_text ||\
|
other.horiz_rotate_text != horiz_rotate_text ||\
|
||||||
other.singleLineProperties != singleLineProperties
|
other.singleLineProperties != singleLineProperties
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ class ConductorProperties {
|
|||||||
QColor color;
|
QColor color;
|
||||||
/// Texte displayed for multiline conductors
|
/// Texte displayed for multiline conductors
|
||||||
QString text;
|
QString text;
|
||||||
|
/// size of text
|
||||||
|
int text_size;
|
||||||
/// rotation angle texte
|
/// rotation angle texte
|
||||||
double verti_rotate_text;
|
double verti_rotate_text;
|
||||||
double horiz_rotate_text;
|
double horiz_rotate_text;
|
||||||
@@ -96,8 +98,8 @@ class ConductorProperties {
|
|||||||
static QString typeToString(ConductorType);
|
static QString typeToString(ConductorType);
|
||||||
|
|
||||||
// operators
|
// operators
|
||||||
int operator==(const ConductorProperties &);
|
bool operator==(const ConductorProperties &) const;
|
||||||
int operator!=(const ConductorProperties &);
|
bool operator!=(const ConductorProperties &) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readStyle(const QString &);
|
void readStyle(const QString &);
|
||||||
|
|||||||
@@ -63,8 +63,13 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
QHBoxLayout *multiline_layout = new QHBoxLayout();
|
QHBoxLayout *multiline_layout = new QHBoxLayout();
|
||||||
QLabel *text = new QLabel(tr("Texte :"));
|
QLabel *text = new QLabel(tr("Texte :"));
|
||||||
text_field = new QLineEdit();
|
text_field = new QLineEdit();
|
||||||
|
QLabel *size_text = new QLabel(tr("Taille"), this);
|
||||||
|
text_size_sb = new QSpinBox(this);
|
||||||
|
text_size_sb->setRange(5,9);
|
||||||
multiline_layout -> addWidget(text);
|
multiline_layout -> addWidget(text);
|
||||||
multiline_layout -> addWidget(text_field);
|
multiline_layout -> addWidget(text_field);
|
||||||
|
multiline_layout -> addWidget(size_text);
|
||||||
|
multiline_layout -> addWidget(text_size_sb);
|
||||||
|
|
||||||
QGridLayout *rotate_text_layout = new QGridLayout;
|
QGridLayout *rotate_text_layout = new QGridLayout;
|
||||||
QLabel *rotate_label = new QLabel(tr("Rotation du texte sur conducteur :"));
|
QLabel *rotate_label = new QLabel(tr("Rotation du texte sur conducteur :"));
|
||||||
@@ -179,6 +184,7 @@ void ConductorPropertiesWidget::buildConnections() {
|
|||||||
connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
||||||
connect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
connect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
||||||
connect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
connect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
||||||
|
connect(text_size_sb, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,6 +231,7 @@ void ConductorPropertiesWidget::destroyConnections() {
|
|||||||
disconnect(line_style, SIGNAL(currentIndexChanged(int)), this, SLOT(updateConfig()));
|
disconnect(line_style, SIGNAL(currentIndexChanged(int)), this, SLOT(updateConfig()));
|
||||||
disconnect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
disconnect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
||||||
disconnect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
disconnect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig()));
|
||||||
|
disconnect(text_size_sb, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -239,6 +246,7 @@ void ConductorPropertiesWidget::updateConfig() {
|
|||||||
properties_.color = colorButton();
|
properties_.color = colorButton();
|
||||||
properties_.style = static_cast<Qt::PenStyle>(line_style -> itemData(line_style -> currentIndex()).toInt());
|
properties_.style = static_cast<Qt::PenStyle>(line_style -> itemData(line_style -> currentIndex()).toInt());
|
||||||
properties_.text = text_field -> text();
|
properties_.text = text_field -> text();
|
||||||
|
properties_.text_size = text_size_sb->value();
|
||||||
properties_.verti_rotate_text = verti_select -> value();
|
properties_.verti_rotate_text = verti_select -> value();
|
||||||
properties_.horiz_rotate_text = horiz_select -> value();
|
properties_.horiz_rotate_text = horiz_select -> value();
|
||||||
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
|
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
|
||||||
@@ -258,6 +266,7 @@ void ConductorPropertiesWidget::updateDisplay() {
|
|||||||
int index = line_style -> findData(properties_.style);
|
int index = line_style -> findData(properties_.style);
|
||||||
if (index != -1) line_style -> setCurrentIndex(index);
|
if (index != -1) line_style -> setCurrentIndex(index);
|
||||||
text_field -> setText(properties_.text);
|
text_field -> setText(properties_.text);
|
||||||
|
text_size_sb -> setValue(properties_.text_size);
|
||||||
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
|
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
|
||||||
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
|
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
|
||||||
merge_checkbox -> setChecked(properties_.singleLineProperties.is_pen);
|
merge_checkbox -> setChecked(properties_.singleLineProperties.is_pen);
|
||||||
@@ -338,6 +347,7 @@ void ConductorPropertiesWidget::setReadOnly(bool ro) {
|
|||||||
multiline -> setDisabled(ro);
|
multiline -> setDisabled(ro);
|
||||||
singleline -> setDisabled(ro);
|
singleline -> setDisabled(ro);
|
||||||
text_field -> setReadOnly(ro);
|
text_field -> setReadOnly(ro);
|
||||||
|
text_size_sb -> setReadOnly(ro);
|
||||||
phase_checkbox -> setDisabled(ro);
|
phase_checkbox -> setDisabled(ro);
|
||||||
phase_spinbox -> setReadOnly(ro);
|
phase_spinbox -> setReadOnly(ro);
|
||||||
ground_checkbox -> setDisabled(ro);
|
ground_checkbox -> setDisabled(ro);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class ConductorPropertiesWidget : public QWidget {
|
|||||||
QPushButton *color_button;
|
QPushButton *color_button;
|
||||||
QComboBox *line_style;
|
QComboBox *line_style;
|
||||||
QCheckBox *merge_checkbox;
|
QCheckBox *merge_checkbox;
|
||||||
|
QSpinBox *text_size_sb;
|
||||||
|
|
||||||
ConductorProperties properties_;
|
ConductorProperties properties_;
|
||||||
|
|
||||||
|
|||||||
@@ -1213,7 +1213,9 @@ QString Conductor::text() const {
|
|||||||
@param t Nouveau texte du conducteur
|
@param t Nouveau texte du conducteur
|
||||||
*/
|
*/
|
||||||
void Conductor::setText(const QString &t) {
|
void Conductor::setText(const QString &t) {
|
||||||
|
text_item -> setFontSize(properties_.text_size);
|
||||||
text_item -> setPlainText(t);
|
text_item -> setPlainText(t);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param p les proprietes de ce conducteur
|
/// @param p les proprietes de ce conducteur
|
||||||
|
|||||||
@@ -184,6 +184,10 @@ QPointF DiagramTextItem::mapMovementFromParent(const QPointF &movement) const {
|
|||||||
return(local_movement_point - local_origin);
|
return(local_movement_point - local_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagramTextItem::setFontSize(int &s) {
|
||||||
|
setFont(QETApp::diagramTextsFont(s));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine le champ de texte.
|
Dessine le champ de texte.
|
||||||
Cette methode delegue simplement le travail a QGraphicsTextItem::paint apres
|
Cette methode delegue simplement le travail a QGraphicsTextItem::paint apres
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
QPointF mapMovementFromScene(const QPointF &) const;
|
QPointF mapMovementFromScene(const QPointF &) const;
|
||||||
QPointF mapMovementToParent(const QPointF &) const;
|
QPointF mapMovementToParent(const QPointF &) const;
|
||||||
QPointF mapMovementFromParent(const QPointF &) const;
|
QPointF mapMovementFromParent(const QPointF &) const;
|
||||||
|
void setFontSize(int &s);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
|
|||||||
Reference in New Issue
Block a user