mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20: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:
@@ -61,7 +61,8 @@ PastePartsCommand::~PastePartsCommand()
|
||||
void PastePartsCommand::undo()
|
||||
{
|
||||
m_scene->blockSignals(true);
|
||||
for (auto qgi : m_pasted_content) {
|
||||
for (auto qgi : std::as_const(m_pasted_content))
|
||||
{
|
||||
m_scene->removeItem(qgi);
|
||||
}
|
||||
m_scene->blockSignals(false);
|
||||
@@ -84,7 +85,8 @@ void PastePartsCommand::redo()
|
||||
m_first_redo = false;
|
||||
} else {
|
||||
m_scene->blockSignals(true);
|
||||
for (auto qgi : m_pasted_content) {
|
||||
for (auto qgi : std::as_const(m_pasted_content))
|
||||
{
|
||||
m_scene->addItem(qgi);
|
||||
}
|
||||
m_scene->blockSignals(false);
|
||||
|
||||
@@ -93,8 +93,9 @@ void ArcEditor::setUpChangeConnections()
|
||||
|
||||
void ArcEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
disconnect(c);
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_change_connections))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene
|
||||
*/
|
||||
void RotateElementsCommand::undo()
|
||||
{
|
||||
for (QGraphicsItem *item : m_items)
|
||||
for (QGraphicsItem* item : std::as_const(m_items))
|
||||
{
|
||||
if (item->type() == PartTerminal::Type) {
|
||||
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
|
||||
@@ -549,7 +549,7 @@ void RotateElementsCommand::undo()
|
||||
*/
|
||||
void RotateElementsCommand::redo()
|
||||
{
|
||||
for (QGraphicsItem *item : m_items)
|
||||
for (QGraphicsItem* item : std::as_const(m_items))
|
||||
{
|
||||
if (item->type() == PartTerminal::Type) {
|
||||
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
|
||||
|
||||
@@ -613,13 +613,13 @@ void ElementPrimitiveDecorator::addHandler()
|
||||
if (m_handler_vector.isEmpty() && scene())
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapFromScene(getResizingsPoints()));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
{
|
||||
scene()->addItem(handler);
|
||||
handler->setColor(Qt::darkGreen);
|
||||
handler->installSceneEventFilter(this);
|
||||
handler->setZValue(this->zValue()+1);
|
||||
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
scene()->addItem(handler);
|
||||
handler->setColor(Qt::darkGreen);
|
||||
handler->installSceneEventFilter(this);
|
||||
handler->setZValue(this->zValue() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -727,12 +727,12 @@ QVariant ElementPrimitiveDecorator::itemChange(QGraphicsItem::GraphicsItemChange
|
||||
else if (change == ItemVisibleHasChanged)
|
||||
{
|
||||
bool visible = value.toBool();
|
||||
for(QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setVisible(visible);
|
||||
}
|
||||
else if (change == ItemZValueHasChanged && !m_handler_vector.isEmpty())
|
||||
{
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setZValue(this->zValue()+1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1099,7 +1099,7 @@ void ElementScene::reset()
|
||||
items_list << qgi;
|
||||
}
|
||||
|
||||
for (QGraphicsItem *qgi : items_list)
|
||||
for (QGraphicsItem* qgi : std::as_const(items_list))
|
||||
{
|
||||
removeItem(qgi);
|
||||
qgiManager().release(qgi);
|
||||
|
||||
@@ -530,7 +530,7 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
|
||||
//Check each pair of style
|
||||
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
||||
for (auto style : styles)
|
||||
for (const auto& style : std::as_const(styles))
|
||||
{
|
||||
auto rx_match = rx.match(style);
|
||||
if (!rx_match.hasMatch()) {
|
||||
|
||||
@@ -265,7 +265,7 @@ void PartArc::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)
|
||||
@@ -276,7 +276,7 @@ void PartArc::switchResizeMode()
|
||||
removeHandler();
|
||||
addHandler();
|
||||
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setColor(Qt::magenta);
|
||||
}
|
||||
else
|
||||
@@ -287,7 +287,7 @@ void PartArc::switchResizeMode()
|
||||
removeHandler();
|
||||
addHandler();
|
||||
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
qghi->setColor(Qt::blue);
|
||||
}
|
||||
}
|
||||
@@ -445,7 +445,7 @@ void PartArc::addHandler()
|
||||
else
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
QColor color = Qt::blue;
|
||||
if (m_resize_mode == 2)
|
||||
|
||||
@@ -241,13 +241,13 @@ void PartEllipse::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);
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void PartEllipse::addHandler()
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
QColor color = Qt::blue;
|
||||
if (m_resize_mode == 2)
|
||||
|
||||
@@ -304,7 +304,7 @@ void PartLine::addHandler()
|
||||
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
handler->setColor(Qt::blue);
|
||||
scene()->addItem(handler);
|
||||
|
||||
@@ -277,7 +277,8 @@ void PartPolygon::setClosed(bool close)
|
||||
*/
|
||||
void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
|
||||
{
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
if (qghi->pos() == mapToScene(pos)) {
|
||||
qghi->setColor(color);
|
||||
}
|
||||
@@ -290,7 +291,8 @@ void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
|
||||
*/
|
||||
void PartPolygon::resetAllHandlerColor()
|
||||
{
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
for (QetGraphicsHandlerItem* qghi : std::as_const(m_handler_vector))
|
||||
{
|
||||
qghi->setColor(Qt::blue);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +382,7 @@ void PartPolygon::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
list << m_insert_point;
|
||||
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())))
|
||||
{
|
||||
@@ -476,7 +478,7 @@ void PartPolygon::addHandler()
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(m_polygon));
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
handler->setColor(Qt::blue);
|
||||
scene()->addItem(handler);
|
||||
|
||||
@@ -361,7 +361,7 @@ void PartRectangle::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)
|
||||
@@ -370,7 +370,8 @@ void PartRectangle::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);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +381,8 @@ void PartRectangle::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);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +514,7 @@ void PartRectangle::addHandler()
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius)));
|
||||
}
|
||||
|
||||
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
for (QetGraphicsHandlerItem* handler : std::as_const(m_handler_vector))
|
||||
{
|
||||
QColor color;
|
||||
if(m_resize_mode == 1) {color = Qt::blue;}
|
||||
|
||||
@@ -469,7 +469,7 @@ void StyleEditor::updateForm()
|
||||
size_weight -> setCurrentIndex(first_part -> lineWeight());
|
||||
filling_color -> setCurrentIndex(first_part -> filling());
|
||||
|
||||
for (auto cegp : m_part_list)
|
||||
for (auto cegp : std::as_const(m_part_list))
|
||||
{
|
||||
if (first_part -> antialiased() != cegp -> antialiased()) antialiasing -> setChecked(false);
|
||||
if (first_part -> color() != cegp -> color()) outline_color -> setCurrentIndex(-1);
|
||||
|
||||
@@ -51,7 +51,9 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
||||
{
|
||||
delete ui;
|
||||
if(!m_connection_list.isEmpty()) {
|
||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||
for (const QMetaObject::Connection& con :
|
||||
std::as_const(m_connection_list))
|
||||
{
|
||||
disconnect(con);
|
||||
}
|
||||
}
|
||||
@@ -203,7 +205,8 @@ void DynamicTextFieldEditor::disconnectConnections()
|
||||
{
|
||||
//Remove previous connection
|
||||
if(!m_connection_list.isEmpty())
|
||||
for(const auto &connection : m_connection_list) {
|
||||
for (const auto& connection : std::as_const(m_connection_list))
|
||||
{
|
||||
disconnect(connection);
|
||||
}
|
||||
m_connection_list.clear();
|
||||
|
||||
@@ -171,7 +171,8 @@ void EllipseEditor::setUpChangeConnections()
|
||||
*/
|
||||
void EllipseEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_change_connections))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
|
||||
@@ -223,7 +223,8 @@ void LineEditor::setUpChangeConnections()
|
||||
*/
|
||||
void LineEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (auto connection : m_change_connections) {
|
||||
for (const auto& connection : std::as_const(m_change_connections))
|
||||
{
|
||||
disconnect(connection);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ void PolygonEditor::setUpChangeConnections()
|
||||
|
||||
void PolygonEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_change_connections))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
|
||||
@@ -545,7 +545,7 @@ void QETElementEditor::updateInformations()
|
||||
QString selection_xml_name = part -> xmlName();
|
||||
bool same_xml_name = true;
|
||||
bool style_editable = true;
|
||||
for (QGraphicsItem *qgi: selected_qgis)
|
||||
for (QGraphicsItem* qgi : std::as_const(selected_qgis))
|
||||
{
|
||||
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||
cep_list << cep;
|
||||
@@ -582,9 +582,11 @@ void QETElementEditor::updateInformations()
|
||||
bool equal = true;
|
||||
QList<CustomElementPart*> parts = editor -> currentParts();
|
||||
if (parts.length() == cep_list.length()) {
|
||||
for (auto cep: cep_list) {
|
||||
for (auto cep : std::as_const(cep_list))
|
||||
{
|
||||
bool part_found = false;
|
||||
for (auto part: parts) {
|
||||
for (auto part : std::as_const(parts))
|
||||
{
|
||||
if (part == cep) {
|
||||
part_found = true;
|
||||
break;
|
||||
@@ -789,12 +791,12 @@ bool QETElementEditor::checkElement()
|
||||
|
||||
dialog_message += "<ol>";
|
||||
QList<QETWarning> total = warnings << errors;
|
||||
for(QETWarning warning : total)
|
||||
for (const QETWarning& warning : total)
|
||||
{
|
||||
dialog_message += "<li>";
|
||||
dialog_message += QString(
|
||||
tr("<b>%1</b> : %2", "warning title: warning description")
|
||||
).arg(warning.first).arg(warning.second);
|
||||
dialog_message +=
|
||||
QString(tr("<b>%1</b> : %2", "warning title: warning description"))
|
||||
.arg(warning.first, warning.second);
|
||||
dialog_message += "</li>";
|
||||
}
|
||||
dialog_message += "</ol>";
|
||||
|
||||
@@ -59,7 +59,8 @@ void RectangleEditor::setUpChangeConnections()
|
||||
|
||||
void RectangleEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
for (const QMetaObject::Connection& c : std::as_const(m_change_connections))
|
||||
{
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
|
||||
@@ -92,8 +92,9 @@ void TextEditor::disconnectChangeConnection()
|
||||
|
||||
void TextEditor::disconnectEditConnection()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user