mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
FS should be updated properly on labeling now
This commit is contained in:
parent
1052cd019b
commit
53919446d4
3 changed files with 34 additions and 20 deletions
|
@ -1645,7 +1645,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
qDebug("Moving storage to %s", qPrintable(new_save_path));
|
qDebug("Moving storage to %s", qPrintable(new_save_path));
|
||||||
QDir().mkpath(new_save_path);
|
QDir().mkpath(new_save_path);
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
emit savePathChanged(h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1658,8 +1657,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
QString new_save_path = misc::updateLabelInSavePath(defaultSavePath, old_save_path, "", label);
|
QString new_save_path = misc::updateLabelInSavePath(defaultSavePath, old_save_path, "", label);
|
||||||
if(old_save_path != new_save_path) {
|
if(old_save_path != new_save_path) {
|
||||||
// Move storage
|
// Move storage
|
||||||
|
QDir().mkpath(new_save_path);
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
emit savePathChanged(h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,9 +1949,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(a.get())) {
|
else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(a.get())) {
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if(h.is_valid())
|
if(h.is_valid()) {
|
||||||
|
TorrentPersistentData::saveSavePath(h.hash(), QString(p->path.c_str()));
|
||||||
|
emit savePathChanged(h);
|
||||||
h.force_recheck(); //XXX: Required by libtorrent for now
|
h.force_recheck(); //XXX: Required by libtorrent for now
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
|
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if(h.is_valid()) {
|
if(h.is_valid()) {
|
||||||
|
@ -2177,14 +2179,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
if(savePath.isEmpty()) {
|
if(savePath.isEmpty()) {
|
||||||
savePath = defaultSavePath;
|
savePath = defaultSavePath;
|
||||||
}
|
}
|
||||||
if(appendLabelToSavePath && savePath.startsWith(defaultSavePath)) {
|
if(appendLabelToSavePath) {
|
||||||
qDebug("appendLabelToSavePath is true");
|
qDebug("appendLabelToSavePath is true");
|
||||||
const QString &label = TorrentTempData::getLabel(hash);
|
const QString &label = TorrentTempData::getLabel(hash);
|
||||||
if(!label.isEmpty()) {
|
if(!label.isEmpty()) {
|
||||||
const QDir save_dir(savePath);
|
savePath = misc::updateLabelInSavePath(defaultSavePath, savePath, "", label);
|
||||||
if(save_dir.dirName() != label) {
|
|
||||||
savePath = save_dir.absoluteFilePath(label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
||||||
|
@ -2207,10 +2206,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
if(!fromScanDir && appendLabelToSavePath) {
|
if(!fromScanDir && appendLabelToSavePath) {
|
||||||
const QString &label = TorrentPersistentData::getLabel(hash);
|
const QString &label = TorrentPersistentData::getLabel(hash);
|
||||||
if(!label.isEmpty()) {
|
if(!label.isEmpty()) {
|
||||||
QDir save_dir(savePath);
|
savePath = misc::updateLabelInSavePath(defaultSavePath, savePath, "", label);
|
||||||
if(save_dir.dirName() != label) {
|
|
||||||
savePath = save_dir.absoluteFilePath(label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(append_root_folder && !root_folder.isEmpty()) {
|
if(append_root_folder && !root_folder.isEmpty()) {
|
||||||
|
|
|
@ -258,14 +258,17 @@ QString misc::updateLabelInSavePath(const QString& defaultSavePath, QString save
|
||||||
path_parts << new_label;
|
path_parts << new_label;
|
||||||
} else {
|
} else {
|
||||||
if(old_label.isEmpty() || path_parts.first() != old_label) {
|
if(old_label.isEmpty() || path_parts.first() != old_label) {
|
||||||
|
if(path_parts.first() != new_label)
|
||||||
path_parts.prepend(new_label);
|
path_parts.prepend(new_label);
|
||||||
} else {
|
} else {
|
||||||
if(new_label.isEmpty())
|
if(new_label.isEmpty()) {
|
||||||
path_parts.removeAt(0);
|
path_parts.removeAt(0);
|
||||||
else
|
} else {
|
||||||
|
if(path_parts.first() != new_label)
|
||||||
path_parts.replace(0, new_label);
|
path_parts.replace(0, new_label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
new_save_path = defaultSavePath;
|
new_save_path = defaultSavePath;
|
||||||
if(!new_save_path.endsWith(QDir::separator())) new_save_path += QDir::separator();
|
if(!new_save_path.endsWith(QDir::separator())) new_save_path += QDir::separator();
|
||||||
new_save_path += path_parts.join(QDir::separator());
|
new_save_path += path_parts.join(QDir::separator());
|
||||||
|
|
|
@ -66,6 +66,9 @@ private:
|
||||||
QString hash;
|
QString hash;
|
||||||
QString filePath;
|
QString filePath;
|
||||||
QString from_url;
|
QString from_url;
|
||||||
|
QString defaultSavePath;
|
||||||
|
QString old_label;
|
||||||
|
bool appendLabelToSavePath;
|
||||||
TorrentFilesModel *PropListModel;
|
TorrentFilesModel *PropListModel;
|
||||||
PropListDelegate *PropDelegate;
|
PropListDelegate *PropDelegate;
|
||||||
unsigned int nbFiles;
|
unsigned int nbFiles;
|
||||||
|
@ -74,7 +77,7 @@ private:
|
||||||
bool is_magnet;
|
bool is_magnet;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession) : QDialog((QWidget*)parent) {
|
torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession) : QDialog((QWidget*)parent), old_label("") {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&)));
|
connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&)));
|
||||||
|
@ -89,10 +92,14 @@ public:
|
||||||
connect(torrentContentList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentListMenu(const QPoint&)));
|
connect(torrentContentList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentListMenu(const QPoint&)));
|
||||||
connect(collapseAllButton, SIGNAL(clicked()), torrentContentList, SLOT(collapseAll()));
|
connect(collapseAllButton, SIGNAL(clicked()), torrentContentList, SLOT(collapseAll()));
|
||||||
connect(expandAllButton, SIGNAL(clicked()), torrentContentList, SLOT(expandAll()));
|
connect(expandAllButton, SIGNAL(clicked()), torrentContentList, SLOT(expandAll()));
|
||||||
|
connect(comboLabel, SIGNAL(editTextChanged(QString)), this, SLOT(updateLabelInSavePath(QString)));
|
||||||
|
connect(comboLabel, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateLabelInSavePath(QString)));
|
||||||
// Remember columns width
|
// Remember columns width
|
||||||
readSettings();
|
readSettings();
|
||||||
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
|
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
|
||||||
savePathTxt->setText(Preferences::getSavePath());
|
defaultSavePath = Preferences::getSavePath();
|
||||||
|
appendLabelToSavePath = Preferences::appendTorrentLabel();
|
||||||
|
savePathTxt->setText(defaultSavePath);
|
||||||
if(Preferences::addTorrentsInPause()) {
|
if(Preferences::addTorrentsInPause()) {
|
||||||
addInPause->setChecked(true);
|
addInPause->setChecked(true);
|
||||||
//addInPause->setEnabled(false);
|
//addInPause->setEnabled(false);
|
||||||
|
@ -516,6 +523,14 @@ public slots:
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateLabelInSavePath(QString label) {
|
||||||
|
if(appendLabelToSavePath) {
|
||||||
|
savePathTxt->setText(misc::updateLabelInSavePath(defaultSavePath, savePathTxt->text(), old_label, label));
|
||||||
|
old_label = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void torrentPaused(QTorrentHandle &h);
|
void torrentPaused(QTorrentHandle &h);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue