mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-23 02:10:52 +01:00
Try Clazy fix-its
clazy is a compiler plugin which allows clang to understand Qt semantics. You get more than 50 Qt related compiler warnings, ranging from unneeded memory allocations to misusage of API, including fix-its for automatic refactoring. https://invent.kde.org/sdk/clazy
This commit is contained in:
@@ -133,7 +133,7 @@ void QetGraphicsHeaderItem::paint(
|
||||
|
||||
//Draw vertical lines
|
||||
auto offset= 0;
|
||||
for(auto size : m_current_sections_width)
|
||||
for (auto size : std::as_const(m_current_sections_width))
|
||||
{
|
||||
QPointF p1(offset+size, m_current_rect.top());
|
||||
QPointF p2(offset+size, m_current_rect.bottom());
|
||||
@@ -188,7 +188,7 @@ bool QetGraphicsHeaderItem::toDXF(const QString &filepath)
|
||||
|
||||
//Draw vertical lines
|
||||
auto offset= 0;
|
||||
for(auto size : m_current_sections_width)
|
||||
for (auto size : std::as_const(m_current_sections_width))
|
||||
{
|
||||
QPointF p1(offset+size, m_current_rect.top());
|
||||
QPointF p2(offset+size, m_current_rect.bottom());
|
||||
|
||||
@@ -75,9 +75,7 @@ GraphicsTablePropertiesEditor::~GraphicsTablePropertiesEditor()
|
||||
void GraphicsTablePropertiesEditor::setTable(QetGraphicsTableItem *table)
|
||||
{
|
||||
if (m_table_item) {
|
||||
for (auto c : m_connect_list) {
|
||||
disconnect(c);
|
||||
}
|
||||
for (const auto& c : std::as_const(m_connect_list)) { disconnect(c); }
|
||||
if (m_current_model_editor)
|
||||
{
|
||||
ui->m_content_layout->removeWidget(m_current_model_editor);
|
||||
@@ -308,9 +306,11 @@ void GraphicsTablePropertiesEditor::updateUi()
|
||||
{
|
||||
//Disconnect every connections of editor widgets
|
||||
//to avoid an unwanted edition (QSpinBox emit valueChanged no matter if changer by user or by program)
|
||||
for (QMetaObject::Connection c : m_edit_connection) {
|
||||
disconnect(c);
|
||||
}
|
||||
for (const QMetaObject::Connection& c :
|
||||
std::as_const(m_edit_connection))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
m_edit_connection.clear();
|
||||
|
||||
ui->m_next_pb->setEnabled(m_table_item->nextTable());
|
||||
@@ -433,7 +433,8 @@ void GraphicsTablePropertiesEditor::updateInfoLabel()
|
||||
*/
|
||||
void GraphicsTablePropertiesEditor::setUpEditConnection()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_edit_connection) {
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_edit_connection))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
|
||||
@@ -542,7 +543,7 @@ void GraphicsTablePropertiesEditor::on_m_apply_geometry_to_linked_table_pb_click
|
||||
auto new_displayN_row = m_table_item->displayNRow();
|
||||
//Apply to all linked table
|
||||
auto parent_undo = new QUndoCommand(tr("Appliquer la géometrie d'un tableau aux tableau liée à celui-ci"));
|
||||
for (auto table : vector_)
|
||||
for (auto table : std::as_const(vector_))
|
||||
{
|
||||
new QPropertyUndoCommand(table, "pos", table->pos(), new_pos, parent_undo);
|
||||
new QPropertyUndoCommand(table, "size", table->size(), new_size, parent_undo);
|
||||
|
||||
@@ -803,7 +803,7 @@ void Conductor::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSc
|
||||
m_moved_segment = segmentsList().at(m_vector_index+1);
|
||||
before_mov_text_pos_ = m_text_item -> pos();
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
if(handler != qghi)
|
||||
handler->hide();
|
||||
}
|
||||
@@ -871,7 +871,7 @@ void Conductor::addHandler()
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(handlerPoints()), QETUtils::graphicsHandlerSize(this));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
handler->setColor(Qt::blue);
|
||||
scene()->addItem(handler);
|
||||
@@ -1703,7 +1703,7 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
|
||||
this_terminal << terminal1 << terminal2;
|
||||
|
||||
// Return all conductors of terminal 1 and 2
|
||||
for (Terminal *terminal : this_terminal)
|
||||
for (Terminal* terminal : std::as_const(this_terminal))
|
||||
{
|
||||
if (!t_list->contains(terminal))
|
||||
{
|
||||
@@ -1723,7 +1723,8 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
|
||||
|
||||
other_conductors_list_t.removeAll(this);
|
||||
//Get the conductors at the same potential for each conductors of other_conductors_list_t
|
||||
for (Conductor *c : other_conductors_list_t) {
|
||||
for (Conductor* c : std::as_const(other_conductors_list_t))
|
||||
{
|
||||
other_conductors += c->relatedPotentialConductors(all_diagram, t_list);
|
||||
}
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
@@ -2016,7 +2017,7 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
||||
QList<QLineF> lines;
|
||||
QList<QPointF> points;
|
||||
|
||||
for (QPolygonF polygon : polygons)
|
||||
for (const QPolygonF& polygon : polygons)
|
||||
{
|
||||
if (polygon.count() <= 1)
|
||||
continue;
|
||||
@@ -2031,7 +2032,7 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
||||
// we make orthogonal projections of the point on the different
|
||||
// segments of the polygon, sorting them by increasing length
|
||||
QMap<qreal, QPointF> intersections;
|
||||
for (QLineF line : lines)
|
||||
for (QLineF line : std::as_const(lines))
|
||||
{
|
||||
QPointF intersection_point;
|
||||
if (QET::orthogonalProjection(point, line, &intersection_point)) {
|
||||
|
||||
@@ -98,7 +98,7 @@ void CrossRefItem::init()
|
||||
*/
|
||||
void CrossRefItem::setUpConnection()
|
||||
{
|
||||
for(const QMetaObject::Connection& c : m_update_connection)
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_update_connection))
|
||||
disconnect(c);
|
||||
|
||||
m_update_connection.clear();
|
||||
@@ -424,7 +424,7 @@ void CrossRefItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
*/
|
||||
void CrossRefItem::linkedChanged()
|
||||
{
|
||||
for(const QMetaObject::Connection& c : m_slave_connection)
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_slave_connection))
|
||||
disconnect(c);
|
||||
|
||||
m_slave_connection.clear();
|
||||
@@ -524,7 +524,7 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
||||
|
||||
//Bounding rect of the NO text
|
||||
QRectF no_bounding;
|
||||
for (auto str : no_str)
|
||||
for (const auto& str : no_str)
|
||||
{
|
||||
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, str);
|
||||
no_bounding = no_bounding.united(bounding);
|
||||
@@ -538,7 +538,7 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
||||
|
||||
//Bounding rect of the NC text
|
||||
QRectF nc_bounding;
|
||||
for (auto str : nc_str)
|
||||
for (const auto& str : nc_str)
|
||||
{
|
||||
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, str);
|
||||
nc_bounding = nc_bounding.united(bounding);
|
||||
|
||||
@@ -1000,7 +1000,8 @@ void DynamicElementTextItem::setupFormulaConnection()
|
||||
|
||||
void DynamicElementTextItem::clearFormulaConnection()
|
||||
{
|
||||
for (const QMetaObject::Connection& con : m_formula_connection)
|
||||
for (const QMetaObject::Connection& con :
|
||||
std::as_const(m_formula_connection))
|
||||
disconnect(con);
|
||||
m_formula_connection.clear();
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ bool Element::fromXml(QDomElement &e,
|
||||
{
|
||||
if (auto terminal_ = qgraphicsitem_cast<Terminal *>(qgi))
|
||||
{
|
||||
for(auto qde : liste_terminals)
|
||||
for (auto qde : std::as_const(liste_terminals))
|
||||
{
|
||||
if (terminal_ -> fromXml(qde))
|
||||
{
|
||||
@@ -812,7 +812,7 @@ bool Element::fromXml(QDomElement &e,
|
||||
|
||||
//Before loading the dynamic text field,
|
||||
//we remove the dynamic text field created from the description of this element, to avoid doublons.
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(m_dynamic_text_list))
|
||||
delete deti;
|
||||
m_dynamic_text_list.clear();
|
||||
|
||||
@@ -868,10 +868,10 @@ bool Element::fromXml(QDomElement &e,
|
||||
|
||||
//We must block the update of the alignment when loading the information
|
||||
//otherwise the pos of the text will not be the same as it was at save time.
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(m_dynamic_text_list))
|
||||
deti->m_block_alignment = true;
|
||||
setElementInformations(dc);
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(m_dynamic_text_list))
|
||||
deti->m_block_alignment = false;
|
||||
|
||||
m_state = QET::GIOK;
|
||||
@@ -1011,15 +1011,15 @@ QDomElement Element::toXml(
|
||||
|
||||
//Remove the texts from group
|
||||
QList<DynamicElementTextItem *> deti_list = group->texts();
|
||||
for(DynamicElementTextItem *deti : deti_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(deti_list))
|
||||
group->removeFromGroup(deti);
|
||||
|
||||
//Save the texts to xml
|
||||
for (DynamicElementTextItem *deti : deti_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(deti_list))
|
||||
dyn_text.appendChild(deti->toXml(document));
|
||||
|
||||
//Re add texts to group
|
||||
for(DynamicElementTextItem *deti : deti_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(deti_list))
|
||||
group->addToGroup(deti);
|
||||
|
||||
//Restorr the alignment
|
||||
@@ -1079,7 +1079,7 @@ void Element::removeDynamicTextItem(DynamicElementTextItem *deti)
|
||||
return;
|
||||
}
|
||||
|
||||
for(ElementTextItemGroup *group : m_texts_group)
|
||||
for (ElementTextItemGroup* group : std::as_const(m_texts_group))
|
||||
{
|
||||
if(group->texts().contains(deti))
|
||||
{
|
||||
|
||||
@@ -214,7 +214,7 @@ void ElementTextItemGroup::updateAlignment()
|
||||
else if (texts.size() > 1)
|
||||
{
|
||||
qreal width = 0;
|
||||
for(QGraphicsItem *item : texts)
|
||||
for (QGraphicsItem* item : std::as_const(texts))
|
||||
if(item->boundingRect().width() > width)
|
||||
width = item->boundingRect().width();
|
||||
|
||||
@@ -226,8 +226,8 @@ void ElementTextItemGroup::updateAlignment()
|
||||
if(m_alignment == Qt::AlignLeft)
|
||||
{
|
||||
QPointF ref = texts.first()->pos();
|
||||
|
||||
for(QGraphicsItem *item : texts)
|
||||
|
||||
for (QGraphicsItem* item : std::as_const(texts))
|
||||
{
|
||||
item->setPos(0, ref.y()+y_offset);
|
||||
y_offset+=item->boundingRect().height() + m_vertical_adjustment;
|
||||
@@ -236,8 +236,8 @@ void ElementTextItemGroup::updateAlignment()
|
||||
else if(m_alignment == Qt::AlignVCenter)
|
||||
{
|
||||
QPointF ref(width/2,0);
|
||||
|
||||
for(QGraphicsItem *item : texts)
|
||||
|
||||
for (QGraphicsItem* item : std::as_const(texts))
|
||||
{
|
||||
item->setPos(ref.x() - item->boundingRect().width()/2,
|
||||
ref.y() + y_offset);
|
||||
@@ -247,8 +247,8 @@ void ElementTextItemGroup::updateAlignment()
|
||||
else if (m_alignment == Qt::AlignRight)
|
||||
{
|
||||
QPointF ref(width,0);
|
||||
|
||||
for(QGraphicsItem *item : texts)
|
||||
|
||||
for (QGraphicsItem* item : std::as_const(texts))
|
||||
{
|
||||
item->setPos(ref.x() - item->boundingRect().width(),
|
||||
ref.y() + y_offset);
|
||||
|
||||
@@ -49,11 +49,14 @@ QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, QGraphicsItem
|
||||
setAcceptHoverEvents(true);
|
||||
m_pen.setStyle(Qt::SolidLine);
|
||||
//ensure handlers are always above this item
|
||||
connect(this, &QetShapeItem::zChanged, [this]()
|
||||
{
|
||||
for(QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
qghi->setZValue(this->zValue()+1);
|
||||
});
|
||||
connect(
|
||||
this,
|
||||
&QetShapeItem::zChanged,
|
||||
[this]()
|
||||
{
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setZValue(this->zValue() + 1);
|
||||
});
|
||||
|
||||
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
||||
m_insert_point->setIcon(QET::Icons::Add);
|
||||
@@ -487,7 +490,8 @@ void QetShapeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
|
||||
if (m_handler_vector.count() > 2)
|
||||
{
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi :
|
||||
std::as_const(m_handler_vector))
|
||||
{
|
||||
if (qghi->contains(qghi->mapFromScene(event->scenePos())))
|
||||
{
|
||||
@@ -520,14 +524,16 @@ void QetShapeItem::switchResizeMode()
|
||||
if (m_resize_mode == 1)
|
||||
{
|
||||
m_resize_mode = 2;
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
qghi->setColor(Qt::darkGreen);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_resize_mode = 1;
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
qghi->setColor(Qt::blue);
|
||||
}
|
||||
}
|
||||
@@ -537,7 +543,7 @@ void QetShapeItem::switchResizeMode()
|
||||
if (m_resize_mode == 1)
|
||||
{
|
||||
m_resize_mode = 2;
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setColor(Qt::darkGreen);
|
||||
}
|
||||
else if (m_resize_mode == 2)
|
||||
@@ -546,7 +552,8 @@ void QetShapeItem::switchResizeMode()
|
||||
qDeleteAll(m_handler_vector);
|
||||
m_handler_vector.clear();
|
||||
addHandler();
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
qghi->setColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
@@ -556,10 +563,10 @@ void QetShapeItem::switchResizeMode()
|
||||
qDeleteAll(m_handler_vector);
|
||||
m_handler_vector.clear();
|
||||
addHandler();
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
qghi->setColor(Qt::blue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
||||
QColor Terminal::warningColor = QColor("#ff8000");
|
||||
QColor Terminal::warningColor = QColor(0xff8000);
|
||||
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
||||
const qreal Terminal::terminalSize = 4.0;
|
||||
const qreal Terminal::Z = 1000;
|
||||
|
||||
Reference in New Issue
Block a user