mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 09:13:08 -07:00
Implement TorrentCategoryDialog class
This commit is contained in:
parent
8c58a69be6
commit
3ec992474d
14 changed files with 346 additions and 71 deletions
|
@ -56,6 +56,7 @@
|
|||
#include "optionsdlg.h"
|
||||
#include "previewselect.h"
|
||||
#include "speedlimitdlg.h"
|
||||
#include "torrentcategorydialog.h"
|
||||
#include "torrentmodel.h"
|
||||
#include "transferlistdelegate.h"
|
||||
#include "transferlistsortmodel.h"
|
||||
|
@ -729,25 +730,9 @@ void TransferListWidget::setSelectedAutoTMMEnabled(bool enabled) const
|
|||
|
||||
void TransferListWidget::askNewCategoryForSelection()
|
||||
{
|
||||
// Ask for category
|
||||
bool ok;
|
||||
bool invalid;
|
||||
do {
|
||||
invalid = false;
|
||||
const QString category = AutoExpandableDialog::getText(this, tr("New Category"), tr("Category:"), QLineEdit::Normal, "", &ok).trimmed();
|
||||
if (ok && !category.isEmpty()) {
|
||||
if (!BitTorrent::Session::isValidCategoryName(category)) {
|
||||
QMessageBox::warning(this, tr("Invalid category name"),
|
||||
tr("Category name must not contain '\\'.\n"
|
||||
"Category name must not start/end with '/'.\n"
|
||||
"Category name must not contain '//' sequence."));
|
||||
invalid = true;
|
||||
}
|
||||
else {
|
||||
setSelectionCategory(category);
|
||||
}
|
||||
}
|
||||
} while(invalid);
|
||||
const QString newCategoryName = TorrentCategoryDialog::createCategory(this);
|
||||
if (!newCategoryName.isEmpty())
|
||||
setSelectionCategory(newCategoryName);
|
||||
}
|
||||
|
||||
void TransferListWidget::askAddTagsForSelection()
|
||||
|
@ -998,7 +983,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
|||
if (selectedIndexes.size() == 1)
|
||||
listMenu.addAction(&actionRename);
|
||||
// Category Menu
|
||||
QStringList categories = BitTorrent::Session::instance()->categories();
|
||||
QStringList categories = BitTorrent::Session::instance()->categories().keys();
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
||||
QList<QAction*> categoryActions;
|
||||
QMenu *categoryMenu = listMenu.addMenu(GuiIconProvider::instance()->getIcon("view-categories"), tr("Category"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue