Replace foreach macro by for-loop

pull/2566/head
elsid 5 years ago
parent 5d5ec1cf63
commit 045ceeac11
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -95,7 +95,7 @@ bool Launcher::DataFilesPage::loadSettings()
qDebug() << "The current profile is: " << currentProfile; qDebug() << "The current profile is: " << currentProfile;
foreach (const QString &item, profiles) for (const QString &item : profiles)
addProfile (item, false); addProfile (item, false);
// Hack: also add the current profile // Hack: also add the current profile
@ -114,7 +114,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
if (!mDataLocal.isEmpty()) if (!mDataLocal.isEmpty())
paths.insert(0, mDataLocal); paths.insert(0, mDataLocal);
foreach(const QString &path, paths) for (const QString &path : paths)
mSelector->addFiles(path); mSelector->addFiles(path);
PathIterator pathIterator(paths); PathIterator pathIterator(paths);
@ -127,7 +127,7 @@ QStringList Launcher::DataFilesPage::filesInProfile(const QString& profileName,
QStringList files = mLauncherSettings.getContentListFiles(profileName); QStringList files = mLauncherSettings.getContentListFiles(profileName);
QStringList filepaths; QStringList filepaths;
foreach(const QString& file, files) for (const QString& file : files)
{ {
QString filepath = pathIterator.findFirstPath(file); QString filepath = pathIterator.findFirstPath(file);
@ -152,7 +152,8 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
mLauncherSettings.setCurrentContentListName(ui.profilesComboBox->currentText()); mLauncherSettings.setCurrentContentListName(ui.profilesComboBox->currentText());
QStringList fileNames; QStringList fileNames;
foreach(const ContentSelectorModel::EsmFile *item, items) { for (const ContentSelectorModel::EsmFile *item : items)
{
fileNames.append(item->fileName()); fileNames.append(item->fileName());
} }
mLauncherSettings.setContentList(profileName, fileNames); mLauncherSettings.setContentList(profileName, fileNames);
@ -164,7 +165,8 @@ QStringList Launcher::DataFilesPage::selectedFilePaths()
//retrieve the files selected for the profile //retrieve the files selected for the profile
ContentSelectorModel::ContentFileList items = mSelector->selectedFiles(); ContentSelectorModel::ContentFileList items = mSelector->selectedFiles();
QStringList filePaths; QStringList filePaths;
foreach(const ContentSelectorModel::EsmFile *item, items) { for (const ContentSelectorModel::EsmFile *item : items)
{
filePaths.append(item->filePath()); filePaths.append(item->filePath());
} }
return filePaths; return filePaths;

@ -280,7 +280,8 @@ bool Launcher::MainDialog::setupLauncherSettings()
paths.append(QString(Config::LauncherSettings::sLauncherConfigFileName)); paths.append(QString(Config::LauncherSettings::sLauncherConfigFileName));
paths.append(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName)); paths.append(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName));
foreach (const QString &path, paths) { for (const QString &path : paths)
{
qDebug() << "Loading config file:" << path.toUtf8().constData(); qDebug() << "Loading config file:" << path.toUtf8().constData();
QFile file(path); QFile file(path);
if (file.exists()) { if (file.exists()) {
@ -338,7 +339,8 @@ bool Launcher::MainDialog::setupGameSettings()
paths.append(localPath + QString("openmw.cfg")); paths.append(localPath + QString("openmw.cfg"));
paths.append(userPath + QString("openmw.cfg")); paths.append(userPath + QString("openmw.cfg"));
foreach (const QString &path2, paths) { for (const QString &path2 : paths)
{
qDebug() << "Loading config file:" << path2.toUtf8().constData(); qDebug() << "Loading config file:" << path2.toUtf8().constData();
file.setFileName(path2); file.setFileName(path2);
@ -366,7 +368,8 @@ bool Launcher::MainDialog::setupGameData()
QStringList dataDirs; QStringList dataDirs;
// Check if the paths actually contain data files // Check if the paths actually contain data files
foreach (const QString path3, mGameSettings.getDataDirs()) { for (const QString& path3 : mGameSettings.getDataDirs())
{
QDir dir(path3); QDir dir(path3);
QStringList filters; QStringList filters;
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon"; filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";

@ -61,7 +61,8 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
// Detect Morrowind configuration files // Detect Morrowind configuration files
QStringList iniPaths; QStringList iniPaths;
foreach (const QString &path, mGameSettings.getDataDirs()) { for (const QString &path : mGameSettings.getDataDirs())
{
QDir dir(path); QDir dir(path);
dir.setPath(dir.canonicalPath()); // Resolve symlinks dir.setPath(dir.canonicalPath()); // Resolve symlinks

@ -228,7 +228,7 @@ void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::
if(discoveredFiles.empty()) if(discoveredFiles.empty())
{ {
foreach(const QString &path, mFileDialog.selectedFilePaths()) for (const QString &path : mFileDialog.selectedFilePaths())
files.push_back(path.toUtf8().constData()); files.push_back(path.toUtf8().constData());
} }
else else
@ -245,7 +245,7 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
{ {
std::vector<boost::filesystem::path> files; std::vector<boost::filesystem::path> files;
foreach (const QString &path, mFileDialog.selectedFilePaths()) { for (const QString &path : mFileDialog.selectedFilePaths()) {
files.push_back(path.toUtf8().constData()); files.push_back(path.toUtf8().constData());
} }

@ -47,7 +47,7 @@ QStringList CSVDoc::FileDialog::selectedFilePaths()
{ {
QStringList filePaths; QStringList filePaths;
foreach (ContentSelectorModel::EsmFile *file, mSelector->selectedFiles() ) for (ContentSelectorModel::EsmFile *file : mSelector->selectedFiles() )
filePaths.append(file->filePath()); filePaths.append(file->filePath());
return filePaths; return filePaths;

@ -404,7 +404,7 @@ void CSVDoc::View::updateSubViewIndices(SubView *view)
updateTitle(); updateTitle();
foreach (SubView *subView, mSubViews) for (SubView *subView : mSubViews)
{ {
if (!subView->isFloating()) if (!subView->isFloating())
{ {
@ -546,7 +546,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
// User setting to reuse sub views (on a per top level view basis) // User setting to reuse sub views (on a per top level view basis)
if (windows["reuse"].isTrue()) if (windows["reuse"].isTrue())
{ {
foreach(SubView *sb, mSubViews) for (SubView *sb : mSubViews)
{ {
bool isSubViewReferenceable = bool isSubViewReferenceable =
sb->getUniversalId().getType() == CSMWorld::UniversalId::Type_Referenceable; sb->getUniversalId().getType() == CSMWorld::UniversalId::Type_Referenceable;
@ -975,7 +975,7 @@ void CSVDoc::View::resizeViewHeight (int height)
void CSVDoc::View::toggleShowStatusBar (bool show) void CSVDoc::View::toggleShowStatusBar (bool show)
{ {
foreach (QObject *view, mSubViewWindow.children()) for (QObject *view : mSubViewWindow.children())
{ {
if (CSVDoc::SubView *subView = dynamic_cast<CSVDoc::SubView *> (view)) if (CSVDoc::SubView *subView = dynamic_cast<CSVDoc::SubView *> (view))
subView->setStatusBar (show); subView->setStatusBar (show);

@ -343,7 +343,7 @@ std::vector< CSMWorld::UniversalId > CSVWorld::RegionMap::getDraggedRecords() co
{ {
QModelIndexList selected(getSelectedCells(true, false)); QModelIndexList selected(getSelectedCells(true, false));
std::vector<CSMWorld::UniversalId> ids; std::vector<CSMWorld::UniversalId> ids;
foreach (QModelIndex it, selected) for (const QModelIndex& it : selected)
{ {
ids.push_back( ids.push_back(
CSMWorld::UniversalId( CSMWorld::UniversalId(
@ -351,7 +351,7 @@ std::vector< CSMWorld::UniversalId > CSVWorld::RegionMap::getDraggedRecords() co
model()->data(it, CSMWorld::RegionMap::Role_CellId).toString().toUtf8().constData())); model()->data(it, CSMWorld::RegionMap::Role_CellId).toString().toUtf8().constData()));
} }
selected = getSelectedCells(false, true); selected = getSelectedCells(false, true);
foreach (QModelIndex it, selected) for (const QModelIndex& it : selected)
{ {
ids.push_back( ids.push_back(
CSMWorld::UniversalId( CSMWorld::UniversalId(

@ -139,7 +139,8 @@ bool Wizard::ComponentSelectionPage::validatePage()
mWizard->mInstallations[path].hasBloodmoon = false; mWizard->mInstallations[path].hasBloodmoon = false;
QList<QListWidgetItem*> items = componentsList->findItems(QLatin1String("Bloodmoon"), Qt::MatchStartsWith); QList<QListWidgetItem*> items = componentsList->findItems(QLatin1String("Bloodmoon"), Qt::MatchStartsWith);
foreach (QListWidgetItem *item, items) { for (QListWidgetItem *item : items)
{
item->setText(QLatin1String("Bloodmoon")); item->setText(QLatin1String("Bloodmoon"));
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
} }

@ -31,7 +31,7 @@ void Wizard::ExistingInstallationPage::initializePage()
// Hide the default item if there are installations to choose from // Hide the default item if there are installations to choose from
installationsList->item(0)->setHidden(!paths.isEmpty()); installationsList->item(0)->setHidden(!paths.isEmpty());
foreach (const QString &path, paths) for (const QString &path : paths)
{ {
if (installationsList->findItems(path, Qt::MatchExactly).isEmpty()) if (installationsList->findItems(path, Qt::MatchExactly).isEmpty())
{ {

@ -21,7 +21,8 @@ QStringList Wizard::IniSettings::findKeys(const QString &text)
{ {
QStringList result; QStringList result;
foreach (const QString &key, mSettings.keys()) { for (const QString &key : mSettings.keys())
{
if (key.startsWith(text)) if (key.startsWith(text))
result << key; result << key;

@ -162,7 +162,8 @@ void Wizard::MainWizard::setupGameSettings()
paths.append(QLatin1String("openmw.cfg")); paths.append(QLatin1String("openmw.cfg"));
paths.append(globalPath + QLatin1String("openmw.cfg")); paths.append(globalPath + QLatin1String("openmw.cfg"));
foreach (const QString &path2, paths) { for (const QString &path2 : paths)
{
qDebug() << "Loading config file:" << path2.toUtf8().constData(); qDebug() << "Loading config file:" << path2.toUtf8().constData();
file.setFileName(path2); file.setFileName(path2);
@ -222,7 +223,8 @@ void Wizard::MainWizard::setupLauncherSettings()
void Wizard::MainWizard::setupInstallations() void Wizard::MainWizard::setupInstallations()
{ {
// Check if the paths actually contain a Morrowind installation // Check if the paths actually contain a Morrowind installation
foreach (const QString path, mGameSettings.getDataDirs()) { for (const QString& path : mGameSettings.getDataDirs())
{
if (findFiles(QLatin1String("Morrowind"), path)) if (findFiles(QLatin1String("Morrowind"), path))
addInstallation(path); addInstallation(path);

@ -217,7 +217,8 @@ bool Wizard::UnshieldWorker::removeDirectory(const QString &dirName)
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot | QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
QDir::System | QDir::Hidden | QDir::System | QDir::Hidden |
QDir::AllDirs | QDir::Files, QDir::DirsFirst)); QDir::AllDirs | QDir::Files, QDir::DirsFirst));
foreach(QFileInfo info, list) { for (const QFileInfo& info : list)
{
if (info.isDir()) { if (info.isDir()) {
result = removeDirectory(info.absoluteFilePath()); result = removeDirectory(info.absoluteFilePath());
} else { } else {
@ -279,7 +280,8 @@ bool Wizard::UnshieldWorker::copyDirectory(const QString &source, const QString
QDir::System | QDir::Hidden | QDir::System | QDir::Hidden |
QDir::AllDirs | QDir::Files, QDir::DirsFirst)); QDir::AllDirs | QDir::Files, QDir::DirsFirst));
foreach (const QFileInfo &info, list) { for (const QFileInfo &info : list)
{
QString relativePath(info.absoluteFilePath()); QString relativePath(info.absoluteFilePath());
relativePath.remove(source); relativePath.remove(source);
@ -315,7 +317,8 @@ bool Wizard::UnshieldWorker::installFiles(const QString &fileName, const QString
QStringList files(findFiles(fileName, path, flags)); QStringList files(findFiles(fileName, path, flags));
foreach (const QString &file, files) { for (const QString &file : files)
{
QFileInfo info(file); QFileInfo info(file);
emit textChanged(tr("Installing: %1").arg(info.fileName())); emit textChanged(tr("Installing: %1").arg(info.fileName()));
@ -339,7 +342,8 @@ bool Wizard::UnshieldWorker::installDirectories(const QString &dirName, const QS
QStringList directories(findDirectories(dirName, path, recursive)); QStringList directories(findDirectories(dirName, path, recursive));
foreach (const QString &dir, directories) { for (const QString &dir : directories)
{
QFileInfo info(dir); QFileInfo info(dir);
emit textChanged(tr("Installing: %1 directory").arg(info.fileName())); emit textChanged(tr("Installing: %1 directory").arg(info.fileName()));
if (!copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName(), keepSource)) if (!copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName(), keepSource))
@ -460,7 +464,8 @@ bool Wizard::UnshieldWorker::setupComponent(Component component)
QStringList list(findFiles(QLatin1String("data1.hdr"), disk.absolutePath())); QStringList list(findFiles(QLatin1String("data1.hdr"), disk.absolutePath()));
foreach (const QString &file, list) { for (const QString &file : list)
{
qDebug() << "current archive: " << file; qDebug() << "current archive: " << file;
@ -579,7 +584,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
<< QLatin1String("Textures") << QLatin1String("Textures")
<< QLatin1String("Video"); << QLatin1String("Video");
foreach (const QString &dir, directories) { for (const QString &dir : directories)
{
if (!installDirectories(dir, temp.absolutePath())) { if (!installDirectories(dir, temp.absolutePath())) {
emit error(tr("Could not install directory!"), emit error(tr("Could not install directory!"),
tr("Installing %1 to %2 failed.").arg(dir, temp.absolutePath())); tr("Installing %1 to %2 failed.").arg(dir, temp.absolutePath()));
@ -588,7 +594,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
} }
// Install directories from disk // Install directories from disk
foreach (const QString &dir, directories) { for (const QString &dir : directories)
{
if (!installDirectories(dir, info.absolutePath(), false, true)) { if (!installDirectories(dir, info.absolutePath(), false, true)) {
emit error(tr("Could not install directory!"), emit error(tr("Could not install directory!"),
tr("Installing %1 to %2 failed.").arg(dir, info.absolutePath())); tr("Installing %1 to %2 failed.").arg(dir, info.absolutePath()));
@ -603,7 +610,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
<< QLatin1String(".top") << QLatin1String(".top")
<< QLatin1String(".mrk"); << QLatin1String(".mrk");
foreach (const QString &extension, extensions) { for (const QString &extension : extensions)
{
if (!installFiles(extension, info.absolutePath(), Qt::MatchEndsWith)) { if (!installFiles(extension, info.absolutePath(), Qt::MatchEndsWith)) {
emit error(tr("Could not install translation file!"), emit error(tr("Could not install translation file!"),
tr("Failed to install *%1 files.").arg(extension)); tr("Failed to install *%1 files.").arg(extension));
@ -617,7 +625,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
files << QLatin1String("Morrowind.esm") files << QLatin1String("Morrowind.esm")
<< QLatin1String("Morrowind.bsa"); << QLatin1String("Morrowind.bsa");
foreach (const QString &file, files) { for (const QString &file : files)
{
if (!installFile(file, temp.absolutePath())) { if (!installFile(file, temp.absolutePath())) {
emit error(tr("Could not install Morrowind data file!"), emit error(tr("Could not install Morrowind data file!"),
tr("Failed to install %1.").arg(file)); tr("Failed to install %1.").arg(file));
@ -658,7 +667,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
files << QLatin1String("Tribunal.esm") files << QLatin1String("Tribunal.esm")
<< QLatin1String("Tribunal.bsa"); << QLatin1String("Tribunal.bsa");
foreach (const QString &file, files) { for (const QString &file : files)
{
if (!installFile(file, temp.absolutePath())) { if (!installFile(file, temp.absolutePath())) {
emit error(tr("Could not find Tribunal data file!"), emit error(tr("Could not find Tribunal data file!"),
tr("Failed to find %1.").arg(file)); tr("Failed to find %1.").arg(file));
@ -683,7 +693,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
files << QLatin1String("Bloodmoon.esm") files << QLatin1String("Bloodmoon.esm")
<< QLatin1String("Bloodmoon.bsa"); << QLatin1String("Bloodmoon.bsa");
foreach (const QString &file, files) { for (const QString &file : files)
{
if (!installFile(file, temp.absolutePath())) { if (!installFile(file, temp.absolutePath())) {
emit error(tr("Could not find Bloodmoon data file!"), emit error(tr("Could not find Bloodmoon data file!"),
tr("Failed to find %1.").arg(file)); tr("Failed to find %1.").arg(file));
@ -696,7 +707,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
emit textChanged(tr("Updating Morrowind configuration file")); emit textChanged(tr("Updating Morrowind configuration file"));
foreach (const QString &inx, list) { for (const QString &inx : list)
{
mIniSettings.parseInx(inx); mIniSettings.parseInx(inx);
} }
} }
@ -705,7 +717,8 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString
QStringList datafiles(findDirectories(QLatin1String("Data Files"), temp.absolutePath())); QStringList datafiles(findDirectories(QLatin1String("Data Files"), temp.absolutePath()));
datafiles.append(findDirectories(QLatin1String("Data Files"), info.absolutePath())); datafiles.append(findDirectories(QLatin1String("Data Files"), info.absolutePath()));
foreach (const QString &dir, datafiles) { for (const QString &dir : datafiles)
{
QFileInfo info(dir); QFileInfo info(dir);
emit textChanged(tr("Installing: %1 directory").arg(info.fileName())); emit textChanged(tr("Installing: %1 directory").arg(info.fileName()));
@ -849,7 +862,8 @@ QStringList Wizard::UnshieldWorker::findFiles(const QString &fileName, const QSt
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot | QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
QDir::AllDirs | QDir::Files, QDir::DirsFirst)); QDir::AllDirs | QDir::Files, QDir::DirsFirst));
foreach(QFileInfo info, list) { for (const QFileInfo& info : list)
{
if (info.isSymLink()) if (info.isSymLink())
continue; continue;

@ -44,7 +44,8 @@ void Config::GameSettings::validatePaths()
QStringList paths = mSettings.values(QString("data")); QStringList paths = mSettings.values(QString("data"));
Files::PathContainer dataDirs; Files::PathContainer dataDirs;
foreach (const QString &path, paths) { for (const QString &path : paths)
{
QByteArray bytes = path.toUtf8(); QByteArray bytes = path.toUtf8();
dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length()))); dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
} }
@ -511,7 +512,7 @@ bool Config::GameSettings::hasMaster()
void Config::GameSettings::setContentList(const QStringList& fileNames) void Config::GameSettings::setContentList(const QStringList& fileNames)
{ {
remove(sContentKey); remove(sContentKey);
foreach(const QString& fileName, fileNames) for (const QString& fileName : fileNames)
{ {
setMultiValue(sContentKey, fileName); setMultiValue(sContentKey, fileName);
} }

@ -29,7 +29,8 @@ QStringList Config::LauncherSettings::subKeys(const QString &key)
QStringList result; QStringList result;
foreach (const QString &currentKey, keys) { for (const QString &currentKey : keys)
{
if (keyRe.indexIn(currentKey) != -1) if (keyRe.indexIn(currentKey) != -1)
{ {
@ -110,7 +111,7 @@ void Config::LauncherSettings::setContentList(const GameSettings& gameSettings)
} }
// if any existing profile in launcher matches the content list, make that profile the default // if any existing profile in launcher matches the content list, make that profile the default
foreach(const QString &listName, getContentLists()) for (const QString &listName : getContentLists())
{ {
if (isEqual(files, getContentListFiles(listName))) if (isEqual(files, getContentListFiles(listName)))
{ {
@ -140,7 +141,7 @@ void Config::LauncherSettings::setContentList(const QString& contentListName, co
{ {
removeContentList(contentListName); removeContentList(contentListName);
QString key = makeContentListKey(contentListName); QString key = makeContentListKey(contentListName);
foreach(const QString& fileName, fileNames) for (const QString& fileName : fileNames)
{ {
setMultiValue(key, fileName); setMultiValue(key, fileName);
} }

@ -70,7 +70,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(co
if (name.contains ('/')) if (name.contains ('/'))
fp = EsmFile::FileProperty_FilePath; fp = EsmFile::FileProperty_FilePath;
foreach (const EsmFile *file, mFiles) for (const EsmFile *file : mFiles)
{ {
if (name.compare(file->fileProperty (fp).toString(), Qt::CaseInsensitive) == 0) if (name.compare(file->fileProperty (fp).toString(), Qt::CaseInsensitive) == 0)
return file; return file;
@ -108,7 +108,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
// addon can be checked if its gamefile is // addon can be checked if its gamefile is
// ... special case, addon with no dependency can be used with any gamefile. // ... special case, addon with no dependency can be used with any gamefile.
bool gamefileChecked = (file->gameFiles().count() == 0); bool gamefileChecked = (file->gameFiles().count() == 0);
foreach (const QString &fileName, file->gameFiles()) for (const QString &fileName : file->gameFiles())
{ {
for (QListIterator<EsmFile *> dependencyIter(mFiles); dependencyIter.hasNext(); dependencyIter.next()) for (QListIterator<EsmFile *> dependencyIter(mFiles); dependencyIter.hasNext(); dependencyIter.next())
{ {
@ -283,7 +283,7 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex &index, const
else else
return success; return success;
foreach (EsmFile *file2, mFiles) for (EsmFile *file2 : mFiles)
{ {
if (file2->gameFiles().contains(fileName, Qt::CaseInsensitive)) if (file2->gameFiles().contains(fileName, Qt::CaseInsensitive))
{ {
@ -346,7 +346,7 @@ QMimeData *ContentSelectorModel::ContentModel::mimeData(const QModelIndexList &i
{ {
QByteArray encodedData; QByteArray encodedData;
foreach (const QModelIndex &index, indexes) for (const QModelIndex &index : indexes)
{ {
if (!index.isValid()) if (!index.isValid())
continue; continue;
@ -424,7 +424,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon"; filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
dir.setNameFilters(filters); dir.setNameFilters(filters);
foreach (const QString &path2, dir.entryList()) for (const QString &path2 : dir.entryList())
{ {
QFileInfo info(dir.absoluteFilePath(path2)); QFileInfo info(dir.absoluteFilePath(path2));
@ -486,7 +486,7 @@ void ContentSelectorModel::ContentModel::clearFiles()
QStringList ContentSelectorModel::ContentModel::gameFiles() const QStringList ContentSelectorModel::ContentModel::gameFiles() const
{ {
QStringList gameFiles; QStringList gameFiles;
foreach(const ContentSelectorModel::EsmFile *file, mFiles) for (const ContentSelectorModel::EsmFile *file : mFiles)
{ {
if (file->isGameFile()) if (file->isGameFile())
{ {
@ -557,7 +557,7 @@ void ContentSelectorModel::ContentModel::setContentList(const QStringList &fileL
{ {
mPluginsWithLoadOrderError.clear(); mPluginsWithLoadOrderError.clear();
int previousPosition = -1; int previousPosition = -1;
foreach (const QString &filepath, fileList) for (const QString &filepath : fileList)
{ {
if (setCheckState(filepath, true)) if (setCheckState(filepath, true))
{ {
@ -598,7 +598,7 @@ void ContentSelectorModel::ContentModel::checkForLoadOrderErrors()
QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::checkForLoadOrderErrors(const EsmFile *file, int row) const QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::checkForLoadOrderErrors(const EsmFile *file, int row) const
{ {
QList<LoadOrderError> errors = QList<LoadOrderError>(); QList<LoadOrderError> errors = QList<LoadOrderError>();
foreach(const QString &dependentfileName, file->gameFiles()) for (const QString &dependentfileName : file->gameFiles())
{ {
const EsmFile* dependentFile = item(dependentfileName); const EsmFile* dependentFile = item(dependentfileName);
@ -627,7 +627,7 @@ QString ContentSelectorModel::ContentModel::toolTip(const EsmFile *file) const
{ {
QString text("<b>"); QString text("<b>");
int index = indexFromItem(item(file->filePath())).row(); int index = indexFromItem(item(file->filePath())).row();
foreach(const LoadOrderError& error, checkForLoadOrderErrors(file, index)) for (const LoadOrderError& error : checkForLoadOrderErrors(file, index))
{ {
text += "<p>"; text += "<p>";
text += error.toolTip(); text += error.toolTip();
@ -672,7 +672,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString &filepath,
//if we're checking an item, ensure all "upstream" files (dependencies) are checked as well. //if we're checking an item, ensure all "upstream" files (dependencies) are checked as well.
if (state == Qt::Checked) if (state == Qt::Checked)
{ {
foreach (QString upstreamName, file->gameFiles()) for (const QString& upstreamName : file->gameFiles())
{ {
const EsmFile *upstreamFile = item(upstreamName); const EsmFile *upstreamFile = item(upstreamName);
@ -689,7 +689,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString &filepath,
//otherwise, if we're unchecking an item (or the file is a game file) ensure all downstream files are unchecked. //otherwise, if we're unchecking an item (or the file is a game file) ensure all downstream files are unchecked.
if (state == Qt::Unchecked) if (state == Qt::Unchecked)
{ {
foreach (const EsmFile *downstreamFile, mFiles) for (const EsmFile *downstreamFile : mFiles)
{ {
QFileInfo fileInfo(filepath); QFileInfo fileInfo(filepath);
QString filename = fileInfo.fileName(); QString filename = fileInfo.fileName();
@ -714,7 +714,7 @@ ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checke
// TODO: // TODO:
// First search for game files and next addons, // First search for game files and next addons,
// so we get more or less correct game files vs addons order. // so we get more or less correct game files vs addons order.
foreach (EsmFile *file, mFiles) for (EsmFile *file : mFiles)
if (isChecked(file->filePath())) if (isChecked(file->filePath()))
list << file; list << file;

@ -72,7 +72,7 @@ void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &
{ {
clearCheckStates(); clearCheckStates();
foreach (const QString &filepath, fileList) for (const QString &filepath : fileList)
{ {
const ContentSelectorModel::EsmFile *file = mContentModel->item(filepath); const ContentSelectorModel::EsmFile *file = mContentModel->item(filepath);
if (file && file->isGameFile()) if (file && file->isGameFile())
@ -139,7 +139,7 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
mContentModel->addFiles(path); mContentModel->addFiles(path);
// add any game files to the combo box // add any game files to the combo box
foreach(const QString gameFileName, mContentModel->gameFiles()) for (const QString& gameFileName : mContentModel->gameFiles())
{ {
if (ui.gameFileView->findText(gameFileName) == -1) if (ui.gameFileView->findText(gameFileName) == -1)
{ {
@ -225,7 +225,7 @@ void ContentSelectorView::ContentSelector::slotShowContextMenu(const QPoint& pos
void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(bool checked) void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(bool checked)
{ {
Qt::CheckState checkState = checked ? Qt::Checked : Qt::Unchecked; Qt::CheckState checkState = checked ? Qt::Checked : Qt::Unchecked;
foreach(const QModelIndex& index, ui.addonView->selectionModel()->selectedIndexes()) for (const QModelIndex& index : ui.addonView->selectionModel()->selectedIndexes())
{ {
QModelIndex sourceIndex = mAddonProxyModel->mapToSource(index); QModelIndex sourceIndex = mAddonProxyModel->mapToSource(index);
if (mContentModel->data(sourceIndex, Qt::CheckStateRole).toInt() != checkState) if (mContentModel->data(sourceIndex, Qt::CheckStateRole).toInt() != checkState)
@ -249,7 +249,7 @@ void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths()
{ {
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
QString filepaths; QString filepaths;
foreach (const QModelIndex& index, ui.addonView->selectionModel()->selectedIndexes()) for (const QModelIndex& index : ui.addonView->selectionModel()->selectedIndexes())
{ {
int row = mAddonProxyModel->mapToSource(index).row(); int row = mAddonProxyModel->mapToSource(index).row();
const ContentSelectorModel::EsmFile *file = mContentModel->item(row); const ContentSelectorModel::EsmFile *file = mContentModel->item(row);

Loading…
Cancel
Save