forked from qt-creator/qt-creator
Fix Krazy warnings about values or keys iteration in project management.
Change-Id: I70674ac326f508b53f50b4dbbc5e051dbdd9017d Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -82,6 +82,9 @@ QHash<QString, QStringList> sortFilesIntoPaths(const QString &base, const QSet<Q
|
||||
|
||||
void GenericProjectNode::refresh(QSet<QString> oldFileList)
|
||||
{
|
||||
typedef QHash<QString, QStringList> FilesInPathHash;
|
||||
typedef FilesInPathHash::ConstIterator FilesInPathHashConstIt;
|
||||
|
||||
if (oldFileList.isEmpty()) {
|
||||
// Only do this once
|
||||
FileNode *projectFilesNode = new FileNode(m_project->filesFileName(),
|
||||
@@ -119,8 +122,11 @@ void GenericProjectNode::refresh(QSet<QString> oldFileList)
|
||||
added.subtract(oldFileList);
|
||||
|
||||
QString baseDir = QFileInfo(path()).absolutePath();
|
||||
QHash<QString, QStringList> filesInPaths = sortFilesIntoPaths(baseDir, added);
|
||||
foreach (const QString &filePath, filesInPaths.keys()) {
|
||||
FilesInPathHash filesInPaths = sortFilesIntoPaths(baseDir, added);
|
||||
|
||||
FilesInPathHashConstIt cend = filesInPaths.constEnd();
|
||||
for (FilesInPathHashConstIt it = filesInPaths.constBegin(); it != cend; ++it) {
|
||||
const QString &filePath = it.key();
|
||||
QStringList components;
|
||||
if (!filePath.isEmpty())
|
||||
components = filePath.split(QLatin1Char('/'));
|
||||
@@ -129,7 +135,7 @@ void GenericProjectNode::refresh(QSet<QString> oldFileList)
|
||||
folder = createFolderByName(components, components.size());
|
||||
|
||||
QList<FileNode *> fileNodes;
|
||||
foreach (const QString &file, filesInPaths.value(filePath)) {
|
||||
foreach (const QString &file, it.value()) {
|
||||
FileType fileType = SourceType; // ### FIXME
|
||||
FileNode *fileNode = new FileNode(file, fileType, /*generated = */ false);
|
||||
fileNodes.append(fileNode);
|
||||
@@ -139,14 +145,16 @@ void GenericProjectNode::refresh(QSet<QString> oldFileList)
|
||||
}
|
||||
|
||||
filesInPaths = sortFilesIntoPaths(baseDir, removed);
|
||||
foreach (const QString &filePath, filesInPaths.keys()) {
|
||||
cend = filesInPaths.constEnd();
|
||||
for (FilesInPathHashConstIt it = filesInPaths.constBegin(); it != cend; ++it) {
|
||||
const QString &filePath = it.key();
|
||||
QStringList components;
|
||||
if (!filePath.isEmpty())
|
||||
components = filePath.split(QLatin1Char('/'));
|
||||
FolderNode *folder = findFolderByName(components, components.size());
|
||||
|
||||
QList<FileNode *> fileNodes;
|
||||
foreach (const QString &file, filesInPaths.value(filePath)) {
|
||||
foreach (const QString &file, it.value()) {
|
||||
foreach (FileNode *fn, folder->fileNodes())
|
||||
if (fn->path() == file)
|
||||
fileNodes.append(fn);
|
||||
|
||||
@@ -114,7 +114,7 @@ EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
|
||||
|
||||
EditorConfiguration::~EditorConfiguration()
|
||||
{
|
||||
qDeleteAll(d->m_languageCodeStylePreferences.values());
|
||||
qDeleteAll(d->m_languageCodeStylePreferences);
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
@@ -378,6 +378,8 @@ bool Kit::isEqual(const Kit *other) const
|
||||
|
||||
QVariantMap Kit::toMap() const
|
||||
{
|
||||
typedef QHash<Core::Id, QVariant>::ConstIterator IdVariantConstIt;
|
||||
|
||||
QVariantMap data;
|
||||
data.insert(QLatin1String(ID_KEY), QString::fromLatin1(d->m_id.name()));
|
||||
data.insert(QLatin1String(DISPLAYNAME_KEY), d->m_displayName);
|
||||
@@ -386,8 +388,10 @@ QVariantMap Kit::toMap() const
|
||||
data.insert(QLatin1String(ICON_KEY), d->m_iconPath);
|
||||
|
||||
QVariantMap extra;
|
||||
foreach (const Id key, d->m_data.keys())
|
||||
extra.insert(QString::fromLatin1(key.name().constData()), d->m_data.value(key));
|
||||
|
||||
const IdVariantConstIt cend = d->m_data.constEnd();
|
||||
for (IdVariantConstIt it = d->m_data.constBegin(); it != cend; ++it)
|
||||
extra.insert(QString::fromLatin1(it.key().name().constData()), it.value());
|
||||
data.insert(QLatin1String(DATA_KEY), extra);
|
||||
|
||||
return data;
|
||||
@@ -471,8 +475,9 @@ bool Kit::fromMap(const QVariantMap &data)
|
||||
setIconPath(data.value(QLatin1String(ICON_KEY)).toString());
|
||||
|
||||
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
|
||||
foreach (const QString &key, extra.keys())
|
||||
setValue(Id(key), extra.value(key));
|
||||
const QVariantMap::ConstIterator cend = extra.constEnd();
|
||||
for (QVariantMap::ConstIterator it = extra.constBegin(); it != cend; ++it)
|
||||
setValue(Id(it.key()), it.value());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -182,13 +182,16 @@ void TaskModel::updateTaskLineNumber(unsigned int id, int line)
|
||||
|
||||
void TaskModel::clearTasks(const Core::Id &categoryId)
|
||||
{
|
||||
typedef QHash<Core::Id,CategoryData>::ConstIterator IdCategoryConstIt;
|
||||
|
||||
if (categoryId.uniqueIdentifier() == 0) {
|
||||
if (m_tasks.count() == 0)
|
||||
return;
|
||||
beginRemoveRows(QModelIndex(), 0, m_tasks.count() -1);
|
||||
m_tasks.clear();
|
||||
foreach (const Core::Id &key, m_categories.keys())
|
||||
m_categories[key].clear();
|
||||
const IdCategoryConstIt cend = m_categories.constEnd();
|
||||
for (IdCategoryConstIt it = m_categories.constBegin(); it != cend; ++it)
|
||||
m_categories[it.key()].clear();
|
||||
endRemoveRows();
|
||||
} else {
|
||||
int index = 0;
|
||||
|
||||
@@ -546,6 +546,8 @@ void TaskWindow::setShowWarnings(bool show)
|
||||
|
||||
void TaskWindow::updateCategoriesMenu()
|
||||
{
|
||||
typedef QMap<QString, QByteArray>::ConstIterator NameToIdsConstIt;
|
||||
|
||||
d->m_categoriesMenu->clear();
|
||||
|
||||
const QList<Core::Id> filteredCategories = d->m_filter->filteredCategories();
|
||||
@@ -554,8 +556,10 @@ void TaskWindow::updateCategoriesMenu()
|
||||
foreach (const Core::Id &categoryId, d->m_model->categoryIds())
|
||||
nameToIds.insert(d->m_model->categoryDisplayName(categoryId), categoryId.name());
|
||||
|
||||
foreach (const QString &displayName, nameToIds.keys()) {
|
||||
const QByteArray categoryId = nameToIds.value(displayName);
|
||||
const NameToIdsConstIt cend = nameToIds.constEnd();
|
||||
for (NameToIdsConstIt it = nameToIds.constBegin(); it != cend; ++it) {
|
||||
const QString &displayName = it.key();
|
||||
const QByteArray categoryId = it.value();
|
||||
QAction *action = new QAction(d->m_categoriesMenu);
|
||||
action->setCheckable(true);
|
||||
action->setText(displayName);
|
||||
|
||||
@@ -162,8 +162,9 @@ qbs::Preferences *QbsManager::preferences()
|
||||
void QbsManager::addProfile(const QString &name, const QVariantMap &data)
|
||||
{
|
||||
const QString base = QLatin1String(PROFILES_PREFIX) + name;
|
||||
foreach (const QString &key, data.keys())
|
||||
m_settings->setValue(base + key, data.value(key));
|
||||
const QVariantMap::ConstIterator cend = data.constEnd();
|
||||
for (QVariantMap::ConstIterator it = data.constBegin(); it != cend; ++it)
|
||||
m_settings->setValue(base + it.key(), it.value());
|
||||
}
|
||||
|
||||
void QbsManager::removeCreatorProfiles()
|
||||
|
||||
@@ -110,11 +110,12 @@ void QmlProjectNode::refresh()
|
||||
filesInDirectory[relativeDirectory].append(absoluteFilePath);
|
||||
}
|
||||
|
||||
foreach (const QString &directory, filesInDirectory.keys()) {
|
||||
FolderNode *folder = findOrCreateFolderByName(directory);
|
||||
const QHash<QString, QStringList>::ConstIterator cend = filesInDirectory.constEnd();
|
||||
for (QHash<QString, QStringList>::ConstIterator it = filesInDirectory.constBegin(); it != cend; ++it) {
|
||||
FolderNode *folder = findOrCreateFolderByName(it.key());
|
||||
|
||||
QList<FileNode *> fileNodes;
|
||||
foreach (const QString &file, filesInDirectory.value(directory)) {
|
||||
foreach (const QString &file, it.value()) {
|
||||
FileType fileType = SourceType; // ### FIXME
|
||||
FileNode *fileNode = new FileNode(file, fileType, /*generated = */ false);
|
||||
fileNodes.append(fileNode);
|
||||
|
||||
@@ -133,9 +133,12 @@ void BlackBerryNdkProcess::processError(QProcess::ProcessError error)
|
||||
|
||||
int BlackBerryNdkProcess::errorLineToReturnStatus(const QString &line) const
|
||||
{
|
||||
foreach (const QString &key, m_errorStringMap.keys()) {
|
||||
if (line.contains(key))
|
||||
return m_errorStringMap.value(key);
|
||||
typedef QMap<QString, int>::ConstIterator ConstIt;
|
||||
|
||||
const ConstIt cend = m_errorStringMap.constEnd();
|
||||
for (ConstIt it = m_errorStringMap.constBegin(); it != cend; ++it) {
|
||||
if (line.contains(it.key()))
|
||||
return it.value();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -204,7 +204,9 @@ bool QtVersionManager::restoreQtVersions()
|
||||
return false;
|
||||
|
||||
const QString keyPrefix = QLatin1String(QTVERSION_DATA_KEY);
|
||||
foreach (const QString &key, data.keys()) {
|
||||
const QVariantMap::ConstIterator dcend = data.constEnd();
|
||||
for (QVariantMap::ConstIterator it = data.constBegin(); it != dcend; ++it) {
|
||||
const QString &key = it.key();
|
||||
if (!key.startsWith(keyPrefix))
|
||||
continue;
|
||||
bool ok;
|
||||
@@ -212,7 +214,7 @@ bool QtVersionManager::restoreQtVersions()
|
||||
if (!ok || count < 0)
|
||||
continue;
|
||||
|
||||
const QVariantMap qtversionMap = data.value(key).toMap();
|
||||
const QVariantMap qtversionMap = it.value().toMap();
|
||||
const QString type = qtversionMap.value(QLatin1String(QTVERSION_TYPE_KEY)).toString();
|
||||
|
||||
bool restored = false;
|
||||
@@ -276,7 +278,9 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
||||
QStringList sdkVersions;
|
||||
|
||||
const QString keyPrefix = QLatin1String(QTVERSION_DATA_KEY);
|
||||
foreach (const QString &key, data.keys()) {
|
||||
const QVariantMap::ConstIterator dcend = data.constEnd();
|
||||
for (QVariantMap::ConstIterator it = data.constBegin(); it != dcend; ++it) {
|
||||
const QString &key = it.key();
|
||||
if (!key.startsWith(keyPrefix))
|
||||
continue;
|
||||
bool ok;
|
||||
@@ -284,7 +288,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
||||
if (!ok || count < 0)
|
||||
continue;
|
||||
|
||||
QVariantMap qtversionMap = data.value(key).toMap();
|
||||
QVariantMap qtversionMap = it.value().toMap();
|
||||
const QString type = qtversionMap.value(QLatin1String(QTVERSION_TYPE_KEY)).toString();
|
||||
const QString autoDetectionSource = qtversionMap.value(QLatin1String("autodetectionSource")).toString();
|
||||
sdkVersions << autoDetectionSource;
|
||||
|
||||
Reference in New Issue
Block a user