Fixed deprecated qAsConst() to std::as_const()

This commit is contained in:
Magnus Hellströmer
2024-09-09 02:03:37 +02:00
parent 4827b23116
commit 25f9f14b04
18 changed files with 47 additions and 47 deletions

View File

@@ -203,7 +203,7 @@ void TerminalStripDrawer::paint(QPainter *painter)
painter->restore(); painter->restore();
//Draw the bridges //Draw the bridges
for (const auto &points_ : qAsConst(bridges_anchor_points)) for (const auto &points_ : std::as_const(bridges_anchor_points))
{ {
painter->save(); painter->save();
auto pen_{painter->pen()}; auto pen_{painter->pen()};

View File

@@ -126,7 +126,7 @@ void RemoveTerminalFromStripCommand::redo()
if (m_strip) if (m_strip)
{ {
QVector<QSharedPointer<RealTerminal>> real_t; QVector<QSharedPointer<RealTerminal>> real_t;
for (const auto &real_t_vector : qAsConst(m_terminals)) { for (const auto &real_t_vector : std::as_const(m_terminals)) {
real_t.append(real_t_vector); real_t.append(real_t_vector);
} }

View File

@@ -68,7 +68,7 @@ void UnGroupTerminalsCommand::undo()
m_terminal_strip->groupTerminals(key, m_physical_real_H.value(key)); m_terminal_strip->groupTerminals(key, m_physical_real_H.value(key));
} }
//Second, set level. //Second, set level.
for (const auto &pair : qAsConst(m_real_t_level)) { for (const auto &pair : std::as_const(m_real_t_level)) {
m_terminal_strip->setLevel(pair.first, pair.second); m_terminal_strip->setLevel(pair.first, pair.second);
} }
} }
@@ -78,7 +78,7 @@ void UnGroupTerminalsCommand::redo()
{ {
if (m_terminal_strip) if (m_terminal_strip)
{ {
for (const auto &value : qAsConst(m_physical_real_H)) { for (const auto &value : std::as_const(m_physical_real_H)) {
m_terminal_strip->unGroupTerminals(value); m_terminal_strip->unGroupTerminals(value);
} }
} }

View File

@@ -466,7 +466,7 @@ QSharedPointer<RealTerminal> TerminalStrip::realTerminalForUuid(const QUuid &uui
QVector<QSharedPointer<RealTerminal>> TerminalStrip::realTerminals() const QVector<QSharedPointer<RealTerminal>> TerminalStrip::realTerminals() const
{ {
QVector<QSharedPointer<RealTerminal>> vector_; QVector<QSharedPointer<RealTerminal>> vector_;
for (const auto &phy : qAsConst(m_physical_terminals)) { for (const auto &phy : std::as_const(m_physical_terminals)) {
vector_.append(phy->realTerminals()); vector_.append(phy->realTerminals());
} }
return vector_; return vector_;
@@ -856,7 +856,7 @@ QSharedPointer<TerminalStripBridge> TerminalStrip::isBridged(const QSharedPointe
{ {
if (real_terminal) if (real_terminal)
{ {
for (const auto &bridge_ : qAsConst(m_bridge)) { for (const auto &bridge_ : std::as_const(m_bridge)) {
if (bridge_->realTerminals().contains(real_terminal)) if (bridge_->realTerminals().contains(real_terminal))
return bridge_; return bridge_;
} }
@@ -983,7 +983,7 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
} }
root_elmt.appendChild(xml_layout); root_elmt.appendChild(xml_layout);
for (const auto &bridge_ : qAsConst(m_bridge)) { for (const auto &bridge_ : std::as_const(m_bridge)) {
root_elmt.appendChild(bridge_->toXml(parent_document)); root_elmt.appendChild(bridge_->toXml(parent_document));
} }
@@ -1024,7 +1024,7 @@ bool TerminalStrip::fromXml(QDomElement &xml_element)
for (auto &xml_real : QETXML::findInDomElement(xml_physical, RealTerminal::xmlTagName())) for (auto &xml_real : QETXML::findInDomElement(xml_physical, RealTerminal::xmlTagName()))
{ {
const auto uuid_ = QUuid(xml_real.attribute(QStringLiteral("element_uuid"))); const auto uuid_ = QUuid(xml_real.attribute(QStringLiteral("element_uuid")));
for (auto terminal_elmt : qAsConst(free_terminals)) for (auto terminal_elmt : std::as_const(free_terminals))
{ {
if (terminal_elmt->uuid() == uuid_) if (terminal_elmt->uuid() == uuid_)
{ {

View File

@@ -85,7 +85,7 @@ QDomElement TerminalStripBridge::toXml(QDomDocument &parent_document) const
root_elmt.setAttribute(QStringLiteral("color"), m_color.name()); root_elmt.setAttribute(QStringLiteral("color"), m_color.name());
auto terminals_elmt = parent_document.createElement(QStringLiteral("real_terminals")); auto terminals_elmt = parent_document.createElement(QStringLiteral("real_terminals"));
for (const auto &real_t : qAsConst(m_real_terminals)) for (const auto &real_t : std::as_const(m_real_terminals))
{ {
if (real_t) if (real_t)
{ {

View File

@@ -535,7 +535,7 @@ modelRealTerminalData TerminalStripModel::dataAtRow(int row) const
else else
{ {
auto current_row = 0; auto current_row = 0;
for (const auto &physical_data : qAsConst(m_physical_data)) for (const auto &physical_data : std::as_const(m_physical_data))
{ {
for (const auto &real_data : physical_data.real_data) for (const auto &real_data : physical_data.real_data)
{ {
@@ -567,7 +567,7 @@ void TerminalStripModel::replaceDataAtRow(modelRealTerminalData data, int row)
auto current_row = 0; auto current_row = 0;
auto current_physical = 0; auto current_physical = 0;
for (const auto &physical_data : qAsConst(m_physical_data)) for (const auto &physical_data : std::as_const(m_physical_data))
{ {
auto current_real = 0; auto current_real = 0;
for (int i=0 ; i<physical_data.real_data.count() ; ++i) for (int i=0 ; i<physical_data.real_data.count() ; ++i)
@@ -606,7 +606,7 @@ modelPhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) con
int current_phy = -1; int current_phy = -1;
bool match_ = false; bool match_ = false;
for (const auto &ptd_ : qAsConst(m_physical_data)) for (const auto &ptd_ : std::as_const(m_physical_data))
{ {
current_checked_index += ptd_.real_data.size(); current_checked_index += ptd_.real_data.size();
++current_phy; ++current_phy;
@@ -637,9 +637,9 @@ modelRealTerminalData TerminalStripModel::realDataAtIndex(int index) const
int current_checked_index = -1; int current_checked_index = -1;
for (const auto & ptd_ : qAsConst(m_physical_data)) for (const auto & ptd_ : std::as_const(m_physical_data))
{ {
for (const auto & rtd_ : qAsConst(ptd_.real_data)) { for (const auto & rtd_ : std::as_const(ptd_.real_data)) {
++current_checked_index; ++current_checked_index;
if (current_checked_index == index) { if (current_checked_index == index) {
return rtd_; return rtd_;

View File

@@ -60,7 +60,7 @@ void TerminalStripTreeDockWidget::reload()
m_uuid_terminal_H.clear(); m_uuid_terminal_H.clear();
m_uuid_strip_H.clear(); m_uuid_strip_H.clear();
for (const auto &connection_ : qAsConst(m_strip_changed_connection)) { for (const auto &connection_ : std::as_const(m_strip_changed_connection)) {
disconnect(connection_); disconnect(connection_);
} }
m_strip_changed_connection.clear(); m_strip_changed_connection.clear();
@@ -222,7 +222,7 @@ void TerminalStripTreeDockWidget::buildTree()
return a->name() < b->name(); return a->name() < b->name();
}); });
for (const auto &ts : qAsConst(ts_vector)) { for (const auto &ts : std::as_const(ts_vector)) {
addTerminalStrip(ts); addTerminalStrip(ts);
} }
addFreeTerminal(); addFreeTerminal();
@@ -324,7 +324,7 @@ void TerminalStripTreeDockWidget::addFreeTerminal()
auto free_terminal_item = ui->m_tree_view->topLevelItem(1); auto free_terminal_item = ui->m_tree_view->topLevelItem(1);
for (const auto terminal : qAsConst(vector_)) for (const auto terminal : std::as_const(vector_))
{ {
QUuid uuid_ = terminal->uuid(); QUuid uuid_ = terminal->uuid();
QStringList strl{terminal->actualLabel()}; QStringList strl{terminal->actualLabel()};

View File

@@ -151,7 +151,7 @@ Diagram::~Diagram()
continue; continue;
deletable_items.append(qgi); deletable_items.append(qgi);
} }
for (const auto &item : qAsConst(deletable_items)) for (const auto &item : std::as_const(deletable_items))
{ {
removeItem(item); removeItem(item);
delete item; delete item;
@@ -1453,13 +1453,13 @@ bool Diagram::fromXml(QDomElement &document,
if (position != QPointF()) if (position != QPointF())
{ {
QVector <QGraphicsItem *> added_items; QVector <QGraphicsItem *> added_items;
for (auto element : qAsConst(added_elements )) added_items << element; for (auto element : std::as_const(added_elements )) added_items << element;
for (auto cond : qAsConst(added_conductors )) added_items << cond; for (auto cond : std::as_const(added_conductors )) added_items << cond;
for (auto shape : qAsConst(added_shapes )) added_items << shape; for (auto shape : std::as_const(added_shapes )) added_items << shape;
for (auto text : qAsConst(added_texts )) added_items << text; for (auto text : std::as_const(added_texts )) added_items << text;
for (auto image : qAsConst(added_images )) added_items << image; for (auto image : std::as_const(added_images )) added_items << image;
for (auto table : qAsConst(added_tables )) added_items << table; for (auto table : std::as_const(added_tables )) added_items << table;
for (const auto &strip : qAsConst(added_strips)) added_items << strip; for (const auto &strip : std::as_const(added_strips)) added_items << strip;
//Get the top left corner of the rectangle that contain all added items //Get the top left corner of the rectangle that contain all added items
QRectF items_rect; QRectF items_rect;
@@ -1568,11 +1568,11 @@ void Diagram::refreshContents()
conductor->refreshText(); conductor->refreshText();
} }
for (auto &table : qAsConst(dc_.m_tables)) { for (auto &table : std::as_const(dc_.m_tables)) {
table->initLink(); table->initLink();
} }
for (auto &strip :qAsConst(dc_.m_terminal_strip)) { for (auto &strip :std::as_const(dc_.m_terminal_strip)) {
strip->refreshPending(); strip->refreshPending();
} }
} }
@@ -1757,7 +1757,7 @@ void Diagram::invertSelection()
item_list << item; item_list << item;
} }
} }
for (auto item : qAsConst(item_list)) { for (auto item : std::as_const(item_list)) {
item -> setSelected(!item -> isSelected()); item -> setSelected(!item -> isSelected());
} }

View File

@@ -55,7 +55,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
item_list = diagram->items(); item_list = diagram->items();
} }
for (const auto &item : qAsConst(item_list)) for (const auto &item : std::as_const(item_list))
{ {
switch (item->type()) switch (item->type())
{ {
@@ -391,10 +391,10 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi; if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi; if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi;
if (filter & Tables) for(auto qgi : m_tables) items_list << qgi; if (filter & Tables) for(auto qgi : m_tables) items_list << qgi;
if (filter & TerminalStrip) for(const auto qgi : qAsConst(m_terminal_strip)) items_list << qgi; if (filter & TerminalStrip) for(const auto qgi : std::as_const(m_terminal_strip)) items_list << qgi;
if (filter & SelectedOnly) { if (filter & SelectedOnly) {
for(const auto &qgi : qAsConst(items_list)) { for(const auto &qgi : std::as_const(items_list)) {
if (!qgi -> isSelected()) items_list.removeOne(qgi); if (!qgi -> isSelected()) items_list.removeOne(qgi);
} }
} }
@@ -420,7 +420,7 @@ int DiagramContent::count(int filter) const
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; } if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; } if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; } if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; }
if (filter & TerminalStrip) for(const auto &strip : qAsConst(m_terminal_strip)) {if (strip->isSelected()) ++ count;} if (filter & TerminalStrip) for(const auto &strip : std::as_const(m_terminal_strip)) {if (strip->isSelected()) ++ count;}
} }
else { else {
if (filter & Elements) count += m_elements.count(); if (filter & Elements) count += m_elements.count();

View File

@@ -1069,7 +1069,7 @@ void QETElementEditor::updateAction()
<< ui->m_revert_selection_action << ui->m_revert_selection_action
<< ui->m_paste_from_file_action << ui->m_paste_from_file_action
<< ui->m_paste_from_element_action; << ui->m_paste_from_element_action;
for (auto action : qAsConst(ro_list)) { for (auto action : std::as_const(ro_list)) {
action->setDisabled(m_read_only); action->setDisabled(m_read_only);
} }
@@ -1084,7 +1084,7 @@ void QETElementEditor::updateAction()
<< ui->m_flip_action << ui->m_flip_action
<< ui->m_mirror_action; << ui->m_mirror_action;
auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count(); auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count();
for (auto action : qAsConst(select_list)) { for (auto action : std::as_const(select_list)) {
action->setEnabled(items_selected); action->setEnabled(items_selected);
} }

View File

@@ -229,7 +229,7 @@ void TerminalEditor::activeConnections(bool active)
m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated), m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::typeEdited); this, &TerminalEditor::typeEdited);
} else { } else {
for (auto const & con : qAsConst(m_editor_connections)) { for (auto const & con : std::as_const(m_editor_connections)) {
QObject::disconnect(con); QObject::disconnect(con);
} }
m_editor_connections.clear(); m_editor_connections.clear();

View File

@@ -84,7 +84,7 @@ void TextEditor::setUpChangeConnection(QPointer<PartText> part)
void TextEditor::disconnectChangeConnection() void TextEditor::disconnectChangeConnection()
{ {
for (const auto &connection : qAsConst(m_change_connection)) { for (const auto &connection : std::as_const(m_change_connection)) {
disconnect(connection); disconnect(connection);
} }
m_change_connection.clear(); m_change_connection.clear();

View File

@@ -59,11 +59,11 @@ QVector <QPointer<Element>> ElementProvider::freeElement(ElementData::Types filt
QList<Element *> elmt_list; QList<Element *> elmt_list;
//search in all diagram //search in all diagram
for (const auto &diagram_ : qAsConst(m_diagram_list)) for (const auto &diagram_ : std::as_const(m_diagram_list))
{ {
//get all element in diagram d //get all element in diagram d
elmt_list = diagram_->elements(); elmt_list = diagram_->elements();
for (const auto &elmt_ : qAsConst(elmt_list)) for (const auto &elmt_ : std::as_const(elmt_list))
{ {
if (filter & elmt_->elementData().m_type && if (filter & elmt_->elementData().m_type &&
elmt_->isFree()) elmt_->isFree())
@@ -106,7 +106,7 @@ QList <Element *> ElementProvider::fromUuids(QList<QUuid> uuid_list) const
QVector<QPointer<Element>> ElementProvider::find(ElementData::Types elmt_type) const QVector<QPointer<Element>> ElementProvider::find(ElementData::Types elmt_type) const
{ {
QVector<QPointer<Element>> returned_vector; QVector<QPointer<Element>> returned_vector;
for (const auto &diagram_ : qAsConst(m_diagram_list)) for (const auto &diagram_ : std::as_const(m_diagram_list))
{ {
const auto elmt_list = diagram_->elements(); const auto elmt_list = diagram_->elements();
for (const auto &elmt_ : elmt_list) for (const auto &elmt_ : elmt_list)
@@ -198,7 +198,7 @@ QVector<TerminalElement *> ElementProvider::freeTerminal() const
{ {
QVector<TerminalElement *> vector_; QVector<TerminalElement *> vector_;
for (const auto &diagram : qAsConst(m_diagram_list)) for (const auto &diagram : std::as_const(m_diagram_list))
{ {
const auto elmt_list{diagram->elements()}; const auto elmt_list{diagram->elements()};

View File

@@ -594,7 +594,7 @@ void QetShapeItem::addHandler()
{ {
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector), QETUtils::graphicsHandlerSize(this)); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector), QETUtils::graphicsHandlerSize(this));
for(const auto handler : qAsConst(m_handler_vector)) for(const auto handler : std::as_const(m_handler_vector))
{ {
handler->setZValue(this->zValue()+1); handler->setZValue(this->zValue()+1);
handler->setColor(Qt::blue); handler->setColor(Qt::blue);

View File

@@ -2077,7 +2077,7 @@ void QETProject::updateDiagramsFolioData()
} }
} }
for (const auto &diagram_ : qAsConst(m_diagrams_list)) { for (const auto &diagram_ : std::as_const(m_diagrams_list)) {
diagram_->update(); diagram_->update();
} }
} }

View File

@@ -203,7 +203,7 @@ void ElementInfoWidget::buildInterface()
*/ */
ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &key) const ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &key) const
{ {
for (const auto &eipw : qAsConst(m_eipw_list)) for (const auto &eipw : std::as_const(m_eipw_list))
{ {
if (eipw->key() == key) if (eipw->key() == key)
return eipw; return eipw;
@@ -245,7 +245,7 @@ DiagramContext ElementInfoWidget::currentInfo() const
{ {
DiagramContext info_; DiagramContext info_;
for (const auto &eipw : qAsConst(m_eipw_list)) for (const auto &eipw : std::as_const(m_eipw_list))
{ {
//add value only if they're something to store //add value only if they're something to store

View File

@@ -504,7 +504,7 @@ void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
void ShapeGraphicsItemPropertiesWidget::clearEditConnection() void ShapeGraphicsItemPropertiesWidget::clearEditConnection()
{ {
for (const auto &c : qAsConst(m_edit_connection)) { for (const auto &c : std::as_const(m_edit_connection)) {
disconnect(c); disconnect(c);
} }
m_edit_connection.clear(); m_edit_connection.clear();

View File

@@ -139,7 +139,7 @@ void MoveGraphicsItemCommand::move(const QPointF &movement)
} }
//Move some conductors //Move some conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) { for (const auto &conductor : std::as_const(m_content.m_conductors_to_move)) {
setupAnimation(conductor, setupAnimation(conductor,
"pos", "pos",
conductor->pos(), conductor->pos(),
@@ -147,7 +147,7 @@ void MoveGraphicsItemCommand::move(const QPointF &movement)
} }
//Recalculate the path of other conductors //Recalculate the path of other conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) { for (const auto &conductor : std::as_const(m_content.m_conductors_to_update)) {
setupAnimation(conductor, "animPath", 1, 1); setupAnimation(conductor, "animPath", 1, 1);
} }
} }