From be338b969cc1b18a544e4d32e55d17bfa994d549 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sat, 18 Oct 2014 03:26:34 +0400 Subject: [PATCH] Remove unneccessary includes of libtorrent in misc.h --- src/misc.cpp | 29 +++++++++++++++++++++++++++++ src/misc.h | 39 ++++++++++++++++----------------------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index fb0e1ebe3..8ace9bbb3 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -70,6 +70,13 @@ const int UNLEN = 256; #endif #endif // DISABLE_GUI +#if LIBTORRENT_VERSION_NUM < 10000 +#include +#else +#include +#endif +#include + using namespace libtorrent; static struct { const char *source; const char *comment; } units[] = { @@ -80,6 +87,28 @@ static struct { const char *source; const char *comment; } units[] = { QT_TRANSLATE_NOOP3("misc", "TiB", "tebibytes (1024 gibibytes)") }; +QString misc::toQString(const std::string &str) { + return QString::fromLocal8Bit(str.c_str()); +} + +QString misc::toQString(const char* str) { + return QString::fromLocal8Bit(str); +} + +QString misc::toQStringU(const std::string &str) { + return QString::fromUtf8(str.c_str()); +} + +QString misc::toQStringU(const char* str) { + return QString::fromUtf8(str); +} + +QString misc::toQString(const libtorrent::sha1_hash &hash) { + char out[41]; + libtorrent::to_hex((char const*)&hash[0], libtorrent::sha1_hash::size, out); + return QString(out); +} + #ifndef DISABLE_GUI void misc::shutdownComputer(shutDownAction action) { #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) diff --git a/src/misc.h b/src/misc.h index 45593c074..334c29d90 100644 --- a/src/misc.h +++ b/src/misc.h @@ -31,8 +31,6 @@ #ifndef MISC_H #define MISC_H -#include -#include #include #include #include @@ -46,33 +44,28 @@ #include #endif +#include + +namespace libtorrent { +#if LIBTORRENT_VERSION_NUM < 10000 + class big_number; + typedef big_number sha1_hash; +#else + class sha1_hash; +#endif +} + const qlonglong MAX_ETA = 8640000; enum shutDownAction { NO_SHUTDOWN, SHUTDOWN_COMPUTER, SUSPEND_COMPUTER, HIBERNATE_COMPUTER }; /* Miscellaneaous functions that can be useful */ namespace misc { - inline QString toQString(const std::string &str) { - return QString::fromLocal8Bit(str.c_str()); - } - - inline QString toQString(const char* str) { - return QString::fromLocal8Bit(str); - } - - inline QString toQStringU(const std::string &str) { - return QString::fromUtf8(str.c_str()); - } - - inline QString toQStringU(const char* str) { - return QString::fromUtf8(str); - } - - inline QString toQString(const libtorrent::sha1_hash &hash) { - char out[41]; - libtorrent::to_hex((char const*)&hash[0], libtorrent::sha1_hash::size, out); - return QString(out); - } + QString toQString(const std::string &str); + QString toQString(const char* str); + QString toQStringU(const std::string &str); + QString toQStringU(const char* str); + QString toQString(const libtorrent::sha1_hash &hash); #ifndef DISABLE_GUI void shutdownComputer(shutDownAction action=SHUTDOWN_COMPUTER);