Skip to content

Commit

Permalink
Add a button to "Query Info" of every download in the list
Browse files Browse the repository at this point in the history
  • Loading branch information
Deewens committed Sep 3, 2023
1 parent c8e247f commit 432782e
Show file tree
Hide file tree
Showing 5 changed files with 1,260 additions and 1,228 deletions.
20 changes: 20 additions & 0 deletions src/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,26 @@ void DownloadManager::refreshList()
}
}

void DownloadManager::queryDownloadListInfo()
{
TimeThis tt("DownloadManager::queryDownloadListInfos()");

startDisableDirWatcher();

log::info("Retrieving infos from every download (if possible)...");

// Just go through all active downloads to query infos
for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
if (isInfoIncomplete(i)) {
queryInfoMd5(i);
}
}

log::info("Files infos have been retrived successfully!");

endDisableDirWatcher();
}

bool DownloadManager::addDownload(const QStringList& URLs, QString gameName, int modID,
int fileID, const ModRepositoryFileInfo* fileInfo)
{
Expand Down
5 changes: 5 additions & 0 deletions src/downloadmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ class DownloadManager : public QObject
*/
void refreshList();

/**
* @brief Query infos for every download in the list
*/
void queryDownloadListInfo();

public: // IDownloadManager interface:
int startDownloadURLs(const QStringList& urls);
int startDownloadNexusFile(int modID, int fileID);
Expand Down
10 changes: 9 additions & 1 deletion src/downloadstab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ui_mainwindow.h"

DownloadsTab::DownloadsTab(OrganizerCore& core, Ui::MainWindow* mwui)
: m_core(core), ui{mwui->btnRefreshDownloads, mwui->downloadView,
: m_core(core), ui{mwui->btnRefreshDownloads, mwui->btnQueryDownloadsInfo, mwui->downloadView,
mwui->showHiddenBox, mwui->downloadFilterEdit}
{
DownloadList* sourceModel = new DownloadList(m_core, ui.list);
Expand All @@ -26,6 +26,9 @@ DownloadsTab::DownloadsTab(OrganizerCore& core, Ui::MainWindow* mwui)
connect(ui.refresh, &QPushButton::clicked, [&] {
refresh();
});
connect(ui.queryInfos, &QPushButton::clicked, [&] {
queryInfos();
});
connect(ui.list, SIGNAL(installDownload(int)), &m_core, SLOT(installDownload(int)));
connect(ui.list, SIGNAL(queryInfo(int)), m_core.downloadManager(),
SLOT(queryInfo(int)));
Expand Down Expand Up @@ -80,6 +83,11 @@ void DownloadsTab::refresh()
m_core.downloadManager()->refreshList();
}

void DownloadsTab::queryInfos()
{
m_core.downloadManager()->queryDownloadListInfo();
}

void DownloadsTab::resumeDownload(int downloadIndex)
{
m_core.loggedInAction(ui.list, [this, downloadIndex] {
Expand Down
7 changes: 7 additions & 0 deletions src/downloadstab.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DownloadsTab : public QObject
struct DownloadsTabUi
{
QPushButton* refresh;
QPushButton* queryInfos;
DownloadListView* list;
QCheckBox* showHidden;
QLineEdit* filter;
Expand All @@ -33,6 +34,12 @@ class DownloadsTab : public QObject
MOBase::FilterWidget m_filter;

void refresh();

/**
* @brief Handle click on the "Query infos" button
**/
void queryInfos();

void resumeDownload(int downloadIndex);
};

Expand Down
Loading

0 comments on commit 432782e

Please sign in to comment.