mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Diagram text item : remove the function fontSize, and use instead font
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5765 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1515,7 +1515,9 @@ void Conductor::setProperties(const ConductorProperties &property)
|
||||
}
|
||||
|
||||
m_text_item->setPlainText(m_properties.text);
|
||||
m_text_item->setFontSize(m_properties.text_size);
|
||||
QFont font = m_text_item->font();
|
||||
font.setPointSize(m_properties.text_size);
|
||||
m_text_item->setFont(font);
|
||||
|
||||
if (m_properties.type != ConductorProperties::Multi)
|
||||
m_text_item->setVisible(false);
|
||||
|
||||
@@ -150,21 +150,6 @@ QPointF DiagramTextItem::mapMovementFromParent(const QPointF &movement) const {
|
||||
return(local_movement_point - local_origin);
|
||||
}
|
||||
|
||||
void DiagramTextItem::setFontSize(int s)
|
||||
{
|
||||
prepareAlignment();
|
||||
QFont font_ = font();
|
||||
font_.setPointSize(s);
|
||||
setFont(font_);
|
||||
finishAlignment();
|
||||
emit fontSizeChanged(s);
|
||||
}
|
||||
|
||||
int DiagramTextItem::fontSize() const
|
||||
{
|
||||
return font().pointSize();
|
||||
}
|
||||
|
||||
void DiagramTextItem::setFont(const QFont &font)
|
||||
{
|
||||
if (this->font() == font) {
|
||||
|
||||
@@ -34,7 +34,6 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText)
|
||||
@@ -42,7 +41,6 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
|
||||
|
||||
signals:
|
||||
void fontSizeChanged(int size);
|
||||
void colorChanged(QColor color);
|
||||
void alignmentChanged(Qt::Alignment alignment);
|
||||
void textEdited(const QString &old_str, const QString &new_str);
|
||||
@@ -69,9 +67,6 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
QPointF mapMovementToParent (const QPointF &) const;
|
||||
QPointF mapMovementFromParent (const QPointF &) const;
|
||||
|
||||
void setFontSize(int s);
|
||||
int fontSize()const;
|
||||
|
||||
void setFont(const QFont &font);
|
||||
|
||||
void setColor(const QColor& color);
|
||||
|
||||
@@ -511,7 +511,9 @@ bool Element::parseInput(const QDomElement &dom_element)
|
||||
{
|
||||
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
||||
deti->setText(dom_element.attribute("text", "_"));
|
||||
deti->setFontSize(dom_element.attribute("size", QString::number(9)).toInt());
|
||||
QFont font = deti->font();
|
||||
font.setPointSize(dom_element.attribute("size", QString::number(9)).toInt());
|
||||
deti->setFont(font);
|
||||
deti->setRotation(dom_element.attribute("rotation", QString::number(0)).toDouble());
|
||||
|
||||
if(dom_element.attribute("tagg", "none") != "none")
|
||||
@@ -903,7 +905,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
comment_text = new DynamicElementTextItem(this);
|
||||
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
comment_text->setInfoName("comment");
|
||||
comment_text->setFontSize(6);
|
||||
QFont font = comment_text->font();
|
||||
font.setPointSize(6);
|
||||
comment_text->setFont(font);
|
||||
comment_text->setFrame(true);
|
||||
if(comment_text->toPlainText().count() > 17)
|
||||
comment_text->setTextWidth(80);
|
||||
@@ -922,7 +926,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
location_text = new DynamicElementTextItem(this);
|
||||
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
location_text->setInfoName("location");
|
||||
location_text->setFontSize(6);
|
||||
QFont font = location_text->font();
|
||||
font.setPointSize(6);
|
||||
location_text->setFont(font);
|
||||
if(location_text->toPlainText().count() > 17)
|
||||
location_text->setTextWidth(80);
|
||||
location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
|
||||
@@ -966,7 +972,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
comment_text = new DynamicElementTextItem(this);
|
||||
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
comment_text->setInfoName("comment");
|
||||
comment_text->setFontSize(6);
|
||||
QFont font = comment_text->font();
|
||||
font.setPointSize(6);
|
||||
comment_text->setFont(font);
|
||||
comment_text->setFrame(true);
|
||||
comment_text->setTextWidth(80);
|
||||
addDynamicTextItem(comment_text);
|
||||
@@ -978,7 +986,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
location_text = new DynamicElementTextItem(this);
|
||||
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
location_text->setInfoName("location");
|
||||
location_text->setFontSize(6);
|
||||
QFont font = location_text->font();
|
||||
font.setPointSize(6);
|
||||
location_text->setFont(font);
|
||||
location_text->setTextWidth(80);
|
||||
if(comment_text)
|
||||
location_text->setPos(comment_text->x(), comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment
|
||||
|
||||
@@ -67,7 +67,7 @@ void ElementTextItemGroup::addToGroup(QGraphicsItem *item)
|
||||
updateAlignment();
|
||||
|
||||
DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item);
|
||||
connect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
connect(deti, &DynamicElementTextItem::fontChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
connect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
connect(deti, &DynamicElementTextItem::textFromChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
connect(deti, &DynamicElementTextItem::infoNameChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
@@ -98,7 +98,7 @@ void ElementTextItemGroup::removeFromGroup(QGraphicsItem *item)
|
||||
|
||||
if(DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item))
|
||||
{
|
||||
disconnect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
disconnect(deti, &DynamicElementTextItem::fontChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
disconnect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
disconnect(deti, &DynamicElementTextItem::textFromChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
disconnect(deti, &DynamicElementTextItem::infoNameChanged, this, &ElementTextItemGroup::updateAlignment);
|
||||
@@ -453,11 +453,11 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
}
|
||||
if(m_frame)
|
||||
{
|
||||
int font_size = 1;
|
||||
qreal font_size = 1;
|
||||
QRectF rect;
|
||||
for(DynamicElementTextItem *deti : this->texts())
|
||||
{
|
||||
font_size = std::max(font_size, deti->fontSize());
|
||||
font_size = std::max(font_size, deti->font().pointSizeF());
|
||||
rect = rect.united(mapFromItem(deti, deti->frameRect()).boundingRect());
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
qreal w=0.3;
|
||||
if (font_size >= 5)
|
||||
{
|
||||
w = (qreal)font_size*0.1;
|
||||
w = font_size*0.1;
|
||||
if(w > 2.5)
|
||||
w = 2.5;
|
||||
}
|
||||
@@ -477,7 +477,7 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
//Adjust the rounding of the rectangle according to the size of the font
|
||||
qreal ro = (qreal)font_size/3;
|
||||
qreal ro = font_size/3;
|
||||
painter->drawRoundedRect(rect, ro, ro);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@@ -488,8 +488,9 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem
|
||||
int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt();
|
||||
if (fs != deti->font().pointSize())
|
||||
{
|
||||
QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "fontSize", QVariant(deti->font().pointSize()), QVariant(fs), undo);
|
||||
quc->setAnimated(true, false);
|
||||
QFont font = deti->font();
|
||||
font.setPointSize(fs);
|
||||
QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "font", QVariant(deti->font()), QVariant(font), undo);
|
||||
quc->setText(tr("Modifier la taille d'un texte d'élément"));
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text)
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::xChanged, this, &IndiTextPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::yChanged, this, &IndiTextPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::rotationChanged, this, &IndiTextPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::fontSizeChanged, this, &IndiTextPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::fontChanged, this, &IndiTextPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_text.data(), &IndependentTextItem::textEdited, this, &IndiTextPropertiesWidget::updateUi);
|
||||
|
||||
updateUi();
|
||||
@@ -192,9 +192,10 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
||||
undo = new QPropertyUndoCommand(m_text.data(), "plainText", m_text->toPlainText(), ui->m_line_edit->text());
|
||||
undo->setText(tr("Modifier un champ texte"));
|
||||
}
|
||||
if (ui->m_size_sb->value() != m_text->fontSize()) {
|
||||
undo = new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value());
|
||||
undo->setAnimated(true, false);
|
||||
if (ui->m_size_sb->value() != m_text->font().pointSize()) {
|
||||
QFont font = m_text->font();
|
||||
font.setPointSize(ui->m_size_sb->value());
|
||||
undo = new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font);
|
||||
undo->setText(tr("Modifier la taille d'un champ texte"));
|
||||
}
|
||||
|
||||
@@ -206,13 +207,13 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
||||
bool size_equal = true;
|
||||
bool angle_equal = true;
|
||||
qreal rotation_ = m_text_list.first()->rotation();
|
||||
int size_ = m_text_list.first()->fontSize();
|
||||
int size_ = m_text_list.first()->font().pointSize();
|
||||
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||
{
|
||||
if (piti->rotation() != rotation_) {
|
||||
angle_equal = false;
|
||||
}
|
||||
if (piti->fontSize() != size_) {
|
||||
if (piti->font().pointSize() != size_) {
|
||||
size_equal = false;
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,9 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
||||
if (!parent_undo) {
|
||||
parent_undo = new QUndoCommand(tr("Modifier la taille de plusieurs champs texte"));
|
||||
}
|
||||
QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "fontSize", QVariant(piti->fontSize()), QVariant(ui->m_size_sb->value()), parent_undo);
|
||||
QFont font = piti->font();
|
||||
font.setPointSize(ui->m_size_sb->value());
|
||||
QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "font", QVariant(piti->font()), QVariant(font), parent_undo);
|
||||
qpuc->setAnimated(true, false);
|
||||
}
|
||||
}
|
||||
@@ -266,8 +269,11 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
||||
if (ui->m_line_edit->text() != m_text->toPlainText()) {
|
||||
new ChangeDiagramTextCommand(m_text.data(), m_text->toHtml(), ui->m_line_edit->text(), undo);
|
||||
}
|
||||
if (ui->m_size_sb->value() != m_text->fontSize()) {
|
||||
new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value(), undo);
|
||||
if (ui->m_size_sb->value() != m_text->font().pointSize())
|
||||
{
|
||||
QFont font = m_text->font();
|
||||
font.setPointSize(ui->m_size_sb->value());
|
||||
new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font, undo);
|
||||
}
|
||||
|
||||
if (undo->childCount()) {
|
||||
@@ -329,7 +335,7 @@ void IndiTextPropertiesWidget::updateUi()
|
||||
ui->m_y_sb->setValue(m_text->pos().y());
|
||||
ui->m_line_edit->setText(m_text->toPlainText());
|
||||
ui->m_angle_sb->setValue(m_text->rotation());
|
||||
ui->m_size_sb->setValue(m_text->fontSize());
|
||||
ui->m_size_sb->setValue(m_text->font().pointSize());
|
||||
|
||||
ui->m_line_edit->setDisabled(m_text->isHtml() ? true : false);
|
||||
ui->m_size_sb->setDisabled(m_text->isHtml() ? true : false);
|
||||
@@ -341,13 +347,13 @@ void IndiTextPropertiesWidget::updateUi()
|
||||
bool size_equal = true;
|
||||
bool angle_equal = true;
|
||||
qreal rotation_ = m_text_list.first()->rotation();
|
||||
int size_ = m_text_list.first()->fontSize();
|
||||
int size_ = m_text_list.first()->font().pointSize();
|
||||
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||
{
|
||||
if (piti->rotation() != rotation_) {
|
||||
angle_equal = false;
|
||||
}
|
||||
if (piti->fontSize() != size_) {
|
||||
if (piti->font().pointSize() != size_) {
|
||||
size_equal = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user