Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f859a8
Encapsulate the downloads directory watcher in DirWatcherManager
Al12rs Apr 18, 2026
ca13e62
Replace aboutToUpdate/update(int) with ModelResetGuard
Al12rs Apr 18, 2026
bb0590b
Centralize row notifications in setState and fix missed emits
Al12rs Apr 18, 2026
9e6d62c
Fix comma operator in addNXMDownload pending-dedup check
Al12rs Apr 18, 2026
66e6f21
Fix lost finished() signal on fast downloads
Al12rs Apr 18, 2026
7c07854
Fix memory leak in DownloadInfo::createFromMeta
Al12rs Apr 18, 2026
12ce5af
Sanitize suffix path in getDownloadFileName
Al12rs Apr 18, 2026
688a866
[pre-commit.ci] Auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Apr 18, 2026
3253747
Remove unused alphabetical translation vector
Al12rs Apr 18, 2026
ce2068f
Address PR feedback: fix redundant check and move refresh outside try…
Al12rs Apr 19, 2026
04c9b33
Coalesce the removeDownload reset with the following refreshList
Al12rs Apr 19, 2026
abaf343
Guard the .meta creation in openMetaFile against the directory watcher
Al12rs Apr 19, 2026
2a8d211
Extract getValidGameShortName method in download manager (#2380)
JonathanFeenstra Apr 26, 2026
e62e839
Add stable download id index and PendingDownload struct
Al12rs Apr 19, 2026
a7c0f90
Return stable ids from the plugin-facing download API
Al12rs Apr 19, 2026
c8df287
Split downloadFinished into onReplyFinished slot and finishDownload
Al12rs Apr 19, 2026
97b2128
Introduce DownloadID alias and row/id accessors
Al12rs Apr 19, 2026
6c3a20e
Convert cancel/pause/resume action methods to take DownloadID
Al12rs Apr 19, 2026
6a24bed
[pre-commit.ci] Auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Apr 19, 2026
114cef4
fix warnings about unused variables and size_t types
Al12rs Apr 21, 2026
d02904e
cleanup dead code
Al12rs Apr 26, 2026
a44dfe7
avoid calling processEvents when releasing the DirWatcherGuard
Al12rs Apr 26, 2026
32d22fd
[pre-commit.ci] Auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Apr 26, 2026
fc4aab0
use QEventLoop instead of manual ProcessEvents
Al12rs Apr 26, 2026
12e7903
don't call processEvents in download started and defer handling finis…
Al12rs Apr 26, 2026
7682433
Cleanup pending download in case of failure.
Al12rs Apr 26, 2026
a3a9d00
Add missing notifyPendingDownloadFailed if user cancels
Al12rs Apr 26, 2026
73a7b19
[pre-commit.ci] Auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Apr 26, 2026
03509b3
Refactor pending download failure handling and cover rename failures
Al12rs Apr 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/downloadlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ DownloadList::DownloadList(OrganizerCore& core, QObject* parent)
: QAbstractTableModel(parent), m_manager(*core.downloadManager()),
m_settings(core.settings())
{
connect(&m_manager, SIGNAL(update(int)), this, SLOT(update(int)));
connect(&m_manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate()));
connect(&m_manager, &DownloadManager::aboutToResetModel, this,
&DownloadList::onAboutToResetModel);
connect(&m_manager, &DownloadManager::modelReset, this, &DownloadList::onModelReset);
connect(&m_manager, &DownloadManager::rowChanged, this, &DownloadList::onRowChanged);
}

int DownloadList::rowCount(const QModelIndex& parent) const
Expand All @@ -56,7 +58,9 @@ int DownloadList::columnCount(const QModelIndex&) const

QModelIndex DownloadList::index(int row, int column, const QModelIndex&) const
{
return createIndex(row, column, row);
// Embed the stable DownloadID in internalId() so any consumer of the index
// can identify the download without having to track row shifts.
return createIndex(row, column, m_manager.downloadIDAtRow(row));
}

QModelIndex DownloadList::parent(const QModelIndex&) const
Expand Down Expand Up @@ -110,14 +114,14 @@ QVariant DownloadList::data(const QModelIndex& index, int role) const
bool pendingDownload = index.row() >= m_manager.numTotalDownloads();
if (role == Qt::DisplayRole) {
if (pendingDownload) {
std::tuple<QString, int, int> nexusids =
const DownloadManager::PendingDownload pending =
m_manager.getPendingDownload(index.row() - m_manager.numTotalDownloads());
switch (index.column()) {
case COL_NAME:
return tr("< game %1 mod %2 file %3 >")
.arg(std::get<0>(nexusids))
.arg(std::get<1>(nexusids))
.arg(std::get<2>(nexusids));
.arg(pending.gameName)
.arg(pending.modID)
.arg(pending.fileID);
case COL_SIZE:
return tr("Unknown");
case COL_STATUS:
Expand Down Expand Up @@ -239,16 +243,19 @@ QVariant DownloadList::data(const QModelIndex& index, int role) const
return QVariant();
}

void DownloadList::aboutToUpdate()
void DownloadList::onAboutToResetModel()
{
emit beginResetModel();
beginResetModel();
}

void DownloadList::update(int row)
void DownloadList::onModelReset()
{
if (row < 0)
emit endResetModel();
else if (row < this->rowCount())
endResetModel();
}

void DownloadList::onRowChanged(int row)
{
if (row < this->rowCount())
emit dataChanged(
this->index(row, 0, QModelIndex()),
this->index(row, this->columnCount(QModelIndex()) - 1, QModelIndex()));
Expand Down
18 changes: 11 additions & 7 deletions src/downloadlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ class DownloadList : public QAbstractTableModel
//
bool lessThanPredicate(const QModelIndex& left, const QModelIndex& right);

public slots:
private slots:

/**
* @brief used to inform the model that data has changed
*
* @param row the row that changed. This can be negative to update the whole view
**/
void update(int row);
* @brief full reset (row count changed). Drops selection and scroll state.
*/
void onAboutToResetModel();
void onModelReset();

void aboutToUpdate();
/**
* @brief single-row data change (row count unchanged). Preserves view state.
*
* @param row the row that changed
*/
void onRowChanged(int row);

private:
DownloadManager& m_manager;
Expand Down
Loading
Loading