diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-26 13:46:43 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-31 15:38:27 +0000 |
commit | 4ca6d6bfb0071aa03744e292f688ef69772a5a47 (patch) | |
tree | e044ed382b28e70c04e5faf3dc986f108fb3ae2b | |
parent | 8829f0044cd54f0a0357f5022a63969d37aa2648 (diff) | |
download | qttools-4ca6d6bfb0071aa03744e292f688ef69772a5a47.tar.gz |
Qt Designer: Remove use of Java-style map iterators
Use STL style iterators instead.
Change-Id: Id82546f667059c69521507f3a3b6b997de5cd6ba
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
11 files changed, 64 insertions, 107 deletions
diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index c412637d5..d45e1b9d3 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -273,9 +273,8 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory DomResourceIcon *ri = new DomResourceIcon; if (!theme.isEmpty()) ri->setAttributeTheme(theme); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPix(pixmaps); - while (itPix.hasNext()) { - const QIcon::Mode mode = itPix.next().key().first; + for (auto itPix = pixmaps.cbegin(), end = pixmaps.cend(); itPix != end; ++itPix) { + const QIcon::Mode mode = itPix.key().first; const QIcon::State state = itPix.key().second; DomResourcePixmap *rp = new DomResourcePixmap; const PropertySheetPixmapValue pix = itPix.value(); diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index bea345c9c..f4b1f5cfd 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -1379,9 +1379,8 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, qdesigner_internal::PropertySheetIconValue icon = m_iconValues.value(property); if (icon.paths().isEmpty()) { QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> subIconProperties = m_propertyToIconSubProperties.value(property); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, QtProperty *> itSub(subIconProperties); - while (itSub.hasNext()) { - QPair<QIcon::Mode, QIcon::State> pair = itSub.next().key(); + for (auto itSub = subIconProperties.cbegin(), end = subIconProperties.cend(); itSub != end; ++itSub) { + QPair<QIcon::Mode, QIcon::State> pair = itSub.key(); QtProperty *subProp = itSub.value(); setAttribute(subProp, QLatin1String(defaultResourceAttributeC), defaultIcon.pixmap(16, 16, pair.first, pair.second)); @@ -1562,9 +1561,8 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const void DesignerPropertyManager::reloadResourceProperties() { DesignerIconCache *iconCache = 0; - QMapIterator<QtProperty *, qdesigner_internal::PropertySheetIconValue> itIcon(m_iconValues); - while (itIcon.hasNext()) { - QtProperty *property = itIcon.next().key(); + for (auto itIcon = m_iconValues.cbegin(), end = m_iconValues.cend(); itIcon!= end; ++itIcon) { + QtProperty *property = itIcon.key(); PropertySheetIconValue icon = itIcon.value(); QIcon defaultIcon = m_defaultIcons.value(property); @@ -1581,9 +1579,8 @@ void DesignerPropertyManager::reloadResourceProperties() QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> iconPaths = icon.paths(); QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> subProperties = m_propertyToIconSubProperties.value(property); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, QtProperty *> itSub(subProperties); - while (itSub.hasNext()) { - const QPair<QIcon::Mode, QIcon::State> pair = itSub.next().key(); + for (auto itSub = subProperties.cbegin(), end = subProperties.cend(); itSub != end; ++itSub) { + const QPair<QIcon::Mode, QIcon::State> pair = itSub.key(); QtVariantProperty *subProperty = variantProperty(itSub.value()); subProperty->setAttribute(QLatin1String(defaultResourceAttributeC), defaultIcon.pixmap(16, 16, pair.first, pair.second)); @@ -1592,9 +1589,8 @@ void DesignerPropertyManager::reloadResourceProperties() emit propertyChanged(property); emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itIcon.value())); } - QMapIterator<QtProperty *, qdesigner_internal::PropertySheetPixmapValue> itPix(m_pixmapValues); - while (itPix.hasNext()) { - QtProperty *property = itPix.next().key(); + for (auto itPix = m_pixmapValues.cbegin(), end = m_pixmapValues.cend(); itPix != end; ++itPix) { + QtProperty *property = itPix.key(); emit propertyChanged(property); emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itPix.value())); } @@ -1829,9 +1825,8 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> iconPaths = icon.paths(); QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> subProperties = m_propertyToIconSubProperties.value(property); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, QtProperty *> itSub(subProperties); - while (itSub.hasNext()) { - const QPair<QIcon::Mode, QIcon::State> pair = itSub.next().key(); + for (auto itSub = subProperties.cbegin(), end = subProperties.cend(); itSub != end; ++itSub) { + const QPair<QIcon::Mode, QIcon::State> pair = itSub.key(); QtVariantProperty *subProperty = variantProperty(itSub.value()); bool hasPath = iconPaths.contains(pair); subProperty->setModified(hasPath); @@ -2122,9 +2117,8 @@ void DesignerPropertyManager::uninitializeProperty(QtProperty *property) m_defaultPixmaps.remove(property); QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> iconSubProperties = m_propertyToIconSubProperties.value(property); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, QtProperty *> itIcon(iconSubProperties); - while (itIcon.hasNext()) { - QtProperty *subIcon = itIcon.next().value(); + for (auto itIcon = iconSubProperties.cbegin(), end = iconSubProperties.cend(); itIcon != end; ++itIcon) { + QtProperty *subIcon = itIcon.value(); delete subIcon; m_iconSubPropertyToState.remove(subIcon); m_iconSubPropertyToProperty.remove(subIcon); @@ -2197,16 +2191,10 @@ void DesignerEditorFactory::setFormWindowBase(qdesigner_internal::FormWindowBase DesignerPixmapCache *cache = 0; if (fwb) cache = fwb->pixmapCache(); - QMapIterator<PixmapEditor *, QtProperty *> itPixmapEditor(m_editorToPixmapProperty); - while (itPixmapEditor.hasNext()) { - PixmapEditor *pe = itPixmapEditor.next().key(); - pe->setPixmapCache(cache); - } - QMapIterator<PixmapEditor *, QtProperty *> itIconEditor(m_editorToIconProperty); - while (itIconEditor.hasNext()) { - PixmapEditor *pe = itIconEditor.next().key(); - pe->setPixmapCache(cache); - } + for (auto it = m_editorToPixmapProperty.cbegin(), end = m_editorToPixmapProperty.cend(); it != end; ++it) + it.key()->setPixmapCache(cache); + for (auto it = m_editorToIconProperty.cbegin(), end = m_editorToIconProperty.cend(); it != end; ++it) + it.key()->setPixmapCache(cache); } void DesignerEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager) @@ -2519,15 +2507,16 @@ bool removeEditor(QObject *object, return false; if (!editorToProperty) return false; - QMapIterator<Editor, QtProperty *> it(*editorToProperty); - while (it.hasNext()) { - Editor editor = it.next().key(); + for (auto e2pIt = editorToProperty->begin(), end = editorToProperty->end(); e2pIt != end; ++e2pIt) { + Editor editor = e2pIt.key(); if (editor == object) { - QtProperty *prop = it.value(); - (*propertyToEditors)[prop].removeAll(editor); - if ((*propertyToEditors)[prop].count() == 0) - propertyToEditors->remove(prop); - editorToProperty->remove(editor); + const auto p2eIt = propertyToEditors->find(e2pIt.value()); + if (p2eIt != propertyToEditors->end()) { + p2eIt.value().removeAll(editor); + if (p2eIt.value().isEmpty()) + propertyToEditors->erase(p2eIt); + } + editorToProperty->erase(e2pIt); return true; } } @@ -2566,9 +2555,8 @@ bool updateManager(QtVariantEditorFactory *factory, bool *changingPropertyValue, { if (!editor) return false; - QMapIterator<Editor, QtProperty *> it(editorToProperty); - while (it.hasNext()) { - if (it.next().key() == editor) { + for (auto it = editorToProperty.cbegin(), end = editorToProperty.cend(); it != end; ++it) { + if (it.key() == editor) { QtProperty *prop = it.value(); QtVariantPropertyManager *manager = factory->propertyManager(prop); *changingPropertyValue = true; diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index 8ee27c0e4..4c26e565c 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -617,11 +617,8 @@ QColor PropertyEditor::propertyColor(QtProperty *property) const void PropertyEditor::fillView() { if (m_sorting) { - QMapIterator<QString, QtVariantProperty *> itProperty(m_nameToProperty); - while (itProperty.hasNext()) { - QtVariantProperty *property = itProperty.next().value(); - m_currentBrowser->addProperty(property); - } + for (auto itProperty = m_nameToProperty.cbegin(), end = m_nameToProperty.cend(); itProperty != end; ++itProperty) + m_currentBrowser->addProperty(itProperty.value()); } else { for (QtProperty *group : qAsConst(m_groups)) { QtBrowserItem *item = m_currentBrowser->addProperty(group); @@ -965,10 +962,7 @@ void PropertyEditor::setObject(QObject *object) } } - QMapIterator<QString, QtVariantProperty *> itRemove(toRemove); - while (itRemove.hasNext()) { - itRemove.next(); - + for (auto itRemove = toRemove.cbegin(), end = toRemove.cend(); itRemove != end; ++itRemove) { QtVariantProperty *property = itRemove.value(); m_nameToProperty.remove(itRemove.key()); m_propertyToGroup.remove(property); @@ -1127,9 +1121,8 @@ void PropertyEditor::setObject(QObject *object) } } QMap<QString, QtVariantProperty *> groups = m_nameToGroup; - QMapIterator<QString, QtVariantProperty *> itGroup(groups); - while (itGroup.hasNext()) { - QtVariantProperty *groupProperty = itGroup.next().value(); + for (auto itGroup = groups.cbegin(), end = groups.cend(); itGroup != end; ++itGroup) { + QtVariantProperty *groupProperty = itGroup.value(); if (groupProperty->subProperties().empty()) { if (groupProperty == m_dynamicGroup) m_dynamicGroup = 0; diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index 570815ec8..493a4c0e1 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -818,10 +818,7 @@ bool QDesignerWorkbench::readInBackup() return false; const QString modifiedPlaceHolder = QStringLiteral("[*]"); - QMapIterator<QString, QString> it(backupFileMap); - while(it.hasNext()) { - it.next(); - + for (auto it = backupFileMap.cbegin(), end = backupFileMap.cend(); it != end; ++it) { QString fileName = it.key(); fileName.remove(modifiedPlaceHolder); diff --git a/src/designer/src/lib/extension/default_extensionfactory.cpp b/src/designer/src/lib/extension/default_extensionfactory.cpp index fca0f2c18..23d2991e2 100644 --- a/src/designer/src/lib/extension/default_extensionfactory.cpp +++ b/src/designer/src/lib/extension/default_extensionfactory.cpp @@ -125,14 +125,11 @@ QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const void QExtensionFactory::objectDestroyed(QObject *object) { - QMutableMapIterator< IdObjectKey, QObject*> it(m_extensions); - while (it.hasNext()) { - it.next(); - - QObject *o = it.key().second; - if (o == object || object == it.value()) { - it.remove(); - } + for (auto it = m_extensions.begin(); it != m_extensions.end(); ) { + if (it.key().second == object || object == it.value()) + it = m_extensions.erase(it); + else + ++it; } m_extended.remove(object); diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp index 0d5fc14db..de15f5ec5 100644 --- a/src/designer/src/lib/shared/iconselector.cpp +++ b/src/designer/src/lib/shared/iconselector.cpp @@ -229,9 +229,8 @@ void IconSelectorPrivate::slotUpdate() icon = m_iconCache->icon(m_icon); QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> paths = m_icon.paths(); - QMapIterator<QPair<QIcon::Mode, QIcon::State>, int> itIndex(m_stateToIndex); - while (itIndex.hasNext()) { - const QPair<QIcon::Mode, QIcon::State> state = itIndex.next().key(); + for (auto itIndex = m_stateToIndex.cbegin(), end = m_stateToIndex.cend(); itIndex != end; ++itIndex) { + const QPair<QIcon::Mode, QIcon::State> state = itIndex.key(); const PropertySheetPixmapValue pixmap = paths.value(state); const int index = itIndex.value(); diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp index 510d07a23..29ada62f9 100644 --- a/src/designer/src/lib/shared/layout.cpp +++ b/src/designer/src/lib/shared/layout.cpp @@ -328,10 +328,7 @@ void Layout::undoLayout() m_formWindow->selectWidget(m_layoutBase, false); QDesignerWidgetFactoryInterface *widgetFactory = m_formWindow->core()->widgetFactory(); - QHashIterator<QWidget *, QRect> it(m_geometries); - while (it.hasNext()) { - it.next(); - + for (auto it = m_geometries.cbegin(), end = m_geometries.cend(); it != end; ++it) { if (!it.key()) continue; @@ -395,10 +392,7 @@ void Layout::breakLayout() m_layoutBase != m_formWindow->mainContainer()); const bool add = m_geometries.isEmpty(); - QMapIterator<QWidget*, QRect> it(rects); - while (it.hasNext()) { - it.next(); - + for (auto it = rects.cbegin(), end = rects.cend(); it != end; ++it) { QWidget *w = it.key(); if (needReparent) { w->setParent(m_layoutBase->parentWidget(), 0); diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index 3d4a6bf18..cab289515 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -336,11 +336,13 @@ namespace qdesigner_internal { if (const int themeCmp = m_data->m_theme.compare(other.m_data->m_theme)) return themeCmp < 0; - QMapIterator<ModeStateKey, PropertySheetPixmapValue> itThis(m_data->m_paths); - QMapIterator<ModeStateKey, PropertySheetPixmapValue> itOther(other.m_data->m_paths); - while (itThis.hasNext() && itOther.hasNext()) { - const ModeStateKey thisPair = itThis.next().key(); - const ModeStateKey otherPair = itOther.next().key(); + auto itThis = m_data->m_paths.cbegin(); + auto itThisEnd = m_data->m_paths.cend(); + auto itOther = other.m_data->m_paths.cbegin(); + auto itOtherEnd = other.m_data->m_paths.cend(); + while (itThis != itThisEnd && itOther != itOtherEnd) { + const ModeStateKey thisPair = itThis.key(); + const ModeStateKey otherPair = itOther.key(); if (thisPair < otherPair) return true; else if (otherPair < thisPair) @@ -351,7 +353,7 @@ namespace qdesigner_internal if (crc > 0) return false; } - if (itOther.hasNext()) + if (itOther != itOtherEnd) return true; return false; } diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index 380b6a8cd..d7a87e013 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -1221,9 +1221,8 @@ void QtResourceEditorDialogPrivate::slotCurrentQrcFileChanged(QListWidgetItem *i if (m_currentQrcFile) { QMap<QtResourcePrefix *, QStandardItem *> currentPrefixList = m_resourcePrefixToPrefixItem; - QMapIterator<QtResourcePrefix *, QStandardItem *> itPrefix(currentPrefixList); - while (itPrefix.hasNext()) { - QtResourcePrefix *resourcePrefix = itPrefix.next().key(); + for (auto it = currentPrefixList.cbegin(), end = currentPrefixList.cend(); it != end; ++it) { + QtResourcePrefix *resourcePrefix = it.key(); const QList<QtResourceFile *> currentResourceFiles = resourcePrefix->resourceFiles(); for (QtResourceFile *rf : currentResourceFiles) slotResourceFileRemoved(rf); diff --git a/src/designer/src/lib/shared/qtresourcemodel.cpp b/src/designer/src/lib/shared/qtresourcemodel.cpp index fac57379d..bd120c542 100644 --- a/src/designer/src/lib/shared/qtresourcemodel.cpp +++ b/src/designer/src/lib/shared/qtresourcemodel.cpp @@ -581,9 +581,8 @@ void QtResourceModel::setWatcherEnabled(bool enable) d_ptr->m_fileWatcherEnabled = enable; - QMapIterator<QString, bool> it(d_ptr->m_fileWatchedMap); - if (it.hasNext()) - d_ptr->setWatcherEnabled(it.next().key(), d_ptr->m_fileWatcherEnabled); + if (!d_ptr->m_fileWatchedMap.isEmpty()) + d_ptr->setWatcherEnabled(d_ptr->m_fileWatchedMap.firstKey(), d_ptr->m_fileWatcherEnabled); } bool QtResourceModel::isWatcherEnabled() const diff --git a/src/designer/src/lib/shared/qtresourceview.cpp b/src/designer/src/lib/shared/qtresourceview.cpp index 24571c283..87b47f45d 100644 --- a/src/designer/src/lib/shared/qtresourceview.cpp +++ b/src/designer/src/lib/shared/qtresourceview.cpp @@ -262,20 +262,14 @@ void QtResourceViewPrivate::slotFilterChanged(const QString &pattern) void QtResourceViewPrivate::storeExpansionState() { - QMapIterator<QString, QTreeWidgetItem *> it(m_pathToItem); - while (it.hasNext()) { - it.next(); - m_expansionState[it.key()] = it.value()->isExpanded(); - } + for (auto it = m_pathToItem.cbegin(), end = m_pathToItem.cend(); it != end; ++it) + m_expansionState.insert(it.key(), it.value()->isExpanded()); } void QtResourceViewPrivate::applyExpansionState() { - QMapIterator<QString, QTreeWidgetItem *> it(m_pathToItem); - while (it.hasNext()) { - it.next(); + for (auto it = m_pathToItem.cbegin(), end = m_pathToItem.cend(); it != end; ++it) it.value()->setExpanded(m_expansionState.value(it.key(), true)); - } } QPixmap QtResourceViewPrivate::makeThumbnail(const QPixmap &pix) const @@ -377,10 +371,8 @@ void QtResourceViewPrivate::createPaths() const QString root(QStringLiteral(":/")); QMap<QString, QString> contents = m_resourceModel->contents(); - QMapIterator<QString, QString> itContents(contents); - while (itContents.hasNext()) { - const QString filePath = itContents.next().key(); - const QFileInfo fi(filePath); + for (auto it = contents.cbegin(), end = contents.cend(); it != end; ++it) { + const QFileInfo fi(it.key()); QString dirPath = fi.absolutePath(); m_pathToContents[dirPath].append(fi.fileName()); while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths @@ -503,11 +495,9 @@ void QtResourceViewPrivate::filterOutResources() m_listWidget->scrollToItem(currentResourceItem); } - QMapIterator<QString, bool> it(pathToVisible); // hide all paths filtered out - while (it.hasNext()) { - const QString path = it.next().key(); - QTreeWidgetItem *item = m_pathToItem.value(path); - if (item) + // hide all paths filtered out + for (auto it = pathToVisible.cbegin(), end = pathToVisible.cend(); it != end; ++it) { + if (QTreeWidgetItem *item = m_pathToItem.value(it.key())) item->setHidden(!it.value()); } } |