mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 14:23:35 -07:00
refactor: move logic from core to torrentscontroller
This commit is contained in:
parent
6e4700e3ad
commit
ceb903ebcf
5 changed files with 9 additions and 20 deletions
|
@ -49,7 +49,6 @@
|
|||
|
||||
#include "base/path.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "base/tagset.h"
|
||||
#include "base/utils/thread.h"
|
||||
#include "addtorrentparams.h"
|
||||
#include "cachestatus.h"
|
||||
|
|
|
@ -209,7 +209,6 @@ namespace BitTorrent
|
|||
virtual TagSet tags() const = 0;
|
||||
virtual bool hasTag(const Tag &tag) const = 0;
|
||||
virtual bool addTag(const Tag &tag) = 0;
|
||||
virtual bool setTags(const TagSet &newTags) = 0;
|
||||
virtual bool removeTag(const Tag &tag) = 0;
|
||||
virtual void removeAllTags() = 0;
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/tagset.h"
|
||||
#include "base/types.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/io.h"
|
||||
|
@ -938,21 +937,6 @@ bool TorrentImpl::addTag(const Tag &tag)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TorrentImpl::setTags(const TagSet &newTags)
|
||||
{
|
||||
// Identify tags to add
|
||||
for (const Tag &tag : newTags)
|
||||
if (!hasTag(tag))
|
||||
addTag(tag);
|
||||
|
||||
// Identify tags to remove
|
||||
for (const Tag &tag : asConst(tags()))
|
||||
if (!newTags.contains(tag))
|
||||
removeTag(tag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TorrentImpl::removeTag(const Tag &tag)
|
||||
{
|
||||
if (m_tags.remove(tag))
|
||||
|
|
|
@ -131,7 +131,6 @@ namespace BitTorrent
|
|||
TagSet tags() const override;
|
||||
bool hasTag(const Tag &tag) const override;
|
||||
bool addTag(const Tag &tag) override;
|
||||
bool setTags(const TagSet &newTags) override;
|
||||
bool removeTag(const Tag &tag) override;
|
||||
void removeAllTags() override;
|
||||
|
||||
|
|
|
@ -1490,7 +1490,15 @@ void TorrentsController::setTagsAction()
|
|||
// Apply the new tags to the selected torrents
|
||||
applyToTorrents(hashes, [&newTags](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
torrent->setTags(newTags);
|
||||
// Identify tags to add
|
||||
for (const Tag &tag : newTags)
|
||||
if (!torrent->hasTag(tag))
|
||||
torrent->addTag(tag);
|
||||
|
||||
// Identify tags to remove
|
||||
for (const Tag &tag : asConst(torrent->tags()))
|
||||
if (!newTags.contains(tag))
|
||||
torrent->removeTag(tag);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue