File: downloadmanager.cpp

package info (click to toggle)
angelfish 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,740 kB
  • sloc: cpp: 2,703; xml: 611; javascript: 273; makefile: 16; sh: 11; sql: 7
file content (31 lines) | stat: -rw-r--r-- 699 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im>
//
// SPDX-License-Identifier: GPL-2.0-or-later

#include "downloadmanager.h"

#include <QUrl>

DownloadManager::DownloadManager() = default;

DownloadManager &DownloadManager::instance()
{
    static DownloadManager instance;
    return instance;
}

void DownloadManager::addDownload(std::unique_ptr<DownloadItem> &&download)
{
    m_downloads.push_back(std::move(download));
}

void DownloadManager::removeDownload(const int index)
{
    m_downloads.at(index)->cancel();
    m_downloads.erase(m_downloads.begin() + index);
}

const std::vector<std::unique_ptr<DownloadItem>> &DownloadManager::downloads()
{
    return m_downloads;
}