From 9b5c238938461f8c811555647e459259b8aca2b3 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 3 Jan 2015 12:35:25 +0100 Subject: - repository info is now stored with the mod --- src/installationmanager.cpp | 13 +++++++++++-- src/installationmanager.h | 2 +- src/modinfo.cpp | 8 ++++++++ src/modinfo.h | 22 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 26329729..880587b7 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -513,7 +513,8 @@ bool InstallationManager::ensureValidModName(GuessedValue &name) const } bool InstallationManager::doInstall(GuessedValue &modName, int modID, - const QString &version, const QString &newestVersion, int categoryID) + const QString &version, const QString &newestVersion, + int categoryID, const QString &repository) { if (!ensureValidModName(modName)) { return false; @@ -568,6 +569,7 @@ bool InstallationManager::doInstall(GuessedValue &modName, int modID, settingsFile.setValue("category", QString::number(categoryID)); } settingsFile.setValue("installationFile", m_CurrentFile); + settingsFile.setValue("repository", repository); if (!merge) { // this does not clear the list we have in memory but the mod is going to have to be re-read anyway @@ -631,6 +633,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue QString version = ""; QString newestVersion = ""; int categoryID = 0; + QString repository = "Nexus"; QString metaName = fileName.mid(0).append(".meta"); if (QFile(metaName).exists()) { @@ -643,6 +646,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue newestVersion = metaFile.value("newestVersion", "").toString(); unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(metaFile.value("category", 0).toInt()); categoryID = CategoryFactory::instance().getCategoryID(categoryIndex); + repository = metaFile.value("repository", "").toString(); } if (version.isEmpty()) { @@ -707,7 +711,7 @@ bool InstallationManager::install(const QString &fileName, GuessedValue if (installResult == IPluginInstaller::RESULT_SUCCESS) { mapToArchive(filesTree.data()); // the simple installer only prepares the installation, the rest works the same for all installers - if (!doInstall(modName, modID, version, newestVersion, categoryID)) { + if (!doInstall(modName, modID, version, newestVersion, categoryID, repository)) { installResult = IPluginInstaller::RESULT_FAILED; } } @@ -722,6 +726,11 @@ bool InstallationManager::install(const QString &fileName, GuessedValue std::set installerExtensions = installerCustom->supportedExtensions(); if (installerExtensions.find(fileInfo.suffix()) != installerExtensions.end()) { installResult = installerCustom->install(modName, fileName, version, modID); + unsigned int idx = ModInfo::getIndex(modName); + if (idx != UINT_MAX) { + ModInfo::Ptr info = ModInfo::getByIndex(idx); + info->setRepository(repository); + } } } } diff --git a/src/installationmanager.h b/src/installationmanager.h index 336c1ce3..40cffad4 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -169,7 +169,7 @@ private: //bool testOverwrite(const QString &modsDirectory, MOBase::GuessedValue &modName, bool *merge = NULL); bool doInstall(MOBase::GuessedValue &modName, - int modID, const QString &version, const QString &newestVersion, int categoryID); + int modID, const QString &version, const QString &newestVersion, int categoryID, const QString &repository); QString generateBackupName(const QString &directoryName) const; diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 9acadd97..c06a50d6 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -445,6 +445,7 @@ ModInfoRegular::ModInfoRegular(const QDir &path, DirectoryEntry **directoryStruc : ModInfoWithConflictInfo(directoryStructure) , m_Name(path.dirName()) , m_Path(path.absolutePath()) + , m_Repository() , m_MetaInfoChanged(false) , m_EndorsedState(ENDORSED_UNKNOWN) { @@ -492,6 +493,7 @@ void ModInfoRegular::readMeta() m_IgnoredVersion = metaFile.value("ignoredVersion", "").toString(); m_InstallationFile = metaFile.value("installationFile", "").toString(); m_NexusDescription = metaFile.value("nexusDescription", "").toString(); + m_Repository = metaFile.value("repository", "Nexus").toString(); m_LastNexusQuery = QDateTime::fromString(metaFile.value("lastNexusQuery", "").toString(), Qt::ISODate); if (metaFile.contains("endorsed")) { if (metaFile.value("endorsed").canConvert()) { @@ -547,6 +549,7 @@ void ModInfoRegular::saveMeta() metaFile.setValue("ignoredVersion", m_IgnoredVersion.canonicalString()); metaFile.setValue("version", m_Version.canonicalString()); metaFile.setValue("installationFile", m_InstallationFile); + metaFile.setValue("repository", m_Repository); metaFile.setValue("modid", m_NexusID); metaFile.setValue("notes", m_Notes); metaFile.setValue("nexusDescription", m_NexusDescription); @@ -886,6 +889,11 @@ QString ModInfoRegular::getNexusDescription() const return m_NexusDescription; } +QString ModInfoRegular::repository() const +{ + return m_Repository; +} + ModInfoRegular::EEndorsedState ModInfoRegular::endorsedState() const { return m_EndorsedState; diff --git a/src/modinfo.h b/src/modinfo.h index 70bc88c6..6fbab1a0 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -266,6 +266,11 @@ public: **/ virtual void setNewestVersion(const MOBase::VersionInfo &version) = 0; + /** + * @brief sets the repository that was used to download the mod + */ + virtual void setRepository(const QString &) {} + /** * @brief changes/updates the nexus description text * @param description the current description text @@ -348,6 +353,11 @@ public: **/ virtual MOBase::VersionInfo getNewestVersion() const = 0; + /** + * @return the repository from which the file was downloaded. Only relevant regular mods + */ + virtual QString repository() const { return ""; } + /** * @brief ignore the newest version for updates */ @@ -726,6 +736,12 @@ public: */ virtual void setPrimaryCategory(int categoryID) { m_PrimaryCategory = categoryID; m_MetaInfoChanged = true; } + /** + * @brief sets the download repository + * @param repository + */ + virtual void setRepository(const QString &repository) { m_Repository = repository; } + /** * update the endorsement state for the mod. This only changes the * buffered state, it does not sync with Nexus @@ -843,6 +859,11 @@ public: */ QString getNexusDescription() const; + /** + * @return repository from which the file was downloaded + */ + virtual QString repository() const; + /** * @return true if the file has been endorsed on nexus */ @@ -881,6 +902,7 @@ private: QString m_InstallationFile; QString m_Notes; QString m_NexusDescription; + QString m_Repository; QDateTime m_CreationTime; QDateTime m_LastNexusQuery; -- cgit v1.3.1