Skip to content

Commit

Permalink
Rework download category parsing
Browse files Browse the repository at this point in the history
- Bypasses issue where hidden downloads are not accessible
- getCategoryID no longer necessary
  • Loading branch information
Silarn committed Sep 21, 2023
1 parent 639fc78 commit 133c072
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
8 changes: 0 additions & 8 deletions src/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,14 +1404,6 @@ int DownloadManager::getModID(int index) const
return m_ActiveDownloads.at(index)->m_FileInfo->modID;
}

int DownloadManager::getCategoryID(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
throw MyException(tr("mod id: invalid download index %1").arg(index));
}
return m_ActiveDownloads.at(index)->m_FileInfo->categoryID;
}

QString DownloadManager::getDisplayGameName(int index) const
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
Expand Down
8 changes: 0 additions & 8 deletions src/downloadmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,6 @@ class DownloadManager : public QObject
**/
int getModID(int index) const;

/**
* @brief retrieve the nexus category id of the download specified by index
*
* @param index index of the file to look up
* @return the nexus category id
*/
int getCategoryID(int index) const;

/**
* @brief retrieve the displayable game name of the download specified by the index
*
Expand Down
19 changes: 10 additions & 9 deletions src/modlistviewactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ void ModListViewActions::assignCategories() const
}
for (auto mod : m_core.modList()->allMods()) {
ModInfo::Ptr modInfo = ModInfo::getByName(mod);
QString file = modInfo->installationFile();
int nexusCategory = modInfo->getNexusCategory();
if (!nexusCategory) {
auto download = m_core.downloadManager()->getDownloadIndex(file);
if (download >= 0) {
nexusCategory = m_core.downloadManager()->getCategoryID(download);
QSettings downloadMeta(m_core.downloadsPath() + "/" +
modInfo->installationFile() + ".meta",
QSettings::IniFormat);
if (downloadMeta.contains("category")) {
nexusCategory = downloadMeta.value("category", 0).toInt();
}
}
int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);
Expand Down Expand Up @@ -1127,11 +1128,11 @@ void ModListViewActions::remapCategory(const QModelIndexList& indices) const

int categoryID = modInfo->getNexusCategory();
if (!categoryID) {
int downloadIndex =
m_core.downloadManager()->getDownloadIndex(modInfo->installationFile());
if (downloadIndex >= 0) {
auto downloadInfo = m_core.downloadManager()->getFileInfo(downloadIndex);
categoryID = downloadInfo->categoryID;
QSettings downloadMeta(m_core.downloadsPath() + "/" +
modInfo->installationFile() + ".meta",
QSettings::IniFormat);
if (downloadMeta.contains("category")) {
categoryID = downloadMeta.value("category", 0).toInt();
}
}
unsigned int categoryIndex =
Expand Down

0 comments on commit 133c072

Please sign in to comment.