From a5267dbaa22581e316f440dc7327f2e7431012d5 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 13 Jan 2019 11:48:06 +0900 Subject: qt_connection_util.h: a new home for connectSingleShot() and newly made connectUntil() --- lib/util.h | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'lib/util.h') diff --git a/lib/util.h b/lib/util.h index 336248d3..bae7f93f 100644 --- a/lib/util.h +++ b/lib/util.h @@ -18,8 +18,9 @@ #pragma once -#include -#if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include #include #endif @@ -166,6 +167,7 @@ namespace QMatrixClient static constexpr auto is_callable = true; using return_type = ReturnT; using arg_types = std::tuple; + using function_type = std::function; static constexpr auto arg_number = std::tuple_size::value; }; @@ -265,33 +267,6 @@ namespace QMatrixClient return std::make_pair(last, sLast); } - /** A guard pointer that disconnects an interested object upon destruction - * It's almost QPointer<> except that you have to initialise it with one - * more additional parameter - a pointer to a QObject that will be - * disconnected from signals of the underlying pointer upon the guard's - * destruction. - */ - template - class ConnectionsGuard : public QPointer - { - public: - ConnectionsGuard(T* publisher, QObject* subscriber) - : QPointer(publisher), subscriber(subscriber) - { } - ~ConnectionsGuard() - { - if (*this) - (*this)->disconnect(subscriber); - } - ConnectionsGuard(ConnectionsGuard&&) = default; - ConnectionsGuard& operator=(ConnectionsGuard&&) = default; - Q_DISABLE_COPY(ConnectionsGuard) - using QPointer::operator=; - - private: - QObject* subscriber; - }; - /** Pretty-prints plain text into HTML * This includes HTML escaping of <,>,",& and URLs linkification. */ -- cgit v1.2.3