From b9403774e670066facaef47a59573afc2c96857e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 7 Feb 2017 14:07:59 +0800 Subject: [PATCH] Use QBT_EXT in all places Cleanup headers on the way --- src/base/utils/fs.cpp | 12 ++++++------ src/gui/previewselect.cpp | 2 +- src/gui/torrentcontentmodelfile.cpp | 4 +++- src/gui/torrentcontentmodelfolder.cpp | 5 +++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 51cfc508d..d734e16a4 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -37,8 +37,9 @@ #include #include -#ifndef Q_OS_WIN -#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) +#if defined(Q_OS_WIN) +#include +#elif defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) #include #include #elif defined(Q_OS_HAIKU) @@ -46,9 +47,8 @@ #else #include #endif -#else -#include -#endif + +#include "base/bittorrent/torrenthandle.h" /** * Converts a path to a string suitable for display. @@ -70,7 +70,7 @@ QString Utils::Fs::fromNativePath(const QString &path) */ QString Utils::Fs::fileExtension(const QString &filename) { - QString ext = QString(filename).remove(".!qB"); + QString ext = QString(filename).remove(QB_EXT); const int point_index = ext.lastIndexOf("."); return (point_index >= 0) ? ext.mid(point_index + 1) : QString(); } diff --git a/src/gui/previewselect.cpp b/src/gui/previewselect.cpp index f1bcbb81e..573f0af85 100644 --- a/src/gui/previewselect.cpp +++ b/src/gui/previewselect.cpp @@ -69,7 +69,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t int nbFiles = torrent->filesCount(); for (int i = 0; i < nbFiles; ++i) { QString fileName = torrent->fileName(i); - if (fileName.endsWith(".!qB")) + if (fileName.endsWith(QB_EXT)) fileName.chop(4); QString extension = Utils::Fs::fileExtension(fileName).toUpper(); if (Utils::Misc::isPreviewable(extension)) { diff --git a/src/gui/torrentcontentmodelfile.cpp b/src/gui/torrentcontentmodelfile.cpp index df66cb9fc..62c925428 100644 --- a/src/gui/torrentcontentmodelfile.cpp +++ b/src/gui/torrentcontentmodelfile.cpp @@ -29,6 +29,8 @@ */ #include "torrentcontentmodelfile.h" + +#include "base/bittorrent/torrenthandle.h" #include "torrentcontentmodelfolder.h" TorrentContentModelFile::TorrentContentModelFile(const QString &fileName, qulonglong fileSize, @@ -41,7 +43,7 @@ TorrentContentModelFile::TorrentContentModelFile(const QString &fileName, qulong m_name = fileName; // Do not display incomplete extensions - if (m_name.endsWith(".!qB")) + if (m_name.endsWith(QB_EXT)) m_name.chop(4); m_size = fileSize; diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index 09df1e671..b74f89ded 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -28,16 +28,17 @@ * Contact : chris@qbittorrent.org */ -#include #include "torrentcontentmodelfolder.h" +#include "base/bittorrent/torrenthandle.h" + TorrentContentModelFolder::TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent) : TorrentContentModelItem(parent) { Q_ASSERT(parent); m_name = name; // Do not display incomplete extensions - if (m_name.endsWith(".!qB")) + if (m_name.endsWith(QB_EXT)) m_name.chop(4); }