Browse Source

- Fix several bugs in new "Append label to save path" feature

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
411a1c641d
  1. 12
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h
  3. 7
      src/propertieswidget.cpp
  4. 1
      src/propertieswidget.h

12
src/bittorrent.cpp

@ -1325,18 +1325,25 @@ void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_labe @@ -1325,18 +1325,25 @@ void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_labe
bool move_storage = (old_dir == QDir(h.save_path()));
if(!old_label.isEmpty()) {
Q_ASSERT(old_dir.dirName() == old_label);
old_dir.cdUp();
QString path = old_save_path;
// Cd UP
if(path.endsWith(QDir::separator()))
path.chop(1);
QStringList path_items = path.split(QDir::separator());
path_items.removeLast();
old_dir = QDir(path_items.join(QDir::separator()));
}
QString new_save_path;
if(new_label.isEmpty())
new_save_path = old_dir.absolutePath();
else
old_dir.absoluteFilePath(new_label);
new_save_path = old_dir.absoluteFilePath(new_label);
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
if(move_storage) {
// Move storage
h.move_storage(new_save_path);
}
emit savePathChanged(h);
}
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
@ -1353,6 +1360,7 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) { @@ -1353,6 +1360,7 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
// Move storage
h.move_storage(new_save_path);
}
emit savePathChanged(h);
}
}

1
src/bittorrent.h

@ -245,6 +245,7 @@ signals: @@ -245,6 +245,7 @@ signals:
void downloadFromUrlFailure(QString url, QString reason);
void torrentFinishedChecking(QTorrentHandle& h);
void metadataReceived(QTorrentHandle &h);
void savePathChanged(QTorrentHandle &h);
};
#endif

7
src/propertieswidget.cpp

@ -98,6 +98,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi @@ -98,6 +98,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
// Downloaded pieces progress bar
downloaded_pieces = new DownloadedPiecesBar(this);
@ -211,6 +212,12 @@ Bittorrent* PropertiesWidget::getBTSession() const { @@ -211,6 +212,12 @@ Bittorrent* PropertiesWidget::getBTSession() const {
return BTSession;
}
void PropertiesWidget::updateSavePath(QTorrentHandle& _h) {
if(h.is_valid() && h == _h) {
save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
}
}
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
clear();
h = _h;

1
src/propertieswidget.h

@ -97,6 +97,7 @@ protected slots: @@ -97,6 +97,7 @@ protected slots:
void filteredFilesChanged();
void showPiecesDownloaded(bool show);
void showPiecesAvailability(bool show);
void updateSavePath(QTorrentHandle& h);
public slots:
void loadDynamicData();

Loading…
Cancel
Save