From c7efd0dd0556319318370b3bf713bcc7978d44f9 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 5 Feb 2013 01:46:00 +0100 Subject: [PATCH 1/3] Fix Preview for .!qB extended files --- src/fs_utils.cpp | 14 ++++++++++++-- src/previewselect.cpp | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fs_utils.cpp b/src/fs_utils.cpp index 2e9ecd8a7..69db2e9c4 100644 --- a/src/fs_utils.cpp +++ b/src/fs_utils.cpp @@ -81,8 +81,18 @@ QString fsutils::toDisplayPath(const QString& path) */ QString fsutils::fileExtension(const QString &filename) { - const int point_index = filename.lastIndexOf("."); - return (point_index >= 0) ? filename.mid(point_index + 1) : QString(); + QString holder; + int point_index = filename.lastIndexOf("."); + if (point_index >= 0) { + QString holder = filename.mid(point_index + 1); + if (holder == "!qB") { + holder = filename.mid(0, point_index); + point_index = holder.lastIndexOf("."); + holder = (point_index >= 0) ? holder.mid(point_index + 1) : QString(); + } + return holder; + } + return QString(); } QString fsutils::fileName(const QString& file_path) diff --git a/src/previewselect.cpp b/src/previewselect.cpp index 5ba887298..c215f5ad5 100644 --- a/src/previewselect.cpp +++ b/src/previewselect.cpp @@ -39,6 +39,7 @@ #include "misc.h" #include "previewlistdelegate.h" #include "previewselect.h" +#include "fs_utils.h" PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h) { setupUi(this); @@ -58,7 +59,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) unsigned int nbFiles = h.num_files(); for (unsigned int i=0; irowCount(); previewListModel->insertRow(row); From ccd50262c6fdc021e21735d98d5a8fb9e1bbc945 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 5 Feb 2013 03:44:54 +0100 Subject: [PATCH 2/3] FIX: Redeclared Variable --- src/fs_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fs_utils.cpp b/src/fs_utils.cpp index 69db2e9c4..be5e9a67b 100644 --- a/src/fs_utils.cpp +++ b/src/fs_utils.cpp @@ -84,7 +84,7 @@ QString fsutils::fileExtension(const QString &filename) QString holder; int point_index = filename.lastIndexOf("."); if (point_index >= 0) { - QString holder = filename.mid(point_index + 1); + holder = filename.mid(point_index + 1); if (holder == "!qB") { holder = filename.mid(0, point_index); point_index = holder.lastIndexOf("."); From b6f156b7dd92a3774ce7abdf3678aba0f3a4b4a0 Mon Sep 17 00:00:00 2001 From: Andrea Villa Date: Sat, 9 Feb 2013 18:55:10 +0100 Subject: [PATCH 3/3] Reverting fs_utils.cpp and fixing callers instead --- src/fs_utils.cpp | 14 ++------------ src/previewselect.cpp | 2 ++ src/qtlibtorrent/qbtsession.cpp | 5 ++++- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/fs_utils.cpp b/src/fs_utils.cpp index be5e9a67b..2e9ecd8a7 100644 --- a/src/fs_utils.cpp +++ b/src/fs_utils.cpp @@ -81,18 +81,8 @@ QString fsutils::toDisplayPath(const QString& path) */ QString fsutils::fileExtension(const QString &filename) { - QString holder; - int point_index = filename.lastIndexOf("."); - if (point_index >= 0) { - holder = filename.mid(point_index + 1); - if (holder == "!qB") { - holder = filename.mid(0, point_index); - point_index = holder.lastIndexOf("."); - holder = (point_index >= 0) ? holder.mid(point_index + 1) : QString(); - } - return holder; - } - return QString(); + const int point_index = filename.lastIndexOf("."); + return (point_index >= 0) ? filename.mid(point_index + 1) : QString(); } QString fsutils::fileName(const QString& file_path) diff --git a/src/previewselect.cpp b/src/previewselect.cpp index c215f5ad5..888653ae0 100644 --- a/src/previewselect.cpp +++ b/src/previewselect.cpp @@ -59,6 +59,8 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) unsigned int nbFiles = h.num_files(); for (unsigned int i=0; irowCount(); diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 6b163748d..3872c0245 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1731,7 +1731,10 @@ bool QBtSession::isFilePreviewPossible(const QString &hash) const { } const unsigned int nbFiles = h.num_files(); for (unsigned int i=0; i