Merge pull request #7490 from glassez/category-path

Allow to set explicit save path for Category from GUI
This commit is contained in:
Vladimir Golovnev 2017-09-29 14:25:40 +03:00 committed by GitHub
commit 66a6674cbc
14 changed files with 363 additions and 84 deletions

View file

@ -56,6 +56,7 @@
#include "optionsdlg.h"
#include "previewselectdialog.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"));