mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix indentation code
This commit is contained in:
@@ -68,7 +68,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
|||||||
if (m_potential_conductors.isEmpty()) {
|
if (m_potential_conductors.isEmpty()) {
|
||||||
m_potential_conductors << c;
|
m_potential_conductors << c;
|
||||||
} else {
|
} else {
|
||||||
if (!potentialIsManaged(c->relatedPotentialConductors(true).values())) {
|
if (!potentialIsManaged(c->relatedPotentialConductors(true).values())) {
|
||||||
m_potential_conductors << c;
|
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 each selected element, we determine if conductors must be moved or updated.
|
||||||
for(Element *elmt : m_elements)
|
for(Element *elmt : m_elements)
|
||||||
{
|
{
|
||||||
if (elmt->isSelected())
|
if (elmt->isSelected())
|
||||||
{
|
{
|
||||||
for(Terminal *terminal : elmt->terminals())
|
for(Terminal *terminal : elmt->terminals())
|
||||||
{
|
{
|
||||||
for(Conductor *conductor : terminal->conductors())
|
for(Conductor *conductor : terminal->conductors())
|
||||||
{
|
{
|
||||||
Terminal *other_terminal;
|
Terminal *other_terminal;
|
||||||
if (conductor->terminal1 == terminal)
|
if (conductor->terminal1 == terminal)
|
||||||
other_terminal = conductor->terminal2;
|
other_terminal = conductor->terminal2;
|
||||||
else
|
else
|
||||||
other_terminal = conductor->terminal1;
|
other_terminal = conductor->terminal1;
|
||||||
|
|
||||||
//If the two elements of conductor are movable
|
//If the two elements of conductor are movable
|
||||||
if (m_elements.contains(other_terminal -> parentElement())) {
|
if (m_elements.contains(other_terminal -> parentElement())) {
|
||||||
if (!m_conductors_to_move.contains(conductor))
|
if (!m_conductors_to_move.contains(conductor))
|
||||||
m_conductors_to_move << conductor;
|
m_conductors_to_move << conductor;
|
||||||
}
|
}
|
||||||
else if (!m_conductors_to_update.contains(conductor))
|
else if (!m_conductors_to_update.contains(conductor))
|
||||||
m_conductors_to_update << conductor;
|
m_conductors_to_update << conductor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
|
|||||||
if (!new_part)
|
if (!new_part)
|
||||||
{
|
{
|
||||||
if (part)
|
if (part)
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
|
|
||||||
part = nullptr;
|
part = nullptr;
|
||||||
style_ -> setPart(nullptr);
|
style_ -> setPart(nullptr);
|
||||||
@@ -117,11 +117,11 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
|
|||||||
{
|
{
|
||||||
if (part == part_arc) return true;
|
if (part == part_arc) return true;
|
||||||
if (part)
|
if (part)
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
part = part_arc;
|
part = part_arc;
|
||||||
style_ -> setPart(part);
|
style_ -> setPart(part);
|
||||||
updateForm();
|
updateForm();
|
||||||
setUpChangeConnections();
|
setUpChangeConnections();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,12 +130,12 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
|
|||||||
|
|
||||||
bool ArcEditor::setParts(QList <CustomElementPart *> parts)
|
bool ArcEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
{
|
{
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setPart(parts.first()))
|
if (!setPart(parts.first()))
|
||||||
return false;
|
return false;
|
||||||
return style_->setParts(parts);
|
return style_->setParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +147,7 @@ CustomElementPart *ArcEditor::currentPart() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart*> ArcEditor::currentParts() const {
|
QList<CustomElementPart*> ArcEditor::currentParts() const {
|
||||||
return style_->currentParts();
|
return style_->currentParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,20 +158,20 @@ void ArcEditor::updateArcS()
|
|||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
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"))
|
if (value != arc->property("startAngle"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "startAngle", arc->property("startAngle"), value);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "startAngle", arc->property("startAngle"), value);
|
||||||
undo->setText("Modifier l'angle de depart d'un arc");
|
undo->setText("Modifier l'angle de depart d'un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
@@ -186,17 +186,17 @@ void ArcEditor::updateArcA()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
double value = angle->value() * 16;
|
double value = 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("spanAngle"))
|
if (value != arc->property("spanAngle"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "spanAngle", arc->property("spanAngle"), value);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "spanAngle", arc->property("spanAngle"), value);
|
||||||
undo->setText("Modifier l'angle d'un arc");
|
undo->setText("Modifier l'angle d'un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
@@ -210,95 +210,95 @@ void ArcEditor::updateArcRectX()
|
|||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartArc* arc = static_cast<PartArc*>(part);
|
PartArc* arc = static_cast<PartArc*>(part);
|
||||||
QRectF rect = arc->property("rect").toRectF();
|
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
|
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
|
rect.setX(point.x()); // change only the x value
|
||||||
|
|
||||||
if (rect != part->property("rect"))
|
if (rect != part->property("rect"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcEditor::updateArcRectY()
|
void ArcEditor::updateArcRectY()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartArc* arc = static_cast<PartArc*>(part);
|
PartArc* arc = static_cast<PartArc*>(part);
|
||||||
QRectF rect = arc->property("rect").toRectF();
|
QRectF rect = arc->property("rect").toRectF();
|
||||||
|
|
||||||
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
|
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
|
||||||
rect.setY(point.y());
|
rect.setY(point.y());
|
||||||
|
|
||||||
if (rect != arc->property("rect"))
|
if (rect != arc->property("rect"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcEditor::updateArcRectH()
|
void ArcEditor::updateArcRectH()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartArc* arc = static_cast<PartArc*>(part);
|
PartArc* arc = static_cast<PartArc*>(part);
|
||||||
QRectF rect = arc->property("rect").toRectF();
|
QRectF rect = arc->property("rect").toRectF();
|
||||||
|
|
||||||
if (rect.width() != h->value())
|
if (rect.width() != h->value())
|
||||||
{
|
{
|
||||||
rect.setWidth(h->value());
|
rect.setWidth(h->value());
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcEditor::updateArcRectV()
|
void ArcEditor::updateArcRectV()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartArc* arc = static_cast<PartArc*>(part);
|
PartArc* arc = static_cast<PartArc*>(part);
|
||||||
QRectF rect = arc->property("rect").toRectF();
|
QRectF rect = arc->property("rect").toRectF();
|
||||||
|
|
||||||
if (rect.height() != v->value())
|
if (rect.height() != v->value())
|
||||||
{
|
{
|
||||||
rect.setHeight(v->value());
|
rect.setHeight(v->value());
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,19 +329,19 @@ void ArcEditor::activeConnections(bool active)
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
|
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
|
||||||
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
|
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
|
||||||
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
|
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
|
||||||
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
|
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
|
||||||
connect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
connect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
||||||
connect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
connect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
|
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
|
||||||
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
|
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
|
||||||
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
|
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
|
||||||
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
|
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
|
||||||
disconnect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
disconnect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
||||||
disconnect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
disconnect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,31 +47,31 @@ class ArcEditor : public ElementItemEditor
|
|||||||
QSpinBox *angle, *start_angle;
|
QSpinBox *angle, *start_angle;
|
||||||
bool m_locked;
|
bool m_locked;
|
||||||
|
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
QList <QMetaObject::Connection> m_change_connections;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
bool setPart(CustomElementPart *) override;
|
bool setPart(CustomElementPart *) override;
|
||||||
bool setParts(QList <CustomElementPart *> parts) override;
|
bool setParts(QList <CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateArcS();
|
void updateArcS();
|
||||||
void updateArcA();
|
void updateArcA();
|
||||||
void updateArcRectX();
|
void updateArcRectX();
|
||||||
void updateArcRectY();
|
void updateArcRectY();
|
||||||
void updateArcRectH();
|
void updateArcRectH();
|
||||||
void updateArcRectV();
|
void updateArcRectV();
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void activeConnections(bool);
|
void activeConnections(bool);
|
||||||
/*!
|
/*!
|
||||||
* \brief setUpChangeConnections
|
* \brief setUpChangeConnections
|
||||||
* Setup the connection from the arc(s) to the widget, to update it when the arc(s) are changed (moved ...)
|
* Setup the connection from the arc(s) to the widget, to update it when the arc(s) are changed (moved ...)
|
||||||
*/
|
*/
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
void disconnectChangeConnections();
|
void disconnectChangeConnections();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ void ElementView::wheelEvent(QWheelEvent *e) {
|
|||||||
if (e -> modifiers() & Qt::ControlModifier)
|
if (e -> modifiers() & Qt::ControlModifier)
|
||||||
e -> angleDelta().y() > 0 ? zoomInSlowly() : zoomOutSlowly();
|
e -> angleDelta().y() > 0 ? zoomInSlowly() : zoomOutSlowly();
|
||||||
else
|
else
|
||||||
QGraphicsView::wheelEvent(e);
|
QGraphicsView::wheelEvent(e);
|
||||||
} else {
|
} else {
|
||||||
e -> angleDelta().y() > 0 ? zoomIn(): zoomOut();
|
e -> angleDelta().y() > 0 ? zoomIn(): zoomOut();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
|
|||||||
if (!new_part)
|
if (!new_part)
|
||||||
{
|
{
|
||||||
if (part)
|
if (part)
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
part = nullptr;
|
part = nullptr;
|
||||||
style_ -> setPart(nullptr);
|
style_ -> setPart(nullptr);
|
||||||
return(true);
|
return(true);
|
||||||
@@ -105,11 +105,11 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
|
|||||||
{
|
{
|
||||||
if (part == part_ellipse) return true;
|
if (part == part_ellipse) return true;
|
||||||
if (part)
|
if (part)
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
part = part_ellipse;
|
part = part_ellipse;
|
||||||
style_ -> setPart(part);
|
style_ -> setPart(part);
|
||||||
updateForm();
|
updateForm();
|
||||||
setUpChangeConnections();
|
setUpChangeConnections();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
@@ -117,12 +117,12 @@ bool EllipseEditor::setPart(CustomElementPart *new_part)
|
|||||||
|
|
||||||
bool EllipseEditor::setParts(QList <CustomElementPart *> parts)
|
bool EllipseEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
{
|
{
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setPart(parts.first()))
|
if (!setPart(parts.first()))
|
||||||
return false;
|
return false;
|
||||||
return style_->setParts(parts);
|
return style_->setParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,98 +138,98 @@ QList<CustomElementPart*> EllipseEditor::currentParts() const {
|
|||||||
|
|
||||||
void EllipseEditor::editingFinishedX()
|
void EllipseEditor::editingFinishedX()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
||||||
QRectF rect = ell->property("rect").toRectF();
|
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
|
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
|
rect.setX(point.x()); // change only the x value
|
||||||
|
|
||||||
if (rect != part->property("rect"))
|
if (rect != part->property("rect"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipseEditor::editingFinishedY()
|
void EllipseEditor::editingFinishedY()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
||||||
QRectF rect = ell->property("rect").toRectF();
|
QRectF rect = ell->property("rect").toRectF();
|
||||||
|
|
||||||
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
|
QPointF point = ell->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
|
||||||
rect.setY(point.y());
|
rect.setY(point.y());
|
||||||
|
|
||||||
if (rect != ell->property("rect"))
|
if (rect != ell->property("rect"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipseEditor::editingFinishedH()
|
void EllipseEditor::editingFinishedH()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
||||||
QRectF rect = ell->property("rect").toRectF();
|
QRectF rect = ell->property("rect").toRectF();
|
||||||
|
|
||||||
if (rect.width() != h->value())
|
if (rect.width() != h->value())
|
||||||
{
|
{
|
||||||
rect.setWidth(h->value());
|
rect.setWidth(h->value());
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipseEditor::editingFinishedV()
|
void EllipseEditor::editingFinishedV()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
PartEllipse* ell = static_cast<PartEllipse*>(part);
|
||||||
QRectF rect = ell->property("rect").toRectF();
|
QRectF rect = ell->property("rect").toRectF();
|
||||||
|
|
||||||
if (rect.height() != v->value())
|
if (rect.height() != v->value())
|
||||||
{
|
{
|
||||||
rect.setHeight(v->value());
|
rect.setHeight(v->value());
|
||||||
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
QPropertyUndoCommand *undo= new QPropertyUndoCommand(ell, "rect", ell->property("rect"), rect);
|
||||||
undo->setText("Modifier un arc");
|
undo->setText("Modifier un arc");
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,16 +255,16 @@ void EllipseEditor::activeConnections(bool active)
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
connect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
|
connect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
|
||||||
connect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
|
connect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
|
||||||
connect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
|
connect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
|
||||||
connect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
|
connect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
|
disconnect(x, SIGNAL(editingFinished()), this, SLOT(editingFinishedX()));
|
||||||
disconnect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
|
disconnect(y, SIGNAL(editingFinished()), this, SLOT(editingFinishedY()));
|
||||||
disconnect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
|
disconnect(h, SIGNAL(editingFinished()), this, SLOT(editingFinishedH()));
|
||||||
disconnect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
|
disconnect(v, SIGNAL(editingFinished()), this, SLOT(editingFinishedV()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,29 +44,29 @@ class EllipseEditor : public ElementItemEditor
|
|||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QDoubleSpinBox *x, *y, *h, *v;
|
QDoubleSpinBox *x, *y, *h, *v;
|
||||||
bool m_locked;
|
bool m_locked;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
QList <QMetaObject::Connection> m_change_connections;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
bool setPart(CustomElementPart *) override;
|
bool setPart(CustomElementPart *) override;
|
||||||
bool setParts(QList <CustomElementPart *> parts) override;
|
bool setParts(QList <CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void editingFinishedX();
|
void editingFinishedX();
|
||||||
void editingFinishedY();
|
void editingFinishedY();
|
||||||
void editingFinishedH();
|
void editingFinishedH();
|
||||||
void editingFinishedV();
|
void editingFinishedV();
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void activeConnections(bool);
|
void activeConnections(bool);
|
||||||
/*!
|
/*!
|
||||||
* \brief setUpChangeConnections
|
* \brief setUpChangeConnections
|
||||||
* Setup the connection from the ellipse(s) to the widget, to update it when the ellipse(s) are changed (moved ...)
|
* Setup the connection from the ellipse(s) to the widget, to update it when the ellipse(s) are changed (moved ...)
|
||||||
*/
|
*/
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
void disconnectChangeConnections();
|
void disconnectChangeConnections();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -265,11 +265,11 @@ void PartPolygon::setClosed(bool close)
|
|||||||
*/
|
*/
|
||||||
void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
|
void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
|
||||||
{
|
{
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||||
if (qghi->pos() == mapToScene(pos)) {
|
if (qghi->pos() == mapToScene(pos)) {
|
||||||
qghi->setColor(color);
|
qghi->setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,9 +278,9 @@ void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
|
|||||||
*/
|
*/
|
||||||
void PartPolygon::resetAllHandlerColor()
|
void PartPolygon::resetAllHandlerColor()
|
||||||
{
|
{
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||||
qghi->setColor(Qt::blue);
|
qghi->setColor(Qt::blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ bool LineEditor::setPart(CustomElementPart *new_part)
|
|||||||
{
|
{
|
||||||
if (part)
|
if (part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
part = nullptr;
|
part = nullptr;
|
||||||
style_ -> setPart(nullptr);
|
style_ -> setPart(nullptr);
|
||||||
@@ -133,12 +133,12 @@ bool LineEditor::setPart(CustomElementPart *new_part)
|
|||||||
if (part == part_line) return true;
|
if (part == part_line) return true;
|
||||||
if (part)
|
if (part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
part = part_line;
|
part = part_line;
|
||||||
style_ -> setPart(part);
|
style_ -> setPart(part);
|
||||||
updateForm();
|
updateForm();
|
||||||
setUpChangeConnections();
|
setUpChangeConnections();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
@@ -146,12 +146,12 @@ bool LineEditor::setPart(CustomElementPart *new_part)
|
|||||||
|
|
||||||
bool LineEditor::setParts(QList <CustomElementPart *> parts)
|
bool LineEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
{
|
{
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setPart(parts.first()))
|
if (!setPart(parts.first()))
|
||||||
return false;
|
return false;
|
||||||
return style_->setParts(parts);
|
return style_->setParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,17 +188,17 @@ void LineEditor::updateLineEndType1()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
QVariant end = end1_type -> itemData(end1_type->currentIndex());
|
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"))
|
if (end != line->property("end1"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end1", line->property("end1"), end);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end1", line->property("end1"), end);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,18 +209,18 @@ void LineEditor::updateLineEndLength1()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
double length = end1_length->value();
|
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"))
|
if (length != line->property("length1"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length1", line->property("length1"), length);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length1", line->property("length1"), length);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,17 +231,17 @@ void LineEditor::updateLineEndType2()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
QVariant end = end2_type -> itemData(end2_type->currentIndex());
|
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"))
|
if (end != line->property("end2"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end2", line->property("end2"), end);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "end2", line->property("end2"), end);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,18 +252,18 @@ void LineEditor::updateLineEndLength2()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
double length = end2_length->value();
|
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"))
|
if (length != line->property("length2"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length2", line->property("length2"), length);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(line, "length2", line->property("length2"), length);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,99 +272,99 @@ void LineEditor::lineEditingFinishedX1()
|
|||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartLine* l = static_cast<PartLine*>(part);
|
PartLine* l = static_cast<PartLine*>(part);
|
||||||
QLineF line = l->property("line").toLineF();
|
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())
|
if (p1.x() != line.p1().x())
|
||||||
{
|
{
|
||||||
p1.setY(line.p1().y()); // restore old y value
|
p1.setY(line.p1().y()); // restore old y value
|
||||||
line.setP1(p1);
|
line.setP1(p1);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEditor::lineEditingFinishedY1()
|
void LineEditor::lineEditingFinishedY1()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartLine* l = static_cast<PartLine*>(part);
|
PartLine* l = static_cast<PartLine*>(part);
|
||||||
QLineF line = l->property("line").toLineF();
|
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())
|
if (p1.y() != line.p1().y())
|
||||||
{
|
{
|
||||||
p1.setX(line.p1().x()); // restore old x value
|
p1.setX(line.p1().x()); // restore old x value
|
||||||
line.setP1(p1);
|
line.setP1(p1);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEditor::lineEditingFinishedX2()
|
void LineEditor::lineEditingFinishedX2()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartLine* l = static_cast<PartLine*>(part);
|
PartLine* l = static_cast<PartLine*>(part);
|
||||||
QLineF line = l->property("line").toLineF();
|
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())
|
if (p2.x() != line.p1().x())
|
||||||
{
|
{
|
||||||
p2.setY(line.p2().y()); // restore old y value
|
p2.setY(line.p2().y()); // restore old y value
|
||||||
line.setP2(p2);
|
line.setP2(p2);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEditor::lineEditingFinishedY2()
|
void LineEditor::lineEditingFinishedY2()
|
||||||
{
|
{
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
|
|
||||||
for (auto part: style_->currentParts()) {
|
for (auto part: style_->currentParts()) {
|
||||||
|
|
||||||
PartLine* l = static_cast<PartLine*>(part);
|
PartLine* l = static_cast<PartLine*>(part);
|
||||||
QLineF line = l->property("line").toLineF();
|
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())
|
if (p2.y() != line.p1().y())
|
||||||
{
|
{
|
||||||
p2.setX(line.p2().x()); // restore old y value
|
p2.setX(line.p2().x()); // restore old y value
|
||||||
line.setP2(p2);
|
line.setP2(p2);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(l, "line", l->property("line"), line);
|
||||||
undo->setText(tr("Modifier une ligne"));
|
undo->setText(tr("Modifier une ligne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,10 +398,10 @@ void LineEditor::activeConnections(bool active)
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
connect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
|
connect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
|
||||||
connect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
|
connect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
|
||||||
connect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
|
connect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
|
||||||
connect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
|
connect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
|
||||||
connect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
connect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
||||||
connect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
connect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
||||||
connect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
connect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
||||||
@@ -409,10 +409,10 @@ void LineEditor::activeConnections(bool active)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
|
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX1()));
|
||||||
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
|
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY1()));
|
||||||
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
|
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedX2()));
|
||||||
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
|
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinishedY2()));
|
||||||
disconnect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
disconnect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
||||||
disconnect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
disconnect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
||||||
disconnect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
disconnect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ class LineEditor : public ElementItemEditor
|
|||||||
QComboBox *end1_type, *end2_type;
|
QComboBox *end1_type, *end2_type;
|
||||||
QDoubleSpinBox*end1_length, *end2_length;
|
QDoubleSpinBox*end1_length, *end2_length;
|
||||||
bool m_locked;
|
bool m_locked;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
QList <QMetaObject::Connection> m_change_connections;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
bool setPart(CustomElementPart *) override;
|
bool setPart(CustomElementPart *) override;
|
||||||
bool setParts(QList <CustomElementPart *> parts) override;
|
bool setParts(QList <CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
QPointF editedP1() const;
|
QPointF editedP1() const;
|
||||||
QPointF editedP2() const;
|
QPointF editedP2() const;
|
||||||
|
|
||||||
@@ -62,19 +62,19 @@ class LineEditor : public ElementItemEditor
|
|||||||
void updateLineEndLength1();
|
void updateLineEndLength1();
|
||||||
void updateLineEndType2();
|
void updateLineEndType2();
|
||||||
void updateLineEndLength2();
|
void updateLineEndLength2();
|
||||||
void lineEditingFinishedX1();
|
void lineEditingFinishedX1();
|
||||||
void lineEditingFinishedY1();
|
void lineEditingFinishedY1();
|
||||||
void lineEditingFinishedX2();
|
void lineEditingFinishedX2();
|
||||||
void lineEditingFinishedY2();
|
void lineEditingFinishedY2();
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void activeConnections(bool);
|
void activeConnections(bool);
|
||||||
/*!
|
/*!
|
||||||
* \brief setUpChangeConnections
|
* \brief setUpChangeConnections
|
||||||
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
||||||
*/
|
*/
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
void disconnectChangeConnections();
|
void disconnectChangeConnections();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -610,119 +610,119 @@ void QETElementEditor::slot_setNoDragToView() {
|
|||||||
void QETElementEditor::slot_updateInformations()
|
void QETElementEditor::slot_updateInformations()
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
|
QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
|
||||||
if (selected_qgis.isEmpty()) {
|
if (selected_qgis.isEmpty()) {
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
|
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
|
||||||
"",
|
"",
|
||||||
selected_qgis.size()));
|
selected_qgis.size()));
|
||||||
m_default_informations -> setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
m_default_informations -> setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||||
m_tools_dock_stack -> setCurrentIndex(0);
|
m_tools_dock_stack -> setCurrentIndex(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart *> cep_list;
|
QList<CustomElementPart *> cep_list;
|
||||||
|
|
||||||
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
|
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
|
||||||
QString selection_xml_name = part->xmlName();
|
QString selection_xml_name = part->xmlName();
|
||||||
bool same_xml_name = true;
|
bool same_xml_name = true;
|
||||||
bool style_editable = true;
|
bool style_editable = true;
|
||||||
for (QGraphicsItem *qgi: selected_qgis) {
|
for (QGraphicsItem *qgi: selected_qgis) {
|
||||||
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||||
cep_list << cep;
|
cep_list << cep;
|
||||||
if (cep->xmlName() != selection_xml_name)
|
if (cep->xmlName() != selection_xml_name)
|
||||||
same_xml_name = false;
|
same_xml_name = false;
|
||||||
} else {
|
} else {
|
||||||
style_editable = false;
|
style_editable = false;
|
||||||
same_xml_name = false;
|
same_xml_name = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (style_editable)
|
if (style_editable)
|
||||||
style_editable = StyleEditor::isStyleEditable(cep_list);
|
style_editable = StyleEditor::isStyleEditable(cep_list);
|
||||||
|
|
||||||
if (same_xml_name) {
|
if (same_xml_name) {
|
||||||
if (selection_xml_name == "terminal" ||
|
if (selection_xml_name == "terminal" ||
|
||||||
selection_xml_name == "text" ||
|
selection_xml_name == "text" ||
|
||||||
selection_xml_name == "dynamic_text" ||
|
selection_xml_name == "dynamic_text" ||
|
||||||
selection_xml_name == "line" ||
|
selection_xml_name == "line" ||
|
||||||
selection_xml_name == "rect" ||
|
selection_xml_name == "rect" ||
|
||||||
selection_xml_name == "ellipse" ||
|
selection_xml_name == "ellipse" ||
|
||||||
selection_xml_name == "arc") {
|
selection_xml_name == "arc") {
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
//We add the editor widget
|
//We add the editor widget
|
||||||
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
||||||
|
|
||||||
// TODO: Check if it takes longer than setting the parts again to the editor.
|
// TODO: Check if it takes longer than setting the parts again to the editor.
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
QList<CustomElementPart*> parts = editor->currentParts();
|
QList<CustomElementPart*> parts = editor->currentParts();
|
||||||
if (parts.length() == cep_list.length()) {
|
if (parts.length() == cep_list.length()) {
|
||||||
for (auto cep: cep_list) {
|
for (auto cep: cep_list) {
|
||||||
bool part_found = false;
|
bool part_found = false;
|
||||||
for (auto part: parts) {
|
for (auto part: parts) {
|
||||||
if (part == cep) {
|
if (part == cep) {
|
||||||
part_found = true;
|
part_found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!part_found) {
|
if (!part_found) {
|
||||||
equal = false;
|
equal = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
equal = false;
|
equal = false;
|
||||||
|
|
||||||
if (editor)
|
if (editor)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (equal == false) {
|
if (equal == false) {
|
||||||
success = editor->setParts(cep_list);
|
success = editor->setParts(cep_list);
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
m_tools_dock_stack->insertWidget(1, editor);
|
m_tools_dock_stack->insertWidget(1, editor);
|
||||||
m_tools_dock_stack -> setCurrentIndex(1);
|
m_tools_dock_stack -> setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Editor refused part.";
|
qDebug() << "Editor refused part.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
|
} else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
|
||||||
// multi edit for polygons makes no sense
|
// multi edit for polygons makes no sense
|
||||||
// TODO: maybe allowing multipart edit when number of points is the same?
|
// TODO: maybe allowing multipart edit when number of points is the same?
|
||||||
//We add the editor widget
|
//We add the editor widget
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
||||||
CustomElementPart* part = editor->currentPart();
|
CustomElementPart* part = editor->currentPart();
|
||||||
bool equal = part == cep_list.first();
|
bool equal = part == cep_list.first();
|
||||||
|
|
||||||
if (editor)
|
if (editor)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (equal == false) {
|
if (equal == false) {
|
||||||
success = editor->setPart(cep_list.first());
|
success = editor->setPart(cep_list.first());
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
m_tools_dock_stack->insertWidget(1, editor);
|
m_tools_dock_stack->insertWidget(1, editor);
|
||||||
m_tools_dock_stack -> setCurrentIndex(1);
|
m_tools_dock_stack -> setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Editor refused part.";
|
qDebug() << "Editor refused part.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Multiedit not supported for: " << cep_list.first()->xmlName();
|
qDebug() << "Multiedit not supported for: " << cep_list.first()->xmlName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//There's several parts selecteds and all can be edited by style editor.
|
//There's several parts selecteds and all can be edited by style editor.
|
||||||
if (style_editable)
|
if (style_editable)
|
||||||
{
|
{
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
ElementItemEditor *selection_editor = m_editors["style"];
|
ElementItemEditor *selection_editor = m_editors["style"];
|
||||||
|
|||||||
@@ -98,22 +98,22 @@ TerminalEditor::~TerminalEditor() {
|
|||||||
*/
|
*/
|
||||||
bool TerminalEditor::setPart(CustomElementPart* new_part)
|
bool TerminalEditor::setPart(CustomElementPart* new_part)
|
||||||
{
|
{
|
||||||
m_terminals.clear();
|
m_terminals.clear();
|
||||||
if (!new_part)
|
if (!new_part)
|
||||||
{
|
{
|
||||||
if (m_part)
|
if (m_part)
|
||||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
m_part = nullptr;
|
m_part = nullptr;
|
||||||
return(true);
|
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 == part_terminal) return true;
|
||||||
if (m_part)
|
if (m_part)
|
||||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
m_part = part_terminal;
|
m_part = part_terminal;
|
||||||
updateForm();
|
updateForm();
|
||||||
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
@@ -121,44 +121,44 @@ bool TerminalEditor::setPart(CustomElementPart* new_part)
|
|||||||
|
|
||||||
bool TerminalEditor::setParts(QList<CustomElementPart *> parts)
|
bool TerminalEditor::setParts(QList<CustomElementPart *> parts)
|
||||||
{
|
{
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
{
|
{
|
||||||
m_terminals.clear();
|
m_terminals.clear();
|
||||||
if (m_part)
|
if (m_part)
|
||||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
m_part = nullptr;
|
m_part = nullptr;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first()))
|
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first()))
|
||||||
{
|
{
|
||||||
if (m_part)
|
if (m_part)
|
||||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
m_part = part_terminal;
|
m_part = part_terminal;
|
||||||
m_terminals.clear();
|
m_terminals.clear();
|
||||||
m_terminals.append(part_terminal);
|
m_terminals.append(part_terminal);
|
||||||
for (int i=1; i < parts.length(); i++)
|
for (int i=1; i < parts.length(); i++)
|
||||||
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
|
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
|
||||||
updateForm();
|
updateForm();
|
||||||
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
|
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
|
||||||
*/
|
*/
|
||||||
CustomElementPart *TerminalEditor::currentPart() const {
|
CustomElementPart *TerminalEditor::currentPart() const {
|
||||||
return(m_part);
|
return(m_part);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart*> TerminalEditor::currentParts() const {
|
QList<CustomElementPart*> TerminalEditor::currentParts() const {
|
||||||
QList<CustomElementPart*> parts;
|
QList<CustomElementPart*> parts;
|
||||||
for (auto term: m_terminals) {
|
for (auto term: m_terminals) {
|
||||||
parts.append(static_cast<CustomElementPart*>(term));
|
parts.append(static_cast<CustomElementPart*>(term));
|
||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'orientation de la borne et cree un objet d'annulation
|
/// Met a jour l'orientation de la borne et cree un objet d'annulation
|
||||||
@@ -168,52 +168,52 @@ void TerminalEditor::updateTerminalO()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
QVariant var(orientation -> itemData(orientation -> currentIndex()));
|
QVariant var(orientation -> itemData(orientation -> currentIndex()));
|
||||||
|
|
||||||
for (int i=0; i < m_terminals.length(); i++) {
|
for (int i=0; i < m_terminals.length(); i++) {
|
||||||
PartTerminal* term = m_terminals[i];
|
PartTerminal* term = m_terminals[i];
|
||||||
if (var != term->property("orientation"))
|
if (var != term->property("orientation"))
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
|
||||||
undo->setText(tr("Modifier l'orientation d'une borne"));
|
undo->setText(tr("Modifier l'orientation d'une borne"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalEditor::updateXPos() {
|
void TerminalEditor::updateXPos() {
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
QPointF new_pos(qle_x->value(), 0);
|
QPointF new_pos(qle_x->value(), 0);
|
||||||
|
|
||||||
for (int i=0; i < m_terminals.length(); i++) {
|
for (int i=0; i < m_terminals.length(); i++) {
|
||||||
PartTerminal* term = m_terminals[i];
|
PartTerminal* term = m_terminals[i];
|
||||||
new_pos.setY(term->pos().y()); // change only x value
|
new_pos.setY(term->pos().y()); // change only x value
|
||||||
if (term->pos() != new_pos) {
|
if (term->pos() != new_pos) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
||||||
undo->setText(tr("Déplacer une borne"));
|
undo->setText(tr("Déplacer une borne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked=false;
|
m_locked=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalEditor::updateYPos() {
|
void TerminalEditor::updateYPos() {
|
||||||
if (m_locked) return;
|
if (m_locked) return;
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
QPointF new_pos(0, qle_y->value()); // change only y value
|
QPointF new_pos(0, qle_y->value()); // change only y value
|
||||||
|
|
||||||
for (int i=0; i < m_terminals.length(); i++) {
|
for (int i=0; i < m_terminals.length(); i++) {
|
||||||
PartTerminal* term = m_terminals[i];
|
PartTerminal* term = m_terminals[i];
|
||||||
new_pos.setX(term->pos().x());
|
new_pos.setX(term->pos().x());
|
||||||
if (term->pos() != new_pos) {
|
if (term->pos() != new_pos) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
||||||
undo->setText(tr("Déplacer une borne"));
|
undo->setText(tr("Déplacer une borne"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_locked=false;
|
m_locked=false;
|
||||||
}
|
}
|
||||||
/// update Number and name, create cancel object
|
/// update Number and name, create cancel object
|
||||||
|
|
||||||
@@ -221,11 +221,11 @@ void TerminalEditor::updateYPos() {
|
|||||||
Met a jour le formulaire d'edition
|
Met a jour le formulaire d'edition
|
||||||
*/
|
*/
|
||||||
void TerminalEditor::updateForm() {
|
void TerminalEditor::updateForm() {
|
||||||
if (!m_part) return;
|
if (!m_part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
qle_x -> setValue(m_part->property("x").toReal());
|
qle_x -> setValue(m_part->property("x").toReal());
|
||||||
qle_y -> setValue(m_part->property("y").toReal());
|
qle_y -> setValue(m_part->property("y").toReal());
|
||||||
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
|
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,14 +237,14 @@ void TerminalEditor::activeConnections(bool active)
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
connect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
|
connect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
|
||||||
connect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
|
connect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
|
||||||
connect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
|
connect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
|
disconnect(qle_x, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateXPos);
|
||||||
disconnect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
|
disconnect(qle_y, &QDoubleSpinBox::editingFinished, this, &TerminalEditor::updateYPos);
|
||||||
disconnect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
|
disconnect(orientation, QOverload<int>::of(&QComboBox::activated), this, &TerminalEditor::updateTerminalO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
|||||||
*/
|
*/
|
||||||
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
||||||
{
|
{
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
|
|
||||||
QGraphicsItem *qgi = part->toItem();
|
QGraphicsItem *qgi = part->toItem();
|
||||||
if(!qgi)
|
if(!qgi)
|
||||||
@@ -69,40 +69,40 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
|||||||
m_text_field = static_cast<PartDynamicTextField *>(qgi);
|
m_text_field = static_cast<PartDynamicTextField *>(qgi);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
setUpConnections();
|
setUpConnections();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
{
|
{
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
if (m_text_field) {
|
if (m_text_field) {
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
}
|
}
|
||||||
m_text_field = nullptr;
|
m_text_field = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
|
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
|
||||||
{
|
{
|
||||||
if (m_text_field) {
|
if (m_text_field) {
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text_field = part;
|
m_text_field = part;
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
m_parts.append(part);
|
m_parts.append(part);
|
||||||
for (int i=1; i < parts.length(); i++)
|
for (int i=1; i < parts.length(); i++)
|
||||||
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
||||||
|
|
||||||
setUpConnections();
|
setUpConnections();
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,11 +115,11 @@ CustomElementPart *DynamicTextFieldEditor::currentPart() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
|
QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
|
||||||
QList<CustomElementPart*> parts;
|
QList<CustomElementPart*> parts;
|
||||||
for (auto part: m_parts) {
|
for (auto part: m_parts) {
|
||||||
parts.append(static_cast<CustomElementPart*>(part));
|
parts.append(static_cast<CustomElementPart*>(part));
|
||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::updateForm()
|
void DynamicTextFieldEditor::updateForm()
|
||||||
@@ -156,26 +156,26 @@ void DynamicTextFieldEditor::updateForm()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections() {
|
void DynamicTextFieldEditor::setUpConnections() {
|
||||||
assert(m_connection_list.isEmpty());
|
assert(m_connection_list.isEmpty());
|
||||||
//Setup the connection
|
//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::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::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::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::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::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::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::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::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::textWidthChanged,[this]() {this->updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
|
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::disconnectConnections() {
|
void DynamicTextFieldEditor::disconnectConnections() {
|
||||||
//Remove previous connection
|
//Remove previous connection
|
||||||
if(!m_connection_list.isEmpty())
|
if(!m_connection_list.isEmpty())
|
||||||
for(const QMetaObject::Connection& con : m_connection_list)
|
for(const QMetaObject::Connection& con : m_connection_list)
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
m_connection_list.clear();
|
m_connection_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,101 +206,101 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
||||||
{
|
{
|
||||||
double value = ui->m_x_sb->value();
|
double value = ui->m_x_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo->enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
||||||
{
|
{
|
||||||
double value = ui->m_y_sb->value();
|
double value = ui->m_y_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo->enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
||||||
{
|
{
|
||||||
int value = ui->m_rotation_sb->value();
|
int value = ui->m_rotation_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
|
||||||
undo->setText(tr("Pivoter un champ texte"));
|
undo->setText(tr("Pivoter un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo->enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
||||||
{
|
{
|
||||||
QString text = ui->m_user_text_le->text();
|
QString text = ui->m_user_text_le->text();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
|
||||||
undo->setText(tr("Modifier le texte d'un champ texte"));
|
undo->setText(tr("Modifier le texte d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
||||||
{
|
{
|
||||||
QFont font_ = m_text_field->font();
|
QFont font_ = m_text_field->font();
|
||||||
font_.setPointSize(ui->m_size_sb->value());
|
font_.setPointSize(ui->m_size_sb->value());
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
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++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(frame != m_parts[i]->frame())
|
if(frame != m_parts[i]->frame())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
|
||||||
undo->setText(tr("Modifier le cadre d'un champ texte"));
|
undo->setText(tr("Modifier le cadre d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
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++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(width != m_parts[i]->textWidth())
|
if(width != m_parts[i]->textWidth())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
|
||||||
undo->setText(tr("Modifier la largeur d'un texte"));
|
undo->setText(tr("Modifier la largeur d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1)
|
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();
|
QString info = ui->m_elmt_info_cb->currentData().toString();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(info != m_parts[i]->infoName())
|
if(info != m_parts[i]->infoName())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
|
||||||
undo->setText(tr("Modifier l'information d'un texte"));
|
undo->setText(tr("Modifier l'information d'un texte"));
|
||||||
undoStack().push(undo);
|
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)
|
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 if(index == 1) tf = DynamicElementTextItem::ElementInfo;
|
||||||
else tf = DynamicElementTextItem::CompositeText;
|
else tf = DynamicElementTextItem::CompositeText;
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(tf != m_parts[i]->textFrom())
|
if(tf != m_parts[i]->textFrom())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
|
||||||
undo->setText(tr("Modifier la source de texte, d'un texte"));
|
undo->setText(tr("Modifier la source de texte, d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
||||||
@@ -337,29 +337,29 @@ void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
|||||||
if(ctd.exec())
|
if(ctd.exec())
|
||||||
{
|
{
|
||||||
QString ct = ctd.plainText();
|
QString ct = ctd.plainText();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(ct != m_parts[i]->compositeText())
|
if(ct != m_parts[i]->compositeText())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_alignment_pb_clicked()
|
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();
|
atd.exec();
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(atd.alignment() != m_parts[i]->alignment())
|
if(atd.alignment() != m_parts[i]->alignment())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.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"));
|
undo->setText(tr("Modifier l'alignement d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
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_font_pb->setText(font_.family());
|
||||||
ui->m_size_sb->setValue(font_.pointSize());
|
ui->m_size_sb->setValue(font_.pointSize());
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
|
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
|
||||||
{
|
{
|
||||||
if (!newColor.isValid())
|
if (!newColor.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(newColor != m_parts[i]->color())
|
if(newColor != m_parts[i]->color())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
|
||||||
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,30 +73,30 @@ void PolygonEditor::disconnectChangeConnections()
|
|||||||
*/
|
*/
|
||||||
bool PolygonEditor::setPart(CustomElementPart *new_part)
|
bool PolygonEditor::setPart(CustomElementPart *new_part)
|
||||||
{
|
{
|
||||||
if (!new_part)
|
if (!new_part)
|
||||||
{
|
{
|
||||||
if (m_part)
|
if (m_part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
m_part = nullptr;
|
m_part = nullptr;
|
||||||
m_style -> setPart(nullptr);
|
m_style -> setPart(nullptr);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
|
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
|
||||||
{
|
{
|
||||||
if (m_part == part_polygon) return true;
|
if (m_part == part_polygon) return true;
|
||||||
if (m_part)
|
if (m_part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
m_part = part_polygon;
|
m_part = part_polygon;
|
||||||
m_style -> setPart(m_part);
|
m_style -> setPart(m_part);
|
||||||
updateForm();
|
updateForm();
|
||||||
setUpChangeConnections();
|
setUpChangeConnections();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,35 +143,35 @@ void PolygonEditor::updateForm()
|
|||||||
*/
|
*/
|
||||||
QVector<QPointF> PolygonEditor::pointsFromTree()
|
QVector<QPointF> PolygonEditor::pointsFromTree()
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
|
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
|
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
|
||||||
bool x_convert_ok, y_convert_ok;
|
bool x_convert_ok, y_convert_ok;
|
||||||
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
|
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
|
||||||
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
|
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
|
||||||
if (x_convert_ok && y_convert_ok) {
|
if (x_convert_ok && y_convert_ok) {
|
||||||
points << m_part->mapFromScene(QPointF(x, y));
|
points << m_part->mapFromScene(QPointF(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(points);
|
return(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
|
bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (watched == ui->m_points_list_tree &&
|
if (watched == ui->m_points_list_tree &&
|
||||||
event->type() == QEvent::FocusOut &&
|
event->type() == QEvent::FocusOut &&
|
||||||
m_part)
|
m_part)
|
||||||
{
|
{
|
||||||
m_part->resetAllHandlerColor();
|
m_part->resetAllHandlerColor();
|
||||||
return true;
|
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)
|
void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arg1);
|
Q_UNUSED(arg1);
|
||||||
|
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool close = ui->m_close_polygon_cb->isChecked();
|
bool close = ui->m_close_polygon_cb->isChecked();
|
||||||
if (close != m_part->isClosed())
|
if (close != m_part->isClosed())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
|
||||||
undo->setText(tr("Modifier un polygone"));
|
undo->setText(tr("Modifier un polygone"));
|
||||||
undoStack().push(undo);
|
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)
|
void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
Q_UNUSED(column);
|
Q_UNUSED(column);
|
||||||
|
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPolygonF points = pointsFromTree();
|
QPolygonF points = pointsFromTree();
|
||||||
if (points.count() < 2)
|
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"));
|
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points != m_part->polygon())
|
if (points != m_part->polygon())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
|
||||||
undo->setText(tr("Modifier un polygone"));
|
undo->setText(tr("Modifier un polygone"));
|
||||||
undoStack().push(undo);
|
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()
|
void PolygonEditor::on_m_points_list_tree_itemSelectionChanged()
|
||||||
{
|
{
|
||||||
//Prevent when selection change but the widget ins't focused
|
//Prevent when selection change but the widget ins't focused
|
||||||
if (!ui->m_points_list_tree->hasFocus()) {
|
if (!ui->m_points_list_tree->hasFocus()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||||
if (!qtwi || !m_part) {
|
if (!qtwi || !m_part) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_part->resetAllHandlerColor();
|
m_part->resetAllHandlerColor();
|
||||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||||
|
|
||||||
//We need to check if index isn't out of range of polygon
|
//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
|
//this case can occur when user remove the last point of the polygon
|
||||||
//with the context menu of the tree widget
|
//with the context menu of the tree widget
|
||||||
if(index >= 0 &&
|
if(index >= 0 &&
|
||||||
index < m_part->polygon().size())
|
index < m_part->polygon().size())
|
||||||
{
|
{
|
||||||
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
|
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolygonEditor::on_m_add_point_action_triggered()
|
void PolygonEditor::on_m_add_point_action_triggered()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||||
if (!qtwi || !m_part) {
|
if (!qtwi || !m_part) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||||
QPolygonF new_polygon = m_part->polygon();
|
QPolygonF new_polygon = m_part->polygon();
|
||||||
|
|
||||||
//Special case when user add a point after the last point of the polygon
|
//Special case when user add a point after the last point of the polygon
|
||||||
if (index == m_part->polygon().size()-1)
|
if (index == m_part->polygon().size()-1)
|
||||||
{
|
{
|
||||||
QPointF p = m_part->polygon().last();
|
QPointF p = m_part->polygon().last();
|
||||||
p.rx()+=20;
|
p.rx()+=20;
|
||||||
p.ry()+=20;
|
p.ry()+=20;
|
||||||
new_polygon.append(p);
|
new_polygon.append(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPointF p = m_part->polygon().at(index) +
|
QPointF p = m_part->polygon().at(index) +
|
||||||
m_part->polygon().at(index+1);
|
m_part->polygon().at(index+1);
|
||||||
p/=2;
|
p/=2;
|
||||||
new_polygon.insert(index+1, p);
|
new_polygon.insert(index+1, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
//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"));
|
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
|
|
||||||
m_part->resetAllHandlerColor();
|
m_part->resetAllHandlerColor();
|
||||||
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
|
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolygonEditor::on_m_remove_point_action_triggered()
|
void PolygonEditor::on_m_remove_point_action_triggered()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||||
if (!qtwi || !m_part) {
|
if (!qtwi || !m_part) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPolygonF new_polygon = m_part->polygon();
|
QPolygonF new_polygon = m_part->polygon();
|
||||||
new_polygon.removeAt(ui->m_points_list_tree->indexOfTopLevelItem(qtwi));
|
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.
|
//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"));
|
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
|
||||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,39 +30,39 @@ namespace Ui {
|
|||||||
|
|
||||||
class PolygonEditor : public ElementItemEditor
|
class PolygonEditor : public ElementItemEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
|
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
|
||||||
~PolygonEditor() override;
|
~PolygonEditor() override;
|
||||||
|
|
||||||
bool setPart(CustomElementPart *part) override;
|
bool setPart(CustomElementPart *part) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
QVector<QPointF> pointsFromTree();
|
QVector<QPointF> pointsFromTree();
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_close_polygon_cb_stateChanged(int arg1);
|
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_itemChanged(QTreeWidgetItem *item, int column);
|
||||||
void on_m_points_list_tree_itemSelectionChanged();
|
void on_m_points_list_tree_itemSelectionChanged();
|
||||||
void on_m_add_point_action_triggered();
|
void on_m_add_point_action_triggered();
|
||||||
void on_m_remove_point_action_triggered();
|
void on_m_remove_point_action_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
* \brief setUpChangeConnections
|
* \brief setUpChangeConnections
|
||||||
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
||||||
*/
|
*/
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
void disconnectChangeConnections();
|
void disconnectChangeConnections();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PolygonEditor *ui;
|
Ui::PolygonEditor *ui;
|
||||||
StyleEditor *m_style = nullptr;
|
StyleEditor *m_style = nullptr;
|
||||||
PartPolygon *m_part = nullptr;
|
PartPolygon *m_part = nullptr;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
QList <QMetaObject::Connection> m_change_connections;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // POLYGONEDITOR_H
|
#endif // POLYGONEDITOR_H
|
||||||
|
|||||||
@@ -48,19 +48,19 @@ RectangleEditor::~RectangleEditor() {
|
|||||||
|
|
||||||
void RectangleEditor::setUpChangeConnections()
|
void RectangleEditor::setUpChangeConnections()
|
||||||
{
|
{
|
||||||
m_change_connections << connect(m_part, &PartRectangle::rectChanged, 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::XRadiusChanged, this, &RectangleEditor::updateForm);
|
||||||
m_change_connections << connect(m_part, &PartRectangle::YRadiusChanged, 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::xChanged, this, &RectangleEditor::updateForm);
|
||||||
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
|
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::disconnectChangeConnections()
|
void RectangleEditor::disconnectChangeConnections()
|
||||||
{
|
{
|
||||||
for (QMetaObject::Connection c : m_change_connections) {
|
for (QMetaObject::Connection c : m_change_connections) {
|
||||||
disconnect(c);
|
disconnect(c);
|
||||||
}
|
}
|
||||||
m_change_connections.clear();
|
m_change_connections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +74,7 @@ bool RectangleEditor::setPart(CustomElementPart *part)
|
|||||||
{
|
{
|
||||||
if (m_part)
|
if (m_part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
m_part = nullptr;
|
m_part = nullptr;
|
||||||
m_style->setPart(nullptr);
|
m_style->setPart(nullptr);
|
||||||
@@ -88,12 +88,12 @@ bool RectangleEditor::setPart(CustomElementPart *part)
|
|||||||
}
|
}
|
||||||
if (m_part)
|
if (m_part)
|
||||||
{
|
{
|
||||||
disconnectChangeConnections();
|
disconnectChangeConnections();
|
||||||
}
|
}
|
||||||
m_part = part_rectangle;
|
m_part = part_rectangle;
|
||||||
m_style->setPart(m_part);
|
m_style->setPart(m_part);
|
||||||
updateForm();
|
updateForm();
|
||||||
setUpChangeConnections();
|
setUpChangeConnections();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,12 +102,12 @@ bool RectangleEditor::setPart(CustomElementPart *part)
|
|||||||
|
|
||||||
bool RectangleEditor::setParts(QList <CustomElementPart *> parts)
|
bool RectangleEditor::setParts(QList <CustomElementPart *> parts)
|
||||||
{
|
{
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setPart(parts.first()))
|
if (!setPart(parts.first()))
|
||||||
return false;
|
return false;
|
||||||
return m_style->setParts(parts);
|
return m_style->setParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +119,7 @@ CustomElementPart *RectangleEditor::currentPart() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart*> RectangleEditor::currentParts() const {
|
QList<CustomElementPart*> RectangleEditor::currentParts() const {
|
||||||
return m_style->currentParts();
|
return m_style->currentParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,152 +192,152 @@ void RectangleEditor::editingFinished()
|
|||||||
|
|
||||||
void RectangleEditor::xPosChanged()
|
void RectangleEditor::xPosChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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()) {
|
if (rect.x() != p.x()) {
|
||||||
rect.moveLeft(p.x());
|
rect.moveLeft(p.x());
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::yPosChanged()
|
void RectangleEditor::yPosChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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()) {
|
if (rect.y() != p.y()) {
|
||||||
rect.moveTop(p.y());
|
rect.moveTop(p.y());
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::widthChanged()
|
void RectangleEditor::widthChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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) {
|
if (rect.width() != width) {
|
||||||
rect.setWidth(width);
|
rect.setWidth(width);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::heightChanged()
|
void RectangleEditor::heightChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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) {
|
if (rect.height() != height) {
|
||||||
rect.setHeight(height);
|
rect.setHeight(height);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::xRadiusChanged()
|
void RectangleEditor::xRadiusChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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) {
|
if (rec->XRadius() != radius) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
|
||||||
undo->setAnimated();
|
undo->setAnimated();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleEditor::yRadiusChanged()
|
void RectangleEditor::yRadiusChanged()
|
||||||
{
|
{
|
||||||
if (m_locked) {
|
if (m_locked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked = true;
|
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) {
|
if (rec->YRadius() != radius) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
|
||||||
undo->setAnimated();
|
undo->setAnimated();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -351,20 +351,20 @@ void RectangleEditor::activeConnections(bool active)
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||||
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||||
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||||
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||||
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||||
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||||
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||||
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||||
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||||
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||||
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,38 +38,38 @@ class RectangleEditor : public ElementItemEditor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RectangleEditor(QETElementEditor *editor, PartRectangle *rect = nullptr, QWidget *parent = nullptr);
|
explicit RectangleEditor(QETElementEditor *editor, PartRectangle *rect = nullptr, QWidget *parent = nullptr);
|
||||||
~RectangleEditor() override;
|
~RectangleEditor() override;
|
||||||
|
|
||||||
bool setPart(CustomElementPart *part) override;
|
bool setPart(CustomElementPart *part) override;
|
||||||
bool setParts(QList <CustomElementPart *> parts) override;
|
bool setParts(QList <CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
QPointF editedTopLeft () const;
|
QPointF editedTopLeft () const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
private:
|
private:
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
void activeConnections(bool active);
|
void activeConnections(bool active);
|
||||||
void xPosChanged();
|
void xPosChanged();
|
||||||
void yPosChanged();
|
void yPosChanged();
|
||||||
void widthChanged();
|
void widthChanged();
|
||||||
void heightChanged();
|
void heightChanged();
|
||||||
void xRadiusChanged();
|
void xRadiusChanged();
|
||||||
void yRadiusChanged();
|
void yRadiusChanged();
|
||||||
/*!
|
/*!
|
||||||
* \brief setUpChangeConnections
|
* \brief setUpChangeConnections
|
||||||
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
|
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
|
||||||
*/
|
*/
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
void disconnectChangeConnections();
|
void disconnectChangeConnections();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_locked = false;
|
bool m_locked = false;
|
||||||
StyleEditor *m_style;
|
StyleEditor *m_style;
|
||||||
PartRectangle *m_part;
|
PartRectangle *m_part;
|
||||||
Ui::RectangleEditor *ui;
|
Ui::RectangleEditor *ui;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
QList <QMetaObject::Connection> m_change_connections;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECTANGLEEDITOR_H
|
#endif // RECTANGLEEDITOR_H
|
||||||
|
|||||||
@@ -107,18 +107,18 @@ bool TextEditor::setPart(CustomElementPart *part)
|
|||||||
if (!part)
|
if (!part)
|
||||||
{
|
{
|
||||||
m_text = nullptr;
|
m_text = nullptr;
|
||||||
disconnectChangeConnection();
|
disconnectChangeConnection();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartText *part_text = static_cast<PartText *>(part))
|
if (PartText *part_text = static_cast<PartText *>(part))
|
||||||
{
|
{
|
||||||
if (part_text == m_text) {
|
if (part_text == m_text) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
m_text = part_text;
|
m_text = part_text;
|
||||||
|
|
||||||
setUpChangeConnection(m_text);
|
setUpChangeConnection(m_text);
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
return true;
|
return true;
|
||||||
@@ -127,34 +127,34 @@ bool TextEditor::setPart(CustomElementPart *part)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditor::setParts(QList <CustomElementPart *> parts) {
|
bool TextEditor::setParts(QList <CustomElementPart *> parts) {
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty())
|
||||||
{
|
{
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
if (m_text) {
|
if (m_text) {
|
||||||
disconnectChangeConnection();
|
disconnectChangeConnection();
|
||||||
}
|
}
|
||||||
m_text = nullptr;
|
m_text = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartText *part= static_cast<PartText *>(parts.first()))
|
if (PartText *part= static_cast<PartText *>(parts.first()))
|
||||||
{
|
{
|
||||||
if (m_text) {
|
if (m_text) {
|
||||||
disconnectChangeConnection();
|
disconnectChangeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text = part;
|
m_text = part;
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
m_parts.append(part);
|
m_parts.append(part);
|
||||||
for (int i=1; i < parts.length(); i++)
|
for (int i=1; i < parts.length(); i++)
|
||||||
m_parts.append(static_cast<PartText*>(parts[i]));
|
m_parts.append(static_cast<PartText*>(parts[i]));
|
||||||
|
|
||||||
setUpChangeConnection(m_text);
|
setUpChangeConnection(m_text);
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,11 +166,11 @@ CustomElementPart *TextEditor::currentPart() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<CustomElementPart*> TextEditor::currentParts() const {
|
QList<CustomElementPart*> TextEditor::currentParts() const {
|
||||||
QList<CustomElementPart*> parts;
|
QList<CustomElementPart*> parts;
|
||||||
for (auto part: m_parts) {
|
for (auto part: m_parts) {
|
||||||
parts.append(static_cast<CustomElementPart*>(part));
|
parts.append(static_cast<CustomElementPart*>(part));
|
||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,77 +180,77 @@ QList<CustomElementPart*> TextEditor::currentParts() const {
|
|||||||
*/
|
*/
|
||||||
void TextEditor::setUpEditConnection()
|
void TextEditor::setUpEditConnection()
|
||||||
{
|
{
|
||||||
disconnectEditConnection();
|
disconnectEditConnection();
|
||||||
|
|
||||||
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]()
|
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]()
|
||||||
{
|
{
|
||||||
QString text_ = ui->m_line_edit->text();
|
QString text_ = ui->m_line_edit->text();
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
if (text_ != partText->toPlainText())
|
if (text_ != partText->toPlainText())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
|
||||||
undo->setText(tr("Modifier le contenu d'un champ texte"));
|
undo->setText(tr("Modifier le contenu d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||||
{
|
{
|
||||||
QPointF pos(ui->m_x_sb->value(), 0);
|
QPointF pos(ui->m_x_sb->value(), 0);
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
pos.setY(partText->pos().y());
|
pos.setY(partText->pos().y());
|
||||||
if (pos != partText->pos())
|
if (pos != partText->pos())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
undo->setAnimated(true, false);
|
undo->setAnimated(true, false);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||||
{
|
{
|
||||||
QPointF pos(0, ui->m_y_sb->value());
|
QPointF pos(0, ui->m_y_sb->value());
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
pos.setX(partText->pos().x());
|
pos.setX(partText->pos().x());
|
||||||
if (pos != partText->pos())
|
if (pos != partText->pos())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
undo->setAnimated(true, false);
|
undo->setAnimated(true, false);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||||
{
|
{
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
if (ui->m_rotation_sb->value() != partText->rotation())
|
if (ui->m_rotation_sb->value() != partText->rotation())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
|
||||||
undo->setText(tr("Pivoter un champ texte"));
|
undo->setText(tr("Pivoter un champ texte"));
|
||||||
undo->setAnimated(true, false);
|
undo->setAnimated(true, false);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||||
{
|
{
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
if (partText->font().pointSize() != ui->m_size_sb->value())
|
if (partText->font().pointSize() != ui->m_size_sb->value())
|
||||||
{
|
{
|
||||||
QFont font_ = partText->font();
|
QFont font_ = partText->font();
|
||||||
font_.setPointSize(ui->m_size_sb->value());
|
font_.setPointSize(ui->m_size_sb->value());
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un texte"));
|
undo->setText(tr("Modifier la police d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,23 +262,23 @@ void TextEditor::on_m_font_pb_clicked()
|
|||||||
bool ok;
|
bool ok;
|
||||||
QFont font_ = QFontDialog::getFont(&ok, m_text->font(), this);
|
QFont font_ = QFontDialog::getFont(&ok, m_text->font(), this);
|
||||||
|
|
||||||
if (ok && font_ != m_text->font()) {
|
if (ok && font_ != m_text->font()) {
|
||||||
ui->m_size_sb->blockSignals(true);
|
ui->m_size_sb->blockSignals(true);
|
||||||
ui->m_size_sb->setValue(font_.pointSize());
|
ui->m_size_sb->setValue(font_.pointSize());
|
||||||
ui->m_size_sb->blockSignals(false);
|
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++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
if (ok && font_ != partText->font())
|
if (ok && font_ != partText->font())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un texte"));
|
undo->setText(tr("Modifier la police d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,13 +287,13 @@ void TextEditor::on_m_font_pb_clicked()
|
|||||||
*/
|
*/
|
||||||
void TextEditor::on_m_color_pb_changed(const QColor &newColor)
|
void TextEditor::on_m_color_pb_changed(const QColor &newColor)
|
||||||
{
|
{
|
||||||
for (int i=0; i < m_parts.length(); i++) {
|
for (int i=0; i < m_parts.length(); i++) {
|
||||||
PartText* partText = m_parts[i];
|
PartText* partText = m_parts[i];
|
||||||
if (newColor != partText->defaultTextColor())
|
if (newColor != partText->defaultTextColor())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
|
||||||
undo->setText(tr("Modifier la couleur d'un texte"));
|
undo->setText(tr("Modifier la couleur d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ QTreeWidgetItem *ElementsPanel::updateTemplateItem(QTreeWidgetItem *tb_template_
|
|||||||
item -> setStatusTip(
|
item -> setStatusTip(
|
||||||
0,
|
0,
|
||||||
tr(
|
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"
|
"Status tip displayed when selecting a title block template"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -167,8 +167,8 @@ ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
|
|||||||
QString ImportElementTextPattern::getName(const QStringList& list, bool *ok, bool *erase) const
|
QString ImportElementTextPattern::getName(const QStringList& list, bool *ok, bool *erase) const
|
||||||
{
|
{
|
||||||
return ImportElementTextPatternDialog::getItem(parentWidget(),
|
return ImportElementTextPatternDialog::getItem(parentWidget(),
|
||||||
QObject::tr("Sélectionner une configuration de textes"),
|
QObject::tr("Sélectionner une configuration de textes"),
|
||||||
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
|
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
|
||||||
list,
|
list,
|
||||||
ok,
|
ok,
|
||||||
erase);
|
erase);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ bool nomenclature::saveToCSVFile()
|
|||||||
if(!QFile::remove ( filename ) ){
|
if(!QFile::remove ( filename ) ){
|
||||||
QMessageBox::critical(this->m_parent, QObject::tr("Erreur"),
|
QMessageBox::critical(this->m_parent, QObject::tr("Erreur"),
|
||||||
QObject::tr("Impossible de remplacer le fichier!\n\n")+
|
QObject::tr("Impossible de remplacer le fichier!\n\n")+
|
||||||
"Destination : "+filename+"\n");
|
"Destination : "+filename+"\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,28 +88,28 @@ QString nomenclature::getNomenclature()
|
|||||||
{
|
{
|
||||||
//Process...
|
//Process...
|
||||||
QString data = QObject::tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
|
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
|
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("B001") +";" //:Don't translate this text! //ID for folio title
|
||||||
""+ QObject::tr("C001") +";" //:Don't translate this text! //ID for folio number
|
""+ 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("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("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("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("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("G001") +";" //:Don't translate this text! //ID for order number
|
||||||
""+ QObject::tr("H001") +";" //:Don't translate this text! //ID for article description
|
""+ 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("H002") +";" //:Don't translate this text! //ID for plant
|
||||||
""+ QObject::tr("I001") +";" //:Don't translate this text! //ID for comment
|
""+ QObject::tr("I001") +";" //:Don't translate this text! //ID for comment
|
||||||
""+ QObject::tr("J001") +";" //:Don't translate this text! //ID for manufacturer
|
""+ 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("K001") +";" //:Don't translate this text! //ID for article number
|
||||||
""+ QObject::tr("L001") +";" //:Don't translate this text! //ID for quantity
|
""+ QObject::tr("L001") +";" //:Don't translate this text! //ID for quantity
|
||||||
""+ QObject::tr("L002") +";" //:Don't translate this text! //ID for unity
|
""+ QObject::tr("L002") +";" //:Don't translate this text! //ID for unity
|
||||||
""+ QObject::tr("L003") +";" //:Don't translate this text! //ID for supplier
|
""+ 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("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("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("N001")+";" //:Don't translate this text! //ID for internal number
|
||||||
""+ QObject::tr("O001")+";" //:Don't translate this text! //ID for location
|
""+ QObject::tr("O001")+";" //:Don't translate this text! //ID for location
|
||||||
""+ QObject::tr("P001") +"\n"; //:Don't translate this text! //ID for function
|
""+ QObject::tr("P001") +"\n"; //:Don't translate this text! //ID for function
|
||||||
data += QObject::tr("Position du folio") +";"
|
data += QObject::tr("Position du folio") +";"
|
||||||
""+ QObject::tr("Titre de folio") +";"
|
""+ QObject::tr("Titre de folio") +";"
|
||||||
""+ QObject::tr("Numéro de folio") +";"
|
""+ QObject::tr("Numéro de folio") +";"
|
||||||
""+ QObject::tr("Désignation qet") +";"
|
""+ QObject::tr("Désignation qet") +";"
|
||||||
|
|||||||
@@ -887,27 +887,27 @@ void ProjectView::diagramAdded(Diagram *diagram)
|
|||||||
*/
|
*/
|
||||||
void ProjectView::updateTabTitle(DiagramView *diagram_view)
|
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)
|
if (diagram_tab_id != -1)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString title;
|
QString title;
|
||||||
Diagram *diagram = diagram_view->diagram();
|
Diagram *diagram = diagram_view->diagram();
|
||||||
|
|
||||||
if (settings.value("genericpanel/folio", false).toBool())
|
if (settings.value("genericpanel/folio", false).toBool())
|
||||||
{
|
{
|
||||||
QString formula = diagram->border_and_titleblock.folio();
|
QString formula = diagram->border_and_titleblock.folio();
|
||||||
autonum::sequentialNumbers seq;
|
autonum::sequentialNumbers seq;
|
||||||
title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
|
title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
title = QString::number(diagram->folioIndex() + 1);
|
title = QString::number(diagram->folioIndex() + 1);
|
||||||
|
|
||||||
title += " - ";
|
title += " - ";
|
||||||
title += diagram->title();
|
title += diagram->title();
|
||||||
m_tab->setTabText(diagram_tab_id ,title);
|
m_tab->setTabText(diagram_tab_id ,title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11063,7 +11063,7 @@ PUGI__NS_BEGIN
|
|||||||
// Use optimized path for @attr = 'value' or @attr = $value
|
// Use optimized path for @attr = 'value' or @attr = $value
|
||||||
if (_type == ast_op_equal &&
|
if (_type == ast_op_equal &&
|
||||||
_left && _right && // workaround for clang static analyzer and Coverity (_left and _right are never null for 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 &&
|
_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)))
|
(_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
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
|
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
|
||||||
bool file_opening = file.open(QIODevice::WriteOnly);
|
bool file_opening = file.open(QIODevice::WriteOnly);
|
||||||
if (!file_opening)
|
if (!file_opening)
|
||||||
{
|
{
|
||||||
if (error_message)
|
if (error_message)
|
||||||
{
|
{
|
||||||
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
|
*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());
|
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
out.setCodec("UTF-8");
|
out.setCodec("UTF-8");
|
||||||
out.setGenerateByteOrderMark(false);
|
out.setGenerateByteOrderMark(false);
|
||||||
out << xml_doc.toString(4);
|
out << xml_doc.toString(4);
|
||||||
if (!file.commit())
|
if (!file.commit())
|
||||||
{
|
{
|
||||||
if (error_message) {
|
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 = 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());
|
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -576,9 +576,9 @@ QString QETApp::customElementsDir()
|
|||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
{
|
{
|
||||||
m_user_custom_elements_dir = path;
|
m_user_custom_elements_dir = path;
|
||||||
if(!m_user_custom_elements_dir.endsWith("/")) {
|
if(!m_user_custom_elements_dir.endsWith("/")) {
|
||||||
m_user_custom_elements_dir.append("/");
|
m_user_custom_elements_dir.append("/");
|
||||||
}
|
}
|
||||||
return m_user_custom_elements_dir;
|
return m_user_custom_elements_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1786,17 +1786,17 @@ void QETApp::buildSystemTrayMenu() {
|
|||||||
*/
|
*/
|
||||||
void QETApp::checkBackupFiles()
|
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;
|
const QList<KAutoSaveFile *> sf = stale_files;
|
||||||
for (KAutoSaveFile *kasf : sf)
|
for (KAutoSaveFile *kasf : sf)
|
||||||
{
|
{
|
||||||
for (QETProject *project : registeredProjects().values())
|
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
|
//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();
|
const QString path = QUrl::fromLocalFile(project->filePath()).adjusted(QUrl::RemoveScheme | QUrl::StripTrailingSlash).path();
|
||||||
if (kasf->managedFile() == path) {
|
if (kasf->managedFile() == path) {
|
||||||
stale_files.removeOne(kasf);
|
stale_files.removeOne(kasf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 QElectroTech Team
|
Copyright 2006-2020 QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "projectdbmodel.h"
|
#include "projectdbmodel.h"
|
||||||
#include "projectdatabase.h"
|
#include "projectdatabase.h"
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
* @param parent : parent QObject
|
* @param parent : parent QObject
|
||||||
*/
|
*/
|
||||||
ProjectDBModel::ProjectDBModel(QETProject *project, QObject *parent) :
|
ProjectDBModel::ProjectDBModel(QETProject *project, QObject *parent) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
||||||
}
|
}
|
||||||
@@ -41,13 +41,13 @@ ProjectDBModel::ProjectDBModel(QETProject *project, QObject *parent) :
|
|||||||
* @param other_model
|
* @param other_model
|
||||||
*/
|
*/
|
||||||
ProjectDBModel::ProjectDBModel(const ProjectDBModel &other_model) :
|
ProjectDBModel::ProjectDBModel(const ProjectDBModel &other_model) :
|
||||||
QAbstractTableModel(other_model.parent())
|
QAbstractTableModel(other_model.parent())
|
||||||
{
|
{
|
||||||
this->setParent(other_model.parent());
|
this->setParent(other_model.parent());
|
||||||
m_project = other_model.m_project;
|
m_project = other_model.m_project;
|
||||||
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
||||||
m_index_0_0_data = other_model.m_index_0_0_data;
|
m_index_0_0_data = other_model.m_index_0_0_data;
|
||||||
setQuery(other_model.queryString());
|
setQuery(other_model.queryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,10 +58,10 @@ ProjectDBModel::ProjectDBModel(const ProjectDBModel &other_model) :
|
|||||||
*/
|
*/
|
||||||
int ProjectDBModel::rowCount(const QModelIndex &parent) const
|
int ProjectDBModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return 0;
|
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
|
int ProjectDBModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (m_record.count()) {
|
if (m_record.count()) {
|
||||||
return m_record.first().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)
|
bool ProjectDBModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto hash_ = m_header_data.value(section);
|
auto hash_ = m_header_data.value(section);
|
||||||
hash_.insert(role, value);
|
hash_.insert(role, value);
|
||||||
m_header_data.insert(section, hash_);
|
m_header_data.insert(section, hash_);
|
||||||
emit headerDataChanged(orientation, section, section);
|
emit headerDataChanged(orientation, section, section);
|
||||||
return true;
|
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
|
QVariant ProjectDBModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_header_data.contains(section))
|
if (m_header_data.contains(section))
|
||||||
{
|
{
|
||||||
auto hash_ = m_header_data.value(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
|
if (role == Qt::DisplayRole && !hash_.contains(Qt::DisplayRole)) { //special case to have the same behavior as Qt
|
||||||
return hash_.value(Qt::EditRole);
|
return hash_.value(Qt::EditRole);
|
||||||
}
|
}
|
||||||
return m_header_data.value(section).value(role);
|
return m_header_data.value(section).value(role);
|
||||||
}
|
}
|
||||||
return QVariant();
|
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)
|
bool ProjectDBModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() != 0 || index.column() != 0) {
|
if (!index.isValid() || index.row() != 0 || index.column() != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_index_0_0_data.insert(role, value);
|
m_index_0_0_data.insert(role, value);
|
||||||
emit dataChanged(index, index, QVector<int>(role));
|
emit dataChanged(index, index, QVector<int>(role));
|
||||||
return true;
|
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
|
QVariant ProjectDBModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (index.row() == 0 &&
|
if (index.row() == 0 &&
|
||||||
index.column() == 0 &&
|
index.column() == 0 &&
|
||||||
role != Qt::DisplayRole) {
|
role != Qt::DisplayRole) {
|
||||||
return m_index_0_0_data.value(role);
|
return m_index_0_0_data.value(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
QVariant v(m_record.at(index.row()).at(index.column()));
|
QVariant v(m_record.at(index.row()).at(index.column()));
|
||||||
return v;
|
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)
|
void ProjectDBModel::setQuery(const QString &query)
|
||||||
{
|
{
|
||||||
auto rm_ = m_query != query;
|
auto rm_ = m_query != query;
|
||||||
if (rm_) {
|
if (rm_) {
|
||||||
emit beginResetModel();
|
emit beginResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_query = query;
|
m_query = query;
|
||||||
|
|
||||||
if (m_project)
|
if (m_project)
|
||||||
{
|
{
|
||||||
if (rm_) {
|
if (rm_) {
|
||||||
disconnect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
disconnect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
||||||
}
|
}
|
||||||
m_project->dataBase()->updateDB();
|
m_project->dataBase()->updateDB();
|
||||||
if (rm_) {
|
if (rm_) {
|
||||||
setHeaderString();
|
setHeaderString();
|
||||||
fillValue();
|
fillValue();
|
||||||
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rm_) {
|
if (rm_) {
|
||||||
emit endResetModel();
|
emit endResetModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,11 +210,11 @@ void ProjectDBModel::setQuery(const QString &query)
|
|||||||
* @return the current query used by this model
|
* @return the current query used by this model
|
||||||
*/
|
*/
|
||||||
QString ProjectDBModel::queryString() const {
|
QString ProjectDBModel::queryString() const {
|
||||||
return m_query;
|
return m_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
QETProject *ProjectDBModel::project() const {
|
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
|
QDomElement ProjectDBModel::toXml(QDomDocument &document) const
|
||||||
{
|
{
|
||||||
auto dom_element = document.createElement(xmlTagName());
|
auto dom_element = document.createElement(xmlTagName());
|
||||||
|
|
||||||
//Identifier
|
//Identifier
|
||||||
auto dom_identifier = document.createElement("identifier");
|
auto dom_identifier = document.createElement("identifier");
|
||||||
auto dom_identifier_text = document.createTextNode(m_identifier);
|
auto dom_identifier_text = document.createTextNode(m_identifier);
|
||||||
dom_identifier.appendChild(dom_identifier_text);
|
dom_identifier.appendChild(dom_identifier_text);
|
||||||
dom_element.appendChild(dom_identifier);
|
dom_element.appendChild(dom_identifier);
|
||||||
|
|
||||||
//query
|
//query
|
||||||
auto dom_query = document.createElement("query");
|
auto dom_query = document.createElement("query");
|
||||||
auto dom_query_text = document.createTextNode(m_query);
|
auto dom_query_text = document.createTextNode(m_query);
|
||||||
dom_query.appendChild(dom_query_text);
|
dom_query.appendChild(dom_query_text);
|
||||||
dom_element.appendChild(dom_query);
|
dom_element.appendChild(dom_query);
|
||||||
|
|
||||||
//Add index 0,0 data
|
//Add index 0,0 data
|
||||||
auto index_00 = document.createElement("index00");
|
auto index_00 = document.createElement("index00");
|
||||||
index_00.setAttribute("font", m_index_0_0_data.value(Qt::FontRole).toString());
|
index_00.setAttribute("font", m_index_0_0_data.value(Qt::FontRole).toString());
|
||||||
auto me = QMetaEnum::fromType<Qt::Alignment>();
|
auto me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
index_00.setAttribute("alignment", me.valueToKey(m_index_0_0_data.value(Qt::TextAlignmentRole).toInt()));
|
index_00.setAttribute("alignment", me.valueToKey(m_index_0_0_data.value(Qt::TextAlignmentRole).toInt()));
|
||||||
dom_element.appendChild(index_00);
|
dom_element.appendChild(index_00);
|
||||||
index_00.setAttribute("margins", m_index_0_0_data.value(Qt::UserRole+1).toString());
|
index_00.setAttribute("margins", m_index_0_0_data.value(Qt::UserRole+1).toString());
|
||||||
|
|
||||||
//header data
|
//header data
|
||||||
QHash<int, QList<int>> horizontal_;
|
QHash<int, QList<int>> horizontal_;
|
||||||
for (auto key : m_header_data.keys())
|
for (auto key : m_header_data.keys())
|
||||||
{
|
{
|
||||||
//We save all data except the display role, because he was generated in the fly
|
//We save all data except the display role, because he was generated in the fly
|
||||||
auto list = m_header_data.value(key).keys();
|
auto list = m_header_data.value(key).keys();
|
||||||
list.removeAll(Qt::DisplayRole);
|
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)
|
void ProjectDBModel::fromXml(const QDomElement &element)
|
||||||
{
|
{
|
||||||
if (element.tagName() != xmlTagName())
|
if (element.tagName() != xmlTagName())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setIdentifier(element.firstChildElement("identifier").text());
|
setIdentifier(element.firstChildElement("identifier").text());
|
||||||
setQuery(element.firstChildElement("query").text());
|
setQuery(element.firstChildElement("query").text());
|
||||||
|
|
||||||
//Index 0,0
|
//Index 0,0
|
||||||
auto index_00 = element.firstChildElement("index00");
|
auto index_00 = element.firstChildElement("index00");
|
||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(index_00.attribute("font"));
|
font_.fromString(index_00.attribute("font"));
|
||||||
m_index_0_0_data.insert(Qt::FontRole, font_);
|
m_index_0_0_data.insert(Qt::FontRole, font_);
|
||||||
auto me = QMetaEnum::fromType<Qt::Alignment>();
|
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::TextAlignmentRole, me.keyToValue(index_00.attribute("alignment").toStdString().data()));
|
||||||
m_index_0_0_data.insert(Qt::UserRole+1, index_00.attribute("margins"));
|
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()
|
void ProjectDBModel::dataBaseUpdated()
|
||||||
{
|
{
|
||||||
auto original_record = m_record;
|
auto original_record = m_record;
|
||||||
fillValue();
|
fillValue();
|
||||||
auto new_record = m_record;
|
auto new_record = m_record;
|
||||||
m_record = original_record;
|
m_record = original_record;
|
||||||
|
|
||||||
//This a very special case, if this nomenclature model is added
|
//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
|
//befor any element, column count return 0, so in this case we emit column inserted
|
||||||
if (new_record.size() != m_record.size())
|
if (new_record.size() != m_record.size())
|
||||||
{
|
{
|
||||||
emit beginResetModel();
|
emit beginResetModel();
|
||||||
m_record = new_record;
|
m_record = new_record;
|
||||||
emit endResetModel();
|
emit endResetModel();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_record = new_record;
|
m_record = new_record;
|
||||||
auto row = m_record.size();
|
auto row = m_record.size();
|
||||||
auto col = row ? m_record.first().count() : 1;
|
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()
|
void ProjectDBModel::setHeaderString()
|
||||||
|
|||||||
@@ -581,27 +581,27 @@ bool Conductor::valideXml(QDomElement &e){
|
|||||||
if (!e.hasAttribute("terminal2")) return(false);
|
if (!e.hasAttribute("terminal2")) return(false);
|
||||||
|
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
// parse l'abscisse
|
// parse l'abscisse
|
||||||
if (e.hasAttribute("element1")) {
|
if (e.hasAttribute("element1")) {
|
||||||
if (QUuid(e.attribute("element1")).isNull())
|
if (QUuid(e.attribute("element1")).isNull())
|
||||||
return false;
|
return false;
|
||||||
if (QUuid(e.attribute("terminal1")).isNull())
|
if (QUuid(e.attribute("terminal1")).isNull())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
e.attribute("terminal1").toInt(&conv_ok);
|
e.attribute("terminal1").toInt(&conv_ok);
|
||||||
if (!conv_ok) return(false);
|
if (!conv_ok) return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse l'ordonnee
|
// parse l'ordonnee
|
||||||
if (e.hasAttribute("element2")) {
|
if (e.hasAttribute("element2")) {
|
||||||
if (QUuid(e.attribute("element2")).isNull())
|
if (QUuid(e.attribute("element2")).isNull())
|
||||||
return false;
|
return false;
|
||||||
if (QUuid(e.attribute("terminal2")).isNull())
|
if (QUuid(e.attribute("terminal2")).isNull())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
e.attribute("terminal2").toInt(&conv_ok);
|
e.attribute("terminal2").toInt(&conv_ok);
|
||||||
if (!conv_ok) return(false);
|
if (!conv_ok) return(false);
|
||||||
}
|
}
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,22 +130,22 @@ void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
|
|||||||
*/
|
*/
|
||||||
void ConductorTextItem::setPos(const QPointF &pos)
|
void ConductorTextItem::setPos(const QPointF &pos)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* In some condition the conductor text item is outside the border of folio in the left.
|
* 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.
|
* 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),
|
* 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.
|
* 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.
|
* 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);
|
DiagramTextItem::setPos(pos);
|
||||||
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
||||||
{
|
{
|
||||||
Conductor *cond = parentConductor();
|
Conductor *cond = parentConductor();
|
||||||
if(cond)
|
if(cond)
|
||||||
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
||||||
else
|
else
|
||||||
DiagramTextItem::setPos(0,0);
|
DiagramTextItem::setPos(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -632,27 +632,27 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
|||||||
// for delay on contact
|
// for delay on contact
|
||||||
if (flags &DelayOn) {
|
if (flags &DelayOn) {
|
||||||
if (flags &NO) {
|
if (flags &NO) {
|
||||||
painter.drawLine(12, offset+8, 12, offset+11);
|
painter.drawLine(12, offset+8, 12, offset+11);
|
||||||
QRectF r(9.5, offset+9, 5, 3);
|
QRectF r(9.5, offset+9, 5, 3);
|
||||||
painter.drawArc(r, 180*16, 180*16);
|
painter.drawArc(r, 180*16, 180*16);
|
||||||
}
|
}
|
||||||
if (flags &NC) {
|
if (flags &NC) {
|
||||||
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
|
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
|
||||||
QRectF r(10, offset+6, 5, 3);
|
QRectF r(10, offset+6, 5, 3);
|
||||||
painter.drawArc(r, 180*16, 180*16);
|
painter.drawArc(r, 180*16, 180*16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for delay off contact
|
// for delay off contact
|
||||||
else if ( flags &DelayOff){
|
else if ( flags &DelayOff){
|
||||||
if (flags &NO) {
|
if (flags &NO) {
|
||||||
painter.drawLine(12, offset+8, 12, offset+9.5);
|
painter.drawLine(12, offset+8, 12, offset+9.5);
|
||||||
QRectF r(9.5, offset+9.5, 5, 3);
|
QRectF r(9.5, offset+9.5, 5, 3);
|
||||||
painter.drawArc(r, 0, 180*16);
|
painter.drawArc(r, 0, 180*16);
|
||||||
}
|
}
|
||||||
if (flags &NC) {
|
if (flags &NC) {
|
||||||
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+7));
|
painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+7));
|
||||||
QRectF r(10, offset+7.5, 5, 3);
|
QRectF r(10, offset+7.5, 5, 3);
|
||||||
painter.drawArc(r, 0, 180*16);
|
painter.drawArc(r, 0, 180*16);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1045,18 +1045,18 @@ void DynamicElementTextItem::updateLabel()
|
|||||||
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
||||||
{
|
{
|
||||||
DiagramContext dc;
|
DiagramContext dc;
|
||||||
Element *element = elementUseForInfo();
|
Element *element = elementUseForInfo();
|
||||||
if(element) {
|
if(element) {
|
||||||
dc = element->elementInformations();
|
dc = element->elementInformations();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(m_text_from == ElementInfo && element) {
|
|
||||||
setPlainText(element->actualLabel());
|
|
||||||
}
|
}
|
||||||
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));
|
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, dc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1377,23 +1377,23 @@ void Element::initLink(QETProject *prj)
|
|||||||
|
|
||||||
QString Element::linkTypeToString() const
|
QString Element::linkTypeToString() const
|
||||||
{
|
{
|
||||||
switch (m_link_type)
|
switch (m_link_type)
|
||||||
{
|
{
|
||||||
case Simple:
|
case Simple:
|
||||||
return "Simple";
|
return "Simple";
|
||||||
case NextReport :
|
case NextReport :
|
||||||
return "NextReport";
|
return "NextReport";
|
||||||
case PreviousReport:
|
case PreviousReport:
|
||||||
return "PreviousReport";
|
return "PreviousReport";
|
||||||
case Master:
|
case Master:
|
||||||
return "Master";
|
return "Master";
|
||||||
case Slave:
|
case Slave:
|
||||||
return "Slave";
|
return "Slave";
|
||||||
case Terminale:
|
case Terminale:
|
||||||
return "Terminale";
|
return "Terminale";
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -366,24 +366,24 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged)
|
if (change == ItemSelectedHasChanged)
|
||||||
{
|
{
|
||||||
if (value.toBool() == true) { //If this is selected, wa add handlers.
|
if (value.toBool() == true) { //If this is selected, wa add handlers.
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else //Else this is deselected, we remove handlers
|
else //Else this is deselected, we remove handlers
|
||||||
{
|
{
|
||||||
if(!m_handler_vector.isEmpty())
|
if(!m_handler_vector.isEmpty())
|
||||||
{
|
{
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
}
|
}
|
||||||
m_resize_mode = 1;
|
m_resize_mode = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change == ItemPositionHasChanged) {
|
else if (change == ItemPositionHasChanged) {
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
else if (change == ItemSceneHasChanged)
|
else if (change == ItemSceneHasChanged)
|
||||||
{
|
{
|
||||||
if (!scene()) //This is removed from scene, then we deselect this, and so, the handlers is also removed.
|
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
@@ -29,87 +29,87 @@ QT_BEGIN_NAMESPACE
|
|||||||
class Ui_AddLinkDialog
|
class Ui_AddLinkDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVBoxLayout *verticalLayout;
|
QVBoxLayout *verticalLayout;
|
||||||
QFormLayout *formLayout;
|
QFormLayout *formLayout;
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
QLineEdit *titleInput;
|
QLineEdit *titleInput;
|
||||||
QLabel *label_2;
|
QLabel *label_2;
|
||||||
QLineEdit *urlInput;
|
QLineEdit *urlInput;
|
||||||
QSpacerItem *verticalSpacer;
|
QSpacerItem *verticalSpacer;
|
||||||
QFrame *line;
|
QFrame *line;
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
|
|
||||||
void setupUi(QDialog *AddLinkDialog)
|
void setupUi(QDialog *AddLinkDialog)
|
||||||
{
|
{
|
||||||
if (AddLinkDialog->objectName().isEmpty())
|
if (AddLinkDialog->objectName().isEmpty())
|
||||||
AddLinkDialog->setObjectName(QString::fromUtf8("AddLinkDialog"));
|
AddLinkDialog->setObjectName(QString::fromUtf8("AddLinkDialog"));
|
||||||
AddLinkDialog->setSizeGripEnabled(false);
|
AddLinkDialog->setSizeGripEnabled(false);
|
||||||
AddLinkDialog->setModal(true);
|
AddLinkDialog->setModal(true);
|
||||||
verticalLayout = new QVBoxLayout(AddLinkDialog);
|
verticalLayout = new QVBoxLayout(AddLinkDialog);
|
||||||
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
|
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
|
||||||
formLayout = new QFormLayout();
|
formLayout = new QFormLayout();
|
||||||
formLayout->setObjectName(QString::fromUtf8("formLayout"));
|
formLayout->setObjectName(QString::fromUtf8("formLayout"));
|
||||||
label = new QLabel(AddLinkDialog);
|
label = new QLabel(AddLinkDialog);
|
||||||
label->setObjectName(QString::fromUtf8("label"));
|
label->setObjectName(QString::fromUtf8("label"));
|
||||||
|
|
||||||
formLayout->setWidget(0, QFormLayout::LabelRole, label);
|
formLayout->setWidget(0, QFormLayout::LabelRole, label);
|
||||||
|
|
||||||
titleInput = new QLineEdit(AddLinkDialog);
|
titleInput = new QLineEdit(AddLinkDialog);
|
||||||
titleInput->setObjectName(QString::fromUtf8("titleInput"));
|
titleInput->setObjectName(QString::fromUtf8("titleInput"));
|
||||||
titleInput->setMinimumSize(QSize(337, 0));
|
titleInput->setMinimumSize(QSize(337, 0));
|
||||||
|
|
||||||
formLayout->setWidget(0, QFormLayout::FieldRole, titleInput);
|
formLayout->setWidget(0, QFormLayout::FieldRole, titleInput);
|
||||||
|
|
||||||
label_2 = new QLabel(AddLinkDialog);
|
label_2 = new QLabel(AddLinkDialog);
|
||||||
label_2->setObjectName(QString::fromUtf8("label_2"));
|
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 = new QLineEdit(AddLinkDialog);
|
||||||
urlInput->setObjectName(QString::fromUtf8("urlInput"));
|
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 = new QFrame(AddLinkDialog);
|
||||||
line->setObjectName(QString::fromUtf8("line"));
|
line->setObjectName(QString::fromUtf8("line"));
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
|
||||||
verticalLayout->addWidget(line);
|
verticalLayout->addWidget(line);
|
||||||
|
|
||||||
buttonBox = new QDialogButtonBox(AddLinkDialog);
|
buttonBox = new QDialogButtonBox(AddLinkDialog);
|
||||||
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
|
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
|
||||||
buttonBox->setOrientation(Qt::Horizontal);
|
buttonBox->setOrientation(Qt::Horizontal);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
verticalLayout->addWidget(buttonBox);
|
verticalLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
|
|
||||||
retranslateUi(AddLinkDialog);
|
retranslateUi(AddLinkDialog);
|
||||||
QObject::connect(buttonBox, SIGNAL(accepted()), AddLinkDialog, SLOT(accept()));
|
QObject::connect(buttonBox, SIGNAL(accepted()), AddLinkDialog, SLOT(accept()));
|
||||||
QObject::connect(buttonBox, SIGNAL(rejected()), AddLinkDialog, SLOT(reject()));
|
QObject::connect(buttonBox, SIGNAL(rejected()), AddLinkDialog, SLOT(reject()));
|
||||||
|
|
||||||
QMetaObject::connectSlotsByName(AddLinkDialog);
|
QMetaObject::connectSlotsByName(AddLinkDialog);
|
||||||
} // setupUi
|
} // setupUi
|
||||||
|
|
||||||
void retranslateUi(QDialog *AddLinkDialog)
|
void retranslateUi(QDialog *AddLinkDialog)
|
||||||
{
|
{
|
||||||
AddLinkDialog->setWindowTitle(QApplication::translate("AddLinkDialog", "Insert Link", nullptr));
|
AddLinkDialog->setWindowTitle(QApplication::translate("AddLinkDialog", "Insert Link", nullptr));
|
||||||
label->setText(QApplication::translate("AddLinkDialog", "Title:", nullptr));
|
label->setText(QApplication::translate("AddLinkDialog", "Title:", nullptr));
|
||||||
label_2->setText(QApplication::translate("AddLinkDialog", "URL:", nullptr));
|
label_2->setText(QApplication::translate("AddLinkDialog", "URL:", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AddLinkDialog: public Ui_AddLinkDialog {};
|
class AddLinkDialog: public Ui_AddLinkDialog {};
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -105,9 +105,9 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
|
|||||||
updateQueryLine();
|
updateQueryLine();
|
||||||
});
|
});
|
||||||
|
|
||||||
setUpItems();
|
setUpItems();
|
||||||
createDataBase();
|
createDataBase();
|
||||||
fillSavedQuery();
|
fillSavedQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +115,8 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
|
|||||||
*/
|
*/
|
||||||
BOMExportDialog::~BOMExportDialog()
|
BOMExportDialog::~BOMExportDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
m_data_base.close();
|
m_data_base.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,39 +126,39 @@ BOMExportDialog::~BOMExportDialog()
|
|||||||
*/
|
*/
|
||||||
int BOMExportDialog::exec()
|
int BOMExportDialog::exec()
|
||||||
{
|
{
|
||||||
int r = QDialog::exec();
|
int r = QDialog::exec();
|
||||||
if (r == QDialog::Accepted)
|
if (r == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
//save in csv file
|
//save in csv file
|
||||||
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
||||||
// if (!file_name.endsWith(".csv")) {
|
// if (!file_name.endsWith(".csv")) {
|
||||||
// file_name += ".csv";
|
// file_name += ".csv";
|
||||||
// }
|
// }
|
||||||
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
||||||
QFile file(file_path);
|
QFile file(file_path);
|
||||||
if (!file_path.isEmpty())
|
if (!file_path.isEmpty())
|
||||||
{
|
{
|
||||||
if (QFile::exists(file_path ))
|
if (QFile::exists(file_path ))
|
||||||
{
|
{
|
||||||
// if file already exist -> delete it
|
// if file already exist -> delete it
|
||||||
if (!QFile::remove(file_path) )
|
if (!QFile::remove(file_path) )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Erreur"),
|
QMessageBox::critical(this, tr("Erreur"),
|
||||||
tr("Impossible de remplacer le fichier!\n\n")+
|
tr("Impossible de remplacer le fichier!\n\n")+
|
||||||
"Destination : "+file_path+"\n");
|
"Destination : "+file_path+"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
|
||||||
stream << getBom() << endl;
|
stream << getBom() << endl;
|
||||||
#else
|
#else
|
||||||
stream << getBom() << &Qt::endl(stream);
|
stream << getBom() << &Qt::endl(stream);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ int BOMExportDialog::exec()
|
|||||||
*/
|
*/
|
||||||
QStringList BOMExportDialog::selectedKeys() const
|
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;
|
QStringList keys;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
while (auto *item = ui->m_choosen_list->item(row))
|
while (auto *item = ui->m_choosen_list->item(row))
|
||||||
@@ -205,13 +205,13 @@ QString BOMExportDialog::translatedKeys(const QString &key) const
|
|||||||
*/
|
*/
|
||||||
void BOMExportDialog::setUpItems()
|
void BOMExportDialog::setUpItems()
|
||||||
{
|
{
|
||||||
for(QString key : QETApp::elementInfoKeys())
|
for(QString key : QETApp::elementInfoKeys())
|
||||||
{
|
{
|
||||||
auto item = new QListWidgetItem(QETApp::elementTranslatedInfoKey(key), ui->m_var_list);
|
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+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.
|
item->setData(Qt::UserRole, key.replace("-", "_")); //We must to replace "-" by "_" because "-" is a sql keyword.
|
||||||
m_items_list << item;
|
m_items_list << item;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto key : m_export_info.keys())
|
for (auto key : m_export_info.keys())
|
||||||
{
|
{
|
||||||
@@ -227,11 +227,11 @@ void BOMExportDialog::setUpItems()
|
|||||||
*/
|
*/
|
||||||
void BOMExportDialog::on_m_add_pb_clicked()
|
void BOMExportDialog::on_m_add_pb_clicked()
|
||||||
{
|
{
|
||||||
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
|
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
|
||||||
ui->m_choosen_list->addItem(item);
|
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()
|
void BOMExportDialog::on_m_remove_pb_clicked()
|
||||||
{
|
{
|
||||||
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
|
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
|
||||||
ui->m_var_list->addItem(item);
|
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()
|
void BOMExportDialog::on_m_up_pb_clicked()
|
||||||
{
|
{
|
||||||
auto row = ui->m_choosen_list->currentRow();
|
auto row = ui->m_choosen_list->currentRow();
|
||||||
if(row <= 0) {
|
if(row <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *item = ui->m_choosen_list->takeItem(row);
|
auto *item = ui->m_choosen_list->takeItem(row);
|
||||||
ui->m_choosen_list->insertItem(row-1, item);
|
ui->m_choosen_list->insertItem(row-1, item);
|
||||||
ui->m_choosen_list->setCurrentItem(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()
|
void BOMExportDialog::on_m_down_pb_clicked()
|
||||||
{
|
{
|
||||||
auto row = ui->m_choosen_list->currentRow();
|
auto row = ui->m_choosen_list->currentRow();
|
||||||
if (row == -1) {
|
if (row == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *item = ui->m_choosen_list->takeItem(row);
|
auto *item = ui->m_choosen_list->takeItem(row);
|
||||||
ui->m_choosen_list->insertItem(row+1, item);
|
ui->m_choosen_list->insertItem(row+1, item);
|
||||||
ui->m_choosen_list->setCurrentItem(item);
|
ui->m_choosen_list->setCurrentItem(item);
|
||||||
|
|
||||||
updateQueryLine();
|
updateQueryLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOMExportDialog::on_m_save_name_le_textChanged(const QString &arg1) {
|
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 BOMExportDialog::getBom()
|
||||||
{
|
{
|
||||||
QString data; //The string to be returned
|
QString data; //The string to be returned
|
||||||
if (ui->m_include_header_cb->isChecked()) {
|
if (ui->m_include_header_cb->isChecked()) {
|
||||||
data = headers();
|
data = headers();
|
||||||
data += "\n";
|
data += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlQuery query (queryStr() , m_data_base);
|
QSqlQuery query (queryStr() , m_data_base);
|
||||||
if (!query.exec()) {
|
if (!query.exec()) {
|
||||||
qDebug() << "Query error : " << query.lastError();
|
qDebug() << "Query error : " << query.lastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList record;
|
QStringList record;
|
||||||
while (query.next())
|
while (query.next())
|
||||||
@@ -326,8 +326,8 @@ QString BOMExportDialog::getBom()
|
|||||||
record.clear();
|
record.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data_base.close();
|
m_data_base.close();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,10 +336,10 @@ QString BOMExportDialog::getBom()
|
|||||||
*/
|
*/
|
||||||
QString BOMExportDialog::headers() const
|
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())
|
for (auto key : selectedKeys())
|
||||||
{
|
{
|
||||||
if (!header_string.isEmpty()) {
|
if (!header_string.isEmpty()) {
|
||||||
@@ -348,31 +348,31 @@ QString BOMExportDialog::headers() const
|
|||||||
header_string += translatedKeys(key);
|
header_string += translatedKeys(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
header_string += "\n";
|
header_string += "\n";
|
||||||
}
|
}
|
||||||
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
|
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
|
||||||
{
|
{
|
||||||
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
|
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
|
||||||
{
|
{
|
||||||
auto header = queryStr();
|
auto header = queryStr();
|
||||||
header.remove(0, 7); //Remove SELECT from the string;
|
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.truncate(header.indexOf("FROM")); //Now we only have the string between SELECT and FROM
|
||||||
header.replace(" ", ""); //remove white space
|
header.replace(" ", ""); //remove white space
|
||||||
QStringList list = header.split(",");
|
QStringList list = header.split(",");
|
||||||
if (!list.isEmpty())
|
if (!list.isEmpty())
|
||||||
{
|
{
|
||||||
for (int i=0 ; i<list.size() ; i++)
|
for (int i=0 ; i<list.size() ; i++)
|
||||||
{
|
{
|
||||||
if(!header_string.isEmpty()) {
|
if(!header_string.isEmpty()) {
|
||||||
header_string += ";";
|
header_string += ";";
|
||||||
}
|
}
|
||||||
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
|
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
|
||||||
}
|
}
|
||||||
header_string += "\n";
|
header_string += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return header_string;
|
return header_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -381,58 +381,58 @@ QString BOMExportDialog::headers() const
|
|||||||
*/
|
*/
|
||||||
bool BOMExportDialog::createDataBase()
|
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");
|
m_data_base = QSqlDatabase::addDatabase("QSQLITE", "bill_of_material");
|
||||||
if (!m_data_base.open())
|
if (!m_data_base.open())
|
||||||
{
|
{
|
||||||
m_data_base.close();
|
m_data_base.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create the table:
|
//Create the table:
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
auto row = 0;
|
auto row = 0;
|
||||||
while (ui->m_var_list->item(row))
|
while (ui->m_var_list->item(row))
|
||||||
{
|
{
|
||||||
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
|
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
|
||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
keys << "element_type" << "element_subtype";
|
keys << "element_type" << "element_subtype";
|
||||||
keys.removeAll("designation_qty");
|
keys.removeAll("designation_qty");
|
||||||
|
|
||||||
QString table("CREATE TABLE bom(");
|
QString table("CREATE TABLE bom(");
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto string : keys)
|
for (auto string : keys)
|
||||||
{
|
{
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
table += ",";
|
table += ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
table += string += " VARCHAR(512)";
|
table += string += " VARCHAR(512)";
|
||||||
}
|
}
|
||||||
table += ");";
|
table += ");";
|
||||||
m_data_base.exec(table);
|
m_data_base.exec(table);
|
||||||
|
|
||||||
QStringList bind_values;
|
QStringList bind_values;
|
||||||
for (auto key : keys) {
|
for (auto key : keys) {
|
||||||
bind_values << key.prepend(":");
|
bind_values << key.prepend(":");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prepare the query used for insert new record
|
//Prepare the query used for insert new record
|
||||||
QString insert("INSERT INTO bom (" +
|
QString insert("INSERT INTO bom (" +
|
||||||
keys.join(", ") +
|
keys.join(", ") +
|
||||||
") VALUES (" +
|
") VALUES (" +
|
||||||
bind_values.join(", ") +
|
bind_values.join(", ") +
|
||||||
")");
|
")");
|
||||||
|
|
||||||
m_insert_query = QSqlQuery(m_data_base);
|
m_insert_query = QSqlQuery(m_data_base);
|
||||||
m_insert_query.prepare(insert);
|
m_insert_query.prepare(insert);
|
||||||
|
|
||||||
populateDataBase();
|
populateDataBase();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,30 +441,30 @@ bool BOMExportDialog::createDataBase()
|
|||||||
*/
|
*/
|
||||||
void BOMExportDialog::populateDataBase()
|
void BOMExportDialog::populateDataBase()
|
||||||
{
|
{
|
||||||
for (auto *diagram : m_project->diagrams())
|
for (auto *diagram : m_project->diagrams())
|
||||||
{
|
{
|
||||||
ElementProvider ep(diagram);
|
ElementProvider ep(diagram);
|
||||||
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
|
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
|
||||||
|
|
||||||
//Insert all value into the database
|
//Insert all value into the database
|
||||||
for (auto elmt : elements_list)
|
for (auto elmt : elements_list)
|
||||||
{
|
{
|
||||||
auto hash = elementInfoToString(elmt);
|
auto hash = elementInfoToString(elmt);
|
||||||
for (auto key : hash.keys())
|
for (auto key : hash.keys())
|
||||||
{
|
{
|
||||||
QString value = hash.value(key);
|
QString value = hash.value(key);
|
||||||
QString bind = key.prepend(":");
|
QString bind = key.prepend(":");
|
||||||
m_insert_query.bindValue(bind, value);
|
m_insert_query.bindValue(bind, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
|
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
|
||||||
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
|
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
|
||||||
|
|
||||||
if (!m_insert_query.exec()) {
|
if (!m_insert_query.exec()) {
|
||||||
qDebug() << "BOMExportDialog::populateDataBase insert error : " << m_insert_query.lastError();
|
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> BOMExportDialog::elementInfoToString(Element *elmt) const
|
||||||
{
|
{
|
||||||
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
|
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
|
||||||
int row = 0;
|
int row = 0;
|
||||||
while (auto *item = ui->m_var_list->item(row))
|
while (auto *item = ui->m_var_list->item(row))
|
||||||
{
|
{
|
||||||
keys_hash.insert(item->data(Qt::UserRole).toString(),
|
keys_hash.insert(item->data(Qt::UserRole).toString(),
|
||||||
item->data(Qt::UserRole+1).toString());
|
item->data(Qt::UserRole+1).toString());
|
||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QString> hash; //Store the value for each columns
|
QHash<QString, QString> hash; //Store the value for each columns
|
||||||
for (auto key : keys_hash.keys())
|
for (auto key : keys_hash.keys())
|
||||||
{
|
{
|
||||||
if (key == "pos") {
|
if (key == "pos") {
|
||||||
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
|
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
|
||||||
}
|
}
|
||||||
else if (key == "folio_title") {
|
else if (key == "folio_title") {
|
||||||
hash.insert(key, elmt->diagram()->title());
|
hash.insert(key, elmt->diagram()->title());
|
||||||
}
|
}
|
||||||
else if (key == "folio_pos") {
|
else if (key == "folio_pos") {
|
||||||
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
|
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
|
||||||
}
|
}
|
||||||
else if (key == "folio_num") {
|
else if (key == "folio_num") {
|
||||||
hash.insert(key, elmt->diagram()->border_and_titleblock.finalfolio());
|
hash.insert(key, elmt->diagram()->border_and_titleblock.finalfolio());
|
||||||
}
|
}
|
||||||
else if (key == "label") {
|
else if (key == "label") {
|
||||||
hash.insert(key, elmt->actualLabel());
|
hash.insert(key, elmt->actualLabel());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hash.insert(key, elmt->elementInformations()[keys_hash.value(key)].toString());
|
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
|
QString BOMExportDialog::queryStr() const
|
||||||
{
|
{
|
||||||
//User define is own query
|
//User define is own query
|
||||||
if (ui->m_edit_sql_query_cb->isChecked()) {
|
if (ui->m_edit_sql_query_cb->isChecked()) {
|
||||||
return ui->m_sql_query->text();
|
return ui->m_sql_query->text();
|
||||||
}
|
}
|
||||||
//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 = selectedKeys();
|
QStringList keys = selectedKeys();
|
||||||
keys.removeAll("designation_qty");
|
keys.removeAll("designation_qty");
|
||||||
|
|
||||||
QString select ="SELECT ";
|
QString select ="SELECT ";
|
||||||
QString order_by = " ORDER BY ";
|
QString order_by = " ORDER BY ";
|
||||||
|
|
||||||
QString column;
|
QString column;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto key: keys) {
|
for (auto key: keys) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
column += ", ";
|
column += ", ";
|
||||||
order_by += ", ";
|
order_by += ", ";
|
||||||
}
|
}
|
||||||
column += key;
|
column += key;
|
||||||
order_by += 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 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_all_cb->checkState() == Qt::PartiallyChecked)
|
||||||
{
|
{
|
||||||
if (ui->m_terminal_cb->isChecked()) {
|
if (ui->m_terminal_cb->isChecked()) {
|
||||||
@@ -564,24 +564,24 @@ QString BOMExportDialog::queryStr() const
|
|||||||
where += str;
|
where += str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString where_bom;
|
QString where_bom;
|
||||||
if(ui->m_format_as_bom_rb->isChecked())
|
if(ui->m_format_as_bom_rb->isChecked())
|
||||||
{
|
{
|
||||||
if (where.isEmpty()) {
|
if (where.isEmpty()) {
|
||||||
where = " WHERE designation IS NOT NULL";
|
where = " WHERE designation IS NOT NULL";
|
||||||
} else {
|
} else {
|
||||||
where.append(" AND designation IS NOT NULL");
|
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);
|
QString q(select + column + count + from + where + where_bom + group_by + order_by);
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOMExportDialog::updateQueryLine() {
|
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()
|
void BOMExportDialog::fillSavedQuery()
|
||||||
{
|
{
|
||||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||||
if (file.open(QFile::ReadOnly))
|
if (file.open(QFile::ReadOnly))
|
||||||
{
|
{
|
||||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||||
QJsonObject jso = jsd.object();
|
QJsonObject jso = jsd.object();
|
||||||
|
|
||||||
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
|
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
|
||||||
ui->m_conf_cb->addItem(it.key());
|
ui->m_conf_cb->addItem(it.key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) {
|
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()
|
void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
|
||||||
{
|
{
|
||||||
ui->m_sql_query->setEnabled(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_info_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||||
ui->m_parametre_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());
|
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())
|
if (ui->m_edit_sql_query_cb->isChecked() && !m_custom_query.isEmpty())
|
||||||
{
|
{
|
||||||
ui->m_sql_query->setText(m_custom_query);
|
ui->m_sql_query->setText(m_custom_query);
|
||||||
}
|
}
|
||||||
else if (!ui->m_edit_sql_query_cb->isChecked())
|
else if (!ui->m_edit_sql_query_cb->isChecked())
|
||||||
{
|
{
|
||||||
m_custom_query = ui->m_sql_query->text();
|
m_custom_query = ui->m_sql_query->text();
|
||||||
updateQueryLine();
|
updateQueryLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -635,22 +635,22 @@ void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
|
|||||||
*/
|
*/
|
||||||
void BOMExportDialog::on_m_save_current_conf_pb_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))
|
if (file.open(QFile::ReadWrite))
|
||||||
{
|
{
|
||||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||||
QJsonObject root_object;
|
QJsonObject root_object;
|
||||||
|
|
||||||
if (!jsd.isEmpty())
|
if (!jsd.isEmpty())
|
||||||
{
|
{
|
||||||
root_object = jsd.object();
|
root_object = jsd.object();
|
||||||
if (root_object.contains(ui->m_save_name_le->text())) {
|
if (root_object.contains(ui->m_save_name_le->text())) {
|
||||||
root_object.remove(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());
|
vm.insert("user query", ui->m_edit_sql_query_cb->isChecked());
|
||||||
|
|
||||||
if (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);
|
root_object[ui->m_save_name_le->text()] = QJsonObject::fromVariantMap(vm);
|
||||||
|
|
||||||
|
|
||||||
jsd.setObject(root_object);
|
jsd.setObject(root_object);
|
||||||
file.resize(0);
|
file.resize(0);
|
||||||
file.write(jsd.toJson());
|
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());
|
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)) {
|
while (auto item = ui->m_choosen_list->takeItem(0)) {
|
||||||
ui->m_var_list->addItem(item);
|
ui->m_var_list->addItem(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
|||||||
if(tabbed)
|
if(tabbed)
|
||||||
ui->m_use_tab_mode_rb->setChecked(true);
|
ui->m_use_tab_mode_rb->setChecked(true);
|
||||||
else
|
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_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_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());
|
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());
|
ui->m_autosave_sb->setValue(settings.value("diagrameditor/autosave-interval", 0).toInt());
|
||||||
|
|
||||||
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
||||||
settings.value("diagramitemsize").toString() + " (" +
|
settings.value("diagramitemsize").toString() + " (" +
|
||||||
settings.value("diagramitemstyle").toString() + ")";
|
settings.value("diagramitemstyle").toString() + ")";
|
||||||
ui->m_font_pb->setText(fontInfos);
|
ui->m_font_pb->setText(fontInfos);
|
||||||
|
|
||||||
|
|
||||||
@@ -309,9 +309,9 @@ void GeneralConfigurationPage::on_m_font_pb_clicked()
|
|||||||
settings.setValue("diagramitemweight", font.weight());
|
settings.setValue("diagramitemweight", font.weight());
|
||||||
settings.setValue("diagramitemstyle", font.styleName());
|
settings.setValue("diagramitemstyle", font.styleName());
|
||||||
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
||||||
settings.value("diagramitemsize").toString() + " (" +
|
settings.value("diagramitemsize").toString() + " (" +
|
||||||
settings.value("diagramitemstyle").toString() + ")";
|
settings.value("diagramitemstyle").toString() + ")";
|
||||||
ui->m_font_pb->setText(fontInfos);
|
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)
|
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());
|
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection commune"), QDir::homePath());
|
||||||
if (!path.isEmpty()) {
|
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)
|
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());
|
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection utilisateur"), QDir::homePath());
|
||||||
if (!path.isEmpty()) {
|
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)
|
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());
|
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin des cartouches utilisateur"), QDir::homePath());
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
|
|||||||
@@ -37,92 +37,92 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ValueType {
|
enum ValueType {
|
||||||
textFrom =1,
|
textFrom =1,
|
||||||
userText,
|
userText,
|
||||||
infoText,
|
infoText,
|
||||||
compositeText,
|
compositeText,
|
||||||
txtAlignment,
|
txtAlignment,
|
||||||
size,
|
size,
|
||||||
font,
|
font,
|
||||||
color,
|
color,
|
||||||
pos,
|
pos,
|
||||||
frame,
|
frame,
|
||||||
rotation,
|
rotation,
|
||||||
textWidth,
|
textWidth,
|
||||||
grpAlignment,
|
grpAlignment,
|
||||||
grpPos,
|
grpPos,
|
||||||
grpRotation,
|
grpRotation,
|
||||||
grpVAdjust,
|
grpVAdjust,
|
||||||
grpName,
|
grpName,
|
||||||
grpHoldBottom,
|
grpHoldBottom,
|
||||||
grpFrame
|
grpFrame
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
||||||
~DynamicElementTextModel() override;
|
~DynamicElementTextModel() override;
|
||||||
|
|
||||||
bool indexIsInGroup(const QModelIndex &index) const;
|
bool indexIsInGroup(const QModelIndex &index) const;
|
||||||
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
||||||
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
||||||
QModelIndex indexFromText(DynamicElementTextItem *text) const;
|
QModelIndex indexFromText(DynamicElementTextItem *text) const;
|
||||||
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
|
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
|
||||||
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
|
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
|
||||||
|
|
||||||
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
||||||
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
||||||
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
||||||
bool indexIsText(const QModelIndex &index) const;
|
bool indexIsText(const QModelIndex &index) const;
|
||||||
bool indexIsGroup(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 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;
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||||
QStringList mimeTypes() const override;
|
QStringList mimeTypes() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
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);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Element> m_element;
|
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
|
||||||
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
|
void addText(DynamicElementTextItem *deti);
|
||||||
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
|
void removeText(DynamicElementTextItem *deti);
|
||||||
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
|
void addGroup(ElementTextItemGroup *group);
|
||||||
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
|
void removeGroup(ElementTextItemGroup *group);
|
||||||
bool m_block_dataChanged = false;
|
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
|
class DynamicTextItemDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 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;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event) override;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DYNAMICELEMENTTEXTMODEL_H
|
#endif // DYNAMICELEMENTTEXTMODEL_H
|
||||||
|
|||||||
@@ -220,10 +220,10 @@ void LinkSingleElementWidget::buildTree()
|
|||||||
QStringList search_list;
|
QStringList search_list;
|
||||||
QStringList str_list;
|
QStringList str_list;
|
||||||
|
|
||||||
str_list << elmt->actualLabel();
|
str_list << elmt->actualLabel();
|
||||||
if(!str_list.last().isEmpty()) {
|
if(!str_list.last().isEmpty()) {
|
||||||
search_list << str_list.last();
|
search_list << str_list.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
str_list << elmt->elementInformations()["comment"].toString();
|
str_list << elmt->elementInformations()["comment"].toString();
|
||||||
if (!str_list.last().isEmpty())
|
if (!str_list.last().isEmpty())
|
||||||
@@ -347,7 +347,7 @@ bool LinkSingleElementWidget::setLiveEdit(bool live_edit)
|
|||||||
QList <Element *> LinkSingleElementWidget::availableElements()
|
QList <Element *> LinkSingleElementWidget::availableElements()
|
||||||
{
|
{
|
||||||
QList <Element *> elmt_list;
|
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)
|
if (!m_element->isFree() && !m_unlink)
|
||||||
return elmt_list;
|
return elmt_list;
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ QList <Element *> LinkSingleElementWidget::availableElements()
|
|||||||
else
|
else
|
||||||
elmt_list = ep.find(m_filter);
|
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());
|
if(!m_element->isFree()) elmt_list.removeAll(m_element->linkedElements().first());
|
||||||
|
|
||||||
return elmt_list;
|
return elmt_list;
|
||||||
@@ -445,8 +445,8 @@ void LinkSingleElementWidget::setUpHeaderLabels()
|
|||||||
*/
|
*/
|
||||||
void LinkSingleElementWidget::diagramWasRemovedFromProject()
|
void LinkSingleElementWidget::diagramWasRemovedFromProject()
|
||||||
{
|
{
|
||||||
//We use a timer because if the removed diagram contain the master element linked to the edited element
|
//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 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()));
|
QTimer::singleShot(10, this, SLOT(updateUi()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,8 +473,8 @@ void LinkSingleElementWidget::linkTriggered()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//In no live edit mode, we set the background of the qtwi green, to inform the user
|
//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
|
//which element will be linked when he press the apply button
|
||||||
if (m_pending_qtwi)
|
if (m_pending_qtwi)
|
||||||
{
|
{
|
||||||
for(int i=0 ; i<6 ; i++)
|
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)
|
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.
|
//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
|
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
|
||||||
QPoint point = pos;
|
QPoint point = pos;
|
||||||
point.ry()+=ui->m_tree_widget->header()->height();
|
point.ry()+=ui->m_tree_widget->header()->height();
|
||||||
point = ui->m_tree_widget->mapToGlobal(point);
|
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)
|
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())
|
foreach(QTreeWidgetItem *qtwi, m_qtwi_elmt_hash.keys())
|
||||||
qtwi->setHidden(!arg1.isEmpty());
|
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)
|
foreach(QTreeWidgetItem *qtwi, qtwi_list)
|
||||||
qtwi->setHidden(false);
|
qtwi->setHidden(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
|
|||||||
seq_num = conductor_in_potential->sequenceNum();
|
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
|
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);
|
c_list.append(conductor_in_potential);
|
||||||
foreach(Conductor *c, c_list)
|
foreach(Conductor *c, c_list)
|
||||||
properties_list.append(c->properties());
|
properties_list.append(c->properties());
|
||||||
|
|||||||
Reference in New Issue
Block a user