mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-25 02:36:10 +03:00
- Torrents can be renamed in transfer list
This commit is contained in:
parent
add2475700
commit
7bac95c9ad
6 changed files with 49 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
|||
- FEATURE: uTorrent compatible tracker list support (use torrentz.com url as a default)
|
||||
- FEATURE: Better proxy support and preferences remodeling
|
||||
- FEATURE: qBittorrent can identify itself as uTorrent or Vuze (Any version)
|
||||
- FEATURE: Torrents can be renamed in transfer list
|
||||
- COSMETIC: Use checkboxes to filter torrent content instead of comboboxes
|
||||
- COSMETIC: Use alternating row colors in transfer list (set in program preferences)
|
||||
- COSMETIC: Added a spin box to speed limiting dialog for manual input
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <math.h>
|
||||
#include "misc.h"
|
||||
#include "qtorrenthandle.h"
|
||||
#include "torrentpersistentdata.h"
|
||||
#include <libtorrent/magnet_uri.hpp>
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
|
@ -62,7 +63,11 @@ QString QTorrentHandle::hash() const {
|
|||
|
||||
QString QTorrentHandle::name() const {
|
||||
Q_ASSERT(h.is_valid());
|
||||
return misc::toQString(h.name());
|
||||
QString name = TorrentPersistentData::getName(hash());
|
||||
if(name.isEmpty()) {
|
||||
name = misc::toQString(h.name());
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
QString QTorrentHandle::creation_date() const {
|
||||
|
|
|
@ -506,7 +506,7 @@ public:
|
|||
return;
|
||||
}
|
||||
// Create parent folder
|
||||
QString root_name = misc::toQString(t.file_at(0).path.string()).split('/').first();
|
||||
QString root_name = misc::toQString(t.file_at(0).path.string()).split(QDir::separator()).first();
|
||||
TreeItem *current_parent = new TreeItem(root_name, parent);
|
||||
//parent->appendChild(current_parent);
|
||||
TreeItem *root_folder = current_parent;
|
||||
|
@ -518,7 +518,7 @@ public:
|
|||
current_parent = root_folder;
|
||||
QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
|
||||
// Iterate of parts of the path to create necessary folders
|
||||
QStringList pathFolders = path.split('/');
|
||||
QStringList pathFolders = path.split(QDir::separator());
|
||||
Q_ASSERT(pathFolders.size() >= 2);
|
||||
QString fileName = pathFolders.takeLast();
|
||||
QString currentFolderName = pathFolders.takeFirst();
|
||||
|
|
|
@ -257,6 +257,16 @@ public:
|
|||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static void saveName(QString hash, QString name) {
|
||||
Q_ASSERT(!hash.isEmpty());
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
data["name"] = name;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static void savePriority(QTorrentHandle h) {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
|
@ -291,6 +301,13 @@ public:
|
|||
return data.value("label", "").toString();
|
||||
}
|
||||
|
||||
static QString getName(QString hash) {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data.value("name", "").toString();
|
||||
}
|
||||
|
||||
static int getPriority(QString hash) {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
|
|
|
@ -866,6 +866,24 @@ void TransferListWidget::askNewLabelForSelection() {
|
|||
}
|
||||
}
|
||||
|
||||
void TransferListWidget::renameSelectedTorrent() {
|
||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if(selectedIndexes.size() != 1) return;
|
||||
if(!selectedIndexes.first().isValid()) return;
|
||||
QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row());
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(!h.is_valid()) return;
|
||||
// Ask for a new Name
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok);
|
||||
if (ok && !name.isEmpty()) {
|
||||
// Remember the name
|
||||
TorrentPersistentData::saveName(hash, name);
|
||||
// Visually change the name
|
||||
proxyModel->setData(selectedIndexes.first(), name);
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListWidget::setSelectionLabel(QString label) {
|
||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
foreach(const QModelIndex &index, selectedIndexes) {
|
||||
|
@ -917,6 +935,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||
QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
|
||||
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
||||
#endif
|
||||
QAction actionRename(QIcon(QString::fromUtf8(":/Icons/oxygen/edit_clear.png")), tr("Rename..."), 0);
|
||||
connect(&actionRename, SIGNAL(triggered()), this, SLOT(renameSelectedTorrent()));
|
||||
QAction actionSequential_download(tr("Download in sequential order"), 0);
|
||||
connect(&actionSequential_download, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSequentialDownload()));
|
||||
QAction actionFirstLastPiece_prio(tr("Download first and last piece first"), 0);
|
||||
|
@ -993,6 +1013,8 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||
listMenu.addSeparator();
|
||||
listMenu.addAction(&actionDelete);
|
||||
listMenu.addSeparator();
|
||||
if(selectedIndexes.size() == 1)
|
||||
listMenu.addAction(&actionRename);
|
||||
// Label Menu
|
||||
QStringList customLabels = getCustomLabels();
|
||||
QList<QAction*> labelActions;
|
||||
|
|
|
@ -117,6 +117,7 @@ public slots:
|
|||
void applyLabelFilter(QString label);
|
||||
void previewFile(QString filePath);
|
||||
void removeLabelFromRows(QString label);
|
||||
void renameSelectedTorrent();
|
||||
|
||||
signals:
|
||||
void currentTorrentChanged(QTorrentHandle &h);
|
||||
|
|
Loading…
Reference in a new issue