ktorrent/fix-build-with-qt5.6.patch

399 lines
13 KiB
Diff

From ce5f7e3de927243c3e9c52eeac66a03f64eaf85d Mon Sep 17 00:00:00 2001
From: Wolfgang Bauer <wbauer@tmo.at>
Date: Fri, 1 Sep 2017 14:33:56 +0200
Subject: [PATCH] Lower minimum Qt version to 5.5.0
As qAsConst() is new in Qt 5.7.0, define it where needed to make
ktorrent compile with lower Qt versions too.
---
CMakeLists.txt | 2 +-
ktmagnetdownloader/magnettest.cpp | 8 ++++++++
ktorrent/core.cpp | 8 ++++++++
ktorrent/trayicon.cpp | 8 ++++++++
ktorrent/view/viewmodel.h | 9 +++++++++
libktcore/groups/groupmanager.cpp | 9 +++++++++
libktcore/gui/tabbarwidget.cpp | 9 +++++++++
libktcore/interfaces/torrentactivityinterface.cpp | 9 +++++++++
libktcore/torrent/magnetmanager.cpp | 9 +++++++++
libktcore/torrent/queuemanager.cpp | 8 ++++++++
libktcore/torrent/torrentfilelistmodel.cpp | 9 +++++++++
libktcore/torrent/torrentfiletreemodel.cpp | 9 +++++++++
plugins/bwscheduler/schedule.h | 9 +++++++++
plugins/infowidget/trackermodel.cpp | 9 +++++++++
plugins/mediaplayer/playlist.cpp | 8 ++++++++
plugins/search/searchactivity.cpp | 8 ++++++++
plugins/search/searchenginelist.cpp | 9 +++++++++
plugins/shutdown/shutdownruleset.cpp | 8 ++++++++
plugins/upnp/routermodel.cpp | 9 +++++++++
19 files changed, 156 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87428597..a5dc007a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(KTORRENT)
-set (QT_MIN_VERSION "5.7.0")
+set (QT_MIN_VERSION "5.5.0")
set (KF5_MIN_VERSION "5.15")
find_package(ECM REQUIRED NO_MODULE)
diff --git a/ktmagnetdownloader/magnettest.cpp b/ktmagnetdownloader/magnettest.cpp
index 7ad15e43..378e3714 100644
--- a/ktmagnetdownloader/magnettest.cpp
+++ b/ktmagnetdownloader/magnettest.cpp
@@ -38,6 +38,14 @@
#include <bcodec/bencoder.h>
#include <peer/authenticationmonitor.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace kt;
using namespace bt;
diff --git a/ktorrent/core.cpp b/ktorrent/core.cpp
index c8b497da..da740e17 100644
--- a/ktorrent/core.cpp
+++ b/ktorrent/core.cpp
@@ -62,6 +62,14 @@
#include "gui.h"
#include "powermanagementinhibit_interface.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace bt;
diff --git a/ktorrent/trayicon.cpp b/ktorrent/trayicon.cpp
index a0b9f6ed..fb723268 100644
--- a/ktorrent/trayicon.cpp
+++ b/ktorrent/trayicon.cpp
@@ -42,6 +42,14 @@
#include "core.h"
#include "gui.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace bt;
diff --git a/ktorrent/view/viewmodel.h b/ktorrent/view/viewmodel.h
index 11217508..b1df54f5 100644
--- a/ktorrent/view/viewmodel.h
+++ b/ktorrent/view/viewmodel.h
@@ -26,6 +26,15 @@
#include <QAbstractTableModel>
#include <interfaces/torrentinterface.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
namespace kt
{
class View;
diff --git a/libktcore/groups/groupmanager.cpp b/libktcore/groups/groupmanager.cpp
index 57ff90a4..902a8e68 100644
--- a/libktcore/groups/groupmanager.cpp
+++ b/libktcore/groups/groupmanager.cpp
@@ -37,6 +37,15 @@
#include "ungroupedgroup.h"
#include "functiongroup.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt
diff --git a/libktcore/gui/tabbarwidget.cpp b/libktcore/gui/tabbarwidget.cpp
index 8bece605..9a9f6e90 100644
--- a/libktcore/gui/tabbarwidget.cpp
+++ b/libktcore/gui/tabbarwidget.cpp
@@ -28,6 +28,15 @@
#include <QTimer>
#include <QVBoxLayout>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
namespace kt
{
diff --git a/libktcore/interfaces/torrentactivityinterface.cpp b/libktcore/interfaces/torrentactivityinterface.cpp
index 4532761f..063497c3 100644
--- a/libktcore/interfaces/torrentactivityinterface.cpp
+++ b/libktcore/interfaces/torrentactivityinterface.cpp
@@ -20,6 +20,15 @@
#include "torrentactivityinterface.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
namespace kt
{
TorrentActivityInterface::TorrentActivityInterface(const QString& name, const QString& icon, QWidget* parent)
diff --git a/libktcore/torrent/magnetmanager.cpp b/libktcore/torrent/magnetmanager.cpp
index 838959bb..4684c841 100644
--- a/libktcore/torrent/magnetmanager.cpp
+++ b/libktcore/torrent/magnetmanager.cpp
@@ -29,6 +29,15 @@
#include <util/error.h>
#include <bcodec/bnode.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt {
diff --git a/libktcore/torrent/queuemanager.cpp b/libktcore/torrent/queuemanager.cpp
index 0b805ef6..c930221d 100644
--- a/libktcore/torrent/queuemanager.cpp
+++ b/libktcore/torrent/queuemanager.cpp
@@ -42,6 +42,14 @@
#include <algorithm>
#include <climits>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace bt;
diff --git a/libktcore/torrent/torrentfilelistmodel.cpp b/libktcore/torrent/torrentfilelistmodel.cpp
index 00b8436f..082971e4 100644
--- a/libktcore/torrent/torrentfilelistmodel.cpp
+++ b/libktcore/torrent/torrentfilelistmodel.cpp
@@ -32,6 +32,15 @@
#include <interfaces/torrentfileinterface.h>
#include <util/functions.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt
diff --git a/libktcore/torrent/torrentfiletreemodel.cpp b/libktcore/torrent/torrentfiletreemodel.cpp
index 35cf59f4..d6ea23b1 100644
--- a/libktcore/torrent/torrentfiletreemodel.cpp
+++ b/libktcore/torrent/torrentfiletreemodel.cpp
@@ -38,6 +38,15 @@
#include <util/log.h>
#include <util/error.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt
diff --git a/plugins/bwscheduler/schedule.h b/plugins/bwscheduler/schedule.h
index 4a630fff..07d95f47 100644
--- a/plugins/bwscheduler/schedule.h
+++ b/plugins/bwscheduler/schedule.h
@@ -26,6 +26,15 @@
#include <QTime>
#include <util/constants.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
namespace bt
{
class BDictNode;
diff --git a/plugins/infowidget/trackermodel.cpp b/plugins/infowidget/trackermodel.cpp
index a94e0e31..80647128 100644
--- a/plugins/infowidget/trackermodel.cpp
+++ b/plugins/infowidget/trackermodel.cpp
@@ -28,6 +28,15 @@
#include <interfaces/torrentinterface.h>
#include <interfaces/trackerinterface.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
namespace kt
{
diff --git a/plugins/mediaplayer/playlist.cpp b/plugins/mediaplayer/playlist.cpp
index ff277a4e..289c8fe7 100644
--- a/plugins/mediaplayer/playlist.cpp
+++ b/plugins/mediaplayer/playlist.cpp
@@ -37,6 +37,14 @@
#include <util/log.h>
#include "mediaplayer.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace bt;
diff --git a/plugins/search/searchactivity.cpp b/plugins/search/searchactivity.cpp
index 196e781e..679f9500 100644
--- a/plugins/search/searchactivity.cpp
+++ b/plugins/search/searchactivity.cpp
@@ -45,6 +45,14 @@
#include <searchpluginsettings.h>
#include "searchtoolbar.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
namespace kt
{
diff --git a/plugins/search/searchenginelist.cpp b/plugins/search/searchenginelist.cpp
index 0d715ed0..766404e0 100644
--- a/plugins/search/searchenginelist.cpp
+++ b/plugins/search/searchenginelist.cpp
@@ -35,6 +35,15 @@
#include "searchenginelist.h"
#include "opensearchdownloadjob.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt
diff --git a/plugins/shutdown/shutdownruleset.cpp b/plugins/shutdown/shutdownruleset.cpp
index ce728fb3..b3774bd6 100644
--- a/plugins/shutdown/shutdownruleset.cpp
+++ b/plugins/shutdown/shutdownruleset.cpp
@@ -31,6 +31,14 @@
#include <torrent/queuemanager.h>
#include "shutdownruleset.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
using namespace bt;
diff --git a/plugins/upnp/routermodel.cpp b/plugins/upnp/routermodel.cpp
index 464e2f14..7167f3d4 100644
--- a/plugins/upnp/routermodel.cpp
+++ b/plugins/upnp/routermodel.cpp
@@ -27,6 +27,15 @@
#include <upnp/upnprouter.h>
#include "routermodel.h"
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
+// this adds const to non-const objects (like std::as_const)
+template <typename T>
+Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
+// prevent rvalue arguments:
+template <typename T>
+void qAsConst(const T &&) Q_DECL_EQ_DELETE;
+#endif
+
using namespace bt;
namespace kt
--
2.13.5