Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to move content files to trash instead of deleting them #20252

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ add_library(qbt_base STATIC
bittorrent/torrent.h
bittorrent/torrentcontenthandler.h
bittorrent/torrentcontentlayout.h
bittorrent/torrentcontentremoveoption.h
bittorrent/torrentcontentremover.h
bittorrent/torrentcreator.h
bittorrent/torrentdescriptor.h
bittorrent/torrentimpl.h
Expand Down Expand Up @@ -137,6 +139,7 @@ add_library(qbt_base STATIC
bittorrent/speedmonitor.cpp
bittorrent/torrent.cpp
bittorrent/torrentcontenthandler.cpp
bittorrent/torrentcontentremover.cpp
bittorrent/torrentcreator.cpp
bittorrent/torrentdescriptor.cpp
bittorrent/torrentimpl.cpp
Expand Down Expand Up @@ -225,7 +228,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
${IOKit_LIBRARY}
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(qbt_base PRIVATE Iphlpapi)
target_link_libraries(qbt_base PRIVATE Iphlpapi PowrProf)
endif()

if (NOT GUI)
Expand Down
19 changes: 11 additions & 8 deletions src/base/bittorrent/session.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015-2023 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -36,6 +36,7 @@
#include "base/tagset.h"
#include "addtorrentparams.h"
#include "categoryoptions.h"
#include "torrentcontentremoveoption.h"
#include "trackerentry.h"

class QString;
Expand All @@ -50,12 +51,6 @@ enum MaxRatioAction
EnableSuperSeeding = 2
};

enum DeleteOption
{
DeleteTorrent,
DeleteTorrentAndFiles
};

namespace BitTorrent
{
class InfoHash;
Expand All @@ -66,6 +61,12 @@ namespace BitTorrent
struct CacheStatus;
struct SessionStatus;

enum class TorrentRemoveOption
{
KeepContent,
RemoveContent
};

// Using `Q_ENUM_NS()` without a wrapper namespace in our case is not advised
// since `Q_NAMESPACE` cannot be used when the same namespace resides at different files.
// https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/#comment-143779
Expand Down Expand Up @@ -431,6 +432,8 @@ namespace BitTorrent
virtual void setResumeDataStorageType(ResumeDataStorageType type) = 0;
virtual bool isMergeTrackersEnabled() const = 0;
virtual void setMergeTrackersEnabled(bool enabled) = 0;
virtual TorrentContentRemoveOption torrentContentRemoveOption() const = 0;
virtual void setTorrentContentRemoveOption(TorrentContentRemoveOption option) = 0;

virtual bool isRestored() const = 0;

Expand All @@ -449,7 +452,7 @@ namespace BitTorrent

virtual bool isKnownTorrent(const InfoHash &infoHash) const = 0;
virtual bool addTorrent(const TorrentDescriptor &torrentDescr, const AddTorrentParams &params = {}) = 0;
virtual bool deleteTorrent(const TorrentID &id, DeleteOption deleteOption = DeleteOption::DeleteTorrent) = 0;
virtual bool removeTorrent(const TorrentID &id, TorrentRemoveOption deleteOption = TorrentRemoveOption::KeepContent) = 0;
virtual bool downloadMetadata(const TorrentDescriptor &torrentDescr) = 0;
virtual bool cancelDownloadMetadata(const TorrentID &id) = 0;

Expand Down