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

@@ -58,6 +58,7 @@
#include "base/utils/compare.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "lineedit.h"
#include "torrenttagsdialog.h"
@@ -363,7 +364,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to
connect(m_ui->categoryComboBox, &QComboBox::currentIndexChanged, this, &AddNewTorrentDialog::categoryChanged);
m_ui->tagsLineEdit->setText(QStringList(m_torrentParams.tags.cbegin(), m_torrentParams.tags.cend()).join(u", "_s));
m_ui->tagsLineEdit->setText(Utils::String::joinIntoString(m_torrentParams.tags, u", "_s));
connect(m_ui->tagsEditButton, &QAbstractButton::clicked, this, [this]
{
auto *dlg = new TorrentTagsDialog(m_torrentParams.tags, this);
@@ -371,7 +372,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to
connect(dlg, &TorrentTagsDialog::accepted, this, [this, dlg]
{
m_torrentParams.tags = dlg->tags();
m_ui->tagsLineEdit->setText(QStringList(m_torrentParams.tags.cbegin(), m_torrentParams.tags.cend()).join(u", "_s));
m_ui->tagsLineEdit->setText(Utils::String::joinIntoString(m_torrentParams.tags, u", "_s));
});
dlg->open();
});

View File

@@ -33,6 +33,7 @@
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrent.h"
#include "base/utils/compare.h"
#include "base/utils/string.h"
#include "flowlayout.h"
#include "fspathedit.h"
#include "torrenttagsdialog.h"
@@ -112,7 +113,7 @@ AddTorrentParamsWidget::AddTorrentParamsWidget(BitTorrent::AddTorrentParams addT
connect(dlg, &TorrentTagsDialog::accepted, this, [this, dlg]
{
m_addTorrentParams.tags = dlg->tags();
m_ui->tagsLineEdit->setText(QStringList(m_addTorrentParams.tags.cbegin(), m_addTorrentParams.tags.cend()).join(u", "_s));
m_ui->tagsLineEdit->setText(Utils::String::joinIntoString(m_addTorrentParams.tags, u", "_s));
});
dlg->open();
});
@@ -230,7 +231,7 @@ void AddTorrentParamsWidget::populate()
m_addTorrentParams.stopCondition = data.value<BitTorrent::Torrent::StopCondition>();
});
m_ui->tagsLineEdit->setText(QStringList(m_addTorrentParams.tags.cbegin(), m_addTorrentParams.tags.cend()).join(u", "_s));
m_ui->tagsLineEdit->setText(Utils::String::joinIntoString(m_addTorrentParams.tags, u", "_s));
m_ui->startTorrentComboBox->disconnect(this);
m_ui->startTorrentComboBox->setCurrentIndex(m_addTorrentParams.addPaused

View File

@@ -380,10 +380,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
case TR_CATEGORY:
return torrent->category();
case TR_TAGS:
{
const TagSet &tags = torrent->tags();
return QStringList(tags.cbegin(), tags.cend()).join(u", "_s);
}
return Utils::String::joinIntoString(torrent->tags(), u", "_s);
case TR_ADD_DATE:
return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat);
case TR_SEED_DATE: