Skip to content

Commit

Permalink
Revert "Try Clazy fix-its"
Browse files Browse the repository at this point in the history
Segfault on old Qt versions!
This reverts commit dba7cae.
  • Loading branch information
scorpio810 committed Feb 14, 2025
1 parent dba7cae commit 43f0107
Show file tree
Hide file tree
Showing 88 changed files with 409 additions and 512 deletions.
5 changes: 2 additions & 3 deletions sources/ElementsCollection/elementscollectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,7 @@ void ElementsCollectionWidget::search()
const QStringList text_list = text.split("+", Qt::SkipEmptyParts);
#endif
QModelIndexList match_index;
for (const QString& txt : text_list)
{
for (QString txt : text_list) {
match_index << m_model->match(m_showed_index.isValid()
? m_model->index(0,0,m_showed_index)
: m_model->index(0,0),
Expand All @@ -791,7 +790,7 @@ void ElementsCollectionWidget::search()
| Qt::MatchRecursive);
}

for (QModelIndex index : std::as_const(match_index))
for(QModelIndex index : match_index)
showAndExpandItem(index);
}

Expand Down
4 changes: 2 additions & 2 deletions sources/ElementsCollection/elementstreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ ElementsTreeView::ElementsTreeView(QWidget *parent) :
QPalette qp = palette();
qp.setColor(QPalette::Text, Qt::black);
qp.setColor(QPalette::Base, Qt::white);
qp.setColor(QPalette::AlternateBase, QColor(0xe8e8e8));
qp.setColor(QPalette::Highlight, QColor(0x678db2));
qp.setColor(QPalette::AlternateBase, QColor("#e8e8e8"));
qp.setColor(QPalette::Highlight, QColor("#678db2"));
qp.setColor(QPalette::HighlightedText, Qt::black);
setPalette(qp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ void XmlProjectElementCollectionItem::setUpData()
ElementsLocation location(embeddedPath(), m_project);
DiagramContext context = location.elementInformations();
QStringList search_list;
for (const QString& key : context.keys())
{
for (QString key : context.keys()) {
search_list.append(context.value(key).toString());
}
search_list.append(localName());
Expand Down
5 changes: 2 additions & 3 deletions sources/NameList/ui/namelistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void NameListWidget::addLine()
*/
void NameListWidget::setNames(const NamesList &name_list)
{
for (const QString& lang : name_list.langs())
for (QString lang : name_list.langs())
{
QString value = name_list[lang];
QStringList values;
Expand Down Expand Up @@ -138,8 +138,7 @@ void NameListWidget::setClipboardValue(QHash<QString, QString> value)

QStringList list = value.keys();
list.sort();
for (const QString& key : list)
{
for (QString key : list) {
ui->m_clipboard_cb->addItem(key, value.value(key));
}
}
Expand Down
3 changes: 1 addition & 2 deletions sources/QWidgetAnimation/qwidgetanimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ void QWidgetAnimation::show()
int available_ = m_orientation == Qt::Horizontal
? m_widget->parentWidget()->width()
: m_widget->parentWidget()->height();
for (auto w : std::as_const(m_widget_to_substract))
{
for (auto w : m_widget_to_substract) {
available_ -= m_orientation == Qt::Horizontal
? w->minimumSizeHint().width()
: w->minimumSizeHint().height();
Expand Down
26 changes: 11 additions & 15 deletions sources/SearchAndReplace/searchandreplaceworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void SearchAndReplaceWorker::replaceElement(QList<Element *> list)
{
DiagramContext old_context;
DiagramContext new_context = old_context = elmt->elementInformations();
for (const QString& key : QETInformation::elementInfoKeys())
for (QString key : QETInformation::elementInfoKeys())
{
new_context.addValue(key, applyChange(old_context.value(key).toString(),
m_element_context.value(key).toString()));
Expand Down Expand Up @@ -219,7 +219,7 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
{
QSet <Conductor *> conductors_list = c->relatedPotentialConductors(true);
conductors_list << c;
for (Conductor* cc : std::as_const(conductors_list))
for (Conductor *cc : conductors_list)
{
QVariant old_value, new_value;
old_value.setValue(cc->properties());
Expand Down Expand Up @@ -270,26 +270,22 @@ void SearchAndReplaceWorker::replaceAdvanced(
return;
}

for (Diagram* dd : std::as_const(diagrams))
{
for (Diagram *dd : diagrams) {
if (dd->project() != project_) {
return;
}
}
for (Element* elmt : std::as_const(elements))
{
for (Element *elmt : elements) {
if (!elmt->diagram() || elmt->diagram()->project() != project_) {
return;
}
}
for (IndependentTextItem* text : std::as_const(texts))
{
for (IndependentTextItem *text : texts) {
if (!text->diagram() || text->diagram()->project() != project_) {
return;
}
}
for (Conductor* cc : std::as_const(conductors))
{
for (Conductor *cc : conductors) {
if (!cc->diagram() || cc->diagram()->project() != project_) {
return;
}
Expand All @@ -304,7 +300,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
project_->undoStack()->beginMacro(QObject::tr("Rechercher / remplacer avancé"));
if (who == 0)
{
for (Diagram* diagram : std::as_const(diagrams))
for (Diagram *diagram : diagrams)
{
TitleBlockProperties old_properties = diagram->border_and_titleblock.exportTitleBlock();
TitleBlockProperties new_properties = replaceAdvanced(diagram);
Expand All @@ -315,7 +311,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
}
else if (who == 1)
{
for (Element* element : std::as_const(elements))
for (Element *element : elements)
{
DiagramContext old_context = element->elementInformations();
DiagramContext new_context = replaceAdvanced(element);
Expand All @@ -326,7 +322,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
}
else if (who == 2)
{
for (Conductor* conductor : std::as_const(conductors))
for (Conductor *conductor : conductors)
{
ConductorProperties old_properties = conductor->properties();
ConductorProperties new_properties = replaceAdvanced(conductor);
Expand All @@ -335,7 +331,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
QSet <Conductor *> potential_conductors = conductor->relatedPotentialConductors(true);
potential_conductors << conductor;

for (Conductor* c : std::as_const(potential_conductors))
for (Conductor *c : potential_conductors)
{
QVariant old_value, new_value;
old_value.setValue(c->properties());
Expand All @@ -347,7 +343,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
}
else if (who == 3)
{
for (IndependentTextItem* text : std::as_const(texts))
for (IndependentTextItem *text : texts)
{
QRegularExpression rx(m_advanced_struct.search);
if (!rx.isValid())
Expand Down
9 changes: 3 additions & 6 deletions sources/SearchAndReplace/ui/replaceadvanceddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,17 @@ void replaceAdvancedDialog::fillWhatComboBox(int index)

if (index == 0)
{
for (const QString& str : QETInformation::diagramInfoKeys())
{
for (QString str : QETInformation::diagramInfoKeys()) {
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
}
}
else if (index == 1) {
for (const QString& str : QETInformation::elementInfoKeys())
{
for (QString str : QETInformation::elementInfoKeys()) {
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
}
}
else if (index == 2) {
for (const auto& str : QETInformation::conductorInfoKeys())
{
for (auto str : QETInformation::conductorInfoKeys()) {
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
}
}
Expand Down
9 changes: 4 additions & 5 deletions sources/SearchAndReplace/ui/replaceelementdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ ReplaceElementDialog::~ReplaceElementDialog()
void ReplaceElementDialog::setContext(DiagramContext context)
{
m_context = context;

for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list))
{

for (ElementInfoPartWidget *eipw : m_eipw_list) {
eipw->setText(m_context[eipw->key()].toString());
}
}
Expand All @@ -74,8 +73,8 @@ void ReplaceElementDialog::buildWidget()
connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) {
this->done(ui->m_button_box->buttonRole(button_));
});

for (const QString& str : QETInformation::elementInfoKeys())
for (QString str : QETInformation::elementInfoKeys())
{
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
eipw->setEraseTextVisible(true);
Expand Down
31 changes: 14 additions & 17 deletions sources/SearchAndReplace/ui/searchandreplacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void SearchAndReplaceWidget::clear()
qDeleteAll(m_conductor_hash.keys());
m_conductor_hash.clear();

for (QTreeWidgetItem* qtwi : std::as_const(m_category_qtwi))
for (QTreeWidgetItem *qtwi : m_category_qtwi)
qtwi->setHidden(false);

ui->m_tree_widget->collapseAll();
Expand Down Expand Up @@ -284,17 +284,18 @@ void SearchAndReplaceWidget::fillItemsList()
dc += DiagramContent(diagram, false);
}

for (Element* elmt : std::as_const(dc.m_elements)) addElement(elmt);
for (Element *elmt : dc.m_elements)
addElement(elmt);

//Sort child of each "element type" tree item.
//we hide, "element type" tree item, if they do not have children
for (QTreeWidgetItem* qtwi : std::as_const(m_qtwi_elmts))
for(QTreeWidgetItem *qtwi : m_qtwi_elmts)
{
qtwi->sortChildren(0, Qt::AscendingOrder);
qtwi->setHidden(qtwi->childCount() ? false : true);
}

for (IndependentTextItem* iti : std::as_const(dc.m_text_fields))
for (IndependentTextItem *iti : dc.m_text_fields)
{
QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_indi_text_qtwi);
qtwi->setText(0, iti->toPlainText());
Expand All @@ -305,7 +306,7 @@ void SearchAndReplaceWidget::fillItemsList()

m_indi_text_qtwi->sortChildren(0, Qt::AscendingOrder);

for (Conductor* c : std::as_const(dc.m_potential_conductors))
for (Conductor *c : dc.m_potential_conductors)
{
QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_conductor_qtwi);
qtwi->setText(0, c->properties().text);
Expand Down Expand Up @@ -378,8 +379,7 @@ void SearchAndReplaceWidget::search()
(*it)->setHidden(false);
}

for (QTreeWidgetItem* item : std::as_const(m_category_qtwi))
{
for (QTreeWidgetItem *item : m_category_qtwi) {
item->setExpanded(false);
}
m_root_qtwi->setExpanded(true);
Expand Down Expand Up @@ -442,9 +442,9 @@ void SearchAndReplaceWidget::search()
}

QPalette background = ui->m_search_le->palette();
background.setColor(
QPalette::Base,
match ? QColor(0xE0FFF0) : QColor(0xFFE0EF));
background.setColor(QPalette::Base, match
? QColor("#E0FFF0")
: QColor("#FFE0EF"));
ui->m_search_le->setPalette(background);

//Go to the first occurrence
Expand Down Expand Up @@ -488,8 +488,7 @@ void SearchAndReplaceWidget::setUpConenctions()
connect(m_select_elements, &QAction::triggered, [this]()
{
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
for (auto elmt : std::as_const(dc.m_elements))
{
for (auto elmt : dc.m_elements) {
if (auto item = m_element_hash.key(elmt)) {
item->setCheckState(0, Qt::Checked);
}
Expand All @@ -509,8 +508,7 @@ void SearchAndReplaceWidget::setUpConenctions()
connect(m_select_texts, &QAction::triggered, [this]()
{
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
for (auto text : std::as_const(dc.m_text_fields))
{
for (auto text : dc.m_text_fields) {
if (auto item = m_text_hash.key(text)) {
item->setCheckState(0, Qt::Checked);
}
Expand Down Expand Up @@ -860,8 +858,7 @@ QStringList SearchAndReplaceWidget::searchTerms(Diagram *diagram)
list.append(prop.indexrev);
list.append(prop.folio);
list.append(prop.date.toString());
for (const QString& key : prop.context.keys())
{
for (QString key : prop.context.keys()) {
list.append(prop.context.value(key).toString());
}

Expand All @@ -877,7 +874,7 @@ QStringList SearchAndReplaceWidget::searchTerms(Element *element)
{
QStringList list;
DiagramContext context = element->elementInformations();
for (const QString& key : QETInformation::elementInfoKeys())
for (QString key : QETInformation::elementInfoKeys())
{
QString str = context.value(key).toString();
if (!str.isEmpty()) {
Expand Down
3 changes: 1 addition & 2 deletions sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ int TerminalStripDrawer::height() const

height_ = std::max(height_, m_pattern->m_spacer_rect.y() + m_pattern->m_spacer_rect.height());

for (const auto& rect : std::as_const(m_pattern->m_terminal_rect))
{
for (const auto &rect : m_pattern->m_terminal_rect) {
height_ = std::max(height_, rect.y() + rect.height());
}

Expand Down
6 changes: 2 additions & 4 deletions sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ RemoveTerminalStripCommand::~RemoveTerminalStripCommand()
void RemoveTerminalStripCommand::undo()
{
if (m_project && m_strip) {
for (const auto& elmt : std::as_const(m_elements))
{
for (auto elmt : m_elements) {
m_strip->addTerminal(elmt);
}
m_project->addTerminalStrip(m_strip);
Expand All @@ -85,8 +84,7 @@ void RemoveTerminalStripCommand::undo()
void RemoveTerminalStripCommand::redo()
{
if (m_project && m_strip) {
for (const auto& elmt : std::as_const(m_elements))
{
for (auto elmt : m_elements) {
m_strip->removeTerminal(elmt);
}
m_project->removeTerminalStrip(m_strip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ MoveTerminalCommand::MoveTerminalCommand(QSharedPointer<PhysicalTerminal> termin
m_new_strip {new_strip}
{
QString t_label;
for (const auto& real_t : terminal->realTerminals())
{
for (auto real_t : terminal->realTerminals()) {
if (!t_label.isEmpty())
t_label.append(", ");
t_label.append(real_t->label());
Expand Down
9 changes: 3 additions & 6 deletions sources/TerminalStrip/physicalterminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ PhysicalTerminal::PhysicalTerminal(TerminalStrip *parent_strip,
m_parent_terminal_strip(parent_strip),
m_real_terminal(terminals)
{
for (const auto& real_t : std::as_const(m_real_terminal))
{
for (const auto &real_t : m_real_terminal) {
if (real_t) {
real_t->setPhysicalTerminal(sharedRef());
}
Expand Down Expand Up @@ -87,8 +86,7 @@ QDomElement PhysicalTerminal::toXml(QDomDocument &parent_document) const
*/
void PhysicalTerminal::setTerminals(const QVector<QSharedPointer<RealTerminal>> &terminals) {
m_real_terminal = terminals;
for (const auto& real_t : std::as_const(m_real_terminal))
{
for (const auto &real_t : m_real_terminal) {
if (real_t) {
real_t->setPhysicalTerminal(sharedRef());
}
Expand Down Expand Up @@ -150,8 +148,7 @@ void PhysicalTerminal::setParentStrip(TerminalStrip *strip)

PhysicalTerminal::~PhysicalTerminal()
{
for (const auto& real_t : std::as_const(m_real_terminal))
{
for (const auto &real_t : m_real_terminal) {
if (real_t) {
real_t->setPhysicalTerminal(QSharedPointer<PhysicalTerminal>());
}
Expand Down
3 changes: 1 addition & 2 deletions sources/TerminalStrip/ui/freeterminalmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ void FreeTerminalModel::fillTerminalVector()
b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString());
});

for (const auto& terminal_ : std::as_const(free_terminal_vector))
{
for (const auto &terminal_ : free_terminal_vector) {
m_terminal_vector.append(terminal_->realTerminal());
m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal()));
}
Expand Down
Loading

0 comments on commit 43f0107

Please sign in to comment.