mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Implement tag management for WebUI
This commit is contained in:
parent
cf2e7d77d6
commit
b530e19a44
12 changed files with 631 additions and 11 deletions
|
@ -445,6 +445,12 @@ void SyncController::maindataAction()
|
|||
|
||||
data["categories"] = categories;
|
||||
|
||||
QVariantList tags;
|
||||
for (const QString &tag : asConst(session->tags()))
|
||||
tags << tag;
|
||||
|
||||
data["tags"] = tags;
|
||||
|
||||
QVariantMap serverState = getTranserInfo();
|
||||
serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace();
|
||||
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();
|
||||
|
|
|
@ -1041,3 +1041,67 @@ void TorrentsController::categoriesAction()
|
|||
|
||||
setResult(categories);
|
||||
}
|
||||
|
||||
void TorrentsController::addTagsAction()
|
||||
{
|
||||
checkParams({"hashes", "tags"});
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags) {
|
||||
const QString tagTrimmed {tag.trimmed()};
|
||||
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
torrent->addTag(tagTrimmed);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentsController::removeTagsAction()
|
||||
{
|
||||
checkParams({"hashes"});
|
||||
|
||||
const QStringList hashes {params()["hashes"].split('|')};
|
||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags) {
|
||||
const QString tagTrimmed {tag.trimmed()};
|
||||
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
torrent->removeTag(tagTrimmed);
|
||||
});
|
||||
}
|
||||
|
||||
if (tags.isEmpty()) {
|
||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
torrent->removeAllTags();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentsController::createTagsAction()
|
||||
{
|
||||
checkParams({"tags"});
|
||||
|
||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags)
|
||||
BitTorrent::Session::instance()->addTag(tag.trimmed());
|
||||
}
|
||||
|
||||
void TorrentsController::deleteTagsAction()
|
||||
{
|
||||
checkParams({"tags"});
|
||||
|
||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||
for (const QString &tag : tags)
|
||||
BitTorrent::Session::instance()->removeTag(tag.trimmed());
|
||||
}
|
||||
|
||||
void TorrentsController::tagsAction()
|
||||
{
|
||||
const QStringList tags = BitTorrent::Session::instance()->tags().toList();
|
||||
setResult(QJsonArray::fromStringList(tags));
|
||||
}
|
||||
|
|
|
@ -56,6 +56,11 @@ private slots:
|
|||
void editCategoryAction();
|
||||
void removeCategoriesAction();
|
||||
void categoriesAction();
|
||||
void addTagsAction();
|
||||
void removeTagsAction();
|
||||
void createTagsAction();
|
||||
void deleteTagsAction();
|
||||
void tagsAction();
|
||||
void addAction();
|
||||
void deleteAction();
|
||||
void addTrackersAction();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue