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

@@ -68,7 +68,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
if (m_potential_conductors.isEmpty()) {
m_potential_conductors << c;
} else {
if (!potentialIsManaged(c->relatedPotentialConductors(true).values())) {
if (!potentialIsManaged(c->relatedPotentialConductors(true).values())) {
m_potential_conductors << c;
}
}
@@ -91,28 +91,28 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
//For each selected element, we determine if conductors must be moved or updated.
for(Element *elmt : m_elements)
{
if (elmt->isSelected())
{
for(Terminal *terminal : elmt->terminals())
{
for(Conductor *conductor : terminal->conductors())
{
Terminal *other_terminal;
if (conductor->terminal1 == terminal)
other_terminal = conductor->terminal2;
else
other_terminal = conductor->terminal1;
if (elmt->isSelected())
{
for(Terminal *terminal : elmt->terminals())
{
for(Conductor *conductor : terminal->conductors())
{
Terminal *other_terminal;
if (conductor->terminal1 == terminal)
other_terminal = conductor->terminal2;
else
other_terminal = conductor->terminal1;
//If the two elements of conductor are movable
if (m_elements.contains(other_terminal -> parentElement())) {
if (!m_conductors_to_move.contains(conductor))
m_conductors_to_move << conductor;
}
else if (!m_conductors_to_update.contains(conductor))
m_conductors_to_update << conductor;
}
}
}
else if (!m_conductors_to_update.contains(conductor))
m_conductors_to_update << conductor;
}
}
}
}
}

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()) {
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.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);
}
}
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 (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
}
/**
@@ -188,17 +188,17 @@ void LineEditor::updateLineEndType1()
m_locked = true;
QVariant end = end1_type -> itemData(end1_type->currentIndex());
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
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);
}
}
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;
}
@@ -209,18 +209,18 @@ void LineEditor::updateLineEndLength1()
m_locked = true;
double length = end1_length->value();
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
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);
}
}
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;
}
@@ -231,17 +231,17 @@ void LineEditor::updateLineEndType2()
m_locked = true;
QVariant end = end2_type -> itemData(end2_type->currentIndex());
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
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);
}
}
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;
}
@@ -252,18 +252,18 @@ void LineEditor::updateLineEndLength2()
m_locked = true;
double length = end2_length->value();
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* line = static_cast<PartLine*>(part);
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);
}
}
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;
}
@@ -272,99 +272,99 @@ void LineEditor::lineEditingFinishedX1()
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
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);
}
}
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;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p1 = l->mapFromScene(x1->value(), y1->value());
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 (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;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
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 (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;
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
for (auto part: style_->currentParts()) {
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
PartLine* l = static_cast<PartLine*>(part);
QLineF line = l->property("line").toLineF();
QPointF p2 = l->mapFromScene(x2->value(), y2->value());
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 (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);
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]);
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;
// 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->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;
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();
}
} 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)
//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 (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 (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
@@ -168,52 +168,52 @@ void TerminalEditor::updateTerminalO()
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);
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;
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
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;
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 (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();
}
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]));
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();
setUpConnections();
updateForm();
return true;
}
return(false);
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);
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());
}
}
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
}
}
}
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
@@ -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()
@@ -371,25 +371,25 @@ 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;
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);
}
}
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;
}
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);
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;
}
if (watched == ui->m_points_list_tree &&
event->type() == QEvent::FocusOut &&
m_part)
{
m_part->resetAllHandlerColor();
return true;
}
return false;
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);
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);
}
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);
Q_UNUSED(item);
Q_UNUSED(column);
if (!m_part) {
return;
}
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;
}
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);
}
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;
}
//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;
}
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);
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));
}
//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;
}
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();
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);
}
//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);
//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));
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;
}
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));
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);
//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
Q_OBJECT
public:
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
~PolygonEditor() override;
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;
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 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:
/*!
* \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;
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,7 +74,7 @@ bool RectangleEditor::setPart(CustomElementPart *part)
{
if (m_part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
m_part = nullptr;
m_style->setPart(nullptr);
@@ -88,12 +88,12 @@ bool RectangleEditor::setPart(CustomElementPart *part)
}
if (m_part)
{
disconnectChangeConnections();
disconnectChangeConnections();
}
m_part = part_rectangle;
m_style->setPart(m_part);
updateForm();
setUpChangeConnections();
setUpChangeConnections();
return(true);
}
@@ -102,12 +102,12 @@ bool RectangleEditor::setPart(CustomElementPart *part)
bool RectangleEditor::setParts(QList <CustomElementPart *> parts)
{
if (parts.isEmpty())
return false;
if (parts.isEmpty())
return false;
if (!setPart(parts.first()))
return false;
return m_style->setParts(parts);
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();
}
/**
@@ -192,152 +192,152 @@ void RectangleEditor::editingFinished()
void RectangleEditor::xPosChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
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);
}
}
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;
m_locked = false;
}
void RectangleEditor::yPosChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
QRectF rect = rec->rect();
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
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);
}
}
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;
m_locked = false;
}
void RectangleEditor::widthChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
double width = ui->m_width_sb->value();
double width = ui->m_width_sb->value();
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
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);
}
}
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;
m_locked = false;
}
void RectangleEditor::heightChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
double height = ui->m_height_sb->value();
double height = ui->m_height_sb->value();
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
PartRectangle* rec = static_cast<PartRectangle*>(part);
QRectF rect = rec->rect();
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);
}
}
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;
m_locked = false;
}
void RectangleEditor::xRadiusChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_rx_sb->value();
double radius = ui->m_rx_sb->value();
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
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);
}
}
if (rec->XRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
m_locked = false;
}
void RectangleEditor::yRadiusChanged()
{
if (m_locked) {
return;
}
m_locked = true;
if (m_locked) {
return;
}
m_locked = true;
double radius = ui->m_ry_sb->value();
double radius = ui->m_ry_sb->value();
for (auto part: m_style->currentParts()) {
for (auto part: m_style->currentParts()) {
PartRectangle* rec = static_cast<PartRectangle*>(part);
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);
}
}
if (rec->YRadius() != radius) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
undo->setAnimated();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
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,18 +107,18 @@ 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 (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();
}
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]));
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);
setUpChangeConnection(m_text);
updateForm();
return true;
}
return(false);
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);
}
}
});
}
@@ -262,23 +262,23 @@ 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);
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());
}
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);
}
}
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);
}
}
}

View File

@@ -164,7 +164,7 @@ QTreeWidgetItem *ElementsPanel::updateTemplateItem(QTreeWidgetItem *tb_template_
item -> setStatusTip(
0,
tr(
"Glissez-déposez ce modèle de cartouche sur un folio pour l'y appliquer.",
"Glissez-déposez ce modèle de cartouche sur un folio pour l'y appliquer.",
"Status tip displayed when selecting a title block template"
)
);

View File

@@ -167,8 +167,8 @@ ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
QString ImportElementTextPattern::getName(const QStringList& list, bool *ok, bool *erase) const
{
return ImportElementTextPatternDialog::getItem(parentWidget(),
QObject::tr("Sélectionner une configuration de textes"),
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
QObject::tr("Sélectionner une configuration de textes"),
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
list,
ok,
erase);

View File

@@ -60,7 +60,7 @@ bool nomenclature::saveToCSVFile()
if(!QFile::remove ( filename ) ){
QMessageBox::critical(this->m_parent, QObject::tr("Erreur"),
QObject::tr("Impossible de remplacer le fichier!\n\n")+
"Destination : "+filename+"\n");
"Destination : "+filename+"\n");
return false;
}
}
@@ -88,28 +88,28 @@ QString nomenclature::getNomenclature()
{
//Process...
QString data = QObject::tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
data += QObject::tr("A001") +";" //:Don't translate this text! //ID for folio position in project
""+ QObject::tr("B001") +";" //:Don't translate this text! //ID for folio title
""+ QObject::tr("C001") +";" //:Don't translate this text! //ID for folio number
""+ QObject::tr("D001") +";" //:Don't translate this text! //ID for qet designation
""+ QObject::tr("E001") +";" //:Don't translate this text! //ID for position of element on the folio
""+ QObject::tr("F001") +";" //:Don't translate this text! //ID for label of element
""+ QObject::tr("F002") +";" //:Don't translate this text! //ID for label formula of element
""+ QObject::tr("G001") +";" //:Don't translate this text! //ID for order number
""+ QObject::tr("H001") +";" //:Don't translate this text! //ID for article description
""+ QObject::tr("H002") +";" //:Don't translate this text! //ID for plant
""+ QObject::tr("I001") +";" //:Don't translate this text! //ID for comment
""+ QObject::tr("J001") +";" //:Don't translate this text! //ID for manufacturer
""+ QObject::tr("K001") +";" //:Don't translate this text! //ID for article number
""+ QObject::tr("L001") +";" //:Don't translate this text! //ID for quantity
""+ QObject::tr("L002") +";" //:Don't translate this text! //ID for unity
""+ QObject::tr("L003") +";" //:Don't translate this text! //ID for supplier
""+ QObject::tr("M001") +";" //:Don't translate this text! //ID for auxiliary field 1
""+ QObject::tr("M002") +";" //:Don't translate this text! //ID for auxiliary field 2
""+ QObject::tr("N001")+";" //:Don't translate this text! //ID for internal number
""+ QObject::tr("O001")+";" //:Don't translate this text! //ID for location
""+ QObject::tr("P001") +"\n"; //:Don't translate this text! //ID for function
data += QObject::tr("Position du folio") +";"
data += QObject::tr("A001") +";" //:Don't translate this text! //ID for folio position in project
""+ QObject::tr("B001") +";" //:Don't translate this text! //ID for folio title
""+ QObject::tr("C001") +";" //:Don't translate this text! //ID for folio number
""+ QObject::tr("D001") +";" //:Don't translate this text! //ID for qet designation
""+ QObject::tr("E001") +";" //:Don't translate this text! //ID for position of element on the folio
""+ QObject::tr("F001") +";" //:Don't translate this text! //ID for label of element
""+ QObject::tr("F002") +";" //:Don't translate this text! //ID for label formula of element
""+ QObject::tr("G001") +";" //:Don't translate this text! //ID for order number
""+ QObject::tr("H001") +";" //:Don't translate this text! //ID for article description
""+ QObject::tr("H002") +";" //:Don't translate this text! //ID for plant
""+ QObject::tr("I001") +";" //:Don't translate this text! //ID for comment
""+ QObject::tr("J001") +";" //:Don't translate this text! //ID for manufacturer
""+ QObject::tr("K001") +";" //:Don't translate this text! //ID for article number
""+ QObject::tr("L001") +";" //:Don't translate this text! //ID for quantity
""+ QObject::tr("L002") +";" //:Don't translate this text! //ID for unity
""+ QObject::tr("L003") +";" //:Don't translate this text! //ID for supplier
""+ QObject::tr("M001") +";" //:Don't translate this text! //ID for auxiliary field 1
""+ QObject::tr("M002") +";" //:Don't translate this text! //ID for auxiliary field 2
""+ QObject::tr("N001")+";" //:Don't translate this text! //ID for internal number
""+ QObject::tr("O001")+";" //:Don't translate this text! //ID for location
""+ QObject::tr("P001") +"\n"; //:Don't translate this text! //ID for function
data += QObject::tr("Position du folio") +";"
""+ QObject::tr("Titre de folio") +";"
""+ QObject::tr("Numéro de folio") +";"
""+ QObject::tr("Désignation qet") +";"

View File

@@ -887,27 +887,27 @@ void ProjectView::diagramAdded(Diagram *diagram)
*/
void ProjectView::updateTabTitle(DiagramView *diagram_view)
{
int diagram_tab_id = m_diagram_ids.key(diagram_view, -1);
int diagram_tab_id = m_diagram_ids.key(diagram_view, -1);
if (diagram_tab_id != -1)
{
QSettings settings;
QString title;
Diagram *diagram = diagram_view->diagram();
if (diagram_tab_id != -1)
{
QSettings settings;
QString title;
Diagram *diagram = diagram_view->diagram();
if (settings.value("genericpanel/folio", false).toBool())
{
QString formula = diagram->border_and_titleblock.folio();
autonum::sequentialNumbers seq;
title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
}
else
title = QString::number(diagram->folioIndex() + 1);
if (settings.value("genericpanel/folio", false).toBool())
{
QString formula = diagram->border_and_titleblock.folio();
autonum::sequentialNumbers seq;
title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
}
else
title = QString::number(diagram->folioIndex() + 1);
title += " - ";
title += diagram->title();
m_tab->setTabText(diagram_tab_id ,title);
}
title += " - ";
title += diagram->title();
m_tab->setTabText(diagram_tab_id ,title);
}
}
/**

View File

@@ -11063,7 +11063,7 @@ PUGI__NS_BEGIN
// Use optimized path for @attr = 'value' or @attr = $value
if (_type == ast_op_equal &&
_left && _right && // workaround for clang static analyzer and Coverity (_left and _right are never null for ast_op_equal)
// coverity[mixed_enums]
// coverity[mixed_enums]
_left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right &&
(_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string)))
{

View File

@@ -561,35 +561,35 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
*/
bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message)
{
QSaveFile file(filepath);
QSaveFile file(filepath);
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
bool file_opening = file.open(QIODevice::WriteOnly);
if (!file_opening)
{
if (error_message)
{
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
return(false);
}
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
bool file_opening = file.open(QIODevice::WriteOnly);
if (!file_opening)
{
if (error_message)
{
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
return(false);
}
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(false);
out << xml_doc.toString(4);
if (!file.commit())
{
if (error_message) {
*error_message = QString(QObject::tr("Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(false);
out << xml_doc.toString(4);
if (!file.commit())
{
if (error_message) {
*error_message = QString(QObject::tr("Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
return false;
}
return false;
}
return(true);
return(true);
}
/**

View File

@@ -576,9 +576,9 @@ QString QETApp::customElementsDir()
if (dir.exists())
{
m_user_custom_elements_dir = path;
if(!m_user_custom_elements_dir.endsWith("/")) {
m_user_custom_elements_dir.append("/");
}
if(!m_user_custom_elements_dir.endsWith("/")) {
m_user_custom_elements_dir.append("/");
}
return m_user_custom_elements_dir;
}
}
@@ -1786,17 +1786,17 @@ void QETApp::buildSystemTrayMenu() {
*/
void QETApp::checkBackupFiles()
{
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
//Remove from the list @stale_files, the stales file of opened project
//Remove from the list @stale_files, the stales file of opened project
const QList<KAutoSaveFile *> sf = stale_files;
for (KAutoSaveFile *kasf : sf)
{
for (QETProject *project : registeredProjects().values())
{
//We must to adjust with the flag QUrl::StripTrailingSlash to compar a path formated like the path returned by KAutoSaveFile
const QString path = QUrl::fromLocalFile(project->filePath()).adjusted(QUrl::RemoveScheme | QUrl::StripTrailingSlash).path();
if (kasf->managedFile() == path) {
for (KAutoSaveFile *kasf : sf)
{
for (QETProject *project : registeredProjects().values())
{
//We must to adjust with the flag QUrl::StripTrailingSlash to compar a path formated like the path returned by KAutoSaveFile
const QString path = QUrl::fromLocalFile(project->filePath()).adjusted(QUrl::RemoveScheme | QUrl::StripTrailingSlash).path();
if (kasf->managedFile() == path) {
stale_files.removeOne(kasf);
}
}

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2020 QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "projectdbmodel.h"
#include "projectdatabase.h"
@@ -30,8 +30,8 @@
* @param parent : parent QObject
*/
ProjectDBModel::ProjectDBModel(QETProject *project, QObject *parent) :
QAbstractTableModel(parent),
m_project(project)
QAbstractTableModel(parent),
m_project(project)
{
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
}
@@ -41,13 +41,13 @@ ProjectDBModel::ProjectDBModel(QETProject *project, QObject *parent) :
* @param other_model
*/
ProjectDBModel::ProjectDBModel(const ProjectDBModel &other_model) :
QAbstractTableModel(other_model.parent())
QAbstractTableModel(other_model.parent())
{
this->setParent(other_model.parent());
m_project = other_model.m_project;
this->setParent(other_model.parent());
m_project = other_model.m_project;
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
m_index_0_0_data = other_model.m_index_0_0_data;
setQuery(other_model.queryString());
m_index_0_0_data = other_model.m_index_0_0_data;
setQuery(other_model.queryString());
}
/**
@@ -58,10 +58,10 @@ ProjectDBModel::ProjectDBModel(const ProjectDBModel &other_model) :
*/
int ProjectDBModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
if (parent.isValid())
return 0;
return m_record.count();
return m_record.count();
}
/**
@@ -72,14 +72,14 @@ int ProjectDBModel::rowCount(const QModelIndex &parent) const
*/
int ProjectDBModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
if (parent.isValid())
return 0;
if (m_record.count()) {
return m_record.first().count();
}
if (m_record.count()) {
return m_record.first().count();
}
return 0;
return 0;
}
/**
@@ -94,14 +94,14 @@ int ProjectDBModel::columnCount(const QModelIndex &parent) const
*/
bool ProjectDBModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
{
if (orientation == Qt::Vertical) {
return false;
}
auto hash_ = m_header_data.value(section);
hash_.insert(role, value);
m_header_data.insert(section, hash_);
emit headerDataChanged(orientation, section, section);
return true;
if (orientation == Qt::Vertical) {
return false;
}
auto hash_ = m_header_data.value(section);
hash_.insert(role, value);
m_header_data.insert(section, hash_);
emit headerDataChanged(orientation, section, section);
return true;
}
/**
@@ -114,19 +114,19 @@ bool ProjectDBModel::setHeaderData(int section, Qt::Orientation orientation, con
*/
QVariant ProjectDBModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Vertical) {
return QVariant();
}
if (orientation == Qt::Vertical) {
return QVariant();
}
if (m_header_data.contains(section))
{
auto hash_ = m_header_data.value(section);
if (role == Qt::DisplayRole && !hash_.contains(Qt::DisplayRole)) { //special case to have the same behavior as Qt
return hash_.value(Qt::EditRole);
}
return m_header_data.value(section).value(role);
}
return QVariant();
if (m_header_data.contains(section))
{
auto hash_ = m_header_data.value(section);
if (role == Qt::DisplayRole && !hash_.contains(Qt::DisplayRole)) { //special case to have the same behavior as Qt
return hash_.value(Qt::EditRole);
}
return m_header_data.value(section).value(role);
}
return QVariant();
}
/**
@@ -139,12 +139,12 @@ QVariant ProjectDBModel::headerData(int section, Qt::Orientation orientation, in
*/
bool ProjectDBModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid() || index.row() != 0 || index.column() != 0) {
return false;
}
m_index_0_0_data.insert(role, value);
emit dataChanged(index, index, QVector<int>(role));
return true;
if (!index.isValid() || index.row() != 0 || index.column() != 0) {
return false;
}
m_index_0_0_data.insert(role, value);
emit dataChanged(index, index, QVector<int>(role));
return true;
}
/**
@@ -156,21 +156,21 @@ bool ProjectDBModel::setData(const QModelIndex &index, const QVariant &value, in
*/
QVariant ProjectDBModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (!index.isValid())
return QVariant();
if (index.row() == 0 &&
index.column() == 0 &&
role != Qt::DisplayRole) {
return m_index_0_0_data.value(role);
}
if (index.row() == 0 &&
index.column() == 0 &&
role != Qt::DisplayRole) {
return m_index_0_0_data.value(role);
}
if (role == Qt::DisplayRole) {
QVariant v(m_record.at(index.row()).at(index.column()));
return v;
}
if (role == Qt::DisplayRole) {
QVariant v(m_record.at(index.row()).at(index.column()));
return v;
}
return QVariant();
return QVariant();
}
/**
@@ -180,29 +180,29 @@ QVariant ProjectDBModel::data(const QModelIndex &index, int role) const
*/
void ProjectDBModel::setQuery(const QString &query)
{
auto rm_ = m_query != query;
if (rm_) {
emit beginResetModel();
}
auto rm_ = m_query != query;
if (rm_) {
emit beginResetModel();
}
m_query = query;
m_query = query;
if (m_project)
{
if (rm_) {
disconnect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
}
m_project->dataBase()->updateDB();
if (rm_) {
setHeaderString();
fillValue();
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
}
}
if (m_project)
{
if (rm_) {
disconnect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
}
m_project->dataBase()->updateDB();
if (rm_) {
setHeaderString();
fillValue();
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
}
}
if (rm_) {
emit endResetModel();
}
if (rm_) {
emit endResetModel();
}
}
/**
@@ -210,11 +210,11 @@ void ProjectDBModel::setQuery(const QString &query)
* @return the current query used by this model
*/
QString ProjectDBModel::queryString() const {
return m_query;
return m_query;
}
QETProject *ProjectDBModel::project() const {
return m_project.data();
return m_project.data();
}
/**
@@ -226,42 +226,42 @@ QETProject *ProjectDBModel::project() const {
*/
QDomElement ProjectDBModel::toXml(QDomDocument &document) const
{
auto dom_element = document.createElement(xmlTagName());
auto dom_element = document.createElement(xmlTagName());
//Identifier
auto dom_identifier = document.createElement("identifier");
auto dom_identifier_text = document.createTextNode(m_identifier);
dom_identifier.appendChild(dom_identifier_text);
dom_element.appendChild(dom_identifier);
//Identifier
auto dom_identifier = document.createElement("identifier");
auto dom_identifier_text = document.createTextNode(m_identifier);
dom_identifier.appendChild(dom_identifier_text);
dom_element.appendChild(dom_identifier);
//query
auto dom_query = document.createElement("query");
auto dom_query_text = document.createTextNode(m_query);
dom_query.appendChild(dom_query_text);
dom_element.appendChild(dom_query);
//query
auto dom_query = document.createElement("query");
auto dom_query_text = document.createTextNode(m_query);
dom_query.appendChild(dom_query_text);
dom_element.appendChild(dom_query);
//Add index 0,0 data
auto index_00 = document.createElement("index00");
index_00.setAttribute("font", m_index_0_0_data.value(Qt::FontRole).toString());
auto me = QMetaEnum::fromType<Qt::Alignment>();
index_00.setAttribute("alignment", me.valueToKey(m_index_0_0_data.value(Qt::TextAlignmentRole).toInt()));
dom_element.appendChild(index_00);
index_00.setAttribute("margins", m_index_0_0_data.value(Qt::UserRole+1).toString());
//Add index 0,0 data
auto index_00 = document.createElement("index00");
index_00.setAttribute("font", m_index_0_0_data.value(Qt::FontRole).toString());
auto me = QMetaEnum::fromType<Qt::Alignment>();
index_00.setAttribute("alignment", me.valueToKey(m_index_0_0_data.value(Qt::TextAlignmentRole).toInt()));
dom_element.appendChild(index_00);
index_00.setAttribute("margins", m_index_0_0_data.value(Qt::UserRole+1).toString());
//header data
QHash<int, QList<int>> horizontal_;
for (auto key : m_header_data.keys())
{
//We save all data except the display role, because he was generated in the fly
auto list = m_header_data.value(key).keys();
list.removeAll(Qt::DisplayRole);
//header data
QHash<int, QList<int>> horizontal_;
for (auto key : m_header_data.keys())
{
//We save all data except the display role, because he was generated in the fly
auto list = m_header_data.value(key).keys();
list.removeAll(Qt::DisplayRole);
horizontal_.insert(key, list);
}
horizontal_.insert(key, list);
}
dom_element.appendChild(QETXML::modelHeaderDataToXml(document, this, horizontal_, QHash<int, QList<int>>()));
dom_element.appendChild(QETXML::modelHeaderDataToXml(document, this, horizontal_, QHash<int, QList<int>>()));
return dom_element;
return dom_element;
}
/**
@@ -271,22 +271,22 @@ QDomElement ProjectDBModel::toXml(QDomDocument &document) const
*/
void ProjectDBModel::fromXml(const QDomElement &element)
{
if (element.tagName() != xmlTagName())
return;
if (element.tagName() != xmlTagName())
return;
setIdentifier(element.firstChildElement("identifier").text());
setQuery(element.firstChildElement("query").text());
setIdentifier(element.firstChildElement("identifier").text());
setQuery(element.firstChildElement("query").text());
//Index 0,0
auto index_00 = element.firstChildElement("index00");
QFont font_;
font_.fromString(index_00.attribute("font"));
m_index_0_0_data.insert(Qt::FontRole, font_);
auto me = QMetaEnum::fromType<Qt::Alignment>();
m_index_0_0_data.insert(Qt::TextAlignmentRole, me.keyToValue(index_00.attribute("alignment").toStdString().data()));
m_index_0_0_data.insert(Qt::UserRole+1, index_00.attribute("margins"));
//Index 0,0
auto index_00 = element.firstChildElement("index00");
QFont font_;
font_.fromString(index_00.attribute("font"));
m_index_0_0_data.insert(Qt::FontRole, font_);
auto me = QMetaEnum::fromType<Qt::Alignment>();
m_index_0_0_data.insert(Qt::TextAlignmentRole, me.keyToValue(index_00.attribute("alignment").toStdString().data()));
m_index_0_0_data.insert(Qt::UserRole+1, index_00.attribute("margins"));
QETXML::modelHeaderDataFromXml(element.firstChildElement("header_data"), this);
QETXML::modelHeaderDataFromXml(element.firstChildElement("header_data"), this);
}
/**
@@ -304,27 +304,27 @@ void ProjectDBModel::setIdentifier(const QString &identifier) {
*/
void ProjectDBModel::dataBaseUpdated()
{
auto original_record = m_record;
fillValue();
auto new_record = m_record;
m_record = original_record;
auto original_record = m_record;
fillValue();
auto new_record = m_record;
m_record = original_record;
//This a very special case, if this nomenclature model is added
//befor any element, column count return 0, so in this case we emit column inserted
if (new_record.size() != m_record.size())
{
emit beginResetModel();
m_record = new_record;
emit endResetModel();
}
else
{
m_record = new_record;
auto row = m_record.size();
auto col = row ? m_record.first().count() : 1;
//This a very special case, if this nomenclature model is added
//befor any element, column count return 0, so in this case we emit column inserted
if (new_record.size() != m_record.size())
{
emit beginResetModel();
m_record = new_record;
emit endResetModel();
}
else
{
m_record = new_record;
auto row = m_record.size();
auto col = row ? m_record.first().count() : 1;
emit dataChanged(this->index(0,0), this->index(row-1, col-1), QVector<int>(Qt::DisplayRole));
}
emit dataChanged(this->index(0,0), this->index(row-1, col-1), QVector<int>(Qt::DisplayRole));
}
}
void ProjectDBModel::setHeaderString()

View File

@@ -581,27 +581,27 @@ bool Conductor::valideXml(QDomElement &e){
if (!e.hasAttribute("terminal2")) return(false);
bool conv_ok;
// parse l'abscisse
if (e.hasAttribute("element1")) {
if (QUuid(e.attribute("element1")).isNull())
return false;
if (QUuid(e.attribute("terminal1")).isNull())
return false;
} else {
e.attribute("terminal1").toInt(&conv_ok);
if (!conv_ok) return(false);
}
// parse l'abscisse
if (e.hasAttribute("element1")) {
if (QUuid(e.attribute("element1")).isNull())
return false;
if (QUuid(e.attribute("terminal1")).isNull())
return false;
} else {
e.attribute("terminal1").toInt(&conv_ok);
if (!conv_ok) return(false);
}
// parse l'ordonnee
if (e.hasAttribute("element2")) {
if (QUuid(e.attribute("element2")).isNull())
return false;
if (QUuid(e.attribute("terminal2")).isNull())
return false;
} else {
e.attribute("terminal2").toInt(&conv_ok);
if (!conv_ok) return(false);
}
if (e.hasAttribute("element2")) {
if (QUuid(e.attribute("element2")).isNull())
return false;
if (QUuid(e.attribute("terminal2")).isNull())
return false;
} else {
e.attribute("terminal2").toInt(&conv_ok);
if (!conv_ok) return(false);
}
return(true);
}

View File

@@ -130,22 +130,22 @@ void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
*/
void ConductorTextItem::setPos(const QPointF &pos)
{
/*
* In some condition the conductor text item is outside the border of folio in the left.
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
* If the text is empty and the scene position is outside the border (left and top),
* we can say that this position, is unwanted by user.
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
*/
DiagramTextItem::setPos(pos);
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
{
Conductor *cond = parentConductor();
if(cond)
DiagramTextItem::setPos(cond->boundingRect().topLeft());
else
DiagramTextItem::setPos(0,0);
}
/*
* In some condition the conductor text item is outside the border of folio in the left.
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
* If the text is empty and the scene position is outside the border (left and top),
* we can say that this position, is unwanted by user.
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
*/
DiagramTextItem::setPos(pos);
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
{
Conductor *cond = parentConductor();
if(cond)
DiagramTextItem::setPos(cond->boundingRect().topLeft());
else
DiagramTextItem::setPos(0,0);
}
}
/**

View File

@@ -632,27 +632,27 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
// for delay on contact
if (flags &DelayOn) {
if (flags &NO) {
painter.drawLine(12, offset+8, 12, offset+11);
QRectF r(9.5, offset+9, 5, 3);
painter.drawArc(r, 180*16, 180*16);
painter.drawLine(12, offset+8, 12, offset+11);
QRectF r(9.5, offset+9, 5, 3);
painter.drawArc(r, 180*16, 180*16);
}
if (flags &NC) {
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
QRectF r(10, offset+6, 5, 3);
painter.drawArc(r, 180*16, 180*16);
if (flags &NC) {
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
QRectF r(10, offset+6, 5, 3);
painter.drawArc(r, 180*16, 180*16);
}
}
// for delay off contact
// for delay off contact
else if ( flags &DelayOff){
if (flags &NO) {
painter.drawLine(12, offset+8, 12, offset+9.5);
QRectF r(9.5, offset+9.5, 5, 3);
painter.drawArc(r, 0, 180*16);
}
painter.drawLine(12, offset+8, 12, offset+9.5);
QRectF r(9.5, offset+9.5, 5, 3);
painter.drawArc(r, 0, 180*16);
}
if (flags &NC) {
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+7));
QRectF r(10, offset+7.5, 5, 3);
painter.drawArc(r, 0, 180*16);
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+7));
QRectF r(10, offset+7.5, 5, 3);
painter.drawArc(r, 0, 180*16);
}
}

View File

@@ -1045,18 +1045,18 @@ void DynamicElementTextItem::updateLabel()
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
{
DiagramContext dc;
Element *element = elementUseForInfo();
if(element) {
dc = element->elementInformations();
}
if(m_text_from == ElementInfo && element) {
setPlainText(element->actualLabel());
Element *element = elementUseForInfo();
if(element) {
dc = element->elementInformations();
}
else if (m_text_from == CompositeText) {
if(m_text_from == ElementInfo && element) {
setPlainText(element->actualLabel());
}
else if (m_text_from == CompositeText) {
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, dc));
}
}
}
}

View File

@@ -1377,23 +1377,23 @@ void Element::initLink(QETProject *prj)
QString Element::linkTypeToString() const
{
switch (m_link_type)
{
case Simple:
return "Simple";
case NextReport :
return "NextReport";
case PreviousReport:
return "PreviousReport";
case Master:
return "Master";
case Slave:
return "Slave";
case Terminale:
return "Terminale";
default:
return "Unknown";
}
switch (m_link_type)
{
case Simple:
return "Simple";
case NextReport :
return "NextReport";
case PreviousReport:
return "PreviousReport";
case Master:
return "Master";
case Slave:
return "Slave";
case Terminale:
return "Terminale";
default:
return "Unknown";
}
}
/**

View File

@@ -366,24 +366,24 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
*/
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemSelectedHasChanged)
{
if (value.toBool() == true) { //If this is selected, wa add handlers.
if (change == ItemSelectedHasChanged)
{
if (value.toBool() == true) { //If this is selected, wa add handlers.
addHandler();
}
else //Else this is deselected, we remove handlers
{
if(!m_handler_vector.isEmpty())
{
qDeleteAll(m_handler_vector);
m_handler_vector.clear();
}
}
else //Else this is deselected, we remove handlers
{
if(!m_handler_vector.isEmpty())
{
qDeleteAll(m_handler_vector);
m_handler_vector.clear();
}
m_resize_mode = 1;
}
}
else if (change == ItemPositionHasChanged) {
}
}
else if (change == ItemPositionHasChanged) {
adjusteHandlerPos();
}
}
else if (change == ItemSceneHasChanged)
{
if (!scene()) //This is removed from scene, then we deselect this, and so, the handlers is also removed.
@@ -392,7 +392,7 @@ QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, cons
}
}
return QGraphicsItem::itemChange(change, value);
return QGraphicsItem::itemChange(change, value);
}
/**

File diff suppressed because it is too large Load Diff

View File

@@ -29,87 +29,87 @@ QT_BEGIN_NAMESPACE
class Ui_AddLinkDialog
{
public:
QVBoxLayout *verticalLayout;
QFormLayout *formLayout;
QLabel *label;
QLineEdit *titleInput;
QLabel *label_2;
QLineEdit *urlInput;
QSpacerItem *verticalSpacer;
QFrame *line;
QDialogButtonBox *buttonBox;
QVBoxLayout *verticalLayout;
QFormLayout *formLayout;
QLabel *label;
QLineEdit *titleInput;
QLabel *label_2;
QLineEdit *urlInput;
QSpacerItem *verticalSpacer;
QFrame *line;
QDialogButtonBox *buttonBox;
void setupUi(QDialog *AddLinkDialog)
{
if (AddLinkDialog->objectName().isEmpty())
AddLinkDialog->setObjectName(QString::fromUtf8("AddLinkDialog"));
AddLinkDialog->setSizeGripEnabled(false);
AddLinkDialog->setModal(true);
verticalLayout = new QVBoxLayout(AddLinkDialog);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
formLayout = new QFormLayout();
formLayout->setObjectName(QString::fromUtf8("formLayout"));
label = new QLabel(AddLinkDialog);
label->setObjectName(QString::fromUtf8("label"));
void setupUi(QDialog *AddLinkDialog)
{
if (AddLinkDialog->objectName().isEmpty())
AddLinkDialog->setObjectName(QString::fromUtf8("AddLinkDialog"));
AddLinkDialog->setSizeGripEnabled(false);
AddLinkDialog->setModal(true);
verticalLayout = new QVBoxLayout(AddLinkDialog);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
formLayout = new QFormLayout();
formLayout->setObjectName(QString::fromUtf8("formLayout"));
label = new QLabel(AddLinkDialog);
label->setObjectName(QString::fromUtf8("label"));
formLayout->setWidget(0, QFormLayout::LabelRole, label);
formLayout->setWidget(0, QFormLayout::LabelRole, label);
titleInput = new QLineEdit(AddLinkDialog);
titleInput->setObjectName(QString::fromUtf8("titleInput"));
titleInput->setMinimumSize(QSize(337, 0));
titleInput = new QLineEdit(AddLinkDialog);
titleInput->setObjectName(QString::fromUtf8("titleInput"));
titleInput->setMinimumSize(QSize(337, 0));
formLayout->setWidget(0, QFormLayout::FieldRole, titleInput);
formLayout->setWidget(0, QFormLayout::FieldRole, titleInput);
label_2 = new QLabel(AddLinkDialog);
label_2->setObjectName(QString::fromUtf8("label_2"));
label_2 = new QLabel(AddLinkDialog);
label_2->setObjectName(QString::fromUtf8("label_2"));
formLayout->setWidget(1, QFormLayout::LabelRole, label_2);
formLayout->setWidget(1, QFormLayout::LabelRole, label_2);
urlInput = new QLineEdit(AddLinkDialog);
urlInput->setObjectName(QString::fromUtf8("urlInput"));
urlInput = new QLineEdit(AddLinkDialog);
urlInput->setObjectName(QString::fromUtf8("urlInput"));
formLayout->setWidget(1, QFormLayout::FieldRole, urlInput);
formLayout->setWidget(1, QFormLayout::FieldRole, urlInput);
verticalLayout->addLayout(formLayout);
verticalLayout->addLayout(formLayout);
verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout->addItem(verticalSpacer);
verticalLayout->addItem(verticalSpacer);
line = new QFrame(AddLinkDialog);
line->setObjectName(QString::fromUtf8("line"));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
line = new QFrame(AddLinkDialog);
line->setObjectName(QString::fromUtf8("line"));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
verticalLayout->addWidget(line);
verticalLayout->addWidget(line);
buttonBox = new QDialogButtonBox(AddLinkDialog);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
buttonBox = new QDialogButtonBox(AddLinkDialog);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
verticalLayout->addWidget(buttonBox);
verticalLayout->addWidget(buttonBox);
retranslateUi(AddLinkDialog);
QObject::connect(buttonBox, SIGNAL(accepted()), AddLinkDialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), AddLinkDialog, SLOT(reject()));
retranslateUi(AddLinkDialog);
QObject::connect(buttonBox, SIGNAL(accepted()), AddLinkDialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), AddLinkDialog, SLOT(reject()));
QMetaObject::connectSlotsByName(AddLinkDialog);
} // setupUi
QMetaObject::connectSlotsByName(AddLinkDialog);
} // setupUi
void retranslateUi(QDialog *AddLinkDialog)
{
void retranslateUi(QDialog *AddLinkDialog)
{
AddLinkDialog->setWindowTitle(QApplication::translate("AddLinkDialog", "Insert Link", nullptr));
label->setText(QApplication::translate("AddLinkDialog", "Title:", nullptr));
label_2->setText(QApplication::translate("AddLinkDialog", "URL:", nullptr));
} // retranslateUi
} // retranslateUi
};
namespace Ui {
class AddLinkDialog: public Ui_AddLinkDialog {};
class AddLinkDialog: public Ui_AddLinkDialog {};
} // namespace Ui
QT_END_NAMESPACE

View File

@@ -105,9 +105,9 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
updateQueryLine();
});
setUpItems();
createDataBase();
fillSavedQuery();
setUpItems();
createDataBase();
fillSavedQuery();
}
/**
@@ -115,8 +115,8 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
*/
BOMExportDialog::~BOMExportDialog()
{
delete ui;
m_data_base.close();
delete ui;
m_data_base.close();
}
/**
@@ -126,39 +126,39 @@ BOMExportDialog::~BOMExportDialog()
*/
int BOMExportDialog::exec()
{
int r = QDialog::exec();
if (r == QDialog::Accepted)
{
//save in csv file
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
// if (!file_name.endsWith(".csv")) {
// file_name += ".csv";
// }
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
QFile file(file_path);
if (!file_path.isEmpty())
{
if (QFile::exists(file_path ))
{
// if file already exist -> delete it
if (!QFile::remove(file_path) )
{
QMessageBox::critical(this, tr("Erreur"),
tr("Impossible de remplacer le fichier!\n\n")+
"Destination : "+file_path+"\n");
}
}
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream(&file);
int r = QDialog::exec();
if (r == QDialog::Accepted)
{
//save in csv file
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
// if (!file_name.endsWith(".csv")) {
// file_name += ".csv";
// }
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
QFile file(file_path);
if (!file_path.isEmpty())
{
if (QFile::exists(file_path ))
{
// if file already exist -> delete it
if (!QFile::remove(file_path) )
{
QMessageBox::critical(this, tr("Erreur"),
tr("Impossible de remplacer le fichier!\n\n")+
"Destination : "+file_path+"\n");
}
}
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << getBom() << endl;
stream << getBom() << endl;
#else
stream << getBom() << &Qt::endl(stream);
stream << getBom() << &Qt::endl(stream);
#endif
}
}
}
}
}
}
return r;
}
@@ -168,7 +168,7 @@ int BOMExportDialog::exec()
*/
QStringList BOMExportDialog::selectedKeys() const
{
//Made a string list with the colomns (keys) choosen by the user
//Made a string list with the colomns (keys) choosen by the user
QStringList keys;
int row = 0;
while (auto *item = ui->m_choosen_list->item(row))
@@ -205,13 +205,13 @@ QString BOMExportDialog::translatedKeys(const QString &key) const
*/
void BOMExportDialog::setUpItems()
{
for(QString key : QETApp::elementInfoKeys())
{
for(QString key : QETApp::elementInfoKeys())
{
auto item = new QListWidgetItem(QETApp::elementTranslatedInfoKey(key), ui->m_var_list);
item->setData(Qt::UserRole+1, key); //We store the real key before replace "-" by "_" to easily retrieve it in the element information
item->setData(Qt::UserRole, key.replace("-", "_")); //We must to replace "-" by "_" because "-" is a sql keyword.
m_items_list << item;
}
}
for (auto key : m_export_info.keys())
{
@@ -227,11 +227,11 @@ void BOMExportDialog::setUpItems()
*/
void BOMExportDialog::on_m_add_pb_clicked()
{
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
ui->m_choosen_list->addItem(item);
}
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
ui->m_choosen_list->addItem(item);
}
updateQueryLine();
updateQueryLine();
}
/**
@@ -239,11 +239,11 @@ void BOMExportDialog::on_m_add_pb_clicked()
*/
void BOMExportDialog::on_m_remove_pb_clicked()
{
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
ui->m_var_list->addItem(item);
}
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
ui->m_var_list->addItem(item);
}
updateQueryLine();
updateQueryLine();
}
/**
@@ -251,16 +251,16 @@ void BOMExportDialog::on_m_remove_pb_clicked()
*/
void BOMExportDialog::on_m_up_pb_clicked()
{
auto row = ui->m_choosen_list->currentRow();
if(row <= 0) {
return;
}
auto row = ui->m_choosen_list->currentRow();
if(row <= 0) {
return;
}
auto *item = ui->m_choosen_list->takeItem(row);
ui->m_choosen_list->insertItem(row-1, item);
ui->m_choosen_list->setCurrentItem(item);
auto *item = ui->m_choosen_list->takeItem(row);
ui->m_choosen_list->insertItem(row-1, item);
ui->m_choosen_list->setCurrentItem(item);
updateQueryLine();
updateQueryLine();
}
/**
@@ -268,20 +268,20 @@ void BOMExportDialog::on_m_up_pb_clicked()
*/
void BOMExportDialog::on_m_down_pb_clicked()
{
auto row = ui->m_choosen_list->currentRow();
if (row == -1) {
return;
}
auto row = ui->m_choosen_list->currentRow();
if (row == -1) {
return;
}
auto *item = ui->m_choosen_list->takeItem(row);
ui->m_choosen_list->insertItem(row+1, item);
ui->m_choosen_list->setCurrentItem(item);
auto *item = ui->m_choosen_list->takeItem(row);
ui->m_choosen_list->insertItem(row+1, item);
ui->m_choosen_list->setCurrentItem(item);
updateQueryLine();
updateQueryLine();
}
void BOMExportDialog::on_m_save_name_le_textChanged(const QString &arg1) {
ui->m_save_current_conf_pb->setDisabled(arg1.isEmpty());
ui->m_save_current_conf_pb->setDisabled(arg1.isEmpty());
}
/**
@@ -291,16 +291,16 @@ void BOMExportDialog::on_m_save_name_le_textChanged(const QString &arg1) {
*/
QString BOMExportDialog::getBom()
{
QString data; //The string to be returned
if (ui->m_include_header_cb->isChecked()) {
data = headers();
QString data; //The string to be returned
if (ui->m_include_header_cb->isChecked()) {
data = headers();
data += "\n";
}
}
QSqlQuery query (queryStr() , m_data_base);
if (!query.exec()) {
qDebug() << "Query error : " << query.lastError();
}
QSqlQuery query (queryStr() , m_data_base);
if (!query.exec()) {
qDebug() << "Query error : " << query.lastError();
}
QStringList record;
while (query.next())
@@ -326,8 +326,8 @@ QString BOMExportDialog::getBom()
record.clear();
}
m_data_base.close();
return data;
m_data_base.close();
return data;
}
/**
@@ -336,10 +336,10 @@ QString BOMExportDialog::getBom()
*/
QString BOMExportDialog::headers() const
{
QString header_string;
QString header_string;
if (!ui->m_edit_sql_query_cb->isChecked())
{
if (!ui->m_edit_sql_query_cb->isChecked())
{
for (auto key : selectedKeys())
{
if (!header_string.isEmpty()) {
@@ -348,31 +348,31 @@ QString BOMExportDialog::headers() const
header_string += translatedKeys(key);
}
header_string += "\n";
}
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
{
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
{
auto header = queryStr();
header.remove(0, 7); //Remove SELECT from the string;
header.truncate(header.indexOf("FROM")); //Now we only have the string between SELECT and FROM
header.replace(" ", ""); //remove white space
QStringList list = header.split(",");
if (!list.isEmpty())
{
for (int i=0 ; i<list.size() ; i++)
{
if(!header_string.isEmpty()) {
header_string += ";";
}
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
}
header_string += "\n";
}
}
}
return header_string;
header_string += "\n";
}
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
{
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
{
auto header = queryStr();
header.remove(0, 7); //Remove SELECT from the string;
header.truncate(header.indexOf("FROM")); //Now we only have the string between SELECT and FROM
header.replace(" ", ""); //remove white space
QStringList list = header.split(",");
if (!list.isEmpty())
{
for (int i=0 ; i<list.size() ; i++)
{
if(!header_string.isEmpty()) {
header_string += ";";
}
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
}
header_string += "\n";
}
}
}
return header_string;
}
/**
@@ -381,58 +381,58 @@ QString BOMExportDialog::headers() const
*/
bool BOMExportDialog::createDataBase()
{
//Create a sqlite data base to sort the bom
//Create a sqlite data base to sort the bom
m_data_base = QSqlDatabase::addDatabase("QSQLITE", "bill_of_material");
if (!m_data_base.open())
{
m_data_base.close();
return false;
}
if (!m_data_base.open())
{
m_data_base.close();
return false;
}
//Create the table:
QStringList keys;
auto row = 0;
while (ui->m_var_list->item(row))
{
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
++row;
}
keys << "element_type" << "element_subtype";
//Create the table:
QStringList keys;
auto row = 0;
while (ui->m_var_list->item(row))
{
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
++row;
}
keys << "element_type" << "element_subtype";
keys.removeAll("designation_qty");
QString table("CREATE TABLE bom(");
bool first = true;
for (auto string : keys)
{
if (first) {
first = false;
} else {
table += ",";
QString table("CREATE TABLE bom(");
bool first = true;
for (auto string : keys)
{
if (first) {
first = false;
} else {
table += ",";
}
table += string += " VARCHAR(512)";
}
table += ");";
m_data_base.exec(table);
}
table += ");";
m_data_base.exec(table);
QStringList bind_values;
for (auto key : keys) {
bind_values << key.prepend(":");
}
QStringList bind_values;
for (auto key : keys) {
bind_values << key.prepend(":");
}
//Prepare the query used for insert new record
QString insert("INSERT INTO bom (" +
keys.join(", ") +
") VALUES (" +
bind_values.join(", ") +
")");
//Prepare the query used for insert new record
QString insert("INSERT INTO bom (" +
keys.join(", ") +
") VALUES (" +
bind_values.join(", ") +
")");
m_insert_query = QSqlQuery(m_data_base);
m_insert_query.prepare(insert);
m_insert_query = QSqlQuery(m_data_base);
m_insert_query.prepare(insert);
populateDataBase();
populateDataBase();
return true;
return true;
}
/**
@@ -441,30 +441,30 @@ bool BOMExportDialog::createDataBase()
*/
void BOMExportDialog::populateDataBase()
{
for (auto *diagram : m_project->diagrams())
{
ElementProvider ep(diagram);
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
for (auto *diagram : m_project->diagrams())
{
ElementProvider ep(diagram);
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
//Insert all value into the database
for (auto elmt : elements_list)
{
auto hash = elementInfoToString(elmt);
for (auto key : hash.keys())
{
QString value = hash.value(key);
QString bind = key.prepend(":");
m_insert_query.bindValue(bind, value);
}
//Insert all value into the database
for (auto elmt : elements_list)
{
auto hash = elementInfoToString(elmt);
for (auto key : hash.keys())
{
QString value = hash.value(key);
QString bind = key.prepend(":");
m_insert_query.bindValue(bind, value);
}
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
if (!m_insert_query.exec()) {
qDebug() << "BOMExportDialog::populateDataBase insert error : " << m_insert_query.lastError();
}
}
}
if (!m_insert_query.exec()) {
qDebug() << "BOMExportDialog::populateDataBase insert error : " << m_insert_query.lastError();
}
}
}
}
/**
@@ -474,39 +474,39 @@ void BOMExportDialog::populateDataBase()
*/
QHash<QString, QString> BOMExportDialog::elementInfoToString(Element *elmt) const
{
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
int row = 0;
while (auto *item = ui->m_var_list->item(row))
{
keys_hash.insert(item->data(Qt::UserRole).toString(),
item->data(Qt::UserRole+1).toString());
++row;
}
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
int row = 0;
while (auto *item = ui->m_var_list->item(row))
{
keys_hash.insert(item->data(Qt::UserRole).toString(),
item->data(Qt::UserRole+1).toString());
++row;
}
QHash<QString, QString> hash; //Store the value for each columns
for (auto key : keys_hash.keys())
{
if (key == "pos") {
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
}
else if (key == "folio_title") {
hash.insert(key, elmt->diagram()->title());
}
else if (key == "folio_pos") {
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
}
else if (key == "folio_num") {
QHash<QString, QString> hash; //Store the value for each columns
for (auto key : keys_hash.keys())
{
if (key == "pos") {
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
}
else if (key == "folio_title") {
hash.insert(key, elmt->diagram()->title());
}
else if (key == "folio_pos") {
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
}
else if (key == "folio_num") {
hash.insert(key, elmt->diagram()->border_and_titleblock.finalfolio());
}
else if (key == "label") {
hash.insert(key, elmt->actualLabel());
}
else {
hash.insert(key, elmt->elementInformations()[keys_hash.value(key)].toString());
}
}
}
else if (key == "label") {
hash.insert(key, elmt->actualLabel());
}
else {
hash.insert(key, elmt->elementInformations()[keys_hash.value(key)].toString());
}
}
return hash;
return hash;
}
/**
@@ -515,33 +515,33 @@ QHash<QString, QString> BOMExportDialog::elementInfoToString(Element *elmt) cons
*/
QString BOMExportDialog::queryStr() const
{
//User define is own query
if (ui->m_edit_sql_query_cb->isChecked()) {
return ui->m_sql_query->text();
}
//Made a string list with the colomns (keys) choosen by the user
//User define is own query
if (ui->m_edit_sql_query_cb->isChecked()) {
return ui->m_sql_query->text();
}
//Made a string list with the colomns (keys) choosen by the user
QStringList keys = selectedKeys();
keys.removeAll("designation_qty");
QString select ="SELECT ";
QString order_by = " ORDER BY ";
QString select ="SELECT ";
QString order_by = " ORDER BY ";
QString column;
bool first = true;
for (auto key: keys) {
if (first) {
first = false;
} else {
column += ", ";
order_by += ", ";
}
column += key;
order_by += key;
}
QString column;
bool first = true;
for (auto key: keys) {
if (first) {
first = false;
} else {
column += ", ";
order_by += ", ";
}
column += key;
order_by += key;
}
QString from = " FROM bom";
QString from = " FROM bom";
QString count = ui->m_format_as_bom_rb->isChecked() ? QString(", COUNT(*) AS designation_qty ") : QString();
QString where;
QString where;
if (ui->m_all_cb->checkState() == Qt::PartiallyChecked)
{
if (ui->m_terminal_cb->isChecked()) {
@@ -564,24 +564,24 @@ QString BOMExportDialog::queryStr() const
where += str;
}
}
QString where_bom;
if(ui->m_format_as_bom_rb->isChecked())
{
if (where.isEmpty()) {
where = " WHERE designation IS NOT NULL";
} else {
where.append(" AND designation IS NOT NULL");
}
QString where_bom;
if(ui->m_format_as_bom_rb->isChecked())
{
if (where.isEmpty()) {
where = " WHERE designation IS NOT NULL";
} else {
where.append(" AND designation IS NOT NULL");
}
}
}
QString group_by = ui->m_format_as_bom_rb->isChecked() ? " GROUP BY designation" : "";
QString group_by = ui->m_format_as_bom_rb->isChecked() ? " GROUP BY designation" : "";
QString q(select + column + count + from + where + where_bom + group_by + order_by);
return q;
return q;
}
void BOMExportDialog::updateQueryLine() {
ui->m_sql_query->setText(queryStr());
ui->m_sql_query->setText(queryStr());
}
/**
@@ -590,16 +590,16 @@ void BOMExportDialog::updateQueryLine() {
*/
void BOMExportDialog::fillSavedQuery()
{
QFile file(QETApp::configDir() + "/bill_of_materials.json");
if (file.open(QFile::ReadOnly))
{
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
QJsonObject jso = jsd.object();
QFile file(QETApp::configDir() + "/bill_of_materials.json");
if (file.open(QFile::ReadOnly))
{
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
QJsonObject jso = jsd.object();
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
ui->m_conf_cb->addItem(it.key());
}
}
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
ui->m_conf_cb->addItem(it.key());
}
}
}
void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) {
@@ -613,20 +613,20 @@ void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) {
*/
void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
{
ui->m_sql_query->setEnabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_info_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_parametre_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_sql_query->setEnabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_info_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_parametre_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
ui->m_format_as_gb->setDisabled(ui->m_edit_sql_query_cb->isChecked());
if (ui->m_edit_sql_query_cb->isChecked() && !m_custom_query.isEmpty())
{
ui->m_sql_query->setText(m_custom_query);
}
else if (!ui->m_edit_sql_query_cb->isChecked())
{
m_custom_query = ui->m_sql_query->text();
updateQueryLine();
}
if (ui->m_edit_sql_query_cb->isChecked() && !m_custom_query.isEmpty())
{
ui->m_sql_query->setText(m_custom_query);
}
else if (!ui->m_edit_sql_query_cb->isChecked())
{
m_custom_query = ui->m_sql_query->text();
updateQueryLine();
}
}
/**
@@ -635,22 +635,22 @@ void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
*/
void BOMExportDialog::on_m_save_current_conf_pb_clicked()
{
QFile file(QETApp::configDir() + "/bill_of_materials.json");
QFile file(QETApp::configDir() + "/bill_of_materials.json");
if (file.open(QFile::ReadWrite))
{
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
QJsonObject root_object;
if (file.open(QFile::ReadWrite))
{
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
QJsonObject root_object;
if (!jsd.isEmpty())
{
root_object = jsd.object();
if (root_object.contains(ui->m_save_name_le->text())) {
root_object.remove(ui->m_save_name_le->text());
}
}
if (!jsd.isEmpty())
{
root_object = jsd.object();
if (root_object.contains(ui->m_save_name_le->text())) {
root_object.remove(ui->m_save_name_le->text());
}
}
QVariantMap vm;
QVariantMap vm;
vm.insert("user query", ui->m_edit_sql_query_cb->isChecked());
if (ui->m_edit_sql_query_cb->isChecked()) {
@@ -681,10 +681,10 @@ void BOMExportDialog::on_m_save_current_conf_pb_clicked()
root_object[ui->m_save_name_le->text()] = QJsonObject::fromVariantMap(vm);
jsd.setObject(root_object);
file.resize(0);
file.write(jsd.toJson());
}
jsd.setObject(root_object);
file.resize(0);
file.write(jsd.toJson());
}
}
/**
@@ -724,7 +724,7 @@ void BOMExportDialog::on_m_load_pb_clicked()
ui->m_format_as_bom_rb->setChecked(value_object["format as bill of material"].toBool());
//Ugly hack to force to remove all selected infos
//Ugly hack to force to remove all selected infos
while (auto item = ui->m_choosen_list->takeItem(0)) {
ui->m_var_list->addItem(item);
}

View File

@@ -47,7 +47,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
if(tabbed)
ui->m_use_tab_mode_rb->setChecked(true);
else
ui->m_use_windows_mode_rb->setChecked(true);
ui->m_use_windows_mode_rb->setChecked(true);
ui->m_zoom_out_beyond_folio->setChecked(settings.value("diagrameditor/zoom-out-beyond-of-folio", false).toBool());
ui->m_use_gesture_trackpad->setChecked(settings.value("diagramview/gestures", false).toBool());
ui->m_save_label_paste->setChecked(settings.value("diagramcommands/erase-label-on-copy", true).toBool());
@@ -57,8 +57,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
ui->m_autosave_sb->setValue(settings.value("diagrameditor/autosave-interval", 0).toInt());
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
settings.value("diagramitemsize").toString() + " (" +
settings.value("diagramitemstyle").toString() + ")";
settings.value("diagramitemsize").toString() + " (" +
settings.value("diagramitemstyle").toString() + ")";
ui->m_font_pb->setText(fontInfos);
@@ -309,9 +309,9 @@ void GeneralConfigurationPage::on_m_font_pb_clicked()
settings.setValue("diagramitemweight", font.weight());
settings.setValue("diagramitemstyle", font.styleName());
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
settings.value("diagramitemsize").toString() + " (" +
settings.value("diagramitemstyle").toString() + ")";
ui->m_font_pb->setText(fontInfos);
settings.value("diagramitemsize").toString() + " (" +
settings.value("diagramitemstyle").toString() + ")";
ui->m_font_pb->setText(fontInfos);
}
}
@@ -339,7 +339,7 @@ void GeneralConfigurationPage::on_m_dyn_text_font_pb_clicked()
void GeneralConfigurationPage::on_m_common_elmt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection commune"), QDir::homePath());
if (!path.isEmpty()) {
@@ -353,7 +353,7 @@ void GeneralConfigurationPage::on_m_common_elmt_path_cb_currentIndexChanged(int
void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection utilisateur"), QDir::homePath());
if (!path.isEmpty()) {
@@ -367,7 +367,7 @@ void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int
void GeneralConfigurationPage::on_m_custom_tbt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin des cartouches utilisateur"), QDir::homePath());
if (!path.isEmpty()) {

View File

@@ -37,92 +37,92 @@ class DynamicElementTextModel : public QStandardItemModel
Q_OBJECT
public:
enum ValueType {
textFrom =1,
userText,
infoText,
compositeText,
txtAlignment,
size,
font,
color,
pos,
frame,
rotation,
textWidth,
grpAlignment,
grpPos,
grpRotation,
grpVAdjust,
grpName,
grpHoldBottom,
grpFrame
};
enum ValueType {
textFrom =1,
userText,
infoText,
compositeText,
txtAlignment,
size,
font,
color,
pos,
frame,
rotation,
textWidth,
grpAlignment,
grpPos,
grpRotation,
grpVAdjust,
grpName,
grpHoldBottom,
grpFrame
};
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
~DynamicElementTextModel() override;
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
~DynamicElementTextModel() override;
bool indexIsInGroup(const QModelIndex &index) const;
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
QModelIndex indexFromText(DynamicElementTextItem *text) const;
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
bool indexIsInGroup(const QModelIndex &index) const;
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
QModelIndex indexFromText(DynamicElementTextItem *text) const;
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
bool indexIsText(const QModelIndex &index) const;
bool indexIsGroup(const QModelIndex &index) const;
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
bool indexIsText(const QModelIndex &index) const;
bool indexIsGroup(const QModelIndex &index) const;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override;
signals:
void dataChanged();
private:
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
void addText(DynamicElementTextItem *deti);
void removeText(DynamicElementTextItem *deti);
void addGroup(ElementTextItemGroup *group);
void removeGroup(ElementTextItemGroup *group);
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
void enableGroupRotationAndPos(ElementTextItemGroup *group);
void itemDataChanged(QStandardItem *qsi);
void setConnection(DynamicElementTextItem *deti, bool set);
void setConnection(ElementTextItemGroup *group, bool set);
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type);
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type);
void dataChanged();
private:
QPointer<Element> m_element;
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
bool m_block_dataChanged = false;
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
void addText(DynamicElementTextItem *deti);
void removeText(DynamicElementTextItem *deti);
void addGroup(ElementTextItemGroup *group);
void removeGroup(ElementTextItemGroup *group);
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
void enableGroupRotationAndPos(ElementTextItemGroup *group);
void itemDataChanged(QStandardItem *qsi);
void setConnection(DynamicElementTextItem *deti, bool set);
void setConnection(ElementTextItemGroup *group, bool set);
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type);
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type);
private:
QPointer<Element> m_element;
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
bool m_block_dataChanged = false;
};
class DynamicTextItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
public:
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
protected:
bool eventFilter(QObject *object, QEvent *event) override;
bool eventFilter(QObject *object, QEvent *event) override;
private:
QStringList availableInfo(DynamicElementTextItem *deti) const;
QStringList availableInfo(DynamicElementTextItem *deti) const;
};
#endif // DYNAMICELEMENTTEXTMODEL_H

View File

@@ -220,10 +220,10 @@ void LinkSingleElementWidget::buildTree()
QStringList search_list;
QStringList str_list;
str_list << elmt->actualLabel();
if(!str_list.last().isEmpty()) {
search_list << str_list.last();
}
str_list << elmt->actualLabel();
if(!str_list.last().isEmpty()) {
search_list << str_list.last();
}
str_list << elmt->elementInformations()["comment"].toString();
if (!str_list.last().isEmpty())
@@ -347,7 +347,7 @@ bool LinkSingleElementWidget::setLiveEdit(bool live_edit)
QList <Element *> LinkSingleElementWidget::availableElements()
{
QList <Element *> elmt_list;
//if element isn't free and unlink isn't pressed, return an empty list
//if element isn't free and unlink isn't pressed, return an empty list
if (!m_element->isFree() && !m_unlink)
return elmt_list;
@@ -359,7 +359,7 @@ QList <Element *> LinkSingleElementWidget::availableElements()
else
elmt_list = ep.find(m_filter);
//If element is linked, remove is parent from the list
//If element is linked, remove is parent from the list
if(!m_element->isFree()) elmt_list.removeAll(m_element->linkedElements().first());
return elmt_list;
@@ -445,8 +445,8 @@ void LinkSingleElementWidget::setUpHeaderLabels()
*/
void LinkSingleElementWidget::diagramWasRemovedFromProject()
{
//We use a timer because if the removed diagram contain the master element linked to the edited element
//we must to wait for this elements be unlinked, else the list of available master isn't up to date
//We use a timer because if the removed diagram contain the master element linked to the edited element
//we must to wait for this elements be unlinked, else the list of available master isn't up to date
QTimer::singleShot(10, this, SLOT(updateUi()));
}
@@ -473,8 +473,8 @@ void LinkSingleElementWidget::linkTriggered()
}
else
{
//In no live edit mode, we set the background of the qtwi green, to inform the user
//which element will be linked when he press the apply button
//In no live edit mode, we set the background of the qtwi green, to inform the user
//which element will be linked when he press the apply button
if (m_pending_qtwi)
{
for(int i=0 ; i<6 ; i++)
@@ -564,8 +564,8 @@ void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem
void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested(const QPoint &pos)
{
//add the size of the header to display the topleft of the QMenu at the position of the mouse.
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
//add the size of the header to display the topleft of the QMenu at the position of the mouse.
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
QPoint point = pos;
point.ry()+=ui->m_tree_widget->header()->height();
point = ui->m_tree_widget->mapToGlobal(point);
@@ -606,7 +606,7 @@ void LinkSingleElementWidget::on_m_show_this_pb_clicked()
*/
void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)
{
//Show all items if arg1 is empty, if not hide all items
//Show all items if arg1 is empty, if not hide all items
foreach(QTreeWidgetItem *qtwi, m_qtwi_elmt_hash.keys())
qtwi->setHidden(!arg1.isEmpty());
@@ -624,7 +624,7 @@ void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)
}
}
//Show items which match with arg1
//Show items which match with arg1
foreach(QTreeWidgetItem *qtwi, qtwi_list)
qtwi->setHidden(false);
}

View File

@@ -104,7 +104,7 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
seq_num = conductor_in_potential->sequenceNum();
number = conductor_in_potential->relatedPotentialConductors().size()+1; //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors
c_list = conductor_in_potential->relatedPotentialConductors().values();
c_list = conductor_in_potential->relatedPotentialConductors().values();
c_list.append(conductor_in_potential);
foreach(Conductor *c, c_list)
properties_list.append(c->properties());