|
|
@ -557,8 +557,9 @@ void PropertiesWidget::renameSelectedFile() { |
|
|
|
path_items.removeLast(); |
|
|
|
path_items.removeLast(); |
|
|
|
path_items << new_name_last; |
|
|
|
path_items << new_name_last; |
|
|
|
QString new_path = path_items.join(QDir::separator()); |
|
|
|
QString new_path = path_items.join(QDir::separator()); |
|
|
|
// XXX: Check for overwriting
|
|
|
|
// Check for overwriting
|
|
|
|
for(int i=0; i<h.num_files(); ++i) { |
|
|
|
int num_files = h.num_files(); |
|
|
|
|
|
|
|
for(int i=0; i<num_files; ++i) { |
|
|
|
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); |
|
|
|
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); |
|
|
|
#ifdef Q_WS_WIN |
|
|
|
#ifdef Q_WS_WIN |
|
|
|
if(current_name.contains(new_path, Qt::CaseInsensitive)) { |
|
|
|
if(current_name.contains(new_path, Qt::CaseInsensitive)) { |
|
|
@ -572,7 +573,7 @@ void PropertiesWidget::renameSelectedFile() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Replace path in all files
|
|
|
|
// Replace path in all files
|
|
|
|
for(int i=0; i<h.num_files(); ++i) { |
|
|
|
for(int i=0; i<num_files; ++i) { |
|
|
|
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); |
|
|
|
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); |
|
|
|
QString new_name = current_name.replace(old_path, new_path); |
|
|
|
QString new_name = current_name.replace(old_path, new_path); |
|
|
|
qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data()); |
|
|
|
qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data()); |
|
|
@ -580,6 +581,13 @@ void PropertiesWidget::renameSelectedFile() { |
|
|
|
} |
|
|
|
} |
|
|
|
// Rename folder in torrent files model too
|
|
|
|
// Rename folder in torrent files model too
|
|
|
|
PropListModel->setData(index, new_name_last); |
|
|
|
PropListModel->setData(index, new_name_last); |
|
|
|
|
|
|
|
// Remove old folder
|
|
|
|
|
|
|
|
QDir old_folder(h.save_path()+QDir::separator()+old_path); |
|
|
|
|
|
|
|
int timeout = 10; |
|
|
|
|
|
|
|
while(!misc::removeEmptyTree(old_folder.absolutePath()) && timeout > 0) { |
|
|
|
|
|
|
|
SleeperThread::msleep(100); |
|
|
|
|
|
|
|
--timeout; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|