|
|
|
@ -557,8 +557,9 @@ void PropertiesWidget::renameSelectedFile() {
@@ -557,8 +557,9 @@ void PropertiesWidget::renameSelectedFile() {
|
|
|
|
|
path_items.removeLast(); |
|
|
|
|
path_items << new_name_last; |
|
|
|
|
QString new_path = path_items.join(QDir::separator()); |
|
|
|
|
// XXX: Check for overwriting
|
|
|
|
|
for(int i=0; i<h.num_files(); ++i) { |
|
|
|
|
// Check for overwriting
|
|
|
|
|
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()); |
|
|
|
|
#ifdef Q_WS_WIN |
|
|
|
|
if(current_name.contains(new_path, Qt::CaseInsensitive)) { |
|
|
|
@ -572,7 +573,7 @@ void PropertiesWidget::renameSelectedFile() {
@@ -572,7 +573,7 @@ void PropertiesWidget::renameSelectedFile() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 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 new_name = current_name.replace(old_path, new_path); |
|
|
|
|
qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data()); |
|
|
|
@ -580,11 +581,18 @@ void PropertiesWidget::renameSelectedFile() {
@@ -580,11 +581,18 @@ void PropertiesWidget::renameSelectedFile() {
|
|
|
|
|
} |
|
|
|
|
// Rename folder in torrent files model too
|
|
|
|
|
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); |
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
|
if(PropListModel->data(index) != QVariant(IGNORED)){ |
|
|
|
@ -592,9 +600,9 @@ void PropertiesWidget::ignoreSelection(){
@@ -592,9 +600,9 @@ void PropertiesWidget::ignoreSelection(){
|
|
|
|
|
filteredFilesChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::normalSelection(){ |
|
|
|
|
void PropertiesWidget::normalSelection(){ |
|
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
|
if(PropListModel->data(index) != QVariant(NORMAL)){ |
|
|
|
@ -602,9 +610,9 @@ void PropertiesWidget::normalSelection(){
@@ -602,9 +610,9 @@ void PropertiesWidget::normalSelection(){
|
|
|
|
|
filteredFilesChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::highSelection(){ |
|
|
|
|
void PropertiesWidget::highSelection(){ |
|
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
|
if(PropListModel->data(index) != QVariant(HIGH)){ |
|
|
|
@ -612,9 +620,9 @@ void PropertiesWidget::highSelection(){
@@ -612,9 +620,9 @@ void PropertiesWidget::highSelection(){
|
|
|
|
|
filteredFilesChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::maximumSelection(){ |
|
|
|
|
void PropertiesWidget::maximumSelection(){ |
|
|
|
|
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(PRIORITY); |
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
|
if(PropListModel->data(index) != QVariant(MAXIMUM)){ |
|
|
|
@ -622,9 +630,9 @@ void PropertiesWidget::maximumSelection(){
@@ -622,9 +630,9 @@ void PropertiesWidget::maximumSelection(){
|
|
|
|
|
filteredFilesChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::askWebSeed(){ |
|
|
|
|
void PropertiesWidget::askWebSeed(){ |
|
|
|
|
bool ok; |
|
|
|
|
// Ask user for a new url seed
|
|
|
|
|
QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"), |
|
|
|
@ -641,9 +649,9 @@ void PropertiesWidget::askWebSeed(){
@@ -641,9 +649,9 @@ void PropertiesWidget::askWebSeed(){
|
|
|
|
|
h.add_url_seed(url_seed); |
|
|
|
|
// Refresh the seeds list
|
|
|
|
|
loadUrlSeeds(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::deleteSelectedUrlSeeds(){ |
|
|
|
|
void PropertiesWidget::deleteSelectedUrlSeeds(){ |
|
|
|
|
QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems(); |
|
|
|
|
bool change = false; |
|
|
|
|
foreach(QListWidgetItem *item, selectedItems){ |
|
|
|
@ -655,9 +663,9 @@ void PropertiesWidget::deleteSelectedUrlSeeds(){
@@ -655,9 +663,9 @@ void PropertiesWidget::deleteSelectedUrlSeeds(){
|
|
|
|
|
// Refresh list
|
|
|
|
|
loadUrlSeeds(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PropertiesWidget::applyPriorities() { |
|
|
|
|
bool PropertiesWidget::applyPriorities() { |
|
|
|
|
qDebug("Saving pieces priorities"); |
|
|
|
|
std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files()); |
|
|
|
|
bool first_last_piece_first = false; |
|
|
|
@ -671,10 +679,10 @@ bool PropertiesWidget::applyPriorities() {
@@ -671,10 +679,10 @@ bool PropertiesWidget::applyPriorities() {
|
|
|
|
|
if(first_last_piece_first) |
|
|
|
|
h.prioritize_first_last_piece(true); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropertiesWidget::on_changeSavePathButton_clicked() { |
|
|
|
|
void PropertiesWidget::on_changeSavePathButton_clicked() { |
|
|
|
|
if(!h.is_valid()) return; |
|
|
|
|
QString dir; |
|
|
|
|
QDir saveDir(h.save_path()); |
|
|
|
@ -700,10 +708,10 @@ void PropertiesWidget::on_changeSavePathButton_clicked() {
@@ -700,10 +708,10 @@ void PropertiesWidget::on_changeSavePathButton_clicked() {
|
|
|
|
|
// Update save_path in dialog
|
|
|
|
|
save_path->setText(savePath.path()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PropertiesWidget::filteredFilesChanged() { |
|
|
|
|
void PropertiesWidget::filteredFilesChanged() { |
|
|
|
|
if(h.is_valid()) { |
|
|
|
|
applyPriorities(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|