Revert "Try Clazy fix-its"

Segfault on old Qt versions!
This reverts commit dba7caed30.
This commit is contained in:
Laurent Trinques
2025-02-14 16:17:58 +01:00
parent dba7caed30
commit 43f0107eb1
88 changed files with 409 additions and 512 deletions

View File

@@ -236,7 +236,7 @@ void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString
QString author_template = "<span style=\"text-decoration: underline;\">%1</span> : %2 &lt;<a href=\"mailto:%3\">%3</a>&gt;&lrm;<br/><br/>";
// Add the function of the person
new_text += author_template.arg(work, name, email);
new_text += author_template.arg(work).arg(name).arg(email);
label->setText(new_text);
}
@@ -253,7 +253,7 @@ void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QStrin
QString Library_template = "<span style=\"text-decoration: underline;\">%1</span> : &lt;<a href=\"%3\">%3</a>&gt;&lrm;<br/><br/>";
// Add the function of the person
new_text += Library_template.arg(name, link);
new_text += Library_template.arg(name).arg(link);
label->setText(new_text);
}

View File

@@ -71,7 +71,7 @@ void DiagramContextWidget::setContext (const DiagramContext &context)
clear();
int i = 0;
for (const QString& key : context.keys(DiagramContext::Alphabetical))
for (QString key : context.keys(DiagramContext::Alphabetical))
{
ui->m_table->setItem(i, 0, new QTableWidgetItem(key));
ui->m_table->setItem(i, 1, new QTableWidgetItem(context[key].toString()));

View File

@@ -79,23 +79,23 @@ void DynamicElementTextItemEditor::apply()
deti_list << m_element.data()->dynamicTextItems();
for(ElementTextItemGroup *group : m_element.data()->textGroups())
deti_list << group->texts();
for (DynamicElementTextItem *deti : deti_list)
{
QUndoCommand *undo = m_model->undoForEditedText(deti);
for (DynamicElementTextItem* deti : std::as_const(deti_list))
if (undo->childCount() == 1)
{
QUndoCommand* undo = m_model->undoForEditedText(deti);
if (undo->childCount() == 1)
{
QPropertyUndoCommand* quc = new QPropertyUndoCommand(
static_cast<const QPropertyUndoCommand*>(undo->child(0)));
if (quc->text().isEmpty()) quc->setText(undo->text());
undo_list << quc;
delete undo;
}
else if (undo->childCount() > 1)
undo_list << undo;
else
delete undo;
QPropertyUndoCommand *quc = new QPropertyUndoCommand(static_cast<const QPropertyUndoCommand *>(undo->child(0)));
if (quc->text().isEmpty())
quc->setText(undo->text());
undo_list << quc;
delete undo;
}
else if(undo->childCount() > 1)
undo_list << undo;
else
delete undo;
}
//Get all texts groups of the edited element
@@ -127,7 +127,8 @@ void DynamicElementTextItemEditor::apply()
{
QUndoStack &us = m_element->diagram()->undoStack();
us.beginMacro(tr("Modifier des textes d'élément"));
for (QUndoCommand* quc : std::as_const(undo_list)) us.push(quc);
for (QUndoCommand *quc : undo_list)
us.push(quc);
us.endMacro();
}
}

View File

@@ -1936,8 +1936,8 @@ QStringList DynamicTextItemDelegate::availableInfo(
QStringList info_list = QETInformation::elementInfoKeys();
info_list.removeAll("formula"); //No need to have formula
DiagramContext dc = elmt->elementInformations();
for (const QString& info : std::as_const(info_list))
for(const QString& info : info_list)
{
if(dc.contains(info))
qstrl << info;

View File

@@ -158,7 +158,7 @@ bool ElementInfoWidget::event(QEvent *event)
*/
void ElementInfoWidget::enableLiveEdit()
{
for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list))
for (ElementInfoPartWidget *eipw : m_eipw_list)
connect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply);
}
@@ -168,7 +168,7 @@ void ElementInfoWidget::enableLiveEdit()
*/
void ElementInfoWidget::disableLiveEdit()
{
for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list))
for (ElementInfoPartWidget *eipw : m_eipw_list)
disconnect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply);
}
@@ -185,14 +185,11 @@ void ElementInfoWidget::buildInterface()
keys = QETInformation::elementInfoKeys();
}
for (const auto& str : std::as_const(keys))
{
ElementInfoPartWidget* eipw = new ElementInfoPartWidget(
str,
QETInformation::translatedInfoKey(str),
this);
ui->scroll_vlayout->addWidget(eipw);
m_eipw_list << eipw;
for (auto str : keys)
{
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
ui->scroll_vlayout->addWidget(eipw);
m_eipw_list << eipw;
}
ui->scroll_vlayout->addStretch();
@@ -230,9 +227,8 @@ void ElementInfoWidget::updateUi()
if (m_live_edit) disableLiveEdit();
const auto element_info{m_element->elementInformations()};
for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list))
{
for (ElementInfoPartWidget *eipw : m_eipw_list) {
eipw -> setText (element_info[eipw->key()].toString());
}

View File

@@ -140,8 +140,7 @@ void ElementPropertiesWidget::setDynamicText(DynamicElementTextItem *text)
if(text->parentElement())
{
setElement(text->parentElement());
for (AbstractElementPropertiesEditorWidget* aepew :
std::as_const(m_list_editor))
for(AbstractElementPropertiesEditorWidget *aepew : m_list_editor)
{
if (QString(aepew->metaObject()->className()) == "DynamicElementTextItemEditor")
{
@@ -167,8 +166,7 @@ void ElementPropertiesWidget::setTextsGroup(ElementTextItemGroup *group)
if(group->parentItem() && group->parentItem()->type() == Element::Type)
{
setElement(static_cast<Element *>(group->parentItem()));
for (AbstractElementPropertiesEditorWidget* aepew :
std::as_const(m_list_editor))
for(AbstractElementPropertiesEditorWidget *aepew : m_list_editor)
{
if (QString(aepew->metaObject()->className()) == "DynamicElementTextItemEditor")
{
@@ -316,8 +314,7 @@ void ElementPropertiesWidget::updateUi()
m_list_editor << new DynamicElementTextItemEditor(m_element, this);
//Add each editors in tab widget
for (AbstractElementPropertiesEditorWidget* aepew :
std::as_const(m_list_editor))
for (AbstractElementPropertiesEditorWidget *aepew : m_list_editor)
{
aepew->setLiveEdit(m_live_edit);
m_tab->addTab(aepew, aepew->title());

View File

@@ -71,8 +71,7 @@ IndiTextPropertiesWidget::~IndiTextPropertiesWidget()
void IndiTextPropertiesWidget::setText(IndependentTextItem *text)
{
if (m_text) {
for (const QMetaObject::Connection& c : std::as_const(m_connect_list))
{
for (QMetaObject::Connection c : m_connect_list) {
disconnect(c);
}
}
@@ -90,8 +89,7 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text)
void IndiTextPropertiesWidget::setText(QList<IndependentTextItem *> text_list)
{
for (const QMetaObject::Connection& c : std::as_const(m_connect_list))
{
for (QMetaObject::Connection c : m_connect_list) {
disconnect(c);
}
m_connect_list.clear();
@@ -127,9 +125,7 @@ void IndiTextPropertiesWidget::apply()
if (m_text && m_text->diagram()) {
d = m_text->diagram();
} else if (!m_text_list.isEmpty()) {
for (const QPointer<IndependentTextItem>& piti :
std::as_const(m_text_list))
{
for (QPointer<IndependentTextItem> piti : m_text_list) {
if (piti->diagram()) {
d = piti->diagram();
break;
@@ -162,9 +158,7 @@ bool IndiTextPropertiesWidget::setLiveEdit(bool live_edit)
setUpEditConnection();
}
else {
for (const QMetaObject::Connection& c :
std::as_const(m_edit_connection))
{
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
@@ -226,7 +220,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
qreal rotation_ = m_text_list.first()->rotation();
int size_ = m_text_list.first()->font().pointSize();
QFont font_ = m_text_list.first()->font();
for (const QPointer<IndependentTextItem>& piti : m_text_list)
for (QPointer<IndependentTextItem> piti : m_text_list)
{
if (piti->rotation() != rotation_) {
angle_equal = false;
@@ -242,7 +236,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
if ((angle_equal && (ui->m_angle_sb->value() != rotation_)) ||
(!angle_equal && (ui->m_angle_sb->value() != ui->m_angle_sb->minimum())))
{
for (const QPointer<IndependentTextItem>& piti : m_text_list)
for (QPointer<IndependentTextItem> piti : m_text_list)
{
if (piti)
{
@@ -257,7 +251,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
else if ((size_equal && (ui->m_size_sb->value() != size_)) ||
(!size_equal && (ui->m_size_sb->value() != ui->m_size_sb->minimum())))
{
for (const QPointer<IndependentTextItem>& piti : m_text_list)
for (QPointer<IndependentTextItem> piti : m_text_list)
{
if (piti)
{
@@ -273,7 +267,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
else if ((m_font_is_selected && !font_equal) ||
(m_font_is_selected && (font_equal && (m_selected_font != font_))))
{
for (const QPointer<IndependentTextItem>& piti : m_text_list)
for (QPointer<IndependentTextItem> piti : m_text_list)
{
if (piti)
{
@@ -330,8 +324,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
*/
void IndiTextPropertiesWidget::setUpEditConnection()
{
for (const QMetaObject::Connection& c : std::as_const(m_edit_connection))
{
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
@@ -361,8 +354,7 @@ void IndiTextPropertiesWidget::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 (const QMetaObject::Connection& c : std::as_const(m_edit_connection))
{
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
@@ -396,8 +388,7 @@ void IndiTextPropertiesWidget::updateUi()
int size_ = m_text_list.first()->font().pointSize();
QFont font_ = m_text_list.first()->font();
for (const QPointer<IndependentTextItem>& piti :
std::as_const(m_text_list))
for (QPointer<IndependentTextItem> piti : m_text_list)
{
if (piti->rotation() != rotation_) {
angle_equal = false;
@@ -412,9 +403,7 @@ void IndiTextPropertiesWidget::updateUi()
ui->m_angle_sb->setValue(angle_equal ? rotation_ : 0);
bool valid_ = true;
for (const QPointer<IndependentTextItem>& piti :
std::as_const(m_text_list))
{
for (QPointer<IndependentTextItem> piti : m_text_list) {
if (piti->isHtml()) {
valid_ = false;
}
@@ -447,11 +436,10 @@ void IndiTextPropertiesWidget::on_m_break_html_pb_clicked()
if (m_text) {
m_text->setPlainText(m_text->toPlainText());
}
for (const QPointer<IndependentTextItem>& piti : std::as_const(m_text_list))
{
for (QPointer<IndependentTextItem> piti : m_text_list) {
piti->setPlainText(piti->toPlainText());
}
updateUi();
}

View File

@@ -117,7 +117,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
m_diagram->clearSelection();
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
for (const DiagramContent& dc : std::as_const(m_pasted_content_list))
for(DiagramContent dc : m_pasted_content_list)
{
QList<Element *> pasted_elements = dc.m_elements;
//Sort the list element by there pos (top -> bottom)

View File

@@ -204,7 +204,7 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
layout.addWidget(&label);
QHash <QRadioButton *, ConductorProperties> H;
for (const ConductorProperties& cp : list)
for (ConductorProperties cp : list)
{
QString text;
if(!cp.text.isEmpty())

View File

@@ -121,7 +121,7 @@ void ShapeGraphicsItemPropertiesWidget::apply()
}
else if (!m_shapes_list.isEmpty())
{
for (const QPointer<QetShapeItem>& qsi : std::as_const(m_shapes_list))
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
if (qsi->diagram()) {
d = qsi->diagram();
@@ -222,7 +222,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
if (ui->m_style_cb->currentIndex() != -1 &&
Qt::PenStyle(ui->m_style_cb->currentIndex() + 1) != shape_->pen().style())
{
for (const QPointer<QetShapeItem>& qsi : m_shapes_list)
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
QPen pen = qsi->pen();
@@ -239,7 +239,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
if (ui->m_size_dsb->value() > 0 &&
ui->m_size_dsb->value() != shape_->pen().widthF())
{
for (const QPointer<QetShapeItem>& qsi : m_shapes_list)
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
QPen pen = pen_H.contains(qsi) ? pen_H.value(qsi) : qsi->pen();
pen.setWidthF(ui->m_size_dsb->value());
@@ -250,7 +250,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
QColor c =ui->m_color_kpb->color();
if (c != QPalette().color(QPalette::Button) && shape_->pen().color() != c)
{
for (const QPointer<QetShapeItem>& qsi : m_shapes_list)
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
QPen pen = pen_H.contains(qsi) ? pen_H.value(qsi) : qsi->pen();
pen.setColor(c);
@@ -258,7 +258,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
}
}
for (const QPointer<QetShapeItem>& qsi : pen_H.keys())
for (QPointer<QetShapeItem> qsi : pen_H.keys())
{
if (!parent_undo) {
parent_undo = new QUndoCommand(tr("Modifier une forme simple"));
@@ -271,7 +271,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
if (ui->m_brush_style_cb->currentIndex() != -1 &&
shape_->brush().style() != Qt::BrushStyle(ui->m_brush_style_cb->currentIndex()))
{
for (const QPointer<QetShapeItem>& qsi : m_shapes_list)
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
QBrush brush = qsi->brush();
brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex()));
@@ -282,7 +282,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
c = ui->m_brush_color_kpb->color();
if (c != QPalette().color(QPalette::Button) && shape_->brush().color() != c)
{
for (const QPointer<QetShapeItem>& qsi : m_shapes_list)
for (QPointer<QetShapeItem> qsi : m_shapes_list)
{
QBrush brush = brush_H.contains(qsi) ? brush_H.value(qsi) : qsi->brush();
brush.setColor(c);
@@ -290,7 +290,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
}
}
for (const QPointer<QetShapeItem>& qsi : brush_H.keys())
for (QPointer<QetShapeItem> qsi : brush_H.keys())
{
if (!parent_undo) {
parent_undo = new QUndoCommand(tr("Modifier une forme simple"));
@@ -383,8 +383,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
bool same = true;
//Pen
Qt::PenStyle ps = m_shapes_list.first()->pen().style();
for (QetShapeItem* qsi : std::as_const(m_shapes_list))
{
for (QetShapeItem *qsi : m_shapes_list) {
if (qsi->pen().style() != ps) {
same = false;
break;
@@ -394,8 +393,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
same = true;
qreal pw = m_shapes_list.first()->pen().widthF();
for (QetShapeItem* qsi : std::as_const(m_shapes_list))
{
for (QetShapeItem *qsi : m_shapes_list) {
if (qsi->pen().widthF() != pw) {
same = false;
break;
@@ -405,8 +403,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
same = true;
QColor pc = m_shapes_list.first()->pen().color();
for (QetShapeItem* qsi : std::as_const(m_shapes_list))
{
for (QetShapeItem *qsi : m_shapes_list) {
if (qsi->pen().color() != pc) {
same = false;
break;
@@ -419,8 +416,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
same = true;
Qt::BrushStyle bs = m_shapes_list.first()->brush().style();
for (QetShapeItem* qsi : std::as_const(m_shapes_list))
{
for (QetShapeItem *qsi : m_shapes_list) {
if (qsi->brush().style() != bs) {
same = false;
break;
@@ -430,8 +426,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
same = true;
QColor bc = m_shapes_list.first()->brush().color();
for (QetShapeItem* qsi : std::as_const(m_shapes_list))
{
for (QetShapeItem *qsi : m_shapes_list) {
if (qsi->brush().color() != bc) {
same = false;
break;
@@ -521,8 +516,7 @@ void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked()
m_shape->setMovable(!ui->m_lock_pos_cb->isChecked());
}
else if (!m_shapes_list.isEmpty()) {
for (const QPointer<QetShapeItem>& qsi : std::as_const(m_shapes_list))
{
for (QPointer<QetShapeItem> qsi : m_shapes_list) {
qsi->setMovable(!ui->m_lock_pos_cb->isChecked());
}
}