forked from qt-creator/qt-creator
Libs: Use qAsConst with non-const Qt containers in range-loops
Change-Id: I00d9f7c1634bbb62191470d58158e1fd150533c0 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -406,7 +406,7 @@ namespace ADS
|
||||
{
|
||||
DockWidget* dockWidget = d->m_tabBar->currentTab()->dockWidget();
|
||||
if (!d->m_dockWidgetActionsButtons.isEmpty()) {
|
||||
for (auto button : d->m_dockWidgetActionsButtons) {
|
||||
for (auto button : qAsConst(d->m_dockWidgetActionsButtons)) {
|
||||
d->m_layout->removeWidget(button);
|
||||
delete button;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace ADS
|
||||
return;
|
||||
|
||||
m_visibleDockAreaCount = 0;
|
||||
for (auto dockArea : m_dockAreas)
|
||||
for (auto dockArea : qAsConst(m_dockAreas))
|
||||
m_visibleDockAreaCount += dockArea->isHidden() ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -1146,7 +1146,7 @@ namespace ADS
|
||||
|
||||
DockAreaWidget *DockContainerWidget::dockAreaAt(const QPoint &globalPosition) const
|
||||
{
|
||||
for (auto dockArea : d->m_dockAreas) {
|
||||
for (auto dockArea : qAsConst(d->m_dockAreas)) {
|
||||
if (dockArea->isVisible()
|
||||
&& dockArea->rect().contains(dockArea->mapFromGlobal(globalPosition)))
|
||||
return dockArea;
|
||||
@@ -1167,7 +1167,7 @@ namespace ADS
|
||||
int DockContainerWidget::visibleDockAreaCount() const
|
||||
{
|
||||
int result = 0;
|
||||
for (auto dockArea : d->m_dockAreas)
|
||||
for (auto dockArea : qAsConst(d->m_dockAreas))
|
||||
result += dockArea->isHidden() ? 0 : 1;
|
||||
|
||||
return result;
|
||||
@@ -1257,7 +1257,7 @@ namespace ADS
|
||||
QList<DockAreaWidget *> DockContainerWidget::openedDockAreas() const
|
||||
{
|
||||
QList<DockAreaWidget *> result;
|
||||
for (auto dockArea : d->m_dockAreas) {
|
||||
for (auto dockArea : qAsConst(d->m_dockAreas)) {
|
||||
if (!dockArea->isHidden())
|
||||
result.append(dockArea);
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ namespace ADS
|
||||
QList<DockWidget *> DockContainerWidget::dockWidgets() const
|
||||
{
|
||||
QList<DockWidget *> result;
|
||||
for (const auto dockArea : d->m_dockAreas)
|
||||
for (const auto dockArea : qAsConst(d->m_dockAreas))
|
||||
result.append(dockArea->dockWidgets());
|
||||
|
||||
return result;
|
||||
@@ -1406,7 +1406,7 @@ namespace ADS
|
||||
DockWidget::DockWidgetFeatures DockContainerWidget::features() const
|
||||
{
|
||||
DockWidget::DockWidgetFeatures features(DockWidget::AllDockWidgetFeatures);
|
||||
for (const auto dockArea : d->m_dockAreas)
|
||||
for (const auto dockArea : qAsConst(d->m_dockAreas))
|
||||
features &= dockArea->features();
|
||||
|
||||
return features;
|
||||
@@ -1419,7 +1419,7 @@ namespace ADS
|
||||
|
||||
void DockContainerWidget::closeOtherAreas(DockAreaWidget *keepOpenArea)
|
||||
{
|
||||
for (const auto dockArea : d->m_dockAreas) {
|
||||
for (const auto dockArea : qAsConst(d->m_dockAreas)) {
|
||||
if (dockArea == keepOpenArea)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace ADS
|
||||
// function are invisible to the user now and have no assigned dock area
|
||||
// They do not belong to any dock container, until the user toggles the
|
||||
// toggle view action the next time
|
||||
for (auto dockWidget : m_dockWidgetsMap) {
|
||||
for (auto dockWidget : qAsConst(m_dockWidgetsMap)) {
|
||||
if (dockWidget->property(internal::dirtyProperty).toBool()) {
|
||||
dockWidget->flagAsUnassigned();
|
||||
emit dockWidget->viewToggled(false);
|
||||
@@ -264,7 +264,7 @@ namespace ADS
|
||||
// The dock areas because the previous toggleView() action has changed
|
||||
// the dock area index
|
||||
int count = 0;
|
||||
for (auto dockContainer : m_containers) {
|
||||
for (auto dockContainer : qAsConst(m_containers)) {
|
||||
count++;
|
||||
for (int i = 0; i < dockContainer->dockAreaCount(); ++i) {
|
||||
DockAreaWidget *dockArea = dockContainer->dockArea(i);
|
||||
@@ -290,7 +290,7 @@ namespace ADS
|
||||
{
|
||||
// Finally we need to send the topLevelChanged() signals for all dock
|
||||
// widgets if top level changed
|
||||
for (auto dockContainer : m_containers) {
|
||||
for (auto dockContainer : qAsConst(m_containers)) {
|
||||
DockWidget *topLevelDockWidget = dockContainer->topLevelDockWidget();
|
||||
if (topLevelDockWidget) {
|
||||
topLevelDockWidget->emitTopLevelChanged(true);
|
||||
@@ -357,7 +357,7 @@ namespace ADS
|
||||
save();
|
||||
saveStartupWorkspace();
|
||||
|
||||
for (auto floatingWidget : d->m_floatingWidgets) {
|
||||
for (auto floatingWidget : qAsConst(d->m_floatingWidgets)) {
|
||||
/* There have been crashes with partially destructed widgets in
|
||||
m_floatingWidgets. Those do not have a parent. */
|
||||
if (floatingWidget && floatingWidget->parent() == this)
|
||||
@@ -507,7 +507,7 @@ namespace ADS
|
||||
stream.writeAttribute("version", QString::number(CurrentVersion));
|
||||
stream.writeAttribute("userVersion", QString::number(version));
|
||||
stream.writeAttribute("containers", QString::number(d->m_containers.count()));
|
||||
for (auto container : d->m_containers)
|
||||
for (auto container : qAsConst(d->m_containers))
|
||||
container->saveState(stream);
|
||||
|
||||
stream.writeEndElement();
|
||||
@@ -551,7 +551,7 @@ namespace ADS
|
||||
if (d->m_uninitializedFloatingWidgets.empty())
|
||||
return;
|
||||
|
||||
for (auto floatingWidget : d->m_uninitializedFloatingWidgets)
|
||||
for (auto floatingWidget : qAsConst(d->m_uninitializedFloatingWidgets))
|
||||
floatingWidget->show();
|
||||
|
||||
d->m_uninitializedFloatingWidgets.clear();
|
||||
|
||||
@@ -624,7 +624,7 @@ namespace ADS {
|
||||
if (windowHandle()->devicePixelRatio() == d->m_lastDevicePixelRatio) // TODO
|
||||
return;
|
||||
|
||||
for (auto widget : d->m_dropIndicatorWidgets)
|
||||
for (auto widget : qAsConst(d->m_dropIndicatorWidgets))
|
||||
d->updateDropIndicatorIcon(widget);
|
||||
|
||||
d->m_lastDevicePixelRatio = devicePixelRatioF();
|
||||
|
||||
@@ -829,7 +829,7 @@ void DiagramSceneModel::onEndRemoveElement(int row, const MDiagram *diagram)
|
||||
Q_UNUSED(diagram)
|
||||
QMT_CHECK(m_busyState == RemoveElement);
|
||||
// update elements from store (see above)
|
||||
for (const Uid &end_uid : m_relationEndsUid) {
|
||||
for (const Uid &end_uid : qAsConst(m_relationEndsUid)) {
|
||||
DElement *dEnd = m_diagramController->findElement(end_uid, diagram);
|
||||
if (dEnd)
|
||||
updateGraphicsItem(graphicsItem(dEnd), dEnd);
|
||||
|
||||
@@ -1220,7 +1220,7 @@ void ModelManagerInterface::updateImportPaths()
|
||||
QSet<QString> newLibraries;
|
||||
for (const Document::Ptr &doc : qAsConst(snapshot))
|
||||
findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths, &newLibraries);
|
||||
for (const QString &path : allApplicationDirectories)
|
||||
for (const QString &path : qAsConst(allApplicationDirectories))
|
||||
findNewQmlApplicationInPath(path, snapshot, this, &newLibraries);
|
||||
|
||||
updateSourceFiles(importedFiles, true);
|
||||
|
||||
@@ -162,7 +162,7 @@ void SftpTransfer::doStart()
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const FileToTransfer &f : d->files) {
|
||||
for (const FileToTransfer &f : qAsConst(d->files)) {
|
||||
QString sourceFileOrLinkTarget = f.sourceFile;
|
||||
bool link = false;
|
||||
if (d->transferType == Internal::FileTransferType::Upload) {
|
||||
|
||||
@@ -1580,7 +1580,7 @@ void AspectContainer::addAspectHelper(BaseAspect *aspect)
|
||||
*/
|
||||
void AspectContainer::addToLayout(LayoutBuilder &builder)
|
||||
{
|
||||
for (BaseAspect *aspect : d->m_items) {
|
||||
for (BaseAspect *aspect : qAsConst(d->m_items)) {
|
||||
if (aspect->isVisible())
|
||||
aspect->addToLayout(builder);
|
||||
}
|
||||
@@ -1591,7 +1591,7 @@ void AspectContainer::addToLayout(LayoutBuilder &builder)
|
||||
*/
|
||||
void AspectContainer::fromMap(const QVariantMap &map)
|
||||
{
|
||||
for (BaseAspect *aspect : d->m_items)
|
||||
for (BaseAspect *aspect : qAsConst(d->m_items))
|
||||
aspect->fromMap(map);
|
||||
}
|
||||
|
||||
@@ -1600,7 +1600,7 @@ void AspectContainer::fromMap(const QVariantMap &map)
|
||||
*/
|
||||
void AspectContainer::toMap(QVariantMap &map) const
|
||||
{
|
||||
for (BaseAspect *aspect : d->m_items)
|
||||
for (BaseAspect *aspect : qAsConst(d->m_items))
|
||||
aspect->toMap(map);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,14 +89,13 @@ static QList<Diff> decode(const QList<Diff> &diffList, const QStringList &lines)
|
||||
{
|
||||
QList<Diff> newDiffList;
|
||||
newDiffList.reserve(diffList.count());
|
||||
for (Diff diff : diffList) {
|
||||
for (const Diff &diff : diffList) {
|
||||
QString text;
|
||||
for (QChar c : diff.text) {
|
||||
const int idx = static_cast<ushort>(c.unicode());
|
||||
text += lines.value(idx);
|
||||
}
|
||||
diff.text = text;
|
||||
newDiffList.append(diff);
|
||||
newDiffList.append({diff.command, text});
|
||||
}
|
||||
return newDiffList;
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ void FileSystemWatcher::slotDirectoryChanged(const QString &path)
|
||||
toReadd.removeOne(rejected);
|
||||
|
||||
// If we've successfully added the file, that means it was deleted and replaced.
|
||||
for (const QString &reAdded : toReadd)
|
||||
for (const QString &reAdded : qAsConst(toReadd))
|
||||
d->fileChanged(reAdded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ void InfoBarDisplay::infoBarDestroyed()
|
||||
|
||||
void InfoBarDisplay::update()
|
||||
{
|
||||
for (QWidget *widget : m_infoWidgets) {
|
||||
for (QWidget *widget : qAsConst(m_infoWidgets)) {
|
||||
widget->disconnect(this); // We want no destroyed() signal now
|
||||
delete widget;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ void InfoBarDisplay::update()
|
||||
if (!m_infoBar)
|
||||
return;
|
||||
|
||||
for (const InfoBarEntry &info : m_infoBar->m_infoBarEntries) {
|
||||
for (const InfoBarEntry &info : qAsConst(m_infoBar->m_infoBarEntries)) {
|
||||
auto infoWidget = new InfoBarWidget(m_edge);
|
||||
|
||||
auto hbox = new QHBoxLayout;
|
||||
|
||||
@@ -363,7 +363,7 @@ QStringList MimeType::suffixes() const
|
||||
MimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
|
||||
|
||||
QStringList result;
|
||||
for (const QString &pattern : d->globPatterns) {
|
||||
for (const QString &pattern : qAsConst(d->globPatterns)) {
|
||||
const QString suffix = suffixFromPattern(pattern);
|
||||
if (!suffix.isEmpty())
|
||||
result.append(suffix);
|
||||
|
||||
@@ -164,7 +164,7 @@ bool PortList::hasMore() const { return !d->ranges.isEmpty(); }
|
||||
|
||||
bool PortList::contains(Port port) const
|
||||
{
|
||||
for (const Internal::Range &r : d->ranges) {
|
||||
for (const Internal::Range &r : qAsConst(d->ranges)) {
|
||||
if (port >= r.first && port <= r.second)
|
||||
return true;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ bool PortList::contains(Port port) const
|
||||
int PortList::count() const
|
||||
{
|
||||
int n = 0;
|
||||
for (const Internal::Range &r : d->ranges)
|
||||
for (const Internal::Range &r : qAsConst(d->ranges))
|
||||
n += r.second.number() - r.first.number() + 1;
|
||||
return n;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ Port PortList::getNext()
|
||||
QString PortList::toString() const
|
||||
{
|
||||
QString stringRep;
|
||||
for (const Internal::Range &range : d->ranges) {
|
||||
for (const Internal::Range &range : qAsConst(d->ranges)) {
|
||||
stringRep += QString::number(range.first.number());
|
||||
if (range.second != range.first)
|
||||
stringRep += QLatin1Char('-') + QString::number(range.second.number());
|
||||
|
||||
Reference in New Issue
Block a user