From c7efd0dd0556319318370b3bf713bcc7978d44f9 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 5 Feb 2013 01:46:00 +0100 Subject: [PATCH] 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);