Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Update qAsConst to std::as_const
Dmitry Kazakov3924c43b6a2d
diff --git a/libs/widgets/KisVisualColorSelector.cpp b/libs/widgets/KisVisualColorSelector.cppindex 1afa323c34..cdbe5f07e1 100644--- a/libs/widgets/KisVisualColorSelector.cpp+++ b/libs/widgets/KisVisualColorSelector.cpp@@ -137,7 +137,7 @@ void KisVisualColorSelector::setConfiguration(const KisColorSelectorConfiguratiovoid KisVisualColorSelector::setAcceptTabletEvents(bool on){m_d->acceptTabletEvents = on;- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->setAcceptTabletEvents(on);}}@@ -173,7 +173,7 @@ void KisVisualColorSelector::setRenderMode(KisVisualColorSelector::RenderMode mo{if (mode != m_d->renderMode) {m_d->renderMode = mode;- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->forceImageUpdate();shape->update();}@@ -199,7 +199,7 @@ void KisVisualColorSelector::setProofColors(bool enabled){if (enabled != m_d->proofColors) {m_d->proofColors = enabled;- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->forceImageUpdate();shape->update();}@@ -262,7 +262,7 @@ void KisVisualColorSelector::slotGamutMaskChanged(KoGamutMaskSP mask)// Note: KisCanvasResourceProvider currently does not distinguish// between activating, switching and property changes of a gamut maskm_d->gamutMask = mask;- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->updateGamutMask();}}@@ -270,7 +270,7 @@ void KisVisualColorSelector::slotGamutMaskChanged(KoGamutMaskSP mask)void KisVisualColorSelector::slotGamutMaskUnset(){m_d->gamutMask.clear();- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->updateGamutMask();}}@@ -278,7 +278,7 @@ void KisVisualColorSelector::slotGamutMaskUnset()void KisVisualColorSelector::slotGamutMaskPreviewUpdate(){// Shapes currently always requests preview shapes if available, so more of the same...- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->updateGamutMask();}}@@ -290,7 +290,7 @@ void KisVisualColorSelector::slotChannelValuesChanged(const QVector4D &values, qreturn;}m_d->channelValues = values;- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->setChannelValues(m_d->channelValues, channelFlags);}}@@ -325,7 +325,7 @@ void KisVisualColorSelector::slotCursorMoved(QPointF pos)m_d->channelValues[shape->channel(1)] = pos.y();}- for (KisVisualColorSelectorShape *widget : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *widget : std::as_const(m_d->widgetlist)) {if (widget != shape){widget->setChannelValues(m_d->channelValues, shape->channelMask());}@@ -339,7 +339,7 @@ void KisVisualColorSelector::slotDisplayConfigurationChanged()m_d->selectorModel->setMaxChannelValues(calculateMaxChannelValues());}// TODO: can we be smarter about forced updates?- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->forceImageUpdate();shape->update();}@@ -495,7 +495,7 @@ void KisVisualColorSelector::rebuildSelector()// make sure we call "our" resize functionKisVisualColorSelector::resizeEvent(0);- for (KisVisualColorSelectorShape *shape : qAsConst(m_d->widgetlist)) {+ for (KisVisualColorSelectorShape *shape : std::as_const(m_d->widgetlist)) {shape->setAcceptTabletEvents(m_d->acceptTabletEvents);// if this widget is currently visible, new children are hidden by defaultshape->show();diff --git a/libs/widgetutils/KisWrappableHBoxLayout.cpp b/libs/widgetutils/KisWrappableHBoxLayout.cppindex 117175e4d0..309f831436 100644--- a/libs/widgetutils/KisWrappableHBoxLayout.cpp+++ b/libs/widgetutils/KisWrappableHBoxLayout.cpp@@ -45,7 +45,7 @@ QSize KisWrappableHBoxLayout::minimumSize() constconst QSize marginsSize = QSize(margins.left() + margins.right(), margins.top() + margins.bottom());QSize size;- for (const QLayoutItem *item : qAsConst(m_items))+ for (const QLayoutItem *item : std::as_const(m_items))size = size.expandedTo(item->minimumSize());if (!geometry().isEmpty()) {@@ -104,7 +104,7 @@ int KisWrappableHBoxLayout::doLayout(const QRect &rect, bool testOnly) constint y = effectiveRect.y();int lineHeight = 0;- for (QLayoutItem *item : qAsConst(m_items)) {+ for (QLayoutItem *item : std::as_const(m_items)) {int nextX = x + item->sizeHint().width() + spacing();if (nextX - spacing() > effectiveRect.right() && lineHeight > 0) {x = effectiveRect.x();diff --git a/libs/widgetutils/commandmodel.cpp b/libs/widgetutils/commandmodel.cppindex abc6e8f0dc..adbab8fd35 100644--- a/libs/widgetutils/commandmodel.cpp+++ b/libs/widgetutils/commandmodel.cpp@@ -18,7 +18,7 @@ void CommandModel::refresh(QVector<QPair<QString, QAction *>> actionList){QVector<Item> temp;temp.reserve(actionList.size());- for (const auto &action : qAsConst(actionList)) {+ for (const auto &action : std::as_const(actionList)) {temp.push_back({action.first, action.second, 0});}diff --git a/libs/widgetutils/katecommandbar.cpp b/libs/widgetutils/katecommandbar.cppindex 98d117bc10..d085b6be30 100644--- a/libs/widgetutils/katecommandbar.cpp+++ b/libs/widgetutils/katecommandbar.cpp@@ -387,7 +387,7 @@ void KateCommandBar::slotReturnPressed()menuActions = menu->actions();}- for (auto menuAction : qAsConst(menuActions)) {+ for (auto menuAction : std::as_const(menuActions)) {if (menuAction) {list.append({KLocalizedString::removeAcceleratorMarker(act->text()), menuAction});}diff --git a/plugins/dockers/widegamutcolorselector/WGColorSelectorSettings.cpp b/plugins/dockers/widegamutcolorselector/WGColorSelectorSettings.cppindex 6a36e10f6d..df3bd9c465 100644--- a/plugins/dockers/widegamutcolorselector/WGColorSelectorSettings.cpp+++ b/plugins/dockers/widegamutcolorselector/WGColorSelectorSettings.cpp@@ -157,7 +157,7 @@ void WGColorSelectorSettings::loadPreferencesImpl(bool defaults)// Generalm_ui->grpQuickSettingsMenu->setChecked(cfg.get(WGConfig::quickSettingsEnabled, defaults));QVector<KisColorSelectorConfiguration> favoriteConfigs = cfg.favoriteConfigurations(defaults);- for (const KisColorSelectorConfiguration &fav : qAsConst(favoriteConfigs)) {+ for (const KisColorSelectorConfiguration &fav : std::as_const(favoriteConfigs)) {m_favoriteConfigGrid->setChecked(fav);}m_ui->cmbSelectionColorSpace->setCurrentIndex(cfg.get(WGConfig::colorSpaceSource, defaults));diff --git a/plugins/dockers/widegamutcolorselector/WGCommonColorSet.cpp b/plugins/dockers/widegamutcolorselector/WGCommonColorSet.cppindex efe2f3fb97..6bbb149e98 100644--- a/plugins/dockers/widegamutcolorselector/WGCommonColorSet.cpp+++ b/plugins/dockers/widegamutcolorselector/WGCommonColorSet.cpp@@ -76,7 +76,7 @@ void WGCommonColorSet::slotCalculationDone()blockSignals(true);clear();- for (const KoColor &color : qAsConst(*m_commonColors)) {+ for (const KoColor &color : std::as_const(*m_commonColors)) {addColor(color);}diff --git a/plugins/dockers/widegamutcolorselector/WGConfig.cpp b/plugins/dockers/widegamutcolorselector/WGConfig.cppindex 0b62dcdd20..08163b70d3 100644--- a/plugins/dockers/widegamutcolorselector/WGConfig.cpp+++ b/plugins/dockers/widegamutcolorselector/WGConfig.cpp@@ -117,7 +117,7 @@ QVector<ShadeLine> WGConfig::shadeSelectorLines(bool defaultValue) const}QVector<ShadeLine> shadeLines;QStringList shadeLineList(configString.split('|'));- for (const QString &line: qAsConst(shadeLineList)) {+ for (const QString &line: std::as_const(shadeLineList)) {QVector4D gradient, offset;int patchCount = -1;QStringList values = line.split(';');diff --git a/plugins/dockers/widegamutcolorselector/WGShadeSelector.cpp b/plugins/dockers/widegamutcolorselector/WGShadeSelector.cppindex 89af70da3e..367728a8f9 100644--- a/plugins/dockers/widegamutcolorselector/WGShadeSelector.cpp+++ b/plugins/dockers/widegamutcolorselector/WGShadeSelector.cpp@@ -31,7 +31,7 @@ void WGShadeSelector::setModel(KisVisualColorModelSP colorModel)disconnect(m_model.data());}m_model = colorModel;- for (WGShadeSlider *slider : qAsConst(m_sliders)) {+ for (WGShadeSlider *slider : std::as_const(m_sliders)) {slider->setModel(m_model);}connectToModel();@@ -76,7 +76,7 @@ void WGShadeSelector::updateSettings()void WGShadeSelector::mousePressEvent(QMouseEvent *event){if (m_resetOnRightClick && event->button() == Qt::RightButton) {- for (WGShadeSlider* slider : qAsConst(m_sliders)) {+ for (WGShadeSlider* slider : std::as_const(m_sliders)) {slider->slotSetChannelValues(m_model->channelValues());}}@@ -95,7 +95,7 @@ void WGShadeSelector::connectToModel()void WGShadeSelector::slotChannelValuesChanged(const QVector4D &values){if (m_allowUpdates && (m_resetOnExternalUpdate || !m_initialized)) {- for (WGShadeSlider* slider : qAsConst(m_sliders)) {+ for (WGShadeSlider* slider : std::as_const(m_sliders)) {slider->slotSetChannelValues(values);}m_initialized = true;@@ -113,7 +113,7 @@ void WGShadeSelector::slotSliderInteraction(bool active){if (active) {const WGShadeSlider* activeLine = qobject_cast<WGShadeSlider*>(sender());- for (WGShadeSlider* slider : qAsConst(m_sliders)) {+ for (WGShadeSlider* slider : std::as_const(m_sliders)) {if (slider != activeLine) {slider->resetHandle();}@@ -129,7 +129,7 @@ void WGShadeSelector::slotSliderInteraction(bool active)else {// reset slider base values if configured for automatic resetif (m_resetOnInteractions) {- for (WGShadeSlider* slider : qAsConst(m_sliders)) {+ for (WGShadeSlider* slider : std::as_const(m_sliders)) {slider->slotSetChannelValues(m_model->channelValues());}}