Fix indentation code

This commit is contained in:
Laurent Trinques
2020-07-15 20:20:07 +02:00
parent 6313319f80
commit 68e78a0de9
38 changed files with 2625 additions and 2625 deletions

View File

@@ -106,7 +106,7 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
if (!new_part)
{
if (part)
disconnectChangeConnections();
disconnectChangeConnections();
part = nullptr;
style_ -> setPart(nullptr);
@@ -117,11 +117,11 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
{
if (part == part_arc) return true;
if (part)
disconnectChangeConnections();
disconnectChangeConnections();
part = part_arc;
style_ -> setPart(part);
updateForm();
setUpChangeConnections();
setUpChangeConnections();
return(true);
}
@@ -130,12 +130,12 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
bool ArcEditor::setParts(QList <CustomElementPart *> parts)
{
if (parts.isEmpty())
return false;
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
}
/**
@@ -147,7 +147,7 @@ CustomElementPart *ArcEditor::currentPart() const {
}
QList<CustomElementPart*> ArcEditor::currentParts() const {
return style_->currentParts();
return style_->currentParts();
}
/**
@@ -158,20 +158,20 @@ void ArcEditor::updateArcS()
{
if (m_locked) return;
m_locked = true;
double value = start_angle->value() * 16;
double value = start_angle->value() * 16;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
PartArc* arc = static_cast<PartArc*>(part);
if (value != arc->property("startAngle"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "startAngle", arc->property("startAngle"), value);
undo->setText("Modifier l'angle de depart d'un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (value != arc->property("startAngle"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "startAngle", arc->property("startAngle"), value);
undo->setText("Modifier l'angle de depart d'un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -186,17 +186,17 @@ void ArcEditor::updateArcA()
m_locked = true;
double value = angle->value() * 16;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
if (value != arc->property("spanAngle"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "spanAngle", arc->property("spanAngle"), value);
undo->setText("Modifier l'angle d'un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
PartArc* arc = static_cast<PartArc*>(part);
if (value != arc->property("spanAngle"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "spanAngle", arc->property("spanAngle"), value);
undo->setText("Modifier l'angle d'un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -210,95 +210,95 @@ void ArcEditor::updateArcRectX()
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2); // does not matter which value y is, because only the x value is used
rect.setX(point.x()); // change only the x value
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2); // does not matter which value y is, because only the x value is used
rect.setX(point.x()); // change only the x value
if (rect != part->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (rect != part->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void ArcEditor::updateArcRectY()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
rect.setY(point.y());
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
rect.setY(point.y());
if (rect != arc->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
if (rect != arc->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
}
m_locked = false;
m_locked = false;
}
void ArcEditor::updateArcRectH()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
if (rect.width() != h->value())
{
rect.setWidth(h->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (rect.width() != h->value())
{
rect.setWidth(h->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
void ArcEditor::updateArcRectV()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
if (rect.height() != v->value())
{
rect.setHeight(v->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (rect.height() != v->value())
{
rect.setHeight(v->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
/**
@@ -329,19 +329,19 @@ void ArcEditor::activeConnections(bool active)
{
if (active)
{
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
connect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
connect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
}
else
{
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
disconnect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
disconnect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
}

View File

@@ -47,31 +47,31 @@ class ArcEditor : public ElementItemEditor
QSpinBox *angle, *start_angle;
bool m_locked;
QList <QMetaObject::Connection> m_change_connections;
QList <QMetaObject::Connection> m_change_connections;
// methods
public:
bool setPart(CustomElementPart *) override;
bool setParts(QList <CustomElementPart *> parts) override;
bool setParts(QList <CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QList<CustomElementPart*> currentParts() const override;
public slots:
void updateArcS();
void updateArcA();
void updateArcRectX();
void updateArcRectY();
void updateArcRectH();
void updateArcRectV();
void updateArcRectX();
void updateArcRectY();
void updateArcRectH();
void updateArcRectV();
void updateForm() override;
private:
void activeConnections(bool);
/*!
* \brief setUpChangeConnections
* Setup the connection from the arc(s) to the widget, to update it when the arc(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
/*!
* \brief setUpChangeConnections
* Setup the connection from the arc(s) to the widget, to update it when the arc(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
};
#endif

View File

@@ -417,7 +417,7 @@ void ElementView::wheelEvent(QWheelEvent *e) {
if (e -> modifiers() & Qt::ControlModifier)
e -> angleDelta().y() > 0 ? zoomInSlowly() : zoomOutSlowly();
else
QGraphicsView::wheelEvent(e);
QGraphicsView::wheelEvent(e);
} else {
e -> angleDelta().y() > 0 ? zoomIn(): zoomOut();
}

View File

@@ -96,7 +96,7 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
if (!new_part)
{
if (part)
disconnectChangeConnections();
disconnectChangeConnections();
part = nullptr;
style_ -> setPart(nullptr);
return(true);
@@ -105,11 +105,11 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
{
if (part == part_ellipse) return true;
if (part)
disconnectChangeConnections();
disconnectChangeConnections();
part = part_ellipse;
style_ -> setPart(part);
updateForm();
setUpChangeConnections();
setUpChangeConnections();
return(true);
}
return(false);
@@ -117,12 +117,12 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
bool EllipseEditor::setParts(QList <CustomElementPart *> parts)
{
if (parts.isEmpty())
return false;
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
}
/**
@@ -138,98 +138,98 @@ QList<CustomElementPart*> EllipseEditor::currentParts() const {
void EllipseEditor::editingFinishedX()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2); // does not matter which value y is, because only the x value is used
rect.setX(point.x()); // change only the x value
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2); // does not matter which value y is, because only the x value is used
rect.setX(point.x()); // change only the x value
if (rect != part->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (rect != part->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
void EllipseEditor::editingFinishedY()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
rect.setY(point.y());
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
rect.setY(point.y());
if (rect != ell->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
if (rect != ell->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
m_locked = false;
}
void EllipseEditor::editingFinishedH()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
if (rect.width() != h->value())
{
rect.setWidth(h->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
if (rect.width() != h->value())
{
rect.setWidth(h->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
void EllipseEditor::editingFinishedV()
{
if (m_locked) return;
m_locked = true;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
if (rect.height() != v->value())
{
rect.setHeight(v->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartEllipse* ell = static_cast<PartEllipse*>(part);
QRectF rect = ell->property("rect").toRectF();
if (rect.height() != v->value())
{
rect.setHeight(v->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
/**
@@ -255,16 +255,16 @@ void EllipseEditor::activeConnections(bool active)
{
if (active)
{
connect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
connect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
connect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
connect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
connect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
connect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
connect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
connect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
}
else
{
disconnect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
disconnect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
disconnect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
disconnect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
disconnect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
disconnect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
disconnect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
disconnect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
}
}

View File

@@ -44,29 +44,29 @@ class EllipseEditor : public ElementItemEditor
StyleEditor *style_;
QDoubleSpinBox *x, *y, *h, *v;
bool m_locked;
QList <QMetaObject::Connection> m_change_connections;
QList <QMetaObject::Connection> m_change_connections;
// methods
public:
bool setPart(CustomElementPart *) override;
bool setParts(QList <CustomElementPart *> parts) override;
bool setParts(QList <CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QList<CustomElementPart*> currentParts() const override;
public slots:
void editingFinishedX();
void editingFinishedY();
void editingFinishedH();
void editingFinishedV();
void editingFinishedX();
void editingFinishedY();
void editingFinishedH();
void editingFinishedV();
void updateForm() override;
private:
void activeConnections(bool);
/*!
* \brief setUpChangeConnections
* Setup the connection from the ellipse(s) to the widget, to update it when the ellipse(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
/*!
* \brief setUpChangeConnections
* Setup the connection from the ellipse(s) to the widget, to update it when the ellipse(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
};
#endif

View File

@@ -265,11 +265,11 @@ void PartPolygon::setClosed(bool close)
*/
void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
{
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
if (qghi->pos() == mapToScene(pos)) {
qghi->setColor(color);
}
}
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
if (qghi->pos() == mapToScene(pos)) {
qghi->setColor(color);
}
}
}
/**
@@ -278,9 +278,9 @@ void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
*/
void PartPolygon::resetAllHandlerColor()
{
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
qghi->setColor(Qt::blue);
}
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
qghi->setColor(Qt::blue);
}
}
/**

View File

@@ -122,7 +122,7 @@ bool LineEditor::setPart(CustomElementPart *new_part)
{
if (part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
part = nullptr;
style_ -> setPart(nullptr);
@@ -133,12 +133,12 @@ bool LineEditor::setPart(CustomElementPart *new_part)
if (part == part_line) return true;
if (part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
part = part_line;
style_ -> setPart(part);
updateForm();
setUpChangeConnections();
setUpChangeConnections();
return(true);
}
return(false);
@@ -146,12 +146,12 @@ bool LineEditor::setPart(CustomElementPart *new_part)
bool LineEditor::setParts(QList <CustomElementPart *> parts)
{
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
}
/**
@@ -187,18 +187,18 @@ void LineEditor::updateLineEndType1()
if (m_locked) return;
m_locked = true;
QVariant end = end1_type -> itemData(end1_type->currentIndex());
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (end != line->property("end1"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end1", line->property("end1"), end);
undo->setText(tr("Modifier une ligne"));
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (end != line->property("end1"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end1", line->property("end1"), end);
undo->setText(tr("Modifier une ligne"));
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -208,19 +208,19 @@ void LineEditor::updateLineEndLength1()
if (m_locked) return;
m_locked = true;
double length = end1_length->value();
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (length != line->property("length1"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length1", line->property("length1"), length);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (length != line->property("length1"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length1", line->property("length1"), length);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -230,18 +230,18 @@ void LineEditor::updateLineEndType2()
if (m_locked) return;
m_locked = true;
QVariant end = end2_type -> itemData(end2_type->currentIndex());
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (end != line->property("end2"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end2", line->property("end2"), end);
undo->setText(tr("Modifier une ligne"));
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (end != line->property("end2"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end2", line->property("end2"), end);
undo->setText(tr("Modifier une ligne"));
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -251,19 +251,19 @@ void LineEditor::updateLineEndLength2()
if (m_locked) return;
m_locked = true;
double length = end2_length->value();
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (length != line->property("length2"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length2", line->property("length2"), length);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
if (length != line->property("length2"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length2", line->property("length2"), length);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -271,100 +271,100 @@ void LineEditor::lineEditingFinishedX1()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
if (p1.x() != line.p1().x())
{
p1.setY(line.p1().y()); // restore old y value
line.setP1(p1);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
if (p1.x() != line.p1().x())
{
p1.setY(line.p1().y()); // restore old y value
line.setP1(p1);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void LineEditor::lineEditingFinishedY1()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
if (p1.y() != line.p1().y())
{
p1.setX(line.p1().x()); // restore old x value
line.setP1(p1);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
if (p1.y() != line.p1().y())
{
p1.setX(line.p1().x()); // restore old x value
line.setP1(p1);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void LineEditor::lineEditingFinishedX2()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
if (p2.x() != line.p1().x())
{
p2.setY(line.p2().y()); // restore old y value
line.setP2(p2);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
if (p2.x() != line.p1().x())
{
p2.setY(line.p2().y()); // restore old y value
line.setP2(p2);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void LineEditor::lineEditingFinishedY2()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
if (p2.y() != line.p1().y())
{
p2.setX(line.p2().x()); // restore old y value
line.setP2(p2);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
if (p2.y() != line.p1().y())
{
p2.setX(line.p2().x()); // restore old y value
line.setP2(p2);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
undo->setText(tr("Modifier une ligne"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
/**
@@ -398,10 +398,10 @@ void LineEditor::activeConnections(bool active)
{
if (active)
{
connect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
connect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
connect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
connect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
connect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
connect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
connect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
connect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
connect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
connect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
connect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
@@ -409,10 +409,10 @@ void LineEditor::activeConnections(bool active)
}
else
{
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
disconnect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
disconnect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
disconnect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));

View File

@@ -46,14 +46,14 @@ class LineEditor : public ElementItemEditor
QComboBox *end1_type, *end2_type;
QDoubleSpinBox*end1_length, *end2_length;
bool m_locked;
QList <QMetaObject::Connection> m_change_connections;
QList <QMetaObject::Connection> m_change_connections;
// methods
public:
bool setPart(CustomElementPart *) override;
bool setParts(QList <CustomElementPart *> parts) override;
bool setParts(QList <CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedP1() const;
QPointF editedP2() const;
@@ -62,19 +62,19 @@ class LineEditor : public ElementItemEditor
void updateLineEndLength1();
void updateLineEndType2();
void updateLineEndLength2();
void lineEditingFinishedX1();
void lineEditingFinishedY1();
void lineEditingFinishedX2();
void lineEditingFinishedY2();
void lineEditingFinishedX1();
void lineEditingFinishedY1();
void lineEditingFinishedX2();
void lineEditingFinishedY2();
void updateForm() override;
private:
private:
void activeConnections(bool);
/*!
* \brief setUpChangeConnections
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
/*!
* \brief setUpChangeConnections
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
};
#endif

View File

@@ -610,119 +610,119 @@ void QETElementEditor::slot_setNoDragToView() {
void QETElementEditor::slot_updateInformations()
{
QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
if (selected_qgis.isEmpty()) {
clearToolsDock();
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
"",
selected_qgis.size()));
m_default_informations -> setAlignment(Qt::AlignHCenter | Qt::AlignTop);
m_tools_dock_stack -> setCurrentIndex(0);
return;
}
if (selected_qgis.isEmpty()) {
clearToolsDock();
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
"",
selected_qgis.size()));
m_default_informations -> setAlignment(Qt::AlignHCenter | Qt::AlignTop);
m_tools_dock_stack -> setCurrentIndex(0);
return;
}
QList<CustomElementPart *> cep_list;
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
QString selection_xml_name = part->xmlName();
bool same_xml_name = true;
bool style_editable = true;
for (QGraphicsItem *qgi: selected_qgis) {
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
cep_list << cep;
if (cep->xmlName() != selection_xml_name)
same_xml_name = false;
} else {
style_editable = false;
same_xml_name = false;
}
}
if (style_editable)
style_editable = StyleEditor::isStyleEditable(cep_list);
if (same_xml_name) {
if (selection_xml_name == "terminal" ||
selection_xml_name == "text" ||
selection_xml_name == "dynamic_text" ||
selection_xml_name == "line" ||
selection_xml_name == "rect" ||
selection_xml_name == "ellipse" ||
selection_xml_name == "arc") {
clearToolsDock();
//We add the editor widget
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
// TODO: Check if it takes longer than setting the parts again to the editor.
bool equal = true;
QList<CustomElementPart*> parts = editor->currentParts();
if (parts.length() == cep_list.length()) {
for (auto cep: cep_list) {
bool part_found = false;
for (auto part: parts) {
if (part == cep) {
part_found = true;
break;
}
}
if (!part_found) {
equal = false;
break;
}
}
} else
equal = false;
if (editor)
{
bool success = true;
if (equal == false) {
success = editor->setParts(cep_list);
}
if (success)
{
m_tools_dock_stack->insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
qDebug() << "Editor refused part.";
}
}
return;
} else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
// multi edit for polygons makes no sense
// TODO: maybe allowing multipart edit when number of points is the same?
//We add the editor widget
clearToolsDock();
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
CustomElementPart* part = editor->currentPart();
bool equal = part == cep_list.first();
if (editor)
{
bool success = true;
if (equal == false) {
success = editor->setPart(cep_list.first());
}
if (success)
{
m_tools_dock_stack->insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
qDebug() << "Editor refused part.";
}
}
return;
} else {
qDebug() << "Multiedit not supported for: " << cep_list.first()->xmlName();
}
}
//There's several parts selecteds and all can be edited by style editor.
if (style_editable)
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
QString selection_xml_name = part->xmlName();
bool same_xml_name = true;
bool style_editable = true;
for (QGraphicsItem *qgi: selected_qgis) {
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
cep_list << cep;
if (cep->xmlName() != selection_xml_name)
same_xml_name = false;
} else {
style_editable = false;
same_xml_name = false;
}
}
if (style_editable)
style_editable = StyleEditor::isStyleEditable(cep_list);
if (same_xml_name) {
if (selection_xml_name == "terminal" ||
selection_xml_name == "text" ||
selection_xml_name == "dynamic_text" ||
selection_xml_name == "line" ||
selection_xml_name == "rect" ||
selection_xml_name == "ellipse" ||
selection_xml_name == "arc") {
clearToolsDock();
//We add the editor widget
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
// TODO: Check if it takes longer than setting the parts again to the editor.
bool equal = true;
QList<CustomElementPart*> parts = editor->currentParts();
if (parts.length() == cep_list.length()) {
for (auto cep: cep_list) {
bool part_found = false;
for (auto part: parts) {
if (part == cep) {
part_found = true;
break;
}
}
if (!part_found) {
equal = false;
break;
}
}
} else
equal = false;
if (editor)
{
bool success = true;
if (equal == false) {
success = editor->setParts(cep_list);
}
if (success)
{
m_tools_dock_stack->insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
qDebug() << "Editor refused part.";
}
}
return;
} else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
// multi edit for polygons makes no sense
// TODO: maybe allowing multipart edit when number of points is the same?
//We add the editor widget
clearToolsDock();
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
CustomElementPart* part = editor->currentPart();
bool equal = part == cep_list.first();
if (editor)
{
bool success = true;
if (equal == false) {
success = editor->setPart(cep_list.first());
}
if (success)
{
m_tools_dock_stack->insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
qDebug() << "Editor refused part.";
}
}
return;
} else {
qDebug() << "Multiedit not supported for: " << cep_list.first()->xmlName();
}
}
//There's several parts selecteds and all can be edited by style editor.
if (style_editable)
{
clearToolsDock();
ElementItemEditor *selection_editor = m_editors["style"];

View File

@@ -98,22 +98,22 @@ TerminalEditor::~TerminalEditor() {
*/
bool TerminalEditor::setPart(CustomElementPart* new_part)
{
m_terminals.clear();
m_terminals.clear();
if (!new_part)
{
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = nullptr;
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(new_part))
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(new_part))
{
if(m_part == part_terminal) return true;
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = part_terminal;
if(m_part == part_terminal) return true;
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = part_terminal;
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
@@ -121,44 +121,44 @@ bool TerminalEditor::setPart(CustomElementPart* new_part)
bool TerminalEditor::setParts(QList<CustomElementPart *> parts)
{
if (parts.isEmpty())
{
m_terminals.clear();
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first()))
{
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = part_terminal;
m_terminals.clear();
m_terminals.append(part_terminal);
for (int i=1; i < parts.length(); i++)
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
if (parts.isEmpty())
{
m_terminals.clear();
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first()))
{
if (m_part)
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_part = part_terminal;
m_terminals.clear();
m_terminals.append(part_terminal);
for (int i=1; i < parts.length(); i++)
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
}
/**
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
*/
CustomElementPart *TerminalEditor::currentPart() const {
return(m_part);
return(m_part);
}
QList<CustomElementPart*> TerminalEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto term: m_terminals) {
parts.append(static_cast<CustomElementPart*>(term));
}
return parts;
QList<CustomElementPart*> parts;
for (auto term: m_terminals) {
parts.append(static_cast<CustomElementPart*>(term));
}
return parts;
}
/// Met a jour l'orientation de la borne et cree un objet d'annulation
@@ -167,53 +167,53 @@ void TerminalEditor::updateTerminalO()
if (m_locked) return;
m_locked = true;
QVariant var(orientation -> itemData(orientation -> currentIndex()));
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("orientation"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
}
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("orientation"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
}
m_locked = false;
}
void TerminalEditor::updateXPos() {
if (m_locked) return;
m_locked = true;
QPointF new_pos(qle_x->value(), 0);
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setY(term->pos().y()); // change only x value
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
if (m_locked) return;
m_locked = true;
QPointF new_pos(qle_x->value(), 0);
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setY(term->pos().y()); // change only x value
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
void TerminalEditor::updateYPos() {
if (m_locked) return;
m_locked = true;
QPointF new_pos(0, qle_y->value()); // change only y value
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setX(term->pos().x());
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
if (m_locked) return;
m_locked = true;
QPointF new_pos(0, qle_y->value()); // change only y value
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setX(term->pos().x());
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
/// update Number and name, create cancel object
@@ -221,11 +221,11 @@ void TerminalEditor::updateYPos() {
Met a jour le formulaire d'edition
*/
void TerminalEditor::updateForm() {
if (!m_part) return;
if (!m_part) return;
activeConnections(false);
qle_x -> setValue(m_part->property("x").toReal());
qle_y -> setValue(m_part->property("y").toReal());
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
qle_x -> setValue(m_part->property("x").toReal());
qle_y -> setValue(m_part->property("y").toReal());
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
activeConnections(true);
}
@@ -237,14 +237,14 @@ void TerminalEditor::activeConnections(bool active)
{
if (active)
{
connect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
connect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
connect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
connect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
connect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
connect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
}
else
{
disconnect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
disconnect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
disconnect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
disconnect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
disconnect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
disconnect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
}
}

View File

@@ -58,7 +58,7 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
*/
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
{
disconnectConnections();
disconnectConnections();
QGraphicsItem *qgi = part->toItem();
if(!qgi)
@@ -69,40 +69,40 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
m_text_field = static_cast<PartDynamicTextField *>(qgi);
updateForm();
setUpConnections();
setUpConnections();
return true;
}
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
if (parts.isEmpty())
{
m_parts.clear();
if (m_text_field) {
disconnectConnections();
}
m_text_field = nullptr;
return true;
}
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
{
if (m_text_field) {
disconnectConnections();
}
m_text_field = part;
m_parts.clear();
m_parts.append(part);
for (int i=1; i < parts.length(); i++)
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
setUpConnections();
updateForm();
return true;
}
return(false);
if (parts.isEmpty())
{
m_parts.clear();
if (m_text_field) {
disconnectConnections();
}
m_text_field = nullptr;
return true;
}
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
{
if (m_text_field) {
disconnectConnections();
}
m_text_field = part;
m_parts.clear();
m_parts.append(part);
for (int i=1; i < parts.length(); i++)
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
setUpConnections();
updateForm();
return true;
}
return(false);
}
/**
@@ -115,11 +115,11 @@ CustomElementPart *DynamicTextFieldEditor::currentPart() const {
}
QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
}
void DynamicTextFieldEditor::updateForm()
@@ -156,26 +156,26 @@ void DynamicTextFieldEditor::updateForm()
}
void DynamicTextFieldEditor::setUpConnections() {
assert(m_connection_list.isEmpty());
//Setup the connection
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,[this]() {this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
assert(m_connection_list.isEmpty());
//Setup the connection
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged, [this](){this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,[this]() {this->updateForm();});
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
}
void DynamicTextFieldEditor::disconnectConnections() {
//Remove previous connection
if(!m_connection_list.isEmpty())
for(const QMetaObject::Connection& con : m_connection_list)
disconnect(con);
m_connection_list.clear();
//Remove previous connection
if(!m_connection_list.isEmpty())
for(const QMetaObject::Connection& con : m_connection_list)
disconnect(con);
m_connection_list.clear();
}
/**
@@ -206,101 +206,101 @@ void DynamicTextFieldEditor::fillInfoComboBox()
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
{
double value = ui->m_x_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
undo->setText(tr("Déplacer un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
double value = ui->m_x_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
undo->setText(tr("Déplacer un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
{
double value = ui->m_y_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
undo->setText(tr("Déplacer un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
double value = ui->m_y_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
undo->setText(tr("Déplacer un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
{
int value = ui->m_rotation_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
undo->setText(tr("Pivoter un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
int value = ui->m_rotation_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
undo->setText(tr("Pivoter un champ texte"));
undo->enableAnimation(true);
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
{
QString text = ui->m_user_text_le->text();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
undo->setText(tr("Modifier le texte d'un champ texte"));
undoStack().push(undo);
}
QString text = ui->m_user_text_le->text();
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
undo->setText(tr("Modifier le texte d'un champ texte"));
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
{
QFont font_ = m_text_field->font();
font_.setPointSize(ui->m_size_sb->value());
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
undo->setText(tr("Modifier la police d'un champ texte"));
undoStack().push(undo);
}
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
undo->setText(tr("Modifier la police d'un champ texte"));
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
{
bool frame = ui->m_frame_cb->isChecked();
bool frame = ui->m_frame_cb->isChecked();
for (int i = 0; i < m_parts.length(); i++) {
if(frame != m_parts[i]->frame())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
undo->setText(tr("Modifier le cadre d'un champ texte"));
undoStack().push(undo);
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(frame != m_parts[i]->frame())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
undo->setText(tr("Modifier le cadre d'un champ texte"));
undoStack().push(undo);
}
}
}
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
{
qreal width = (qreal)ui->m_width_sb->value();
qreal width = (qreal)ui->m_width_sb->value();
for (int i = 0; i < m_parts.length(); i++) {
if(width != m_parts[i]->textWidth())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
undo->setText(tr("Modifier la largeur d'un texte"));
undoStack().push(undo);
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(width != m_parts[i]->textWidth())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
undo->setText(tr("Modifier la largeur d'un texte"));
undoStack().push(undo);
}
}
}
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1)
{
Q_UNUSED(arg1)
Q_UNUSED(arg1)
QString info = ui->m_elmt_info_cb->currentData().toString();
for (int i = 0; i < m_parts.length(); i++) {
if(info != m_parts[i]->infoName())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
undo->setText(tr("Modifier l'information d'un texte"));
undoStack().push(undo);
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(info != m_parts[i]->infoName())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
undo->setText(tr("Modifier l'information d'un texte"));
undoStack().push(undo);
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
}
}
}
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
@@ -308,7 +308,7 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
ui->m_user_text_le->setDisabled(true);
ui->m_elmt_info_cb->setDisabled(true);
ui->m_composite_text_pb->setDisabled(true);
if(index == 0)
ui->m_user_text_le->setEnabled(true);
else if (index == 1)
@@ -321,14 +321,14 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
else if(index == 1) tf = DynamicElementTextItem::ElementInfo;
else tf = DynamicElementTextItem::CompositeText;
for (int i = 0; i < m_parts.length(); i++) {
if(tf != m_parts[i]->textFrom())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
undo->setText(tr("Modifier la source de texte, d'un texte"));
undoStack().push(undo);
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(tf != m_parts[i]->textFrom())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
undo->setText(tr("Modifier la source de texte, d'un texte"));
undoStack().push(undo);
}
}
}
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
@@ -337,29 +337,29 @@ void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
if(ctd.exec())
{
QString ct = ctd.plainText();
for (int i = 0; i < m_parts.length(); i++) {
if(ct != m_parts[i]->compositeText())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
undoStack().push(undo);
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(ct != m_parts[i]->compositeText())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
undoStack().push(undo);
}
}
}
}
void DynamicTextFieldEditor::on_m_alignment_pb_clicked()
{
AlignmentTextDialog atd(m_text_field.data()->alignment(), this);
AlignmentTextDialog atd(m_text_field.data()->alignment(), this);
atd.exec();
for (int i = 0; i < m_parts.length(); i++) {
if(atd.alignment() != m_parts[i]->alignment())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.alignment()));
undo->setText(tr("Modifier l'alignement d'un champ texte"));
undoStack().push(undo);
}
}
for (int i = 0; i < m_parts.length(); i++) {
if(atd.alignment() != m_parts[i]->alignment())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.alignment()));
undo->setText(tr("Modifier l'alignement d'un champ texte"));
undoStack().push(undo);
}
}
}
void DynamicTextFieldEditor::on_m_font_pb_clicked()
@@ -370,26 +370,26 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
{
ui->m_font_pb->setText(font_.family());
ui->m_size_sb->setValue(font_.pointSize());
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
undo->setText(tr("Modifier la police d'un champ texte"));
undoStack().push(undo);
}
for (int i = 0; i < m_parts.length(); i++) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
undo->setText(tr("Modifier la police d'un champ texte"));
undoStack().push(undo);
}
}
}
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
{
if (!newColor.isValid())
return;
for (int i = 0; i < m_parts.length(); i++) {
if(newColor != m_parts[i]->color())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
undo->setText(tr("Modifier la couleur d'un champ texte"));
undoStack().push(undo);
}
}
if (!newColor.isValid())
return;
for (int i = 0; i < m_parts.length(); i++) {
if(newColor != m_parts[i]->color())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
undo->setText(tr("Modifier la couleur d'un champ texte"));
undoStack().push(undo);
}
}
}

View File

@@ -73,30 +73,30 @@ void PolygonEditor::disconnectChangeConnections()
*/
bool PolygonEditor::setPart(CustomElementPart *new_part)
{
if (!new_part)
{
if (m_part)
{
disconnectChangeConnections();
}
m_part = nullptr;
m_style -> setPart(nullptr);
return(true);
}
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
{
if (m_part == part_polygon) return true;
if (m_part)
{
disconnectChangeConnections();
}
m_part = part_polygon;
m_style -> setPart(m_part);
updateForm();
setUpChangeConnections();
return(true);
}
return(false);
if (!new_part)
{
if (m_part)
{
disconnectChangeConnections();
}
m_part = nullptr;
m_style -> setPart(nullptr);
return(true);
}
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
{
if (m_part == part_polygon) return true;
if (m_part)
{
disconnectChangeConnections();
}
m_part = part_polygon;
m_style -> setPart(m_part);
updateForm();
setUpChangeConnections();
return(true);
}
return(false);
}
/**
@@ -143,35 +143,35 @@ void PolygonEditor::updateForm()
*/
QVector<QPointF> PolygonEditor::pointsFromTree()
{
QVector<QPointF> points;
if (!m_part) {
return points;
}
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
{
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
bool x_convert_ok, y_convert_ok;
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
if (x_convert_ok && y_convert_ok) {
points << m_part->mapFromScene(QPointF(x, y));
}
}
return(points);
QVector<QPointF> points;
if (!m_part) {
return points;
}
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
{
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
bool x_convert_ok, y_convert_ok;
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
if (x_convert_ok && y_convert_ok) {
points << m_part->mapFromScene(QPointF(x, y));
}
}
return(points);
}
bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
{
if (watched == ui->m_points_list_tree &&
event->type() == QEvent::FocusOut &&
m_part)
{
m_part->resetAllHandlerColor();
return true;
}
return false;
if (watched == ui->m_points_list_tree &&
event->type() == QEvent::FocusOut &&
m_part)
{
m_part->resetAllHandlerColor();
return true;
}
return false;
}
/**
@@ -179,18 +179,18 @@ bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
*/
void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
{
Q_UNUSED(arg1);
if (!m_part) {
return;
}
bool close = ui->m_close_polygon_cb->isChecked();
if (close != m_part->isClosed())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
undo->setText(tr("Modifier un polygone"));
undoStack().push(undo);
}
Q_UNUSED(arg1);
if (!m_part) {
return;
}
bool close = ui->m_close_polygon_cb->isChecked();
if (close != m_part->isClosed())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
undo->setText(tr("Modifier un polygone"));
undoStack().push(undo);
}
}
/**
@@ -199,26 +199,26 @@ void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
*/
void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column)
{
Q_UNUSED(item);
Q_UNUSED(column);
if (!m_part) {
return;
}
QPolygonF points = pointsFromTree();
if (points.count() < 2)
{
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content"));
return;
}
if (points != m_part->polygon())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
undo->setText(tr("Modifier un polygone"));
undoStack().push(undo);
}
Q_UNUSED(item);
Q_UNUSED(column);
if (!m_part) {
return;
}
QPolygonF points = pointsFromTree();
if (points.count() < 2)
{
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content"));
return;
}
if (points != m_part->polygon())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
undo->setText(tr("Modifier un polygone"));
undoStack().push(undo);
}
}
/**
@@ -227,76 +227,76 @@ void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int
*/
void PolygonEditor::on_m_points_list_tree_itemSelectionChanged()
{
//Prevent when selection change but the widget ins't focused
if (!ui->m_points_list_tree->hasFocus()) {
return;
}
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
m_part->resetAllHandlerColor();
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
//We need to check if index isn't out of range of polygon
//this case can occur when user remove the last point of the polygon
//with the context menu of the tree widget
if(index >= 0 &&
index < m_part->polygon().size())
{
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
}
//Prevent when selection change but the widget ins't focused
if (!ui->m_points_list_tree->hasFocus()) {
return;
}
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
m_part->resetAllHandlerColor();
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
//We need to check if index isn't out of range of polygon
//this case can occur when user remove the last point of the polygon
//with the context menu of the tree widget
if(index >= 0 &&
index < m_part->polygon().size())
{
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
}
}
void PolygonEditor::on_m_add_point_action_triggered()
{
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
QPolygonF new_polygon = m_part->polygon();
//Special case when user add a point after the last point of the polygon
if (index == m_part->polygon().size()-1)
{
QPointF p = m_part->polygon().last();
p.rx()+=20;
p.ry()+=20;
new_polygon.append(p);
}
else
{
QPointF p = m_part->polygon().at(index) +
m_part->polygon().at(index+1);
p/=2;
new_polygon.insert(index+1, p);
}
//Wrap the undo for avoid to merge the undo commands when user add several points.
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
elementScene()->undoStack().push(undo);
m_part->resetAllHandlerColor();
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
QPolygonF new_polygon = m_part->polygon();
//Special case when user add a point after the last point of the polygon
if (index == m_part->polygon().size()-1)
{
QPointF p = m_part->polygon().last();
p.rx()+=20;
p.ry()+=20;
new_polygon.append(p);
}
else
{
QPointF p = m_part->polygon().at(index) +
m_part->polygon().at(index+1);
p/=2;
new_polygon.insert(index+1, p);
}
//Wrap the undo for avoid to merge the undo commands when user add several points.
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
elementScene()->undoStack().push(undo);
m_part->resetAllHandlerColor();
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
}
void PolygonEditor::on_m_remove_point_action_triggered()
{
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
QPolygonF new_polygon = m_part->polygon();
new_polygon.removeAt(ui->m_points_list_tree->indexOfTopLevelItem(qtwi));
//Wrap the undo for avoid to merge the undo commands when user remove several points.
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
elementScene()->undoStack().push(undo);
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
if (!qtwi || !m_part) {
return;
}
QPolygonF new_polygon = m_part->polygon();
new_polygon.removeAt(ui->m_points_list_tree->indexOfTopLevelItem(qtwi));
//Wrap the undo for avoid to merge the undo commands when user remove several points.
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
elementScene()->undoStack().push(undo);
}

View File

@@ -30,39 +30,39 @@ namespace Ui {
class PolygonEditor : public ElementItemEditor
{
Q_OBJECT
public:
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
~PolygonEditor() override;
bool setPart(CustomElementPart *part) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
void updateForm() override;
QVector<QPointF> pointsFromTree();
bool eventFilter(QObject *watched, QEvent *event) override;
private slots:
void on_m_close_polygon_cb_stateChanged(int arg1);
void on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column);
void on_m_points_list_tree_itemSelectionChanged();
void on_m_add_point_action_triggered();
void on_m_remove_point_action_triggered();
private:
/*!
* \brief setUpChangeConnections
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
private:
Ui::PolygonEditor *ui;
StyleEditor *m_style = nullptr;
PartPolygon *m_part = nullptr;
QList <QMetaObject::Connection> m_change_connections;
Q_OBJECT
public:
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
~PolygonEditor() override;
bool setPart(CustomElementPart *part) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
void updateForm() override;
QVector<QPointF> pointsFromTree();
bool eventFilter(QObject *watched, QEvent *event) override;
private slots:
void on_m_close_polygon_cb_stateChanged(int arg1);
void on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column);
void on_m_points_list_tree_itemSelectionChanged();
void on_m_add_point_action_triggered();
void on_m_remove_point_action_triggered();
private:
/*!
* \brief setUpChangeConnections
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
private:
Ui::PolygonEditor *ui;
StyleEditor *m_style = nullptr;
PartPolygon *m_part = nullptr;
QList <QMetaObject::Connection> m_change_connections;
};
#endif // POLYGONEDITOR_H

View File

@@ -48,19 +48,19 @@ RectangleEditor::~RectangleEditor() {
void RectangleEditor::setUpChangeConnections()
{
m_change_connections << connect(m_part, &PartRectangle::rectChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::XRadiusChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::YRadiusChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::xChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::rectChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::XRadiusChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::YRadiusChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::xChanged, this, &RectangleEditor::updateForm);
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
}
void RectangleEditor::disconnectChangeConnections()
{
for (QMetaObject::Connection c : m_change_connections) {
disconnect(c);
}
m_change_connections.clear();
for (QMetaObject::Connection c : m_change_connections) {
disconnect(c);
}
m_change_connections.clear();
}
/**
@@ -74,13 +74,13 @@ bool RectangleEditor::setPart(CustomElementPart *part)
{
if (m_part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
m_part = nullptr;
m_style->setPart(nullptr);
return(true);
}
if (PartRectangle *part_rectangle = dynamic_cast<PartRectangle *>(part))
{
if (m_part == part_rectangle) {
@@ -88,26 +88,26 @@ bool RectangleEditor::setPart(CustomElementPart *part)
}
if (m_part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
m_part = part_rectangle;
m_style->setPart(m_part);
updateForm();
setUpChangeConnections();
setUpChangeConnections();
return(true);
}
return(false);
}
bool RectangleEditor::setParts(QList <CustomElementPart *> parts)
{
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return m_style->setParts(parts);
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return m_style->setParts(parts);
}
/**
@@ -119,7 +119,7 @@ CustomElementPart *RectangleEditor::currentPart() const {
}
QList<CustomElementPart*> RectangleEditor::currentParts() const {
return m_style->currentParts();
return m_style->currentParts();
}
/**
@@ -165,7 +165,7 @@ void RectangleEditor::editingFinished()
return;
}
m_locked = true;
QUndoCommand *undo = new QUndoCommand();
undo->setText(tr("Modifier un rectangle"));
@@ -186,158 +186,158 @@ void RectangleEditor::editingFinished()
u->setAnimated();
}
elementScene()->undoStack().push(undo);
m_locked = false;
}
void RectangleEditor::xPosChanged()
{
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
if (rect.x() != p.x()) {
rect.moveLeft(p.x());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
if (rect.x() != p.x()) {
rect.moveLeft(p.x());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void RectangleEditor::yPosChanged()
{
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
if (rect.y() != p.y()) {
rect.moveTop(p.y());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
if (rect.y() != p.y()) {
rect.moveTop(p.y());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void RectangleEditor::widthChanged()
{
if (m_locked) {
return;
}
m_locked = true;
double width = ui->m_width_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
if (rect.width() != width) {
rect.setWidth(width);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
double width = ui->m_width_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
if (rect.width() != width) {
rect.setWidth(width);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void RectangleEditor::heightChanged()
{
if (m_locked) {
return;
}
m_locked = true;
double height = ui->m_height_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
if (rect.height() != height) {
rect.setHeight(height);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
double height = ui->m_height_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
if (rect.height() != height) {
rect.setHeight(height);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void RectangleEditor::xRadiusChanged()
{
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_rx_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
if (rec->XRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_rx_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
if (rec->XRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void RectangleEditor::yRadiusChanged()
{
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_ry_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
if (rec->YRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_ry_sb->value();
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
if (rec->YRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
@@ -351,20 +351,20 @@ void RectangleEditor::activeConnections(bool active)
{
if (active)
{
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
}
else
{
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
}
}

View File

@@ -38,38 +38,38 @@ class RectangleEditor : public ElementItemEditor
public:
explicit RectangleEditor(QETElementEditor *editor, PartRectangle *rect = nullptr, QWidget *parent = nullptr);
~RectangleEditor() override;
~RectangleEditor() override;
bool setPart(CustomElementPart *part) override;
bool setParts(QList <CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedTopLeft () const;
bool setPart(CustomElementPart *part) override;
bool setParts(QList <CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedTopLeft () const;
public slots:
void updateForm() override;
void updateForm() override;
private:
void editingFinished();
void activeConnections(bool active);
void xPosChanged();
void yPosChanged();
void widthChanged();
void heightChanged();
void xRadiusChanged();
void yRadiusChanged();
/*!
* \brief setUpChangeConnections
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
void editingFinished();
void activeConnections(bool active);
void xPosChanged();
void yPosChanged();
void widthChanged();
void heightChanged();
void xRadiusChanged();
void yRadiusChanged();
/*!
* \brief setUpChangeConnections
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
*/
void setUpChangeConnections();
void disconnectChangeConnections();
private:
bool m_locked = false;
StyleEditor *m_style;
PartRectangle *m_part;
Ui::RectangleEditor *ui;
QList <QMetaObject::Connection> m_change_connections;
bool m_locked = false;
StyleEditor *m_style;
PartRectangle *m_part;
Ui::RectangleEditor *ui;
QList <QMetaObject::Connection> m_change_connections;
};
#endif // RECTANGLEEDITOR_H

View File

@@ -107,19 +107,19 @@ bool TextEditor::setPart(CustomElementPart *part)
if (!part)
{
m_text = nullptr;
disconnectChangeConnection();
disconnectChangeConnection();
return true;
}
if (PartText *part_text = static_cast<PartText *>(part))
if (PartText *part_text = static_cast<PartText *>(part))
{
if (part_text == m_text) {
return true;
}
m_text = part_text;
setUpChangeConnection(m_text);
setUpChangeConnection(m_text);
updateForm();
return true;
}
@@ -127,34 +127,34 @@ bool TextEditor::setPart(CustomElementPart *part)
}
bool TextEditor::setParts(QList <CustomElementPart *> parts) {
if (parts.isEmpty())
{
m_parts.clear();
if (m_text) {
disconnectChangeConnection();
}
m_text = nullptr;
return true;
}
if (PartText *part= static_cast<PartText *>(parts.first()))
{
if (m_text) {
disconnectChangeConnection();
}
m_text = part;
m_parts.clear();
m_parts.append(part);
for (int i=1; i < parts.length(); i++)
m_parts.append(static_cast<PartText*>(parts[i]));
setUpChangeConnection(m_text);
updateForm();
return true;
}
return(false);
if (parts.isEmpty())
{
m_parts.clear();
if (m_text) {
disconnectChangeConnection();
}
m_text = nullptr;
return true;
}
if (PartText *part= static_cast<PartText *>(parts.first()))
{
if (m_text) {
disconnectChangeConnection();
}
m_text = part;
m_parts.clear();
m_parts.append(part);
for (int i=1; i < parts.length(); i++)
m_parts.append(static_cast<PartText*>(parts[i]));
setUpChangeConnection(m_text);
updateForm();
return true;
}
return(false);
}
/**
@@ -166,11 +166,11 @@ CustomElementPart *TextEditor::currentPart() const {
}
QList<CustomElementPart*> TextEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
}
/**
@@ -180,77 +180,77 @@ QList<CustomElementPart*> TextEditor::currentParts() const {
*/
void TextEditor::setUpEditConnection()
{
disconnectEditConnection();
disconnectEditConnection();
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]()
{
QString text_ = ui->m_line_edit->text();
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (text_ != partText->toPlainText())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
undo->setText(tr("Modifier le contenu d'un champ texte"));
undoStack().push(undo);
}
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (text_ != partText->toPlainText())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
undo->setText(tr("Modifier le contenu d'un champ texte"));
undoStack().push(undo);
}
}
});
m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
{
QPointF pos(ui->m_x_sb->value(), 0);
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setY(partText->pos().y());
if (pos != partText->pos())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
undo->setText(tr("Déplacer un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
QPointF pos(ui->m_x_sb->value(), 0);
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setY(partText->pos().y());
if (pos != partText->pos())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
undo->setText(tr("Déplacer un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
});
m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
{
QPointF pos(0, ui->m_y_sb->value());
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setX(partText->pos().x());
if (pos != partText->pos())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
undo->setText(tr("Déplacer un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
QPointF pos(0, ui->m_y_sb->value());
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setX(partText->pos().x());
if (pos != partText->pos())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
undo->setText(tr("Déplacer un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
});
m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
{
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ui->m_rotation_sb->value() != partText->rotation())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
undo->setText(tr("Pivoter un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ui->m_rotation_sb->value() != partText->rotation())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
undo->setText(tr("Pivoter un champ texte"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
}
});
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
{
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (partText->font().pointSize() != ui->m_size_sb->value())
{
QFont font_ = partText->font();
font_.setPointSize(ui->m_size_sb->value());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
undo->setText(tr("Modifier la police d'un texte"));
undoStack().push(undo);
}
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (partText->font().pointSize() != ui->m_size_sb->value())
{
QFont font_ = partText->font();
font_.setPointSize(ui->m_size_sb->value());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
undo->setText(tr("Modifier la police d'un texte"));
undoStack().push(undo);
}
}
});
}
@@ -261,24 +261,24 @@ void TextEditor::on_m_font_pb_clicked()
{
bool ok;
QFont font_ = QFontDialog::getFont(&ok, m_text->font(), this);
if (ok && font_ != m_text->font()) {
ui->m_size_sb->blockSignals(true);
ui->m_size_sb->setValue(font_.pointSize());
ui->m_size_sb->blockSignals(false);
ui->m_font_pb->setText(font_.family());
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ok && font_ != partText->font())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
undo->setText(tr("Modifier la police d'un texte"));
undoStack().push(undo);
}
}
if (ok && font_ != m_text->font()) {
ui->m_size_sb->blockSignals(true);
ui->m_size_sb->setValue(font_.pointSize());
ui->m_size_sb->blockSignals(false);
ui->m_font_pb->setText(font_.family());
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ok && font_ != partText->font())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
undo->setText(tr("Modifier la police d'un texte"));
undoStack().push(undo);
}
}
}
/**
@@ -287,13 +287,13 @@ void TextEditor::on_m_font_pb_clicked()
*/
void TextEditor::on_m_color_pb_changed(const QColor &newColor)
{
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (newColor != partText->defaultTextColor())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
undo->setText(tr("Modifier la couleur d'un texte"));
undoStack().push(undo);
}
}
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (newColor != partText->defaultTextColor())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
undo->setText(tr("Modifier la couleur d'un texte"));
undoStack().push(undo);
}
}
}