|
|
@ -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,11 +581,18 @@ 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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::ignoreSelection(){ |
|
|
|
void PropertiesWidget::ignoreSelection(){ |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
if(PropListModel->data(index) != QVariant(IGNORED)){ |
|
|
|
if(PropListModel->data(index) != QVariant(IGNORED)){ |
|
|
@ -592,9 +600,9 @@ void PropertiesWidget::ignoreSelection(){ |
|
|
|
filteredFilesChanged(); |
|
|
|
filteredFilesChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::normalSelection(){ |
|
|
|
void PropertiesWidget::normalSelection(){ |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
if(PropListModel->data(index) != QVariant(NORMAL)){ |
|
|
|
if(PropListModel->data(index) != QVariant(NORMAL)){ |
|
|
@ -602,9 +610,9 @@ void PropertiesWidget::normalSelection(){ |
|
|
|
filteredFilesChanged(); |
|
|
|
filteredFilesChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::highSelection(){ |
|
|
|
void PropertiesWidget::highSelection(){ |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
if(PropListModel->data(index) != QVariant(HIGH)){ |
|
|
|
if(PropListModel->data(index) != QVariant(HIGH)){ |
|
|
@ -612,9 +620,9 @@ void PropertiesWidget::highSelection(){ |
|
|
|
filteredFilesChanged(); |
|
|
|
filteredFilesChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::maximumSelection(){ |
|
|
|
void PropertiesWidget::maximumSelection(){ |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
if(PropListModel->data(index) != QVariant(MAXIMUM)){ |
|
|
|
if(PropListModel->data(index) != QVariant(MAXIMUM)){ |
|
|
@ -622,9 +630,9 @@ void PropertiesWidget::maximumSelection(){ |
|
|
|
filteredFilesChanged(); |
|
|
|
filteredFilesChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::askWebSeed(){ |
|
|
|
void PropertiesWidget::askWebSeed(){ |
|
|
|
bool ok; |
|
|
|
bool ok; |
|
|
|
// Ask user for a new url seed
|
|
|
|
// Ask user for a new url seed
|
|
|
|
QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"), |
|
|
|
QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"), |
|
|
@ -641,9 +649,9 @@ void PropertiesWidget::askWebSeed(){ |
|
|
|
h.add_url_seed(url_seed); |
|
|
|
h.add_url_seed(url_seed); |
|
|
|
// Refresh the seeds list
|
|
|
|
// Refresh the seeds list
|
|
|
|
loadUrlSeeds(); |
|
|
|
loadUrlSeeds(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::deleteSelectedUrlSeeds(){ |
|
|
|
void PropertiesWidget::deleteSelectedUrlSeeds(){ |
|
|
|
QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems(); |
|
|
|
QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems(); |
|
|
|
bool change = false; |
|
|
|
bool change = false; |
|
|
|
foreach(QListWidgetItem *item, selectedItems){ |
|
|
|
foreach(QListWidgetItem *item, selectedItems){ |
|
|
@ -655,9 +663,9 @@ void PropertiesWidget::deleteSelectedUrlSeeds(){ |
|
|
|
// Refresh list
|
|
|
|
// Refresh list
|
|
|
|
loadUrlSeeds(); |
|
|
|
loadUrlSeeds(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool PropertiesWidget::applyPriorities() { |
|
|
|
bool PropertiesWidget::applyPriorities() { |
|
|
|
qDebug("Saving pieces priorities"); |
|
|
|
qDebug("Saving pieces priorities"); |
|
|
|
std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files()); |
|
|
|
std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files()); |
|
|
|
bool first_last_piece_first = false; |
|
|
|
bool first_last_piece_first = false; |
|
|
@ -671,10 +679,10 @@ bool PropertiesWidget::applyPriorities() { |
|
|
|
if(first_last_piece_first) |
|
|
|
if(first_last_piece_first) |
|
|
|
h.prioritize_first_last_piece(true); |
|
|
|
h.prioritize_first_last_piece(true); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::on_changeSavePathButton_clicked() { |
|
|
|
void PropertiesWidget::on_changeSavePathButton_clicked() { |
|
|
|
if(!h.is_valid()) return; |
|
|
|
if(!h.is_valid()) return; |
|
|
|
QString dir; |
|
|
|
QString dir; |
|
|
|
QDir saveDir(h.save_path()); |
|
|
|
QDir saveDir(h.save_path()); |
|
|
@ -700,10 +708,10 @@ void PropertiesWidget::on_changeSavePathButton_clicked() { |
|
|
|
// Update save_path in dialog
|
|
|
|
// Update save_path in dialog
|
|
|
|
save_path->setText(savePath.path()); |
|
|
|
save_path->setText(savePath.path()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::filteredFilesChanged() { |
|
|
|
void PropertiesWidget::filteredFilesChanged() { |
|
|
|
if(h.is_valid()) { |
|
|
|
if(h.is_valid()) { |
|
|
|
applyPriorities(); |
|
|
|
applyPriorities(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|