From dba7caed3035585af4b301ed87bd4131dcac994c Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Fri, 14 Feb 2025 15:52:23 +0100 Subject: [PATCH] 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 --- .../elementscollectionwidget.cpp | 5 +- .../ElementsCollection/elementstreeview.cpp | 4 +- .../xmlprojectelementcollectionitem.cpp | 3 +- sources/NameList/ui/namelistwidget.cpp | 5 +- sources/QWidgetAnimation/qwidgetanimation.cpp | 3 +- .../searchandreplaceworker.cpp | 26 ++++--- .../ui/replaceadvanceddialog.cpp | 9 ++- .../ui/replaceelementdialog.cpp | 9 ++- .../ui/searchandreplacewidget.cpp | 31 ++++---- .../GraphicsItem/terminalstripdrawer.cpp | 3 +- .../UndoCommand/addterminalstripcommand.cpp | 6 +- .../UndoCommand/addterminaltostripcommand.cpp | 3 +- sources/TerminalStrip/physicalterminal.cpp | 9 ++- .../TerminalStrip/ui/freeterminalmodel.cpp | 3 +- .../TerminalStrip/ui/terminalstripeditor.cpp | 2 +- .../TerminalStrip/ui/terminalstripmodel.cpp | 2 +- sources/conductornumexport.cpp | 2 +- sources/conductorproperties.cpp | 42 +++++----- sources/dataBase/projectdatabase.cpp | 11 ++- sources/dataBase/ui/elementquerywidget.cpp | 17 ++-- sources/dataBase/ui/summaryquerywidget.cpp | 9 ++- sources/diagram.cpp | 77 ++++++++++--------- sources/diagramcontent.cpp | 4 +- sources/diagramcontext.cpp | 7 +- .../editor/UndoCommand/pastepartscommand.cpp | 6 +- sources/editor/arceditor.cpp | 5 +- sources/editor/editorcommands.cpp | 4 +- sources/editor/elementprimitivedecorator.cpp | 18 ++--- sources/editor/elementscene.cpp | 2 +- .../graphicspart/customelementgraphicpart.cpp | 2 +- sources/editor/graphicspart/partarc.cpp | 8 +- sources/editor/graphicspart/partellipse.cpp | 6 +- sources/editor/graphicspart/partline.cpp | 2 +- sources/editor/graphicspart/partpolygon.cpp | 10 ++- sources/editor/graphicspart/partrectangle.cpp | 10 ++- sources/editor/styleeditor.cpp | 2 +- sources/editor/ui/dynamictextfieldeditor.cpp | 7 +- sources/editor/ui/ellipseeditor.cpp | 3 +- sources/editor/ui/lineeditor.cpp | 3 +- sources/editor/ui/polygoneditor.cpp | 3 +- sources/editor/ui/qetelementeditor.cpp | 16 ++-- sources/editor/ui/rectangleeditor.cpp | 3 +- sources/editor/ui/texteditor.cpp | 5 +- sources/elementprovider.cpp | 3 +- sources/elementspanel.cpp | 4 +- sources/elementtextpattern.cpp | 8 +- sources/exportdialog.cpp | 15 ++-- sources/factory/elementpicturefactory.cpp | 5 +- sources/genericpanel.cpp | 18 ++--- sources/print/projectprintwindow.cpp | 5 +- sources/properties/xrefproperties.cpp | 3 +- sources/qetapp.cpp | 4 +- sources/qetdiagrameditor.cpp | 18 +++-- .../ViewItem/qetgraphicsheaderitem.cpp | 4 +- .../ui/graphicstablepropertieseditor.cpp | 17 ++-- sources/qetgraphicsitem/conductor.cpp | 13 ++-- sources/qetgraphicsitem/crossrefitem.cpp | 8 +- .../dynamicelementtextitem.cpp | 3 +- sources/qetgraphicsitem/element.cpp | 16 ++-- .../qetgraphicsitem/elementtextitemgroup.cpp | 14 ++-- sources/qetgraphicsitem/qetshapeitem.cpp | 31 +++++--- sources/qetgraphicsitem/terminal.cpp | 2 +- sources/qetinformation.cpp | 3 +- sources/qetxml.cpp | 2 +- sources/qtextorientationwidget.cpp | 10 +-- sources/titleblock/helpercell.cpp | 6 +- .../integrationmovetemplateshandler.cpp | 9 ++- sources/titleblock/qettemplateeditor.cpp | 21 +++-- sources/titleblock/templatescollection.cpp | 2 +- sources/titleblock/templateview.cpp | 7 +- sources/titleblocktemplate.cpp | 8 +- sources/ui/aboutqetdialog.cpp | 4 +- sources/ui/diagramcontextwidget.cpp | 2 +- sources/ui/dynamicelementtextitemeditor.cpp | 33 ++++---- sources/ui/dynamicelementtextmodel.cpp | 4 +- sources/ui/elementinfowidget.cpp | 22 +++--- sources/ui/elementpropertieswidget.cpp | 9 ++- sources/ui/inditextpropertieswidget.cpp | 40 ++++++---- sources/ui/multipastedialog.cpp | 2 +- sources/ui/potentialselectordialog.cpp | 2 +- .../ui/shapegraphicsitempropertieswidget.cpp | 34 ++++---- sources/undocommand/addelementtextcommand.cpp | 12 +-- .../changeelementinformationcommand.cpp | 19 ++--- .../deleteqgraphicsitemcommand.cpp | 28 ++++--- sources/undocommand/linkelementcommand.cpp | 2 +- .../undocommand/rotateselectioncommand.cpp | 18 ++--- sources/undocommand/rotatetextscommand.cpp | 6 +- sources/utils/conductorcreator.cpp | 18 +++-- 88 files changed, 512 insertions(+), 409 deletions(-) diff --git a/sources/ElementsCollection/elementscollectionwidget.cpp b/sources/ElementsCollection/elementscollectionwidget.cpp index 2ab4e9ab3..24e71f8f5 100644 --- a/sources/ElementsCollection/elementscollectionwidget.cpp +++ b/sources/ElementsCollection/elementscollectionwidget.cpp @@ -779,7 +779,8 @@ void ElementsCollectionWidget::search() const QStringList text_list = text.split("+", Qt::SkipEmptyParts); #endif QModelIndexList match_index; - for (QString txt : text_list) { + for (const 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), @@ -790,7 +791,7 @@ void ElementsCollectionWidget::search() | Qt::MatchRecursive); } - for(QModelIndex index : match_index) + for (QModelIndex index : std::as_const(match_index)) showAndExpandItem(index); } diff --git a/sources/ElementsCollection/elementstreeview.cpp b/sources/ElementsCollection/elementstreeview.cpp index e84b6a3ce..be59d0760 100644 --- a/sources/ElementsCollection/elementstreeview.cpp +++ b/sources/ElementsCollection/elementstreeview.cpp @@ -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("#e8e8e8")); - qp.setColor(QPalette::Highlight, QColor("#678db2")); + qp.setColor(QPalette::AlternateBase, QColor(0xe8e8e8)); + qp.setColor(QPalette::Highlight, QColor(0x678db2)); qp.setColor(QPalette::HighlightedText, Qt::black); setPalette(qp); } diff --git a/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp b/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp index 7015b9ec3..fa61ec7cf 100644 --- a/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp +++ b/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp @@ -206,7 +206,8 @@ void XmlProjectElementCollectionItem::setUpData() ElementsLocation location(embeddedPath(), m_project); DiagramContext context = location.elementInformations(); QStringList search_list; - for (QString key : context.keys()) { + for (const QString& key : context.keys()) + { search_list.append(context.value(key).toString()); } search_list.append(localName()); diff --git a/sources/NameList/ui/namelistwidget.cpp b/sources/NameList/ui/namelistwidget.cpp index 0024f5a3d..7f3cb9a12 100644 --- a/sources/NameList/ui/namelistwidget.cpp +++ b/sources/NameList/ui/namelistwidget.cpp @@ -59,7 +59,7 @@ void NameListWidget::addLine() */ void NameListWidget::setNames(const NamesList &name_list) { - for (QString lang : name_list.langs()) + for (const QString& lang : name_list.langs()) { QString value = name_list[lang]; QStringList values; @@ -138,7 +138,8 @@ void NameListWidget::setClipboardValue(QHash value) QStringList list = value.keys(); list.sort(); - for (QString key : list) { + for (const QString& key : list) + { ui->m_clipboard_cb->addItem(key, value.value(key)); } } diff --git a/sources/QWidgetAnimation/qwidgetanimation.cpp b/sources/QWidgetAnimation/qwidgetanimation.cpp index b76114522..f07a683eb 100644 --- a/sources/QWidgetAnimation/qwidgetanimation.cpp +++ b/sources/QWidgetAnimation/qwidgetanimation.cpp @@ -98,7 +98,8 @@ void QWidgetAnimation::show() int available_ = m_orientation == Qt::Horizontal ? m_widget->parentWidget()->width() : m_widget->parentWidget()->height(); - for (auto w : m_widget_to_substract) { + for (auto w : std::as_const(m_widget_to_substract)) + { available_ -= m_orientation == Qt::Horizontal ? w->minimumSizeHint().width() : w->minimumSizeHint().height(); diff --git a/sources/SearchAndReplace/searchandreplaceworker.cpp b/sources/SearchAndReplace/searchandreplaceworker.cpp index 6bd0722c3..6874f0e98 100644 --- a/sources/SearchAndReplace/searchandreplaceworker.cpp +++ b/sources/SearchAndReplace/searchandreplaceworker.cpp @@ -128,7 +128,7 @@ void SearchAndReplaceWorker::replaceElement(QList list) { DiagramContext old_context; DiagramContext new_context = old_context = elmt->elementInformations(); - for (QString key : QETInformation::elementInfoKeys()) + for (const QString& key : QETInformation::elementInfoKeys()) { new_context.addValue(key, applyChange(old_context.value(key).toString(), m_element_context.value(key).toString())); @@ -219,7 +219,7 @@ void SearchAndReplaceWorker::replaceConductor(QList list) { QSet conductors_list = c->relatedPotentialConductors(true); conductors_list << c; - for (Conductor *cc : conductors_list) + for (Conductor* cc : std::as_const(conductors_list)) { QVariant old_value, new_value; old_value.setValue(cc->properties()); @@ -270,22 +270,26 @@ void SearchAndReplaceWorker::replaceAdvanced( return; } - for (Diagram *dd : diagrams) { + for (Diagram* dd : std::as_const(diagrams)) + { if (dd->project() != project_) { return; } } - for (Element *elmt : elements) { + for (Element* elmt : std::as_const(elements)) + { if (!elmt->diagram() || elmt->diagram()->project() != project_) { return; } } - for (IndependentTextItem *text : texts) { + for (IndependentTextItem* text : std::as_const(texts)) + { if (!text->diagram() || text->diagram()->project() != project_) { return; } } - for (Conductor *cc : conductors) { + for (Conductor* cc : std::as_const(conductors)) + { if (!cc->diagram() || cc->diagram()->project() != project_) { return; } @@ -300,7 +304,7 @@ void SearchAndReplaceWorker::replaceAdvanced( project_->undoStack()->beginMacro(QObject::tr("Rechercher / remplacer avancé")); if (who == 0) { - for (Diagram *diagram : diagrams) + for (Diagram* diagram : std::as_const(diagrams)) { TitleBlockProperties old_properties = diagram->border_and_titleblock.exportTitleBlock(); TitleBlockProperties new_properties = replaceAdvanced(diagram); @@ -311,7 +315,7 @@ void SearchAndReplaceWorker::replaceAdvanced( } else if (who == 1) { - for (Element *element : elements) + for (Element* element : std::as_const(elements)) { DiagramContext old_context = element->elementInformations(); DiagramContext new_context = replaceAdvanced(element); @@ -322,7 +326,7 @@ void SearchAndReplaceWorker::replaceAdvanced( } else if (who == 2) { - for (Conductor *conductor : conductors) + for (Conductor* conductor : std::as_const(conductors)) { ConductorProperties old_properties = conductor->properties(); ConductorProperties new_properties = replaceAdvanced(conductor); @@ -331,7 +335,7 @@ void SearchAndReplaceWorker::replaceAdvanced( QSet potential_conductors = conductor->relatedPotentialConductors(true); potential_conductors << conductor; - for (Conductor *c : potential_conductors) + for (Conductor* c : std::as_const(potential_conductors)) { QVariant old_value, new_value; old_value.setValue(c->properties()); @@ -343,7 +347,7 @@ void SearchAndReplaceWorker::replaceAdvanced( } else if (who == 3) { - for (IndependentTextItem *text : texts) + for (IndependentTextItem* text : std::as_const(texts)) { QRegularExpression rx(m_advanced_struct.search); if (!rx.isValid()) diff --git a/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp b/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp index 6a7035375..ddcfc547d 100644 --- a/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp +++ b/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp @@ -95,17 +95,20 @@ void replaceAdvancedDialog::fillWhatComboBox(int index) if (index == 0) { - for (QString str : QETInformation::diagramInfoKeys()) { + for (const QString& str : QETInformation::diagramInfoKeys()) + { ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str); } } else if (index == 1) { - for (QString str : QETInformation::elementInfoKeys()) { + for (const QString& str : QETInformation::elementInfoKeys()) + { ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str); } } else if (index == 2) { - for (auto str : QETInformation::conductorInfoKeys()) { + for (const auto& str : QETInformation::conductorInfoKeys()) + { ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str); } } diff --git a/sources/SearchAndReplace/ui/replaceelementdialog.cpp b/sources/SearchAndReplace/ui/replaceelementdialog.cpp index eb030c1be..dc28e2cd7 100644 --- a/sources/SearchAndReplace/ui/replaceelementdialog.cpp +++ b/sources/SearchAndReplace/ui/replaceelementdialog.cpp @@ -48,8 +48,9 @@ ReplaceElementDialog::~ReplaceElementDialog() void ReplaceElementDialog::setContext(DiagramContext context) { m_context = context; - - for (ElementInfoPartWidget *eipw : m_eipw_list) { + + for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list)) + { eipw->setText(m_context[eipw->key()].toString()); } } @@ -73,8 +74,8 @@ void ReplaceElementDialog::buildWidget() connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) { this->done(ui->m_button_box->buttonRole(button_)); }); - - for (QString str : QETInformation::elementInfoKeys()) + + for (const QString& str : QETInformation::elementInfoKeys()) { ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this); eipw->setEraseTextVisible(true); diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp index 75ae79c1b..cc1bf40ab 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp @@ -127,7 +127,7 @@ void SearchAndReplaceWidget::clear() qDeleteAll(m_conductor_hash.keys()); m_conductor_hash.clear(); - for (QTreeWidgetItem *qtwi : m_category_qtwi) + for (QTreeWidgetItem* qtwi : std::as_const(m_category_qtwi)) qtwi->setHidden(false); ui->m_tree_widget->collapseAll(); @@ -284,18 +284,17 @@ void SearchAndReplaceWidget::fillItemsList() dc += DiagramContent(diagram, false); } - for (Element *elmt : dc.m_elements) - addElement(elmt); + for (Element* elmt : std::as_const(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 : m_qtwi_elmts) + for (QTreeWidgetItem* qtwi : std::as_const(m_qtwi_elmts)) { qtwi->sortChildren(0, Qt::AscendingOrder); qtwi->setHidden(qtwi->childCount() ? false : true); } - for (IndependentTextItem *iti : dc.m_text_fields) + for (IndependentTextItem* iti : std::as_const(dc.m_text_fields)) { QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_indi_text_qtwi); qtwi->setText(0, iti->toPlainText()); @@ -306,7 +305,7 @@ void SearchAndReplaceWidget::fillItemsList() m_indi_text_qtwi->sortChildren(0, Qt::AscendingOrder); - for (Conductor *c : dc.m_potential_conductors) + for (Conductor* c : std::as_const(dc.m_potential_conductors)) { QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_conductor_qtwi); qtwi->setText(0, c->properties().text); @@ -379,7 +378,8 @@ void SearchAndReplaceWidget::search() (*it)->setHidden(false); } - for (QTreeWidgetItem *item : m_category_qtwi) { + for (QTreeWidgetItem* item : std::as_const(m_category_qtwi)) + { item->setExpanded(false); } m_root_qtwi->setExpanded(true); @@ -442,9 +442,9 @@ void SearchAndReplaceWidget::search() } QPalette background = ui->m_search_le->palette(); - background.setColor(QPalette::Base, match - ? QColor("#E0FFF0") - : QColor("#FFE0EF")); + background.setColor( + QPalette::Base, + match ? QColor(0xE0FFF0) : QColor(0xFFE0EF)); ui->m_search_le->setPalette(background); //Go to the first occurrence @@ -488,7 +488,8 @@ 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 : dc.m_elements) { + for (auto elmt : std::as_const(dc.m_elements)) + { if (auto item = m_element_hash.key(elmt)) { item->setCheckState(0, Qt::Checked); } @@ -508,7 +509,8 @@ 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 : dc.m_text_fields) { + for (auto text : std::as_const(dc.m_text_fields)) + { if (auto item = m_text_hash.key(text)) { item->setCheckState(0, Qt::Checked); } @@ -858,7 +860,8 @@ QStringList SearchAndReplaceWidget::searchTerms(Diagram *diagram) list.append(prop.indexrev); list.append(prop.folio); list.append(prop.date.toString()); - for (QString key : prop.context.keys()) { + for (const QString& key : prop.context.keys()) + { list.append(prop.context.value(key).toString()); } @@ -874,7 +877,7 @@ QStringList SearchAndReplaceWidget::searchTerms(Element *element) { QStringList list; DiagramContext context = element->elementInformations(); - for (QString key : QETInformation::elementInfoKeys()) + for (const QString& key : QETInformation::elementInfoKeys()) { QString str = context.value(key).toString(); if (!str.isEmpty()) { diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp index 16c2b5146..449778637 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp +++ b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp @@ -241,7 +241,8 @@ int TerminalStripDrawer::height() const height_ = std::max(height_, m_pattern->m_spacer_rect.y() + m_pattern->m_spacer_rect.height()); - for (const auto &rect : m_pattern->m_terminal_rect) { + for (const auto& rect : std::as_const(m_pattern->m_terminal_rect)) + { height_ = std::max(height_, rect.y() + rect.height()); } diff --git a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp index 9e1a30db1..135077948 100644 --- a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp +++ b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp @@ -74,7 +74,8 @@ RemoveTerminalStripCommand::~RemoveTerminalStripCommand() void RemoveTerminalStripCommand::undo() { if (m_project && m_strip) { - for (auto elmt : m_elements) { + for (const auto& elmt : std::as_const(m_elements)) + { m_strip->addTerminal(elmt); } m_project->addTerminalStrip(m_strip); @@ -84,7 +85,8 @@ void RemoveTerminalStripCommand::undo() void RemoveTerminalStripCommand::redo() { if (m_project && m_strip) { - for (auto elmt : m_elements) { + for (const auto& elmt : std::as_const(m_elements)) + { m_strip->removeTerminal(elmt); } m_project->removeTerminalStrip(m_strip); diff --git a/sources/TerminalStrip/UndoCommand/addterminaltostripcommand.cpp b/sources/TerminalStrip/UndoCommand/addterminaltostripcommand.cpp index 8ae0cc0e2..305e8aa22 100644 --- a/sources/TerminalStrip/UndoCommand/addterminaltostripcommand.cpp +++ b/sources/TerminalStrip/UndoCommand/addterminaltostripcommand.cpp @@ -161,7 +161,8 @@ MoveTerminalCommand::MoveTerminalCommand(QSharedPointer termin m_new_strip {new_strip} { QString t_label; - for (auto real_t : terminal->realTerminals()) { + for (const auto& real_t : terminal->realTerminals()) + { if (!t_label.isEmpty()) t_label.append(", "); t_label.append(real_t->label()); diff --git a/sources/TerminalStrip/physicalterminal.cpp b/sources/TerminalStrip/physicalterminal.cpp index f9c06de3e..9fac582ed 100644 --- a/sources/TerminalStrip/physicalterminal.cpp +++ b/sources/TerminalStrip/physicalterminal.cpp @@ -31,7 +31,8 @@ PhysicalTerminal::PhysicalTerminal(TerminalStrip *parent_strip, m_parent_terminal_strip(parent_strip), m_real_terminal(terminals) { - for (const auto &real_t : m_real_terminal) { + for (const auto& real_t : std::as_const(m_real_terminal)) + { if (real_t) { real_t->setPhysicalTerminal(sharedRef()); } @@ -86,7 +87,8 @@ QDomElement PhysicalTerminal::toXml(QDomDocument &parent_document) const */ void PhysicalTerminal::setTerminals(const QVector> &terminals) { m_real_terminal = terminals; - for (const auto &real_t : m_real_terminal) { + for (const auto& real_t : std::as_const(m_real_terminal)) + { if (real_t) { real_t->setPhysicalTerminal(sharedRef()); } @@ -148,7 +150,8 @@ void PhysicalTerminal::setParentStrip(TerminalStrip *strip) PhysicalTerminal::~PhysicalTerminal() { - for (const auto &real_t : m_real_terminal) { + for (const auto& real_t : std::as_const(m_real_terminal)) + { if (real_t) { real_t->setPhysicalTerminal(QSharedPointer()); } diff --git a/sources/TerminalStrip/ui/freeterminalmodel.cpp b/sources/TerminalStrip/ui/freeterminalmodel.cpp index 546851ea7..147ca35a8 100644 --- a/sources/TerminalStrip/ui/freeterminalmodel.cpp +++ b/sources/TerminalStrip/ui/freeterminalmodel.cpp @@ -315,7 +315,8 @@ void FreeTerminalModel::fillTerminalVector() b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString()); }); - for (const auto &terminal_ : free_terminal_vector) { + for (const auto& terminal_ : std::as_const(free_terminal_vector)) + { m_terminal_vector.append(terminal_->realTerminal()); m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal())); } diff --git a/sources/TerminalStrip/ui/terminalstripeditor.cpp b/sources/TerminalStrip/ui/terminalstripeditor.cpp index d9ad4e0eb..d4322b27d 100644 --- a/sources/TerminalStrip/ui/terminalstripeditor.cpp +++ b/sources/TerminalStrip/ui/terminalstripeditor.cpp @@ -456,7 +456,7 @@ void TerminalStripEditor::on_m_group_terminals_pb_clicked() QVector> vector_; int count_ = 0; - for (const auto & mrtd : mrtd_vector) + for (const auto& mrtd : std::as_const(mrtd_vector)) { const auto real_t = mrtd.real_terminal.toStrongRef(); vector_.append(real_t); diff --git a/sources/TerminalStrip/ui/terminalstripmodel.cpp b/sources/TerminalStrip/ui/terminalstripmodel.cpp index 7cd2c4014..fc6bc2043 100644 --- a/sources/TerminalStrip/ui/terminalstripmodel.cpp +++ b/sources/TerminalStrip/ui/terminalstripmodel.cpp @@ -428,7 +428,7 @@ modelRealTerminalData TerminalStripModel::modelRealTerminalDataForIndex(const QM void TerminalStripModel::buildBridgePixmap(const QSize &pixmap_size) { m_bridges_pixmaps.clear(); - for (auto color_ : TerminalStripBridge::bridgeColor()) + for (const auto& color_ : TerminalStripBridge::bridgeColor()) { QPen pen; pen.setColor(color_); diff --git a/sources/conductornumexport.cpp b/sources/conductornumexport.cpp index a18bf527b..deca66438 100644 --- a/sources/conductornumexport.cpp +++ b/sources/conductornumexport.cpp @@ -102,7 +102,7 @@ QString ConductorNumExport::wiresNum() const QStringList list = m_hash.keys(); list.sort(); - for (QString key : list) + for (const QString& key : list) { for (int i=0; i lis //Color c_value = clist.first().color; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.color != c_value) equal = false; @@ -524,7 +524,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //bicolor b_value = clist.first().m_bicolor; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_bicolor != b_value) equal = false; @@ -535,7 +535,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //second color c_value = clist.first().m_color_2; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_color_2 != c_value) equal = false; @@ -546,7 +546,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Dash size i_value = clist.first().m_dash_size; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_dash_size != i_value) equal = false; @@ -557,7 +557,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //text s_value = clist.first().text; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.text != s_value) equal = false; @@ -568,7 +568,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //text color c_value = clist.first().text_color; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.text_color != c_value) equal = false; @@ -579,7 +579,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //formula s_value = clist.first().m_formula; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_formula != s_value) equal = false; @@ -590,7 +590,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //cable s_value = clist.first().m_cable; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_cable != s_value) equal = false; @@ -601,7 +601,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //bus s_value = clist.first().m_bus; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_bus != s_value) equal = false; @@ -612,7 +612,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //function s_value = clist.first().m_function; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_function != s_value) equal = false; @@ -623,7 +623,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Tension protocol s_value = clist.first().m_tension_protocol; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_tension_protocol != s_value) equal = false; @@ -634,7 +634,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //conductor_color s_value = clist.first().m_wire_color; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_wire_color != s_value) equal = false; @@ -645,7 +645,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //conductor_section s_value = clist.first().m_wire_section; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_wire_section != s_value) equal = false; @@ -657,7 +657,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //text size i_value = clist.first().text_size; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.text_size != i_value) equal = false; @@ -668,7 +668,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //conductor size d_value = clist.first().cond_size; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.cond_size != d_value) equal = false; @@ -679,7 +679,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //show text b_value = clist.first().m_show_text; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_show_text != b_value) equal = false; @@ -690,7 +690,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //One text per folio b_value = clist.first().m_one_text_per_folio; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_one_text_per_folio != b_value) equal = false; @@ -701,7 +701,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Text rotation for vertical conducor d_value = clist.first().verti_rotate_text; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.verti_rotate_text != d_value) equal = false; @@ -712,7 +712,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Text rotation for horizontal conducor d_value = clist.first().horiz_rotate_text; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.horiz_rotate_text != d_value) equal = false; @@ -723,7 +723,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Text alignment for horizontal conducor align_value = clist.first().m_horizontal_alignment; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_horizontal_alignment != align_value) equal = false; @@ -734,7 +734,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis //Text alignment for vertical conducor align_value = clist.first().m_vertical_alignment; - for(ConductorProperties cp : clist) + for (const ConductorProperties& cp : clist) { if (cp.m_vertical_alignment != align_value) equal = false; diff --git a/sources/dataBase/projectdatabase.cpp b/sources/dataBase/projectdatabase.cpp index f645a8d4d..d6eb313c8 100644 --- a/sources/dataBase/projectdatabase.cpp +++ b/sources/dataBase/projectdatabase.cpp @@ -160,7 +160,8 @@ void projectDataBase::removeElement(Element *element) void projectDataBase::elementInfoChanged(Element *element) { auto hash = elementInfoToString(element); - for (auto str : QETInformation::elementInfoKeys()) { + for (const auto& str : QETInformation::elementInfoKeys()) + { m_update_element_query.bindValue(":" + str, hash.value(str)); } m_update_element_query.bindValue(":uuid", element->uuid().toString()); @@ -540,7 +541,8 @@ void projectDataBase::prepareQuery() //UPDATE DIAGRAM INFO QString update_diagram_str("UPDATE diagram_info SET "); - for (auto str : QETInformation::diagramInfoKeys()) { + for (const auto& str : QETInformation::diagramInfoKeys()) + { update_diagram_str.append(str + " = :" + str + ", "); } update_diagram_str.remove(update_diagram_str.length()-2, 2); //Remove the last ", " @@ -580,7 +582,8 @@ void projectDataBase::prepareQuery() //UPDATE ELEMENT INFO QString update_str("UPDATE element_info SET "); - for (auto string : QETInformation::elementInfoKeys()) { + for (const auto& string : QETInformation::elementInfoKeys()) + { update_str.append(string + " = :" + string + ", "); } update_str.remove(update_str.length()-2, 2); //Remove the last ", " @@ -597,7 +600,7 @@ void projectDataBase::prepareQuery() QHash projectDataBase::elementInfoToString(Element *elmt) { QHash hash; //Store the value for each columns - for (auto key : QETInformation::elementInfoKeys()) + for (const auto& key : QETInformation::elementInfoKeys()) { if (key == "label") { hash.insert(key, elmt->actualLabel()); diff --git a/sources/dataBase/ui/elementquerywidget.cpp b/sources/dataBase/ui/elementquerywidget.cpp index ecdc6b5b4..8538a03ea 100644 --- a/sources/dataBase/ui/elementquerywidget.cpp +++ b/sources/dataBase/ui/elementquerywidget.cpp @@ -130,9 +130,9 @@ void ElementQueryWidget::setQuery(const QString &query) //Get the select -> the item in the right list QStringList split = select.split(","); - for (auto str : split) + for (const auto& str : std::as_const(split)) { - for (auto item : m_items_list) + for (auto item : std::as_const(m_items_list)) { if (item->data(Qt::UserRole).toString() == str) { ui->m_var_list->takeItem(ui->m_var_list->row(item)); @@ -209,7 +209,8 @@ void ElementQueryWidget::setQuery(const QString &query) //Filter for selected data QStringList strl; - for (auto item : m_items_list) { + for (auto item : std::as_const(m_items_list)) + { strl.append(item->data(Qt::UserRole).toString()); } @@ -236,7 +237,7 @@ void ElementQueryWidget::setQuery(const QString &query) QRegularExpressionMatch rxm; - for (auto str : split_where) + for (const auto& str : split_where) { rxm = rx_is_not_null.match(str); if (rxm.hasMatch()) { @@ -297,7 +298,8 @@ QString ElementQueryWidget::queryStr() const QString column; bool first = true; - for (auto key: keys) { + for (auto key : std::as_const(keys)) + { if (first) { first = false; } else { @@ -454,7 +456,7 @@ QStringList ElementQueryWidget::selectedKeys() const */ void ElementQueryWidget::setUpItems() { - for(QString key : QETInformation::elementInfoKeys()) + for (const QString& key : QETInformation::elementInfoKeys()) { if (key == "formula") continue; @@ -464,8 +466,7 @@ void ElementQueryWidget::setUpItems() m_items_list << item; } - - for (auto key : m_export_info.keys()) + for (const auto& key : m_export_info.keys()) { auto item = new QListWidgetItem(m_export_info.value(key), ui->m_var_list); item->setData(Qt::UserRole, key); diff --git a/sources/dataBase/ui/summaryquerywidget.cpp b/sources/dataBase/ui/summaryquerywidget.cpp index efc2c1d5a..c0274294d 100644 --- a/sources/dataBase/ui/summaryquerywidget.cpp +++ b/sources/dataBase/ui/summaryquerywidget.cpp @@ -67,7 +67,8 @@ QString SummaryQueryWidget::queryStr() const QString column; bool first = true; - for (auto key: keys) { + for (const auto& key : std::as_const(keys)) + { if (first) { first = false; } else { @@ -104,9 +105,9 @@ void SummaryQueryWidget::setQuery(const QString &query) //Get the select -> the item in the right list QStringList split = select.split(","); - for (auto str : split) + for (const auto& str : std::as_const(split)) { - for (auto item : m_items_list) + for (auto item : std::as_const(m_items_list)) { if (item->data(Qt::UserRole).toString() == str) { ui->m_available_list->takeItem(ui->m_available_list->row(item)); @@ -123,7 +124,7 @@ void SummaryQueryWidget::setQuery(const QString &query) */ void SummaryQueryWidget::setUpItems() { - for (auto key : QETInformation::diagramInfoKeys()) + for (const auto& key : QETInformation::diagramInfoKeys()) { if (key == "filename" || key == "display_folio") { continue; diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 91cc9b660..9a1de9e72 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -377,7 +377,7 @@ void Diagram::keyPressEvent(QKeyEvent *event) switch(event->key()) { case Qt::Key_Left: - for (Element *item : dc.m_elements) + for (Element* item : std::as_const(dc.m_elements)) { left_position = item->sceneBoundingRect().x(); if(left_position <= 5) @@ -389,7 +389,7 @@ void Diagram::keyPressEvent(QKeyEvent *event) movement = QPointF(+xKeyGrid, 0.0); break; case Qt::Key_Up: - for(Element *item : dc.m_elements) + for (Element* item : std::as_const(dc.m_elements)) { top_position = item->sceneBoundingRect().y(); if(top_position <= 5) @@ -420,7 +420,7 @@ void Diagram::keyPressEvent(QKeyEvent *event) switch(event->key()) { case Qt::Key_Left: - for (Element *item : dc.m_elements) + for (Element* item : std::as_const(dc.m_elements)) { left_position = item->sceneBoundingRect().x(); if(left_position <= 5) @@ -432,7 +432,7 @@ void Diagram::keyPressEvent(QKeyEvent *event) movement = QPointF(+xKeyGridFine, 0.0); break; case Qt::Key_Up: - for(Element *item : dc.m_elements) + for (Element* item : std::as_const(dc.m_elements)) { top_position = item->sceneBoundingRect().y(); if(top_position <= 5) @@ -949,7 +949,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (!list_elements.isEmpty()) { auto dom_elements = document.createElement(QStringLiteral("elements")); - for (auto elmt : list_elements) { + for (auto elmt : std::as_const(list_elements)) + { dom_elements.appendChild(elmt->toXml(document, table_adr_id)); } @@ -958,7 +959,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (!list_conductors.isEmpty()) { auto dom_conductors = document.createElement(QStringLiteral("conductors")); - for (auto cond : list_conductors) { + for (auto cond : std::as_const(list_conductors)) + { dom_conductors.appendChild(cond->toXml(document, table_adr_id)); } @@ -967,7 +969,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (!list_texts.isEmpty()) { auto dom_texts = document.createElement(QStringLiteral("inputs")); - for (auto dti : list_texts) { + for (auto dti : std::as_const(list_texts)) + { dom_texts.appendChild(dti->toXml(document)); } dom_root.appendChild(dom_texts); @@ -975,7 +978,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (!list_images.isEmpty()) { auto dom_images = document.createElement(QStringLiteral("images")); - for (auto dii : list_images) { + for (auto dii : std::as_const(list_images)) + { dom_images.appendChild(dii->toXml(document)); } dom_root.appendChild(dom_images); @@ -983,7 +987,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (!list_shapes.isEmpty()) { auto dom_shapes = document.createElement(QStringLiteral("shapes")); - for (auto dii : list_shapes) { + for (auto dii : std::as_const(list_shapes)) + { dom_shapes.appendChild(dii -> toXml(document)); } dom_root.appendChild(dom_shapes); @@ -991,7 +996,8 @@ QDomDocument Diagram::toXml(bool whole_content) { if (table_vector.size()) { auto tables = document.createElement(QStringLiteral("tables")); - for (auto table : table_vector) { + for (auto table : std::as_const(table_vector)) + { tables.appendChild(table->toXml(document)); } dom_root.appendChild(tables); @@ -1376,9 +1382,11 @@ bool Diagram::fromXml(QDomElement &document, // Load text QList added_texts; - for (auto text_xml : QET::findInDomElement(root, - QStringLiteral("inputs"), - QStringLiteral("input"))) { + for (const auto& text_xml : QET::findInDomElement( + root, + QStringLiteral("inputs"), + QStringLiteral("input"))) + { IndependentTextItem *iti = new IndependentTextItem(); iti -> fromXml(text_xml); addItem(iti); @@ -1387,9 +1395,11 @@ bool Diagram::fromXml(QDomElement &document, // Load image QList added_images; - for (auto image_xml : QET::findInDomElement(root, - QStringLiteral("images"), - QStringLiteral("image"))) { + for (const auto& image_xml : QET::findInDomElement( + root, + QStringLiteral("images"), + QStringLiteral("image"))) + { DiagramImageItem *dii = new DiagramImageItem (); dii -> fromXml(image_xml); addItem(dii); @@ -1398,9 +1408,11 @@ bool Diagram::fromXml(QDomElement &document, // Load shape QList added_shapes; - for (auto shape_xml : QET::findInDomElement(root, - QStringLiteral("shapes"), - QStringLiteral("shape"))) { + for (const auto& shape_xml : QET::findInDomElement( + root, + QStringLiteral("shapes"), + QStringLiteral("shape"))) + { QetShapeItem *dii = new QetShapeItem (QPointF(0,0)); dii -> fromXml(shape_xml); addItem(dii); @@ -1463,7 +1475,8 @@ bool Diagram::fromXml(QDomElement &document, //Get the top left corner of the rectangle that contain all added items QRectF items_rect; - for (auto item : added_items) { + for (auto item : std::as_const(added_items)) + { items_rect = items_rect.united( item->mapToScene( item->boundingRect() @@ -1475,7 +1488,7 @@ bool Diagram::fromXml(QDomElement &document, position.y() - point_.y())); //Translate all added items - for (auto qgi : added_items) + for (auto qgi : std::as_const(added_items)) qgi->setPos(qgi->pos() += pos_); } @@ -1834,7 +1847,7 @@ void Diagram::changeZValue(QET::DepthOption option) DiagramContent::Shapes | \ DiagramContent::Images); QList list; - for(QGraphicsItem *item : l) + for (QGraphicsItem* item : std::as_const(l)) list << item->toGraphicsObject(); qreal maxz=0, @@ -1850,7 +1863,7 @@ void Diagram::changeZValue(QET::DepthOption option) if(option == QET::Raise) { - for(QGraphicsObject *qgo : list) + for (QGraphicsObject* qgo : std::as_const(list)) if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal new QPropertyUndoCommand(qgo, "z", @@ -1860,7 +1873,7 @@ void Diagram::changeZValue(QET::DepthOption option) } else if(option == QET::Lower) { - for(QGraphicsObject *qgo : list) + for (QGraphicsObject* qgo : std::as_const(list)) if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal new QPropertyUndoCommand(qgo, "z", @@ -1870,21 +1883,13 @@ void Diagram::changeZValue(QET::DepthOption option) } else if (option == QET::BringForward) { - for(QGraphicsObject *qgo : list) - new QPropertyUndoCommand(qgo, - "z", - qgo->zValue(), - maxz+1, - undo); + for (QGraphicsObject* qgo : std::as_const(list)) + new QPropertyUndoCommand(qgo, "z", qgo->zValue(), maxz + 1, undo); } else if(option == QET::SendBackward) { - for(QGraphicsObject *qgo : list) - new QPropertyUndoCommand(qgo, - "z", - qgo->zValue(), - minz-1, - undo); + for (QGraphicsObject* qgo : std::as_const(list)) + new QPropertyUndoCommand(qgo, "z", qgo->zValue(), minz - 1, undo); } if(undo->childCount()) diff --git a/sources/diagramcontent.cpp b/sources/diagramcontent.cpp index 30bbcc5c1..f60dacaf9 100644 --- a/sources/diagramcontent.cpp +++ b/sources/diagramcontent.cpp @@ -95,7 +95,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) : //For each selected element, we determine if conductors must be moved or updated. - for(Element *elmt : m_elements) + for (Element* elmt : std::as_const(m_elements)) { if (elmt->isSelected()) { @@ -176,7 +176,7 @@ QList DiagramContent::conductors(int filter) const if (filter & ConductorsToUpdate) result += m_conductors_to_update; if (filter & OtherConductors) result += m_other_conductors; if (filter & SelectedOnly) { - for(Conductor *conductor : result) + for (Conductor* conductor : std::as_const(result)) { if (!conductor->isSelected()) result.removeAll(conductor); diff --git a/sources/diagramcontext.cpp b/sources/diagramcontext.cpp index 681fed49e..330b223bc 100644 --- a/sources/diagramcontext.cpp +++ b/sources/diagramcontext.cpp @@ -31,9 +31,7 @@ */ void DiagramContext::add(DiagramContext other) { - for (QString key : other.keys()) { - addValue(key, other.value(key)); - } + for (const QString& key : other.keys()) { addValue(key, other.value(key)); } } /** @@ -258,7 +256,8 @@ bool DiagramContext::isKeyAcceptable(const QString &key) QDebug operator <<(QDebug debug, const DiagramContext &context) { debug << "DiagramContext"; - for (auto key : context.keys()) { + for (const auto& key : context.keys()) + { debug.nospace() << key << " : " << context.value(key) << "\n"; } debug << " end DiagramContext"; diff --git a/sources/editor/UndoCommand/pastepartscommand.cpp b/sources/editor/UndoCommand/pastepartscommand.cpp index 664039c2b..0a7a8b9f5 100644 --- a/sources/editor/UndoCommand/pastepartscommand.cpp +++ b/sources/editor/UndoCommand/pastepartscommand.cpp @@ -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); diff --git a/sources/editor/arceditor.cpp b/sources/editor/arceditor.cpp index ec5bc51b4..a3e9110a9 100644 --- a/sources/editor/arceditor.cpp +++ b/sources/editor/arceditor.cpp @@ -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(); } diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index 100cc9a3d..245defb70 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -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(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(item); diff --git a/sources/editor/elementprimitivedecorator.cpp b/sources/editor/elementprimitivedecorator.cpp index 28a89ff66..20cb1c2d3 100644 --- a/sources/editor/elementprimitivedecorator.cpp +++ b/sources/editor/elementprimitivedecorator.cpp @@ -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); } diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index c0bc81ab5..087f589da 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -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); diff --git a/sources/editor/graphicspart/customelementgraphicpart.cpp b/sources/editor/graphicspart/customelementgraphicpart.cpp index 6e2966e47..98af42a64 100644 --- a/sources/editor/graphicspart/customelementgraphicpart.cpp +++ b/sources/editor/graphicspart/customelementgraphicpart.cpp @@ -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()) { diff --git a/sources/editor/graphicspart/partarc.cpp b/sources/editor/graphicspart/partarc.cpp index cb697d42c..78211c56f 100644 --- a/sources/editor/graphicspart/partarc.cpp +++ b/sources/editor/graphicspart/partarc.cpp @@ -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) diff --git a/sources/editor/graphicspart/partellipse.cpp b/sources/editor/graphicspart/partellipse.cpp index 9c2ed802b..2111a9011 100644 --- a/sources/editor/graphicspart/partellipse.cpp +++ b/sources/editor/graphicspart/partellipse.cpp @@ -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) diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp index 0ad0e1e91..ff678f794 100644 --- a/sources/editor/graphicspart/partline.cpp +++ b/sources/editor/graphicspart/partline.cpp @@ -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); diff --git a/sources/editor/graphicspart/partpolygon.cpp b/sources/editor/graphicspart/partpolygon.cpp index 08813a359..1ae843e88 100644 --- a/sources/editor/graphicspart/partpolygon.cpp +++ b/sources/editor/graphicspart/partpolygon.cpp @@ -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); diff --git a/sources/editor/graphicspart/partrectangle.cpp b/sources/editor/graphicspart/partrectangle.cpp index 6b5e39391..82eedccc5 100644 --- a/sources/editor/graphicspart/partrectangle.cpp +++ b/sources/editor/graphicspart/partrectangle.cpp @@ -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;} diff --git a/sources/editor/styleeditor.cpp b/sources/editor/styleeditor.cpp index 3b549c425..bdc194832 100644 --- a/sources/editor/styleeditor.cpp +++ b/sources/editor/styleeditor.cpp @@ -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); diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index b21c2039d..07a504b9c 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -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(); diff --git a/sources/editor/ui/ellipseeditor.cpp b/sources/editor/ui/ellipseeditor.cpp index 7272c07ae..82d7b1d66 100644 --- a/sources/editor/ui/ellipseeditor.cpp +++ b/sources/editor/ui/ellipseeditor.cpp @@ -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(); diff --git a/sources/editor/ui/lineeditor.cpp b/sources/editor/ui/lineeditor.cpp index e23333bfe..20f8f3f45 100644 --- a/sources/editor/ui/lineeditor.cpp +++ b/sources/editor/ui/lineeditor.cpp @@ -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); } diff --git a/sources/editor/ui/polygoneditor.cpp b/sources/editor/ui/polygoneditor.cpp index d9003fc10..9afdc35f5 100644 --- a/sources/editor/ui/polygoneditor.cpp +++ b/sources/editor/ui/polygoneditor.cpp @@ -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(); diff --git a/sources/editor/ui/qetelementeditor.cpp b/sources/editor/ui/qetelementeditor.cpp index 2e0f2b34a..ceaea5d1f 100644 --- a/sources/editor/ui/qetelementeditor.cpp +++ b/sources/editor/ui/qetelementeditor.cpp @@ -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(qgi)) { cep_list << cep; @@ -582,9 +582,11 @@ void QETElementEditor::updateInformations() bool equal = true; QList 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 += "
    "; QList total = warnings << errors; - for(QETWarning warning : total) + for (const QETWarning& warning : total) { dialog_message += "
  1. "; - dialog_message += QString( - tr("%1 : %2", "warning title: warning description") - ).arg(warning.first).arg(warning.second); + dialog_message += + QString(tr("%1 : %2", "warning title: warning description")) + .arg(warning.first, warning.second); dialog_message += "
  2. "; } dialog_message += "
"; diff --git a/sources/editor/ui/rectangleeditor.cpp b/sources/editor/ui/rectangleeditor.cpp index 2380f35a1..9be037bff 100644 --- a/sources/editor/ui/rectangleeditor.cpp +++ b/sources/editor/ui/rectangleeditor.cpp @@ -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(); diff --git a/sources/editor/ui/texteditor.cpp b/sources/editor/ui/texteditor.cpp index b088e6571..67c5aced6 100644 --- a/sources/editor/ui/texteditor.cpp +++ b/sources/editor/ui/texteditor.cpp @@ -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(); } diff --git a/sources/elementprovider.cpp b/sources/elementprovider.cpp index fdf89c049..de73148db 100644 --- a/sources/elementprovider.cpp +++ b/sources/elementprovider.cpp @@ -153,7 +153,8 @@ QVector ElementProvider::table( } } - for (auto d : m_diagram_list) { + for (auto d : std::as_const(m_diagram_list)) + { for (auto item_ : d->items()) { if(item_->type() == QetGraphicsTableItem::Type) diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 30925b6e9..69769f772 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -58,8 +58,8 @@ ElementsPanel::ElementsPanel(QWidget *parent) : QPalette qp = palette(); qp.setColor(QPalette::Text, Qt::black); qp.setColor(QPalette::Base, Qt::white); - qp.setColor(QPalette::AlternateBase, QColor("#e8e8e8")); - qp.setColor(QPalette::Highlight, QColor("#678db2")); + qp.setColor(QPalette::AlternateBase, QColor(0xe8e8e8)); + qp.setColor(QPalette::Highlight, QColor(0x678db2)); qp.setColor(QPalette::HighlightedText, Qt::black); setPalette(qp); diff --git a/sources/elementtextpattern.cpp b/sources/elementtextpattern.cpp index f76fae68b..600fe5e67 100644 --- a/sources/elementtextpattern.cpp +++ b/sources/elementtextpattern.cpp @@ -220,7 +220,7 @@ void ImportElementTextPattern::apply(QString name, bool erase) const //Replace the original uuid of texts in the xml description, by a new one for every texts QHash uuid_hash; - for(QDomElement text : texts) + for (QDomElement text : std::as_const(texts)) { QUuid original_uuid(text.attribute("uuid")); QUuid new_uuid = QUuid::createUuid(); @@ -231,7 +231,7 @@ void ImportElementTextPattern::apply(QString name, bool erase) const //In each group of the xml description, replace the original uuids, by the news created upper. QList groups = QET::findInDomElement(root, "texts_groups", "texts_group"); - for(const QDomElement& group : groups) + for (const QDomElement& group : std::as_const(groups)) { for(QDomElement text : QET::findInDomElement(group, "texts", "text")) { @@ -260,14 +260,14 @@ void ImportElementTextPattern::apply(QString name, bool erase) const } //Add the texts to element - for(const QDomElement& text : texts) + for (const QDomElement& text : std::as_const(texts)) { DynamicElementTextItem *deti = new DynamicElementTextItem(m_element); undo_stack.push(new AddElementTextCommand(m_element, deti)); deti->fromXml(text); } //Add the groups to element - for(const QDomElement& xml_group : groups) + for (const QDomElement& xml_group : std::as_const(groups)) undo_stack.push(new AddTextsGroupCommand(m_element, xml_group)); undo_stack.endMacro(); diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 2e593ed75..91a681047 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -505,7 +505,7 @@ void ExportDialog::generateDxf( ElementPictureFactory::primitives primitives = ElementPictureFactory::instance()->getPrimitives(elmt->location()); - for(QGraphicsSimpleTextItem *text : primitives.m_texts) + for (QGraphicsSimpleTextItem* text : std::as_const(primitives.m_texts)) { qreal fontSize = text->font().pointSizeF(); if (fontSize < 0) @@ -524,7 +524,7 @@ void ExportDialog::generateDxf( y = transformed_point.y() - xdir * fontSize * 0.5; QStringList lines = text->text().split('\n'); qreal offset = fontSize * 1.6; - for (QString line : lines) + for (const QString& line : std::as_const(lines)) { if (line.size() > 0 && line != "_" ) { Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360 - angle, 0, 0.72); @@ -534,28 +534,29 @@ void ExportDialog::generateDxf( } } - for (QLineF line : primitives.m_lines) + for (QLineF line : std::as_const(primitives.m_lines)) { QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle); QLineF l = t.map(line); Createdxf::drawLine(file_path, l, 0); } - for (QRectF rect : primitives.m_rectangles) + for (QRectF rect : std::as_const(primitives.m_rectangles)) { QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle); QRectF r = t.mapRect(rect); Createdxf::drawRectangle(file_path,r,0); } - for (QRectF circle_rect : primitives.m_circles) + for (QRectF circle_rect : std::as_const(primitives.m_circles)) { QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle); QPointF c = t.map(QPointF(circle_rect.center().x(),circle_rect.center().y())); Createdxf::drawCircle(file_path,c,circle_rect.width()/2,0); } - for (QVector polygon : primitives.m_polygons) + for (const QVector& polygon : + std::as_const(primitives.m_polygons)) { if (polygon.size() == 0) continue; @@ -568,7 +569,7 @@ void ExportDialog::generateDxf( } // Draw arcs and ellipses - for (QVector arc : primitives.m_arcs) + for (const QVector& arc : std::as_const(primitives.m_arcs)) { if (arc.size() == 0) continue; diff --git a/sources/factory/elementpicturefactory.cpp b/sources/factory/elementpicturefactory.cpp index 522c1a721..d896611b2 100644 --- a/sources/factory/elementpicturefactory.cpp +++ b/sources/factory/elementpicturefactory.cpp @@ -130,7 +130,8 @@ ElementPictureFactory::primitives ElementPictureFactory::getPrimitives( ElementPictureFactory::~ElementPictureFactory() { - for (primitives p : m_primitives_H.values()) { + for (const primitives& p : m_primitives_H.values()) + { qDeleteAll(p.m_texts); } } @@ -580,7 +581,7 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa << rx.patternErrorOffset(); return; } - for (auto style : styles) + for (const auto& style : styles) { QRegularExpressionMatch match = rx.match(style); if (!match.hasMatch()) { diff --git a/sources/genericpanel.cpp b/sources/genericpanel.cpp index fd6103313..e28590d1b 100644 --- a/sources/genericpanel.cpp +++ b/sources/genericpanel.cpp @@ -356,14 +356,12 @@ QTreeWidgetItem *GenericPanel::updateDiagramItem(QTreeWidgetItem *diagram_qtwi, int diagram_folio_idx = diagram -> folioIndex(); if (diagram_folio_idx != -1) { - displayed_label = QString( - tr( - "%1 - %2", - "label displayed for a diagram in the panel ;" - " %1 is the folio index, %2 is the diagram title" - ) - ).arg(displayed_label).arg(displayed_title); - diagram_qtwi -> setText(0, displayed_label); + displayed_label = + QString(tr("%1 - %2", + "label displayed for a diagram in the panel ;" + " %1 is the folio index, %2 is the diagram title")) + .arg(displayed_label, displayed_title); + diagram_qtwi->setText(0, displayed_label); } } @@ -910,8 +908,8 @@ void GenericPanel::deleteItem(QTreeWidgetItem *item, bool deleted_on_cascade) { */ void GenericPanel::markItemAsUnused(QTreeWidgetItem *qtwi) { QLinearGradient t(0, 0, 200, 0); - t.setColorAt(0, QColor("#ffc0c0")); - t.setColorAt(1, QColor("#ffffff")); + t.setColorAt(0, QColor(0xffc0c0)); + t.setColorAt(1, QColor(0xffffff)); qtwi -> setBackground(0, QBrush(t)); qtwi -> setToolTip(0, QString(tr("%1 [non utilisé dans le projet]")).arg( diff --git a/sources/print/projectprintwindow.cpp b/sources/print/projectprintwindow.cpp index 6522020d3..171b45d4e 100644 --- a/sources/print/projectprintwindow.cpp +++ b/sources/print/projectprintwindow.cpp @@ -309,7 +309,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter //Scrolls through the page for print bool first_ = true; - for (auto page : page_to_print) + for (auto page : std::as_const(page_to_print)) { first_ ? first_ = false : m_printer->newPage(); diagram->render(painter, QRect(QPoint(0,0), page.size()), page.translated(diagram_rect.topLeft()), Qt::KeepAspectRatio); @@ -320,7 +320,8 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter for (auto view : diagram->views()) { view->setInteractive(true); } - for (auto qgi : focusable_items) { + for (auto qgi : std::as_const(focusable_items)) + { qgi->setFlag(QGraphicsItem::ItemIsFocusable, true); } saveReloadDiagramParameters(diagram, option, false); diff --git a/sources/properties/xrefproperties.cpp b/sources/properties/xrefproperties.cpp index 2ce72747e..09b100265 100644 --- a/sources/properties/xrefproperties.cpp +++ b/sources/properties/xrefproperties.cpp @@ -89,7 +89,8 @@ void XRefProperties::fromSettings(const QSettings &settings, QMetaEnum var = QMetaEnum::fromType(); m_xref_pos = Qt::AlignmentFlag(var.keyToValue((settings.value(prefix + "xrefpos").toString()).toStdString().data())); - for (QString key : m_prefix_keys) { + for (const QString& key : std::as_const(m_prefix_keys)) + { m_prefix.insert(key, settings.value(prefix + key + "prefix").toString()); } } diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 8967347ae..6d1ef5af7 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -2405,7 +2405,7 @@ void QETApp::checkBackupFiles() text.append(tr("Les fichiers de restauration suivant on été trouvé,
" "Voulez-vous les ouvrir ?

")); } - for(const KAutoSaveFile *kasf : stale_files) + for (const KAutoSaveFile* kasf : std::as_const(stale_files)) { # ifdef Q_OS_WIN //Remove the first character '/' before the name of the drive @@ -2439,7 +2439,7 @@ void QETApp::checkBackupFiles() else //Clear backup file { //Remove the stale files - for (KAutoSaveFile *stale : stale_files) + for (KAutoSaveFile* stale : std::as_const(stale_files)) { stale->open(QIODevice::ReadWrite); delete stale; diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index ad941588f..a1a622ccc 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -929,7 +929,10 @@ void QETDiagramEditor::save() QString title = (project_view -> project() -> title ()); if (title.isEmpty()) title = "QElectroTech "; QString filePath = (project_view -> project() -> filePath ()); - statusBar()-> showMessage(tr("Projet %1 enregistré dans le repertoire: %2.").arg(title).arg (filePath), 2000); + statusBar()->showMessage( + tr("Projet %1 enregistré dans le repertoire: %2.") + .arg(title, filePath), + 2000); m_element_collection_widget->highlightUnusedElement(); } else { @@ -952,7 +955,10 @@ void QETDiagramEditor::saveAs() QString title = (project_view -> project() -> title ()); if (title.isEmpty()) title = "QElectroTech "; QString filePath = (project_view -> project() -> filePath ()); - statusBar()->showMessage(tr("Projet %1 enregistré dans le repertoire: %2.").arg(title).arg (filePath), 2000); + statusBar()->showMessage( + tr("Projet %1 enregistré dans le repertoire: %2.") + .arg(title, filePath), + 2000); m_element_collection_widget->highlightUnusedElement(); } else { @@ -1614,7 +1620,7 @@ void QETDiagramEditor::slot_updateComplexActions() << m_rotate_selection << m_edit_selection << m_group_selected_texts; - for(QAction *action : action_list) + for (QAction* action : std::as_const(action_list)) action->setEnabled(false); return; @@ -1646,13 +1652,13 @@ void QETDiagramEditor::slot_updateComplexActions() QList groups = DiagramContent(diagram_).selectedTextsGroup(); int selected_texts = texts.count(); int selected_conductor_texts = 0; - for(DiagramTextItem *dti : texts) + for (DiagramTextItem* dti : std::as_const(texts)) { if(dti->type() == ConductorTextItem::Type) selected_conductor_texts++; } int selected_dynamic_elmt_text = 0; - for(DiagramTextItem *dti : texts) + for (DiagramTextItem* dti : std::as_const(texts)) { if(dti->type() == DynamicElementTextItem::Type) selected_dynamic_elmt_text++; @@ -1665,7 +1671,7 @@ void QETDiagramEditor::slot_updateComplexActions() { Element *elmt = deti_list.first()->parentElement(); bool ok = true; - for(DynamicElementTextItem *deti : deti_list) + for (DynamicElementTextItem* deti : std::as_const(deti_list)) { if(elmt != deti->parentElement()) ok = false; diff --git a/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp b/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp index ba64c8221..c0cf638f8 100644 --- a/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp +++ b/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp @@ -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()); diff --git a/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp b/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp index 5ea8364bf..eb1fc3ff9 100644 --- a/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp +++ b/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp @@ -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); diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index ab22bcbf5..22e928619 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -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::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::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 lines; QList 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 intersections; - for (QLineF line : lines) + for (QLineF line : std::as_const(lines)) { QPointF intersection_point; if (QET::orthogonalProjection(point, line, &intersection_point)) { diff --git a/sources/qetgraphicsitem/crossrefitem.cpp b/sources/qetgraphicsitem/crossrefitem.cpp index 98d941c6a..b7ab74fd1 100644 --- a/sources/qetgraphicsitem/crossrefitem.cpp +++ b/sources/qetgraphicsitem/crossrefitem.cpp @@ -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); diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index 17c4369b4..e6f2521d0 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -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(); } diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 8a20472e6..a321456b3 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -732,7 +732,7 @@ bool Element::fromXml(QDomElement &e, { if (auto terminal_ = qgraphicsitem_cast(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 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)) { diff --git a/sources/qetgraphicsitem/elementtextitemgroup.cpp b/sources/qetgraphicsitem/elementtextitemgroup.cpp index 4a4f8a3e9..38d2b999d 100644 --- a/sources/qetgraphicsitem/elementtextitemgroup.cpp +++ b/sources/qetgraphicsitem/elementtextitemgroup.cpp @@ -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); diff --git a/sources/qetgraphicsitem/qetshapeitem.cpp b/sources/qetgraphicsitem/qetshapeitem.cpp index aaeff3d6e..d78354662 100644 --- a/sources/qetgraphicsitem/qetshapeitem.cpp +++ b/sources/qetgraphicsitem/qetshapeitem.cpp @@ -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); } - } } } diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp index b0028a0dc..ae7eb13b9 100644 --- a/sources/qetgraphicsitem/terminal.cpp +++ b/sources/qetgraphicsitem/terminal.cpp @@ -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; diff --git a/sources/qetinformation.cpp b/sources/qetinformation.cpp index c180644f0..25d384459 100644 --- a/sources/qetinformation.cpp +++ b/sources/qetinformation.cpp @@ -73,7 +73,8 @@ QString QETInformation::titleblockInfoKeysToVar(const QString &info) QHash QETInformation::titleblockTranslatedKeyHashVar() { QHash hash_; - for (QString str : titleblockInfoKeys()) { + for (const QString& str : titleblockInfoKeys()) + { hash_.insert(translatedInfoKey(str), titleblockInfoKeysToVar(str)); } return hash_; diff --git a/sources/qetxml.cpp b/sources/qetxml.cpp index dde86d6c9..a21fb54e0 100644 --- a/sources/qetxml.cpp +++ b/sources/qetxml.cpp @@ -516,7 +516,7 @@ void QETXML::modelHeaderDataFromXml( auto meta_enum_orientation = QMetaEnum::fromType(); auto meta_enum_role = QMetaEnum::fromType(); - for (auto child : QETXML::directChild(element, "data")) + for (const auto& child : QETXML::directChild(element, "data")) { auto section_ = child.attribute("section", "-1").toInt(); auto orientation_ = Qt::Orientation( diff --git a/sources/qtextorientationwidget.cpp b/sources/qtextorientationwidget.cpp index 110fea82f..ab232af32 100644 --- a/sources/qtextorientationwidget.cpp +++ b/sources/qtextorientationwidget.cpp @@ -201,8 +201,8 @@ void QTextOrientationWidget::paintEvent(QPaintEvent *event) { p.setRenderHint(QPainter::TextAntialiasing, true); // cercle gris a fond jaune - p.setPen(QPen(QBrush(QColor("#9FA8A8")), 2.0)); - p.setBrush(QBrush(QColor("#ffffaa"))); + p.setPen(QPen(QBrush(QColor(0x9FA8A8)), 2.0)); + p.setBrush(QBrush(QColor(0xffffaa))); p.drawEllipse(drawing_rectangle); // ligne rouge indiquant l'angle actuel @@ -230,10 +230,10 @@ void QTextOrientationWidget::paintEvent(QPaintEvent *event) { qreal square_offset = - squares_size / 2.0; QRectF square_qrect = QRect(square_offset, square_offset, squares_size, squares_size); p.setPen(Qt::NoPen); - p.setBrush(QBrush(QColor("#248A34"))); + p.setBrush(QBrush(QColor(0x248A34))); for (double drawing_angle = 0.0 ; drawing_angle < 360.0 ; drawing_angle += squares_interval_) { if (must_highlight_angle_ && highlight_angle_ == drawing_angle && underMouse()) { - p.setBrush(QBrush(QColor("#43FF5F"))); + p.setBrush(QBrush(QColor(0x43FF5F))); } p.resetTransform(); p.translate(drawing_rectangle_center); @@ -242,7 +242,7 @@ void QTextOrientationWidget::paintEvent(QPaintEvent *event) { p.rotate(-45.0); p.drawRect(square_qrect); if (must_highlight_angle_ && highlight_angle_ == drawing_angle) { - p.setBrush(QBrush(QColor("#248A34"))); + p.setBrush(QBrush(QColor(0x248A34))); } } diff --git a/sources/titleblock/helpercell.cpp b/sources/titleblock/helpercell.cpp index 02d6ca5cd..6b23e0a4e 100644 --- a/sources/titleblock/helpercell.cpp +++ b/sources/titleblock/helpercell.cpp @@ -96,13 +96,13 @@ void HelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option */ void HelperCell::setType(QET::TitleBlockColumnLength type) { if (type == QET::Absolute) { - background_color = QColor("#C0FFFF"); + background_color = QColor(0xC0FFFF); foreground_color = Qt::black; } else if (type == QET::RelativeToTotalLength) { - background_color = QColor("#FFA858"); + background_color = QColor(0xFFA858); foreground_color = Qt::black; } else if (type == QET::RelativeToRemainingLength) { - background_color = QColor("#FFC0C0"); + background_color = QColor(0xFFC0C0); foreground_color = Qt::black; } } diff --git a/sources/titleblock/integrationmovetemplateshandler.cpp b/sources/titleblock/integrationmovetemplateshandler.cpp index be6e759b8..0bf5225da 100644 --- a/sources/titleblock/integrationmovetemplateshandler.cpp +++ b/sources/titleblock/integrationmovetemplateshandler.cpp @@ -82,14 +82,15 @@ QET::Action IntegrationMoveTitleBlockTemplatesHandler::templateAlreadyExists(con @param message Error message. */ QET::Action IntegrationMoveTitleBlockTemplatesHandler::errorWithATemplate(const TitleBlockTemplateLocation &tbt, const QString &message) { - QString error_message = QString("Une erreur s'est produite avec le modèle %1 : %2").arg(tbt.toString()).arg(message); + QString error_message = + QString("Une erreur s'est produite avec le modèle %1 : %2") + .arg(tbt.toString(), message); QET::QetMessageBox::critical( parent_widget_, tr("Erreur", "message box title"), error_message, QMessageBox::Ok, - QMessageBox::Ok - ); + QMessageBox::Ok); return(QET::Ignore); } @@ -116,7 +117,7 @@ QString IntegrationMoveTitleBlockTemplatesHandler::dateString() const This name is based on the current date. */ QString IntegrationMoveTitleBlockTemplatesHandler::newNameForTemplate(const TitleBlockTemplateLocation &tbt) { - return(QString("%1-%2.elmt").arg(tbt.name()).arg(dateString())); + return (QString("%1-%2.elmt").arg(tbt.name(), dateString())); } /** diff --git a/sources/titleblock/qettemplateeditor.cpp b/sources/titleblock/qettemplateeditor.cpp index d270567cd..1689d89d8 100644 --- a/sources/titleblock/qettemplateeditor.cpp +++ b/sources/titleblock/qettemplateeditor.cpp @@ -620,12 +620,11 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const if (read_only_) { tag = tr("[Lecture seule]", "window title tag"); } - titleblock_title = QString( - tr( - "%1 %2", - "part of the window title - %1 is the filepath or template name, %2 is the [Changed] or [Read only] tag" - ) - ).arg(titleblock_title).arg(tag); + titleblock_title = + QString(tr("%1 %2", + "part of the window title - %1 is the filepath or " + "template name, %2 is the [Changed] or [Read only] tag")) + .arg(titleblock_title, tag); } return(titleblock_title); @@ -725,12 +724,10 @@ void QETTitleBlockTemplateEditor::updateEditorTitle() if (titleblock_title.isEmpty()) { title = min_title; } else { - title = QString( - tr( - "%1 - %2", - "window title: %1 is the base window title, %2 is a template name" - ) - ).arg(min_title).arg(titleblock_title); + title = QString(tr("%1 - %2", + "window title: %1 is the base window title, %2 is a " + "template name")) + .arg(min_title, titleblock_title); } setWindowTitle(title); } diff --git a/sources/titleblock/templatescollection.cpp b/sources/titleblock/templatescollection.cpp index b2b0ae40c..11f7f9c9a 100644 --- a/sources/titleblock/templatescollection.cpp +++ b/sources/titleblock/templatescollection.cpp @@ -557,7 +557,7 @@ QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_n @return the file name for \a template_name */ QString TitleBlockTemplatesFilesCollection::toFileName(const QString &template_name) { - return(QString("%1%2").arg(template_name).arg(TITLEBLOCKS_FILE_EXTENSION)); + return (QString("%1%2").arg(template_name, TITLEBLOCKS_FILE_EXTENSION)); } /** diff --git a/sources/titleblock/templateview.cpp b/sources/titleblock/templateview.cpp index d755eca4a..9c20aa2b0 100644 --- a/sources/titleblock/templateview.cpp +++ b/sources/titleblock/templateview.cpp @@ -1150,11 +1150,10 @@ TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems QString TitleBlockTemplateView::makePrettyToolTip(const QString &string) { QString css_style = QString("white-space: pre;"); - QString final_tooltip_content = QString( - "
%2
" - ).arg(css_style).arg(string); + QString final_tooltip_content = + QString("
%2
").arg(css_style, string); - return(final_tooltip_content); + return (final_tooltip_content); } /** diff --git a/sources/titleblocktemplate.cpp b/sources/titleblocktemplate.cpp index b889e1e49..6ec46d738 100644 --- a/sources/titleblocktemplate.cpp +++ b/sources/titleblocktemplate.cpp @@ -1717,10 +1717,12 @@ QString TitleBlockTemplate::finalTextForCell( if (cell.display_label && !cell.label.isEmpty()) { cell_label = interpreteVariables(cell_label, diagram_context); - cell_text = QString(tr(" %1 : %2", "titleblock content - please let the blank space at the beginning")).arg(cell_label).arg(cell_text); - } else { - cell_text = QString(tr(" %1")).arg(cell_text); + cell_text = QString(tr(" %1 : %2", + "titleblock content - please let the blank " + "space at the beginning")) + .arg(cell_label, cell_text); } + else { cell_text = QString(tr(" %1")).arg(cell_text); } return(cell_text); } diff --git a/sources/ui/aboutqetdialog.cpp b/sources/ui/aboutqetdialog.cpp index f94b62449..21f7346bf 100644 --- a/sources/ui/aboutqetdialog.cpp +++ b/sources/ui/aboutqetdialog.cpp @@ -236,7 +236,7 @@ void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString QString author_template = "%1 : %2 <%3>‎

"; // Add the function of the person - new_text += author_template.arg(work).arg(name).arg(email); + new_text += author_template.arg(work, name, email); label->setText(new_text); } @@ -253,7 +253,7 @@ void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QStrin QString Library_template = "%1 : <%3>‎

"; // Add the function of the person - new_text += Library_template.arg(name).arg(link); + new_text += Library_template.arg(name, link); label->setText(new_text); } diff --git a/sources/ui/diagramcontextwidget.cpp b/sources/ui/diagramcontextwidget.cpp index 169ca2882..0b9b25b0d 100644 --- a/sources/ui/diagramcontextwidget.cpp +++ b/sources/ui/diagramcontextwidget.cpp @@ -71,7 +71,7 @@ void DiagramContextWidget::setContext (const DiagramContext &context) clear(); int i = 0; - for (QString key : context.keys(DiagramContext::Alphabetical)) + for (const 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())); diff --git a/sources/ui/dynamicelementtextitemeditor.cpp b/sources/ui/dynamicelementtextitemeditor.cpp index 4b3a10a7a..c73fc89d7 100644 --- a/sources/ui/dynamicelementtextitemeditor.cpp +++ b/sources/ui/dynamicelementtextitemeditor.cpp @@ -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); - if (undo->childCount() == 1) + for (DynamicElementTextItem* deti : std::as_const(deti_list)) { - QPropertyUndoCommand *quc = new QPropertyUndoCommand(static_cast(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; + QUndoCommand* undo = m_model->undoForEditedText(deti); + + if (undo->childCount() == 1) + { + QPropertyUndoCommand* quc = new QPropertyUndoCommand( + static_cast(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,8 +127,7 @@ void DynamicElementTextItemEditor::apply() { QUndoStack &us = m_element->diagram()->undoStack(); us.beginMacro(tr("Modifier des textes d'élément")); - for (QUndoCommand *quc : undo_list) - us.push(quc); + for (QUndoCommand* quc : std::as_const(undo_list)) us.push(quc); us.endMacro(); } } diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index c3c85ea04..a9bff7134 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -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 : info_list) + + for (const QString& info : std::as_const(info_list)) { if(dc.contains(info)) qstrl << info; diff --git a/sources/ui/elementinfowidget.cpp b/sources/ui/elementinfowidget.cpp index 951623070..aab46ea82 100644 --- a/sources/ui/elementinfowidget.cpp +++ b/sources/ui/elementinfowidget.cpp @@ -158,7 +158,7 @@ bool ElementInfoWidget::event(QEvent *event) */ void ElementInfoWidget::enableLiveEdit() { - for (ElementInfoPartWidget *eipw : m_eipw_list) + for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list)) connect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply); } @@ -168,7 +168,7 @@ void ElementInfoWidget::enableLiveEdit() */ void ElementInfoWidget::disableLiveEdit() { - for (ElementInfoPartWidget *eipw : m_eipw_list) + for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list)) disconnect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply); } @@ -185,11 +185,14 @@ void ElementInfoWidget::buildInterface() keys = QETInformation::elementInfoKeys(); } - for (auto str : keys) - { - ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this); - ui->scroll_vlayout->addWidget(eipw); - m_eipw_list << eipw; + 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; } ui->scroll_vlayout->addStretch(); @@ -227,8 +230,9 @@ void ElementInfoWidget::updateUi() if (m_live_edit) disableLiveEdit(); const auto element_info{m_element->elementInformations()}; - - for (ElementInfoPartWidget *eipw : m_eipw_list) { + + for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list)) + { eipw -> setText (element_info[eipw->key()].toString()); } diff --git a/sources/ui/elementpropertieswidget.cpp b/sources/ui/elementpropertieswidget.cpp index e93e8e914..ebd792476 100644 --- a/sources/ui/elementpropertieswidget.cpp +++ b/sources/ui/elementpropertieswidget.cpp @@ -140,7 +140,8 @@ void ElementPropertiesWidget::setDynamicText(DynamicElementTextItem *text) if(text->parentElement()) { setElement(text->parentElement()); - for(AbstractElementPropertiesEditorWidget *aepew : m_list_editor) + for (AbstractElementPropertiesEditorWidget* aepew : + std::as_const(m_list_editor)) { if (QString(aepew->metaObject()->className()) == "DynamicElementTextItemEditor") { @@ -166,7 +167,8 @@ void ElementPropertiesWidget::setTextsGroup(ElementTextItemGroup *group) if(group->parentItem() && group->parentItem()->type() == Element::Type) { setElement(static_cast(group->parentItem())); - for(AbstractElementPropertiesEditorWidget *aepew : m_list_editor) + for (AbstractElementPropertiesEditorWidget* aepew : + std::as_const(m_list_editor)) { if (QString(aepew->metaObject()->className()) == "DynamicElementTextItemEditor") { @@ -314,7 +316,8 @@ void ElementPropertiesWidget::updateUi() m_list_editor << new DynamicElementTextItemEditor(m_element, this); //Add each editors in tab widget - for (AbstractElementPropertiesEditorWidget *aepew : m_list_editor) + for (AbstractElementPropertiesEditorWidget* aepew : + std::as_const(m_list_editor)) { aepew->setLiveEdit(m_live_edit); m_tab->addTab(aepew, aepew->title()); diff --git a/sources/ui/inditextpropertieswidget.cpp b/sources/ui/inditextpropertieswidget.cpp index 7edfe0b53..2b049e956 100644 --- a/sources/ui/inditextpropertieswidget.cpp +++ b/sources/ui/inditextpropertieswidget.cpp @@ -71,7 +71,8 @@ IndiTextPropertiesWidget::~IndiTextPropertiesWidget() void IndiTextPropertiesWidget::setText(IndependentTextItem *text) { if (m_text) { - for (QMetaObject::Connection c : m_connect_list) { + for (const QMetaObject::Connection& c : std::as_const(m_connect_list)) + { disconnect(c); } } @@ -89,7 +90,8 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text) void IndiTextPropertiesWidget::setText(QList text_list) { - for (QMetaObject::Connection c : m_connect_list) { + for (const QMetaObject::Connection& c : std::as_const(m_connect_list)) + { disconnect(c); } m_connect_list.clear(); @@ -125,7 +127,9 @@ void IndiTextPropertiesWidget::apply() if (m_text && m_text->diagram()) { d = m_text->diagram(); } else if (!m_text_list.isEmpty()) { - for (QPointer piti : m_text_list) { + for (const QPointer& piti : + std::as_const(m_text_list)) + { if (piti->diagram()) { d = piti->diagram(); break; @@ -158,7 +162,9 @@ bool IndiTextPropertiesWidget::setLiveEdit(bool live_edit) setUpEditConnection(); } else { - for (QMetaObject::Connection c : m_edit_connection) { + for (const QMetaObject::Connection& c : + std::as_const(m_edit_connection)) + { disconnect(c); } m_edit_connection.clear(); @@ -220,7 +226,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 (QPointer piti : m_text_list) + for (const QPointer& piti : m_text_list) { if (piti->rotation() != rotation_) { angle_equal = false; @@ -236,7 +242,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 (QPointer piti : m_text_list) + for (const QPointer& piti : m_text_list) { if (piti) { @@ -251,7 +257,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 (QPointer piti : m_text_list) + for (const QPointer& piti : m_text_list) { if (piti) { @@ -267,7 +273,7 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const else if ((m_font_is_selected && !font_equal) || (m_font_is_selected && (font_equal && (m_selected_font != font_)))) { - for (QPointer piti : m_text_list) + for (const QPointer& piti : m_text_list) { if (piti) { @@ -324,7 +330,8 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const */ void IndiTextPropertiesWidget::setUpEditConnection() { - for (QMetaObject::Connection c : m_edit_connection) { + for (const QMetaObject::Connection& c : std::as_const(m_edit_connection)) + { disconnect(c); } m_edit_connection.clear(); @@ -354,7 +361,8 @@ 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 (QMetaObject::Connection c : m_edit_connection) { + for (const QMetaObject::Connection& c : std::as_const(m_edit_connection)) + { disconnect(c); } m_edit_connection.clear(); @@ -388,7 +396,8 @@ void IndiTextPropertiesWidget::updateUi() int size_ = m_text_list.first()->font().pointSize(); QFont font_ = m_text_list.first()->font(); - for (QPointer piti : m_text_list) + for (const QPointer& piti : + std::as_const(m_text_list)) { if (piti->rotation() != rotation_) { angle_equal = false; @@ -403,7 +412,9 @@ void IndiTextPropertiesWidget::updateUi() ui->m_angle_sb->setValue(angle_equal ? rotation_ : 0); bool valid_ = true; - for (QPointer piti : m_text_list) { + for (const QPointer& piti : + std::as_const(m_text_list)) + { if (piti->isHtml()) { valid_ = false; } @@ -436,10 +447,11 @@ void IndiTextPropertiesWidget::on_m_break_html_pb_clicked() if (m_text) { m_text->setPlainText(m_text->toPlainText()); } - for (QPointer piti : m_text_list) { + for (const QPointer& piti : std::as_const(m_text_list)) + { piti->setPlainText(piti->toPlainText()); } - + updateUi(); } diff --git a/sources/ui/multipastedialog.cpp b/sources/ui/multipastedialog.cpp index 321f36a84..afa981a89 100644 --- a/sources/ui/multipastedialog.cpp +++ b/sources/ui/multipastedialog.cpp @@ -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(DiagramContent dc : m_pasted_content_list) + for (const DiagramContent& dc : std::as_const(m_pasted_content_list)) { QList pasted_elements = dc.m_elements; //Sort the list element by there pos (top -> bottom) diff --git a/sources/ui/potentialselectordialog.cpp b/sources/ui/potentialselectordialog.cpp index 353bf7168..f3461e124 100644 --- a/sources/ui/potentialselectordialog.cpp +++ b/sources/ui/potentialselectordialog.cpp @@ -204,7 +204,7 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList H; - for (ConductorProperties cp : list) + for (const ConductorProperties& cp : list) { QString text; if(!cp.text.isEmpty()) diff --git a/sources/ui/shapegraphicsitempropertieswidget.cpp b/sources/ui/shapegraphicsitempropertieswidget.cpp index 2eb9eb8e0..521abe577 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.cpp +++ b/sources/ui/shapegraphicsitempropertieswidget.cpp @@ -121,7 +121,7 @@ void ShapeGraphicsItemPropertiesWidget::apply() } else if (!m_shapes_list.isEmpty()) { - for (QPointer qsi : m_shapes_list) + for (const QPointer& qsi : std::as_const(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 (QPointer qsi : m_shapes_list) + for (const QPointer& 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 (QPointer qsi : m_shapes_list) + for (const QPointer& 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 (QPointer qsi : m_shapes_list) + for (const QPointer& 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 (QPointer qsi : pen_H.keys()) + for (const QPointer& 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 (QPointer qsi : m_shapes_list) + for (const QPointer& 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 (QPointer qsi : m_shapes_list) + for (const QPointer& 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 (QPointer qsi : brush_H.keys()) + for (const QPointer& qsi : brush_H.keys()) { if (!parent_undo) { parent_undo = new QUndoCommand(tr("Modifier une forme simple")); @@ -383,7 +383,8 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() bool same = true; //Pen Qt::PenStyle ps = m_shapes_list.first()->pen().style(); - for (QetShapeItem *qsi : m_shapes_list) { + for (QetShapeItem* qsi : std::as_const(m_shapes_list)) + { if (qsi->pen().style() != ps) { same = false; break; @@ -393,7 +394,8 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() same = true; qreal pw = m_shapes_list.first()->pen().widthF(); - for (QetShapeItem *qsi : m_shapes_list) { + for (QetShapeItem* qsi : std::as_const(m_shapes_list)) + { if (qsi->pen().widthF() != pw) { same = false; break; @@ -403,7 +405,8 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() same = true; QColor pc = m_shapes_list.first()->pen().color(); - for (QetShapeItem *qsi : m_shapes_list) { + for (QetShapeItem* qsi : std::as_const(m_shapes_list)) + { if (qsi->pen().color() != pc) { same = false; break; @@ -416,7 +419,8 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() same = true; Qt::BrushStyle bs = m_shapes_list.first()->brush().style(); - for (QetShapeItem *qsi : m_shapes_list) { + for (QetShapeItem* qsi : std::as_const(m_shapes_list)) + { if (qsi->brush().style() != bs) { same = false; break; @@ -426,7 +430,8 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() same = true; QColor bc = m_shapes_list.first()->brush().color(); - for (QetShapeItem *qsi : m_shapes_list) { + for (QetShapeItem* qsi : std::as_const(m_shapes_list)) + { if (qsi->brush().color() != bc) { same = false; break; @@ -516,7 +521,8 @@ void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() m_shape->setMovable(!ui->m_lock_pos_cb->isChecked()); } else if (!m_shapes_list.isEmpty()) { - for (QPointer qsi : m_shapes_list) { + for (const QPointer& qsi : std::as_const(m_shapes_list)) + { qsi->setMovable(!ui->m_lock_pos_cb->isChecked()); } } diff --git a/sources/undocommand/addelementtextcommand.cpp b/sources/undocommand/addelementtextcommand.cpp index 4e97f6ad1..cd20c0133 100644 --- a/sources/undocommand/addelementtextcommand.cpp +++ b/sources/undocommand/addelementtextcommand.cpp @@ -184,7 +184,7 @@ void AddTextsGroupCommand::redo() } else { - for(DynamicElementTextItem *deti : m_deti_list) + for (DynamicElementTextItem* deti : std::as_const(m_deti_list)) m_element.data()->addTextToGroup( deti, m_group.data()); @@ -194,7 +194,7 @@ void AddTextsGroupCommand::redo() else if(m_group) { m_element.data()->addTextGroup(m_group.data()); - for(DynamicElementTextItem *deti : m_deti_list) + for (DynamicElementTextItem* deti : std::as_const(m_deti_list)) m_element.data()->addTextToGroup(deti, m_group.data()); } } @@ -236,8 +236,9 @@ void RemoveTextsGroupCommand::undo() if(m_element && m_group) { m_element.data()->addTextGroup(m_group.data()); - - for(const QPointer& p : m_text_list) + + for (const QPointer& p : + std::as_const(m_text_list)) if(p) m_element.data()->addTextToGroup( p.data(), @@ -252,7 +253,8 @@ void RemoveTextsGroupCommand::redo() { if(m_element && m_group) { - for(const QPointer& p : m_text_list) + for (const QPointer& p : + std::as_const(m_text_list)) if(p) m_element.data()->removeTextFromGroup( p.data(), diff --git a/sources/undocommand/changeelementinformationcommand.cpp b/sources/undocommand/changeelementinformationcommand.cpp index 728369a31..c6eb839e6 100644 --- a/sources/undocommand/changeelementinformationcommand.cpp +++ b/sources/undocommand/changeelementinformationcommand.cpp @@ -60,7 +60,8 @@ bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other) //In case of other undo_undo have the same elements as keys if (m_map.size() == other_undo->m_map.size()) { - for (auto key : other_undo->m_map.keys()) { + for (const auto& key : other_undo->m_map.keys()) + { if (!m_map.keys().contains(key)) { return false; } @@ -69,12 +70,13 @@ bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other) //Other_undo will be merged with this undo : //Replace the new_info values of this m_map //by the new_info values of other_undo's m_map - for (auto key : other_undo->m_map.keys()) - { - m_map.insert(key, - qMakePair( - m_map.value(key).first, - other_undo->m_map.value(key).second)); + for (const auto& key : other_undo->m_map.keys()) + { + m_map.insert( + key, + qMakePair( + m_map.value(key).first, + other_undo->m_map.value(key).second)); } return true; } @@ -113,8 +115,7 @@ void ChangeElementInformationCommand::updateProjectDB() //need to have a list of element instead of QPointer //for the function elementInfoChange of the database QList list_; - for (auto p_elmt : m_map.keys()) - list_ << p_elmt.data(); + for (const auto& p_elmt : m_map.keys()) list_ << p_elmt.data(); elmt->diagram()->project()->dataBase()->elementInfoChanged(list_); } diff --git a/sources/undocommand/deleteqgraphicsitemcommand.cpp b/sources/undocommand/deleteqgraphicsitemcommand.cpp index 5aa85ca42..977f63ba3 100644 --- a/sources/undocommand/deleteqgraphicsitemcommand.cpp +++ b/sources/undocommand/deleteqgraphicsitemcommand.cpp @@ -55,7 +55,8 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand( //When removing a deti we must know its parent item, for re-adding deti as child of the parent //when undoing this command - for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts) + for (DynamicElementTextItem* deti : + std::as_const(m_removed_contents.m_element_texts)) { if(deti->parentGroup()) m_grp_texts_hash.insert(deti, deti->parentGroup()); @@ -73,7 +74,9 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand( } //The deletion of the groups is not managed by this undo, but by a RemoveTextsGroupCommand - for(ElementTextItemGroup *group : m_removed_contents.m_texts_groups) { + for (ElementTextItemGroup* group : + std::as_const(m_removed_contents.m_texts_groups)) + { new RemoveTextsGroupCommand(group->parentElement(), group, this); } @@ -81,7 +84,7 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand( setPotentialsOfRemovedElements(); //Get all linkeds table of removed table. - for (auto table : m_removed_contents.m_tables) + for (auto table : std::as_const(m_removed_contents.m_tables)) { //Table is already managed, jump to next loop if (m_table_scene_hash.keys().contains(table)) @@ -122,7 +125,7 @@ DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand() */ void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements() { - for (Element *elmt : m_removed_contents.m_elements) + for (Element* elmt : std::as_const(m_removed_contents.m_elements)) { //a list of terminals who have at least two conductors docked in. QList terminals_list; @@ -179,7 +182,8 @@ void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements() //If a conductor was already created between these two terminals //in this undo command, from another removed element, we do nothing bool exist_ = false; - for (QPair pair : m_connected_terminals) + for (QPair pair : + std::as_const(m_connected_terminals)) { if (pair.first == hub_terminal && pair.second == t) { exist_ = true; @@ -226,7 +230,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential( { QList conductor_list = terminal->conductors(); conductor_list.removeAll(conductor_to_exclude); - for(Conductor *c : conductor_list) + for (Conductor* c : std::as_const(conductor_list)) { Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1; if(!m_removed_contents.items(DiagramContent::Elements).contains(other_terminal->parentElement())) { @@ -234,7 +238,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential( } } //No one of direct conductor of terminal are docked to an element which is not removed - for(Conductor *c : conductor_list) + for (Conductor* c : std::as_const(conductor_list)) { Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1; Terminal *terminal_to_return = terminalInSamePotential(other_terminal, c); @@ -258,11 +262,12 @@ void DeleteQGraphicsItemCommand::undo() m_diagram->addItem(item); //We relink element after every element was added to diagram - for(Element *e : m_removed_contents.m_elements) + for (Element* e : std::as_const(m_removed_contents.m_elements)) for(Element *elmt : m_link_hash[e]) e->linkToElement(elmt); - for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts) + for (DynamicElementTextItem* deti : + std::as_const(m_removed_contents.m_element_texts)) { if(m_elmt_text_hash.keys().contains(deti)) m_elmt_text_hash.value(deti)->addDynamicTextItem(deti); @@ -307,14 +312,15 @@ void DeleteQGraphicsItemCommand::redo() } } - for(Element *e : m_removed_contents.m_elements) + for (Element* e : std::as_const(m_removed_contents.m_elements)) { //Get linked element, for relink it at undo if (!e->linkedElements().isEmpty()) m_link_hash.insert(e, e->linkedElements()); } - for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts) + for (DynamicElementTextItem* deti : + std::as_const(m_removed_contents.m_element_texts)) { if(deti->parentGroup() && deti->parentGroup()->parentElement()) deti->parentGroup()->parentElement()->removeTextFromGroup(deti, deti->parentGroup()); diff --git a/sources/undocommand/linkelementcommand.cpp b/sources/undocommand/linkelementcommand.cpp index c5e3d82a4..c3a9afe62 100644 --- a/sources/undocommand/linkelementcommand.cpp +++ b/sources/undocommand/linkelementcommand.cpp @@ -203,7 +203,7 @@ void LinkElementCommand::redo() QStringList str_txt; QStringList str_funct; QStringList str_tens; - for (const Conductor *c : c_list) + for (const Conductor* c : std::as_const(c_list)) { str_txt << c->properties().text; str_funct << c->properties().m_function; diff --git a/sources/undocommand/rotateselectioncommand.cpp b/sources/undocommand/rotateselectioncommand.cpp index bac35b594..60fb74e1f 100644 --- a/sources/undocommand/rotateselectioncommand.cpp +++ b/sources/undocommand/rotateselectioncommand.cpp @@ -74,8 +74,8 @@ m_diagram(diagram) break; } } - - for (QPropertyUndoCommand *undo : m_undo) + + for (QPropertyUndoCommand* undo : std::as_const(m_undo)) undo->setAnimated(true, false); } } @@ -87,8 +87,8 @@ void RotateSelectionCommand::undo() { m_diagram->showMe(); QUndoCommand::undo(); - - for(const QPointer& cti : m_cond_text) + + for (const QPointer& cti : std::as_const(m_cond_text)) { cti->forceRotateByUser(m_rotate_by_user.value(cti.data())); if(!cti->wasRotateByUser()) @@ -103,11 +103,11 @@ void RotateSelectionCommand::redo() { m_diagram->showMe(); QUndoCommand::redo(); - - for(const QPointer& cti : m_cond_text) - { - m_rotate_by_user.insert(cti, cti->wasRotateByUser()); - cti->forceRotateByUser(true); + + for (const QPointer& cti : std::as_const(m_cond_text)) + { + m_rotate_by_user.insert(cti, cti->wasRotateByUser()); + cti->forceRotateByUser(true); } } diff --git a/sources/undocommand/rotatetextscommand.cpp b/sources/undocommand/rotatetextscommand.cpp index c06a4f35c..070a4d795 100644 --- a/sources/undocommand/rotatetextscommand.cpp +++ b/sources/undocommand/rotatetextscommand.cpp @@ -69,10 +69,10 @@ m_diagram(diagram) } if(!text.isNull()) setText(text); - - for(DiagramTextItem *dti : texts_list) + + for (DiagramTextItem* dti : std::as_const(texts_list)) setupAnimation(dti, "rotation", dti->rotation(), m_rotation); - for(ElementTextItemGroup *grp : groups_list) + for (ElementTextItemGroup* grp : std::as_const(groups_list)) setupAnimation(grp, "rotation", grp->rotation(), m_rotation); } else diff --git a/sources/utils/conductorcreator.cpp b/sources/utils/conductorcreator.cpp index 2bacc1f4f..774a6804b 100644 --- a/sources/utils/conductorcreator.cpp +++ b/sources/utils/conductorcreator.cpp @@ -49,7 +49,7 @@ ConductorCreator::ConductorCreator(Diagram *d, QList terminals_list) d->undoStack().beginMacro(QObject::tr("Création de conducteurs")); QList c_list; - for (Terminal *t : m_terminals_list) + for (Terminal* t : std::as_const(m_terminals_list)) { if (t == hub_terminal) { continue; @@ -108,12 +108,14 @@ void ConductorCreator::setUpPropertieToUse() if (potentials.size() >= 2) { QList cp_list; - for(Conductor *c : potentials) { + for (Conductor* c : std::as_const(potentials)) + { cp_list.append(c->properties()); } - + m_properties = PotentialSelectorDialog::chosenProperties(cp_list); - for (Conductor *c : potentials) { + for (Conductor* c : std::as_const(potentials)) + { if (c->properties() == m_properties) { m_sequential_number = c->sequenceNum(); } @@ -141,8 +143,8 @@ QList ConductorCreator::existingPotential() { QList c_list; QList t_exclude; - - for (Terminal *t : m_terminals_list) + + for (Terminal* t : std::as_const(m_terminals_list)) { if (t_exclude.contains(t)) { continue; @@ -182,8 +184,8 @@ QList ConductorCreator::existingPotential() Terminal *ConductorCreator::hubTerminal() { Terminal *hub_terminal = m_terminals_list.first(); - - for (Terminal *tt : m_terminals_list) + + for (Terminal* tt : std::as_const(m_terminals_list)) { if (tt->scenePos().x() < hub_terminal->scenePos().x()) { hub_terminal = tt;