1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Properly add torrent with new tags

First, an attempt is made to add new tags to the Session.
Closes #15105.
This commit is contained in:
Vladimir Golovnev (Glassez) 2021-06-16 19:03:36 +03:00 committed by Vladimir Golovnev
parent 50ddfea617
commit 6070b41c9b

View File

@ -838,18 +838,14 @@ bool Session::hasTag(const QString &tag) const
bool Session::addTag(const QString &tag) bool Session::addTag(const QString &tag)
{ {
if (!isValidTag(tag)) if (!isValidTag(tag) || hasTag(tag))
return false; return false;
if (!hasTag(tag))
{
m_tags.insert(tag); m_tags.insert(tag);
m_storedTags = m_tags.values(); m_storedTags = m_tags.values();
emit tagAdded(tag); emit tagAdded(tag);
return true; return true;
} }
return false;
}
bool Session::removeTag(const QString &tag) bool Session::removeTag(const QString &tag)
{ {
@ -2056,7 +2052,6 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
LoadTorrentParams loadTorrentParams; LoadTorrentParams loadTorrentParams;
loadTorrentParams.name = addTorrentParams.name; loadTorrentParams.name = addTorrentParams.name;
loadTorrentParams.tags = addTorrentParams.tags;
loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority; loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority;
loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping
loadTorrentParams.contentLayout = addTorrentParams.contentLayout.value_or(torrentContentLayout()); loadTorrentParams.contentLayout = addTorrentParams.contentLayout.value_or(torrentContentLayout());
@ -2081,6 +2076,12 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
else else
loadTorrentParams.category = addTorrentParams.category; loadTorrentParams.category = addTorrentParams.category;
for (const QString &tag : addTorrentParams.tags)
{
if (hasTag(tag) || addTag(tag))
loadTorrentParams.tags.insert(tag);
}
return loadTorrentParams; return loadTorrentParams;
} }