Implemented QET coding style (replaced 4 space with tab)

This commit is contained in:
Adrien Allain
2021-09-13 21:00:44 +02:00
committed by Laurent Trinques
parent c640d96bca
commit ccfb46b354
10 changed files with 83 additions and 83 deletions

View File

@@ -613,63 +613,63 @@ void changeElementDataCommand::redo() {
RotateElementsCommand::RotateElementsCommand(ElementScene *scene, QUndoCommand *parent) : RotateElementsCommand::RotateElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent) ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent)
{ {
m_items = scene->selectedItems(); m_items = scene->selectedItems();
} }
/** /**
@brief RotateElementsCommand::undo @brief RotateElementsCommand::undo
*/ */
void RotateElementsCommand::undo() void RotateElementsCommand::undo()
{ {
for (QGraphicsItem *item : m_items) for (QGraphicsItem *item : m_items)
{ {
if (item->type() == PartTerminal::Type) { if (item->type() == PartTerminal::Type) {
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item); PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
term->setRotation(term->rotation()-90); term->setRotation(term->rotation()-90);
} }
else if (item->type() == PartRectangle::Type) { else if (item->type() == PartRectangle::Type) {
PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item); PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item);
rect->setRotation(rect->rotation()-90); rect->setRotation(rect->rotation()-90);
} }
else if (item->type() == PartLine::Type) { else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item); PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()-90); line->setRotation(line->rotation()-90);
} }
else if (item->type() == PartPolygon::Type) { else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item); PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()-90); poly->setRotation(poly->rotation()-90);
} }
else { else {
item->setRotation(item->rotation()-90); item->setRotation(item->rotation()-90);
} }
} }
} }
/** /**
@brief RotateElementsCommand::redo @brief RotateElementsCommand::redo
*/ */
void RotateElementsCommand::redo() void RotateElementsCommand::redo()
{ {
for (QGraphicsItem *item : m_items) for (QGraphicsItem *item : m_items)
{ {
if (item->type() == PartTerminal::Type) { if (item->type() == PartTerminal::Type) {
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item); PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
term->setRotation(term->rotation()+90); term->setRotation(term->rotation()+90);
} }
else if (item->type() == PartRectangle::Type) { else if (item->type() == PartRectangle::Type) {
PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item); PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item);
rect->setRotation(rect->rotation()+90); rect->setRotation(rect->rotation()+90);
} }
else if (item->type() == PartLine::Type) { else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item); PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()+90); line->setRotation(line->rotation()+90);
} }
else if (item->type() == PartPolygon::Type) { else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item); PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()+90); poly->setRotation(poly->rotation()+90);
} }
else { else {
item->setRotation(item->rotation()+90); item->setRotation(item->rotation()+90);
} }
} }
} }

View File

@@ -605,14 +605,14 @@ void PartLine::setSecondEndLength(const qreal &l)
void PartLine::setRotation(qreal angle) { void PartLine::setRotation(qreal angle) {
QTransform rotation = QTransform().translate(m_line.p1().x(),m_line.p1().y()).rotate(angle-m_rot).translate(-m_line.p1().x(),-m_line.p1().y()); QTransform rotation = QTransform().translate(m_line.p1().x(),m_line.p1().y()).rotate(angle-m_rot).translate(-m_line.p1().x(),-m_line.p1().y());
m_rot=angle; m_rot=angle;
setLine(rotation.map(m_line)); setLine(rotation.map(m_line));
} }
qreal PartLine::rotation() const { qreal PartLine::rotation() const {
return m_rot; return m_rot;
} }

View File

@@ -94,8 +94,8 @@ class PartLine : public CustomElementGraphicPart
void setFirstEndLength(const qreal &l); void setFirstEndLength(const qreal &l);
qreal secondEndLength() const {return second_length;} qreal secondEndLength() const {return second_length;}
void setSecondEndLength(const qreal &l); void setSecondEndLength(const qreal &l);
void setRotation(qreal angle); void setRotation(qreal angle);
qreal rotation() const; qreal rotation() const;
protected: protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;

View File

@@ -296,14 +296,14 @@ void PartPolygon::resetAllHandlerColor()
void PartPolygon::setRotation(qreal angle) { void PartPolygon::setRotation(qreal angle) {
QTransform rotation = QTransform().translate(m_polygon.first().x(),m_polygon.first().y()).rotate(angle-m_rot).translate(-m_polygon.first().x(),-m_polygon.first().y()); QTransform rotation = QTransform().translate(m_polygon.first().x(),m_polygon.first().y()).rotate(angle-m_rot).translate(-m_polygon.first().x(),-m_polygon.first().y());
m_rot=angle; m_rot=angle;
setPolygon(rotation.map(m_polygon)); setPolygon(rotation.map(m_polygon));
} }
qreal PartPolygon::rotation() const { qreal PartPolygon::rotation() const {
return m_rot; return m_rot;
} }

View File

@@ -87,8 +87,8 @@ class PartPolygon : public CustomElementGraphicPart
void setHandlerColor(QPointF pos, const QColor &color) final; void setHandlerColor(QPointF pos, const QColor &color) final;
void resetAllHandlerColor() final; void resetAllHandlerColor() final;
void setRotation (qreal angle); void setRotation (qreal angle);
qreal rotation () const; qreal rotation () const;
protected: protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;

View File

@@ -173,14 +173,14 @@ void PartRectangle::setYRadius(qreal Y)
void PartRectangle::setRotation(qreal angle) { void PartRectangle::setRotation(qreal angle) {
QTransform rotation = QTransform().rotate(angle-m_rot); QTransform rotation = QTransform().rotate(angle-m_rot);
m_rot=angle; m_rot=angle;
setRect(rotation.mapRect(m_rect)); setRect(rotation.mapRect(m_rect));
} }
qreal PartRectangle::rotation() const { qreal PartRectangle::rotation() const {
return m_rot; return m_rot;
} }
/** /**

View File

@@ -71,8 +71,8 @@ class PartRectangle : public CustomElementGraphicPart
void setXRadius(qreal X); void setXRadius(qreal X);
qreal YRadius() const {return m_yRadius;} qreal YRadius() const {return m_yRadius;}
void setYRadius(qreal Y); void setYRadius(qreal Y);
void setRotation(qreal angle); void setRotation(qreal angle);
qreal rotation() const; qreal rotation() const;
QRectF sceneGeometricRect() const override; QRectF sceneGeometricRect() const override;
virtual QPointF sceneTopLeft() const; virtual QPointF sceneTopLeft() const;

View File

@@ -154,28 +154,28 @@ void PartTerminal::setOrientation(Qet::Orientation ori) {
} }
/** /**
Redéfinit la fonction de rotation pour la traduire en orientation de la borne Redefines setRotation to call setOrientation
@param angle @param angle
*/ */
void PartTerminal::setRotation(qreal angle) { void PartTerminal::setRotation(qreal angle) {
qreal angle_mod = std::fmod(angle,360); qreal angle_mod = std::fmod(angle,360);
Qet::Orientation new_ori = Qet::North; Qet::Orientation new_ori = Qet::North;
if (0 <= angle_mod && angle_mod < 90 ) new_ori = Qet::North; if (0 <= angle_mod && angle_mod < 90 ) new_ori = Qet::North;
else if (90 <= angle_mod && angle_mod < 180) new_ori = Qet::East; else if (90 <= angle_mod && angle_mod < 180) new_ori = Qet::East;
else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South; else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South;
else new_ori = Qet::West; else new_ori = Qet::West;
setOrientation(new_ori); setOrientation(new_ori);
} }
qreal PartTerminal::rotation() const { qreal PartTerminal::rotation() const {
switch (d->m_orientation) { switch (d->m_orientation) {
case Qet::North : return 0; case Qet::North : return 0;
case Qet::East : return 90; case Qet::East : return 90;
case Qet::South : return 180; case Qet::South : return 180;
case Qet::West : return 270; case Qet::West : return 270;
} }
} }
/** /**

View File

@@ -74,8 +74,8 @@ class PartTerminal : public CustomElementGraphicPart
Qet::Orientation orientation() const {return d -> m_orientation;} Qet::Orientation orientation() const {return d -> m_orientation;}
void setOrientation(Qet::Orientation ori); void setOrientation(Qet::Orientation ori);
qreal rotation() const; qreal rotation() const;
void setRotation(qreal angle); void setRotation(qreal angle);
QString name() const override { return d -> m_name; } QString name() const override { return d -> m_name; }

View File

@@ -1020,7 +1020,7 @@ void QETElementEditor::setupActions()
addToolBar(Qt::TopToolBarArea, depth_toolbar); addToolBar(Qt::TopToolBarArea, depth_toolbar);
//Rotate action //Rotate action
connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));}); connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));});
//Zoom action //Zoom action
ui->m_zoom_in_action -> setShortcut(QKeySequence::ZoomIn); ui->m_zoom_in_action -> setShortcut(QKeySequence::ZoomIn);