From d13f6bb870cdda71257f665367be8ef9fca86255 Mon Sep 17 00:00:00 2001 From: MikaĆ«l Capelle Date: Tue, 17 May 2022 11:47:01 +0200 Subject: Apply clang-format. --- src/modinforegular.cpp | 310 +++++++++++++++++++++++++++---------------------- 1 file changed, 168 insertions(+), 142 deletions(-) (limited to 'src/modinforegular.cpp') diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index eb84a2ad..4c1004e6 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -2,11 +2,11 @@ #include "categories.h" #include "messagedialog.h" -#include "report.h" #include "moddatacontent.h" -#include "settings.h" #include "organizercore.h" #include "plugincontainer.h" +#include "report.h" +#include "settings.h" #include #include @@ -18,28 +18,24 @@ using namespace MOBase; using namespace MOShared; -namespace { - //Arguably this should be a class static or we should be using FileString rather - //than QString for the names. Or both. - static bool ByName(const ModInfo::Ptr &LHS, const ModInfo::Ptr &RHS) - { - return QString::compare(LHS->name(), RHS->name(), Qt::CaseInsensitive) < 0; - } -} - -ModInfoRegular::ModInfoRegular(const QDir &path, OrganizerCore& core) - : ModInfoWithConflictInfo(core) - , m_Name(path.dirName()) - , m_Path(path.absolutePath()) - , m_Repository() - , m_GameName(core.managedGame()->gameShortName()) - , m_IsAlternate(false) - , m_Converted(false) - , m_Validated(false) - , m_MetaInfoChanged(false) - , m_EndorsedState(EndorsedState::ENDORSED_UNKNOWN) - , m_TrackedState(TrackedState::TRACKED_UNKNOWN) - , m_NexusBridge(&core.pluginContainer()) +namespace +{ +// Arguably this should be a class static or we should be using FileString rather +// than QString for the names. Or both. +static bool ByName(const ModInfo::Ptr& LHS, const ModInfo::Ptr& RHS) +{ + return QString::compare(LHS->name(), RHS->name(), Qt::CaseInsensitive) < 0; +} +} // namespace + +ModInfoRegular::ModInfoRegular(const QDir& path, OrganizerCore& core) + : ModInfoWithConflictInfo(core), m_Name(path.dirName()), + m_Path(path.absolutePath()), m_Repository(), + m_GameName(core.managedGame()->gameShortName()), m_IsAlternate(false), + m_Converted(false), m_Validated(false), m_MetaInfoChanged(false), + m_EndorsedState(EndorsedState::ENDORSED_UNKNOWN), + m_TrackedState(TrackedState::TRACKED_UNKNOWN), + m_NexusBridge(&core.pluginContainer()) { m_CreationTime = QFileInfo(path.absolutePath()).birthTime(); // read out the meta-file for information @@ -48,28 +44,29 @@ ModInfoRegular::ModInfoRegular(const QDir &path, OrganizerCore& core) if (!core.managedGame()->primarySources().contains(m_GameName, Qt::CaseInsensitive)) m_IsAlternate = true; - //populate m_Archives + // populate m_Archives m_Archives = QStringList(); if (Settings::instance().archiveParsing()) { archives(true); } - connect(&m_NexusBridge, SIGNAL(descriptionAvailable(QString,int,QVariant,QVariant)) - , this, SLOT(nxmDescriptionAvailable(QString,int,QVariant,QVariant))); - connect(&m_NexusBridge, SIGNAL(endorsementToggled(QString,int,QVariant,QVariant)) - , this, SLOT(nxmEndorsementToggled(QString,int,QVariant,QVariant))); - connect(&m_NexusBridge, SIGNAL(trackingToggled(QString,int,QVariant,bool)) - , this, SLOT(nxmTrackingToggled(QString,int,QVariant,bool))); - connect(&m_NexusBridge, SIGNAL(requestFailed(QString,int,int,QVariant,int,QString)) - , this, SLOT(nxmRequestFailed(QString,int,int,QVariant,int,QString))); + connect(&m_NexusBridge, + SIGNAL(descriptionAvailable(QString, int, QVariant, QVariant)), this, + SLOT(nxmDescriptionAvailable(QString, int, QVariant, QVariant))); + connect(&m_NexusBridge, SIGNAL(endorsementToggled(QString, int, QVariant, QVariant)), + this, SLOT(nxmEndorsementToggled(QString, int, QVariant, QVariant))); + connect(&m_NexusBridge, SIGNAL(trackingToggled(QString, int, QVariant, bool)), this, + SLOT(nxmTrackingToggled(QString, int, QVariant, bool))); + connect(&m_NexusBridge, + SIGNAL(requestFailed(QString, int, int, QVariant, int, QString)), this, + SLOT(nxmRequestFailed(QString, int, int, QVariant, int, QString))); } - ModInfoRegular::~ModInfoRegular() { try { saveMeta(); - } catch (const std::exception &e) { + } catch (const std::exception& e) { log::error("failed to save meta information for \"{}\": {}", m_Name, e.what()); } } @@ -77,21 +74,23 @@ ModInfoRegular::~ModInfoRegular() bool ModInfoRegular::isEmpty() const { QDirIterator iter(m_Path, QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); - if (!iter.hasNext()) return true; + if (!iter.hasNext()) + return true; iter.next(); - if ((iter.fileName() == "meta.ini") && !iter.hasNext()) return true; + if ((iter.fileName() == "meta.ini") && !iter.hasNext()) + return true; return false; } - void ModInfoRegular::readMeta() { QSettings metaFile(m_Path + "/meta.ini", QSettings::IniFormat); - m_Comments = metaFile.value("comments", "").toString(); - m_Notes = metaFile.value("notes", "").toString(); + m_Comments = metaFile.value("comments", "").toString(); + m_Notes = metaFile.value("notes", "").toString(); QString tempGameName = metaFile.value("gameName", m_GameName).toString(); - if (tempGameName.size()) m_GameName = tempGameName; - m_NexusID = metaFile.value("modid", -1).toInt(); + if (tempGameName.size()) + m_GameName = tempGameName; + m_NexusID = metaFile.value("modid", -1).toInt(); m_Version.parse(metaFile.value("version", "").toString()); m_NewestVersion = metaFile.value("newestVersion", "").toString(); m_IgnoredVersion = metaFile.value("ignoredVersion", "").toString(); @@ -165,36 +164,54 @@ void ModInfoRegular::readMeta() } } - m_LastNexusQuery = QDateTime::fromString(metaFile.value("lastNexusQuery", "").toString(), Qt::ISODate); - m_LastNexusUpdate = QDateTime::fromString(metaFile.value("lastNexusUpdate", "").toString(), Qt::ISODate); - m_NexusLastModified = QDateTime::fromString(metaFile.value("nexusLastModified", QDateTime::currentDateTimeUtc()).toString(), Qt::ISODate); - m_Color = metaFile.value("color",QColor()).value(); - m_TrackedState = metaFile.value("tracked", false).toBool() ? TrackedState::TRACKED_TRUE : TrackedState::TRACKED_FALSE; + m_LastNexusQuery = QDateTime::fromString( + metaFile.value("lastNexusQuery", "").toString(), Qt::ISODate); + m_LastNexusUpdate = QDateTime::fromString( + metaFile.value("lastNexusUpdate", "").toString(), Qt::ISODate); + m_NexusLastModified = QDateTime::fromString( + metaFile.value("nexusLastModified", QDateTime::currentDateTimeUtc()).toString(), + Qt::ISODate); + m_Color = metaFile.value("color", QColor()).value(); + m_TrackedState = metaFile.value("tracked", false).toBool() + ? TrackedState::TRACKED_TRUE + : TrackedState::TRACKED_FALSE; if (metaFile.contains("endorsed")) { if (metaFile.value("endorsed").canConvert()) { using ut = std::underlying_type_t; switch (metaFile.value("endorsed").toInt()) { - case static_cast(EndorsedState::ENDORSED_FALSE): m_EndorsedState = EndorsedState::ENDORSED_FALSE; break; - case static_cast(EndorsedState::ENDORSED_TRUE): m_EndorsedState = EndorsedState::ENDORSED_TRUE; break; - case static_cast(EndorsedState::ENDORSED_NEVER): m_EndorsedState = EndorsedState::ENDORSED_NEVER; break; - default: m_EndorsedState = EndorsedState::ENDORSED_UNKNOWN; break; + case static_cast(EndorsedState::ENDORSED_FALSE): + m_EndorsedState = EndorsedState::ENDORSED_FALSE; + break; + case static_cast(EndorsedState::ENDORSED_TRUE): + m_EndorsedState = EndorsedState::ENDORSED_TRUE; + break; + case static_cast(EndorsedState::ENDORSED_NEVER): + m_EndorsedState = EndorsedState::ENDORSED_NEVER; + break; + default: + m_EndorsedState = EndorsedState::ENDORSED_UNKNOWN; + break; } } else { - m_EndorsedState = metaFile.value("endorsed", false).toBool() ? EndorsedState::ENDORSED_TRUE : EndorsedState::ENDORSED_FALSE; + m_EndorsedState = metaFile.value("endorsed", false).toBool() + ? EndorsedState::ENDORSED_TRUE + : EndorsedState::ENDORSED_FALSE; } } QString categoriesString = metaFile.value("category", "").toString(); QStringList categories = categoriesString.split(',', Qt::SkipEmptyParts); - for (QStringList::iterator iter = categories.begin(); iter != categories.end(); ++iter) { - bool ok = false; + for (QStringList::iterator iter = categories.begin(); iter != categories.end(); + ++iter) { + bool ok = false; int categoryID = iter->toInt(&ok); if (categoryID < 0) { // ignore invalid id continue; } - if (ok && (categoryID != 0) && (CategoryFactory::instance().categoryExists(categoryID))) { + if (ok && (categoryID != 0) && + (CategoryFactory::instance().categoryExists(categoryID))) { m_Categories.insert(categoryID); if (iter == categories.begin()) { m_PrimaryCategory = categoryID; @@ -205,13 +222,14 @@ void ModInfoRegular::readMeta() int numFiles = metaFile.beginReadArray("installedFiles"); for (int i = 0; i < numFiles; ++i) { metaFile.setArrayIndex(i); - m_InstalledFileIDs.insert(std::make_pair(metaFile.value("modid").toInt(), metaFile.value("fileid").toInt())); + m_InstalledFileIDs.insert(std::make_pair(metaFile.value("modid").toInt(), + metaFile.value("fileid").toInt())); } metaFile.endArray(); // Plugin settings: metaFile.beginGroup("Plugins"); - for (auto pluginName: metaFile.childGroups()) { + for (auto pluginName : metaFile.childGroups()) { metaFile.beginGroup(pluginName); for (auto settingKey : metaFile.childKeys()) { m_PluginSettings[pluginName][settingKey] = metaFile.value(settingKey); @@ -231,7 +249,8 @@ void ModInfoRegular::saveMeta() if (metaFile.status() == QSettings::NoError) { std::set temp = m_Categories; temp.erase(m_PrimaryCategory); - metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + SetJoin(temp, ",")); + metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + + SetJoin(temp, ",")); metaFile.setValue("newestVersion", m_NewestVersion.canonicalString()); metaFile.setValue("ignoredVersion", m_IgnoredVersion.canonicalString()); metaFile.setValue("version", m_Version.canonicalString()); @@ -252,16 +271,20 @@ void ModInfoRegular::saveMeta() metaFile.setValue("validated", m_Validated); metaFile.setValue("color", m_Color); if (m_EndorsedState != EndorsedState::ENDORSED_UNKNOWN) { - metaFile.setValue("endorsed", static_cast>(m_EndorsedState)); + metaFile.setValue( + "endorsed", + static_cast>(m_EndorsedState)); } if (m_TrackedState != TrackedState::TRACKED_UNKNOWN) { - metaFile.setValue("tracked", static_cast>(m_TrackedState)); + metaFile.setValue("tracked", static_cast>( + m_TrackedState)); } metaFile.remove("installedFiles"); metaFile.beginWriteArray("installedFiles"); int idx = 0; - for (auto iter = m_InstalledFileIDs.begin(); iter != m_InstalledFileIDs.end(); ++iter) { + for (auto iter = m_InstalledFileIDs.begin(); iter != m_InstalledFileIDs.end(); + ++iter) { metaFile.setArrayIndex(idx++); metaFile.setValue("modid", iter->first); metaFile.setValue("fileid", iter->second); @@ -271,33 +294,30 @@ void ModInfoRegular::saveMeta() // Plugin settings: metaFile.remove("Plugins"); metaFile.beginGroup("Plugins"); - for (const auto& [pluginName, pluginSettings]: m_PluginSettings) { + for (const auto& [pluginName, pluginSettings] : m_PluginSettings) { metaFile.beginGroup(pluginName); - for (const auto& [settingName, settingValue]: pluginSettings) { + for (const auto& [settingName, settingValue] : pluginSettings) { metaFile.setValue(settingName, settingValue); } metaFile.endGroup(); } metaFile.endGroup(); - metaFile.sync(); // sync needs to be called to ensure the file is created + metaFile.sync(); // sync needs to be called to ensure the file is created if (metaFile.status() == QSettings::NoError) { m_MetaInfoChanged = false; } else { - log::error( - "failed to write {}/meta.ini: error {}", - absolutePath(), metaFile.status()); + log::error("failed to write {}/meta.ini: error {}", absolutePath(), + metaFile.status()); } } else { - log::error( - "failed to write {}/meta.ini: error {}", - absolutePath(), metaFile.status()); + log::error("failed to write {}/meta.ini: error {}", absolutePath(), + metaFile.status()); } } } - bool ModInfoRegular::updateAvailable() const { if (m_IgnoredVersion.isValid() && (m_IgnoredVersion == m_NewestVersion)) { @@ -309,7 +329,6 @@ bool ModInfoRegular::updateAvailable() const return m_NewestVersion.isValid() && (m_Version < m_NewestVersion); } - bool ModInfoRegular::downgradeAvailable() const { if (m_IgnoredVersion.isValid() && (m_IgnoredVersion == m_NewestVersion)) { @@ -318,14 +337,15 @@ bool ModInfoRegular::downgradeAvailable() const return m_NewestVersion.isValid() && (m_NewestVersion < m_Version); } - -void ModInfoRegular::nxmDescriptionAvailable(QString, int, QVariant, QVariant resultData) +void ModInfoRegular::nxmDescriptionAvailable(QString, int, QVariant, + QVariant resultData) { QVariantMap result = resultData.toMap(); setNexusDescription(result["description"].toString()); - if ((m_EndorsedState != EndorsedState::ENDORSED_NEVER) && (result.contains("endorsement"))) { - QVariantMap endorsement = result["endorsement"].toMap(); + if ((m_EndorsedState != EndorsedState::ENDORSED_NEVER) && + (result.contains("endorsement"))) { + QVariantMap endorsement = result["endorsement"].toMap(); QString endorsementStatus = endorsement["endorse_status"].toString(); if (endorsementStatus.compare("Endorsed", Qt::CaseInsensitive) == 00) setEndorsedState(EndorsedState::ENDORSED_TRUE); @@ -335,14 +355,14 @@ void ModInfoRegular::nxmDescriptionAvailable(QString, int, QVariant, QVariant re setEndorsedState(EndorsedState::ENDORSED_FALSE); } m_LastNexusQuery = QDateTime::currentDateTimeUtc(); - m_NexusLastModified = QDateTime::fromSecsSinceEpoch(result["updated_timestamp"].toInt(), Qt::UTC); + m_NexusLastModified = + QDateTime::fromSecsSinceEpoch(result["updated_timestamp"].toInt(), Qt::UTC); m_MetaInfoChanged = true; saveMeta(); disconnect(sender(), SIGNAL(descriptionAvailable(QString, int, QVariant, QVariant))); emit modDetailsUpdated(true); } - void ModInfoRegular::nxmEndorsementToggled(QString, int, QVariant, QVariant resultData) { QMap results = resultData.toMap(); @@ -358,7 +378,6 @@ void ModInfoRegular::nxmEndorsementToggled(QString, int, QVariant, QVariant resu emit modDetailsUpdated(true); } - void ModInfoRegular::nxmTrackingToggled(QString, int, QVariant, bool tracked) { if (tracked) @@ -370,12 +389,13 @@ void ModInfoRegular::nxmTrackingToggled(QString, int, QVariant, bool tracked) emit modDetailsUpdated(true); } - -void ModInfoRegular::nxmRequestFailed(QString, int, int, QVariant userData, int errorCode, const QString &errorMessage) +void ModInfoRegular::nxmRequestFailed(QString, int, int, QVariant userData, + int errorCode, const QString& errorMessage) { QString fullMessage = errorMessage; if (userData.canConvert() && (userData.toInt() == 1)) { - fullMessage += "\nNexus will reject endorsements within 15 Minutes of a failed attempt, the error message may be misleading."; + fullMessage += "\nNexus will reject endorsements within 15 Minutes of a failed " + "attempt, the error message may be misleading."; } if (QApplication::activeWindow() != nullptr) { MessageDialog::showMessage(fullMessage, QApplication::activeWindow()); @@ -383,7 +403,6 @@ void ModInfoRegular::nxmRequestFailed(QString, int, int, QVariant userData, int emit modDetailsUpdated(false); } - bool ModInfoRegular::updateNXMInfo() { if (needsDescriptionUpdate()) { @@ -397,7 +416,7 @@ bool ModInfoRegular::updateNXMInfo() bool ModInfoRegular::needsDescriptionUpdate() const { if (m_NexusID > 0) { - QDateTime time = QDateTime::currentDateTimeUtc(); + QDateTime time = QDateTime::currentDateTimeUtc(); QDateTime target = m_LastNexusQuery.addDays(1); if (time >= target) { @@ -432,14 +451,14 @@ void ModInfoRegular::setCategory(int categoryID, bool active) } } - -bool ModInfoRegular::setName(const QString &name) +bool ModInfoRegular::setName(const QString& name) { if (name.contains('/') || name.contains('\\')) { return false; } - QString newPath = m_Path.mid(0).replace(m_Path.length() - m_Name.length(), m_Name.length(), name); + QString newPath = + m_Path.mid(0).replace(m_Path.length() - m_Name.length(), m_Name.length(), name); QDir modDir(m_Path.mid(0, m_Path.length() - m_Name.length())); if (m_Name.compare(name, Qt::CaseInsensitive) == 0) { @@ -452,7 +471,8 @@ bool ModInfoRegular::setName(const QString &name) return false; } if (!modDir.rename(tempName, name)) { - log::error("rename to final name failed after successful rename to intermediate name"); + log::error( + "rename to final name failed after successful rename to intermediate name"); modDir.rename(tempName, m_Name); return false; } @@ -477,7 +497,7 @@ bool ModInfoRegular::setName(const QString &name) std::sort(s_Collection.begin(), s_Collection.end(), ModInfo::ByName); updateIndices(); - } else { // otherwise mod isn't registered yet? + } else { // otherwise mod isn't registered yet? m_Name = name; m_Path = newPath; } @@ -485,56 +505,56 @@ bool ModInfoRegular::setName(const QString &name) return true; } -void ModInfoRegular::setComments(const QString &comments) +void ModInfoRegular::setComments(const QString& comments) { - m_Comments = comments; + m_Comments = comments; m_MetaInfoChanged = true; } -void ModInfoRegular::setNotes(const QString ¬es) +void ModInfoRegular::setNotes(const QString& notes) { - m_Notes = notes; + m_Notes = notes; m_MetaInfoChanged = true; } void ModInfoRegular::setGameName(const QString& gameName) { - m_GameName = gameName; + m_GameName = gameName; m_MetaInfoChanged = true; } void ModInfoRegular::setNexusID(int modID) { - m_NexusID = modID; + m_NexusID = modID; m_MetaInfoChanged = true; } -void ModInfoRegular::setVersion(const VersionInfo &version) +void ModInfoRegular::setVersion(const VersionInfo& version) { - m_Version = version; + m_Version = version; m_MetaInfoChanged = true; } -void ModInfoRegular::setNewestVersion(const VersionInfo &version) +void ModInfoRegular::setNewestVersion(const VersionInfo& version) { if (version != m_NewestVersion) { - m_NewestVersion = version; + m_NewestVersion = version; m_MetaInfoChanged = true; } } -void ModInfoRegular::setNexusDescription(const QString &description) +void ModInfoRegular::setNexusDescription(const QString& description) { if (qHash(description) != qHash(m_NexusDescription)) { m_NexusDescription = description; - m_MetaInfoChanged = true; + m_MetaInfoChanged = true; } } void ModInfoRegular::setEndorsedState(EndorsedState endorsedState) { if (endorsedState != m_EndorsedState) { - m_EndorsedState = endorsedState; + m_EndorsedState = endorsedState; m_MetaInfoChanged = true; } } @@ -542,15 +562,15 @@ void ModInfoRegular::setEndorsedState(EndorsedState endorsedState) void ModInfoRegular::setTrackedState(TrackedState trackedState) { if (trackedState != m_TrackedState) { - m_TrackedState = trackedState; + m_TrackedState = trackedState; m_MetaInfoChanged = true; } } -void ModInfoRegular::setInstallationFile(const QString &fileName) +void ModInfoRegular::setInstallationFile(const QString& fileName) { m_InstallationFile = fileName; - m_MetaInfoChanged = true; + m_MetaInfoChanged = true; } void ModInfoRegular::addNexusCategory(int categoryID) @@ -561,14 +581,15 @@ void ModInfoRegular::addNexusCategory(int categoryID) void ModInfoRegular::setIsEndorsed(bool endorsed) { if (m_EndorsedState != EndorsedState::ENDORSED_NEVER) { - m_EndorsedState = endorsed ? EndorsedState::ENDORSED_TRUE : EndorsedState::ENDORSED_FALSE; + m_EndorsedState = + endorsed ? EndorsedState::ENDORSED_TRUE : EndorsedState::ENDORSED_FALSE; m_MetaInfoChanged = true; } } void ModInfoRegular::setNeverEndorse() { - m_EndorsedState = EndorsedState::ENDORSED_NEVER; + m_EndorsedState = EndorsedState::ENDORSED_NEVER; m_MetaInfoChanged = true; } @@ -582,7 +603,7 @@ void ModInfoRegular::setIsTracked(bool tracked) void ModInfoRegular::setColor(QColor color) { - m_Color = color; + m_Color = color; m_MetaInfoChanged = true; } @@ -594,7 +615,8 @@ QColor ModInfoRegular::color() const void ModInfoRegular::endorse(bool doEndorse) { if (doEndorse != (m_EndorsedState == EndorsedState::ENDORSED_TRUE)) { - m_NexusBridge.requestToggleEndorsement(m_GameName, nexusId(), m_Version.canonicalString(), doEndorse, QVariant(1)); + m_NexusBridge.requestToggleEndorsement( + m_GameName, nexusId(), m_Version.canonicalString(), doEndorse, QVariant(1)); } } @@ -607,7 +629,7 @@ void ModInfoRegular::track(bool doTrack) void ModInfoRegular::markConverted(bool converted) { - m_Converted = converted; + m_Converted = converted; m_MetaInfoChanged = true; saveMeta(); emit modDetailsUpdated(true); @@ -615,7 +637,7 @@ void ModInfoRegular::markConverted(bool converted) void ModInfoRegular::markValidated(bool validated) { - m_Validated = validated; + m_Validated = validated; m_MetaInfoChanged = true; saveMeta(); emit modDetailsUpdated(true); @@ -638,7 +660,7 @@ void ModInfoRegular::ignoreUpdate(bool ignore) bool ModInfoRegular::canBeUpdated() const { - QDateTime now = QDateTime::currentDateTimeUtc(); + QDateTime now = QDateTime::currentDateTimeUtc(); QDateTime target = getExpires(); if (now >= target) return m_NexusID > 0; @@ -653,13 +675,11 @@ QDateTime ModInfoRegular::getExpires() const std::vector ModInfoRegular::getFlags() const { std::vector result = ModInfoWithConflictInfo::getFlags(); - if ((m_NexusID > 0) && - (endorsedState() == EndorsedState::ENDORSED_FALSE) && + if ((m_NexusID > 0) && (endorsedState() == EndorsedState::ENDORSED_FALSE) && Settings::instance().nexus().endorsementIntegration()) { result.push_back(ModInfo::FLAG_NOTENDORSED); } - if ((m_NexusID > 0) && - (trackedState() == TrackedState::TRACKED_TRUE) && + if ((m_NexusID > 0) && (trackedState() == TrackedState::TRACKED_TRUE) && Settings::instance().nexus().trackedIntegration()) { result.push_back(ModInfo::FLAG_TRACKED); } @@ -678,7 +698,6 @@ std::vector ModInfoRegular::getFlags() const return result; } - std::set ModInfoRegular::doGetContents() const { ModDataContent* contentFeature = m_Core.managedGame()->feature(); @@ -691,33 +710,37 @@ std::set ModInfoRegular::doGetContents() const return {}; } - int ModInfoRegular::getHighlight() const { if (!isValid() && !m_Validated) return HIGHLIGHT_INVALID; auto flags = getFlags(); - if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_PLUGIN_SELECTED) != flags.end()) + if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_PLUGIN_SELECTED) != + flags.end()) return HIGHLIGHT_PLUGIN; return HIGHLIGHT_NONE; } - QString ModInfoRegular::getDescription() const { - if (!isValid() && !m_Validated) { - return tr("%1 contains no esp/esm/esl and no asset (textures, meshes, interface, ...) directory").arg(name()); + if (!isValid() && !m_Validated) { + return tr("%1 contains no esp/esm/esl and no asset (textures, meshes, interface, " + "...) directory") + .arg(name()); } else { - const std::set &categories = getCategories(); + const std::set& categories = getCategories(); std::wostringstream categoryString; categoryString << ToWString(tr("Categories:
")); - CategoryFactory &categoryFactory = CategoryFactory::instance(); + CategoryFactory& categoryFactory = CategoryFactory::instance(); for (std::set::const_iterator catIter = categories.begin(); catIter != categories.end(); ++catIter) { if (catIter != categories.begin()) { categoryString << " , "; } - categoryString << "" << ToWString(categoryFactory.getCategoryName(categoryFactory.getCategoryIndex(*catIter))) << ""; + categoryString << "" + << ToWString(categoryFactory.getCategoryName( + categoryFactory.getCategoryIndex(*catIter))) + << ""; } return ToQString(categoryString.str()); @@ -792,7 +815,7 @@ QDateTime ModInfoRegular::getLastNexusQuery() const void ModInfoRegular::setLastNexusQuery(QDateTime time) { - m_LastNexusQuery = time; + m_LastNexusQuery = time; m_MetaInfoChanged = true; saveMeta(); emit modDetailsUpdated(true); @@ -806,14 +829,14 @@ QDateTime ModInfoRegular::getNexusLastModified() const void ModInfoRegular::setNexusLastModified(QDateTime time) { m_NexusLastModified = time; - m_MetaInfoChanged = true; + m_MetaInfoChanged = true; saveMeta(); emit modDetailsUpdated(true); } -void ModInfoRegular::setCustomURL(QString const &url) +void ModInfoRegular::setCustomURL(QString const& url) { - m_CustomURL = url; + m_CustomURL = url; m_MetaInfoChanged = true; } @@ -824,7 +847,7 @@ QString ModInfoRegular::url() const void ModInfoRegular::setHasCustomURL(bool b) { - m_HasCustomURL = b; + m_HasCustomURL = b; m_MetaInfoChanged = true; } @@ -838,8 +861,8 @@ QStringList ModInfoRegular::archives(bool checkOnDisk) if (checkOnDisk) { QStringList result; QDir dir(this->absolutePath()); - QStringList bsaList = dir.entryList(QStringList({ "*.bsa", "*.ba2" })); - for (const QString &archive : bsaList) { + QStringList bsaList = dir.entryList(QStringList({"*.bsa", "*.ba2"})); + for (const QString& archive : bsaList) { result.append(this->absolutePath() + "/" + archive); } m_Archives = result; @@ -863,22 +886,22 @@ std::vector ModInfoRegular::getIniTweaks() const int numTweaks = metaFile.beginReadArray("INI Tweaks"); if (numTweaks != 0) { - log::debug( - "{} active ini tweaks in {}", - numTweaks, QDir::toNativeSeparators(metaFileName)); + log::debug("{} active ini tweaks in {}", numTweaks, + QDir::toNativeSeparators(metaFileName)); } for (int i = 0; i < numTweaks; ++i) { metaFile.setArrayIndex(i); - QString filename = absolutePath().append("/INI Tweaks/").append(metaFile.value("name").toString()); + QString filename = + absolutePath().append("/INI Tweaks/").append(metaFile.value("name").toString()); result.push_back(filename); } metaFile.endArray(); return result; } - -std::map ModInfoRegular::pluginSettings(const QString& pluginName) const +std::map +ModInfoRegular::pluginSettings(const QString& pluginName) const { auto itp = m_PluginSettings.find(pluginName); if (itp == std::end(m_PluginSettings)) { @@ -887,7 +910,8 @@ std::map ModInfoRegular::pluginSettings(const QString& plugin return itp->second; } -QVariant ModInfoRegular::pluginSetting(const QString& pluginName, const QString& key, const QVariant& defaultValue) const +QVariant ModInfoRegular::pluginSetting(const QString& pluginName, const QString& key, + const QVariant& defaultValue) const { auto itp = m_PluginSettings.find(pluginName); if (itp == std::end(m_PluginSettings)) { @@ -902,15 +926,17 @@ QVariant ModInfoRegular::pluginSetting(const QString& pluginName, const QString& return its->second; } -bool ModInfoRegular::setPluginSetting(const QString& pluginName, const QString& key, const QVariant& value) +bool ModInfoRegular::setPluginSetting(const QString& pluginName, const QString& key, + const QVariant& value) { m_PluginSettings[pluginName][key] = value; - m_MetaInfoChanged = true; + m_MetaInfoChanged = true; saveMeta(); return true; } -std::map ModInfoRegular::clearPluginSettings(const QString& pluginName) +std::map +ModInfoRegular::clearPluginSettings(const QString& pluginName) { auto itp = m_PluginSettings.find(pluginName); if (itp == std::end(m_PluginSettings)) { -- cgit v1.3.1