mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
FS should be updated properly on labeling now
This commit is contained in:
parent
1052cd019b
commit
53919446d4
@ -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,8 +1949,11 @@ 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);
|
||||||
@ -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()) {
|
||||||
|
11
src/misc.cpp
11
src/misc.cpp
@ -258,12 +258,15 @@ 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) {
|
||||||
path_parts.prepend(new_label);
|
if(path_parts.first() != 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 {
|
||||||
path_parts.replace(0, new_label);
|
if(path_parts.first() != new_label)
|
||||||
|
path_parts.replace(0, new_label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_save_path = defaultSavePath;
|
new_save_path = defaultSavePath;
|
||||||
|
@ -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);
|
||||||
@ -295,8 +302,8 @@ public slots:
|
|||||||
// Ask for new name
|
// Ask for new name
|
||||||
bool ok;
|
bool ok;
|
||||||
const QString &new_name_last = QInputDialog::getText(this, tr("Rename the file"),
|
const QString &new_name_last = QInputDialog::getText(this, tr("Rename the file"),
|
||||||
tr("New name:"), QLineEdit::Normal,
|
tr("New name:"), QLineEdit::Normal,
|
||||||
index.data().toString(), &ok);
|
index.data().toString(), &ok);
|
||||||
if (ok && !new_name_last.isEmpty()) {
|
if (ok && !new_name_last.isEmpty()) {
|
||||||
if(!misc::isValidFileSystemName(new_name_last)) {
|
if(!misc::isValidFileSystemName(new_name_last)) {
|
||||||
QMessageBox::warning(this, tr("The file could not be renamed"),
|
QMessageBox::warning(this, tr("The file could not be renamed"),
|
||||||
@ -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…
x
Reference in New Issue
Block a user