Introduce helper function to join values as string

PR #20130.
This commit is contained in:
Chocobo1
2023-12-19 00:08:37 +08:00
committed by GitHub
parent 9d90141c29
commit 073ca4267c
17 changed files with 188 additions and 77 deletions

View File

@@ -29,7 +29,6 @@
#include "serialize_torrent.h"
#include <QDateTime>
#include <QStringList>
#include <QVector>
#include "base/bittorrent/infohash.h"
@@ -37,6 +36,7 @@
#include "base/bittorrent/trackerentry.h"
#include "base/path.h"
#include "base/tagset.h"
#include "base/utils/string.h"
namespace
{
@@ -106,8 +106,6 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
: (QDateTime::currentDateTime().toSecsSinceEpoch() - timeSinceActivity);
};
const TagSet &tags = torrent.tags();
return {
{KEY_TORRENT_ID, torrent.id().toString()},
{KEY_TORRENT_INFOHASHV1, torrent.infoHash().v1().toString()},
@@ -130,7 +128,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
{KEY_TORRENT_FIRST_LAST_PIECE_PRIO, torrent.hasFirstLastPiecePriority()},
{KEY_TORRENT_CATEGORY, torrent.category()},
{KEY_TORRENT_TAGS, QStringList(tags.cbegin(), tags.cend()).join(u", "_s)},
{KEY_TORRENT_TAGS, Utils::String::joinIntoString(torrent.tags(), u", "_s)},
{KEY_TORRENT_SUPER_SEEDING, torrent.superSeeding()},
{KEY_TORRENT_FORCE_START, torrent.isForced()},
{KEY_TORRENT_SAVE_PATH, torrent.savePath().toString()},