aboutsummaryrefslogtreecommitdiff
path: root/lib/util.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-13 11:48:06 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-13 17:12:48 +0900
commita5267dbaa22581e316f440dc7327f2e7431012d5 (patch)
treedd13d8013dcd479f0610a447887c0d2e524a7ace /lib/util.h
parent4824705ea4eddfdb5d3845a64a96a1f5e2c022d0 (diff)
downloadlibquotient-a5267dbaa22581e316f440dc7327f2e7431012d5.tar.gz
libquotient-a5267dbaa22581e316f440dc7327f2e7431012d5.zip
qt_connection_util.h: a new home for connectSingleShot() and newly made connectUntil()
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h33
1 files changed, 4 insertions, 29 deletions
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 <QtCore/QPointer>
-#if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
+#include <QtCore/QLatin1String>
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QtCore/QMetaEnum>
#include <QtCore/QDebug>
#endif
@@ -166,6 +167,7 @@ namespace QMatrixClient
static constexpr auto is_callable = true;
using return_type = ReturnT;
using arg_types = std::tuple<ArgTs...>;
+ using function_type = std::function<ReturnT(ArgTs...)>;
static constexpr auto arg_number = std::tuple_size<arg_types>::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 <typename T>
- class ConnectionsGuard : public QPointer<T>
- {
- public:
- ConnectionsGuard(T* publisher, QObject* subscriber)
- : QPointer<T>(publisher), subscriber(subscriber)
- { }
- ~ConnectionsGuard()
- {
- if (*this)
- (*this)->disconnect(subscriber);
- }
- ConnectionsGuard(ConnectionsGuard&&) = default;
- ConnectionsGuard& operator=(ConnectionsGuard&&) = default;
- Q_DISABLE_COPY(ConnectionsGuard)
- using QPointer<T>::operator=;
-
- private:
- QObject* subscriber;
- };
-
/** Pretty-prints plain text into HTML
* This includes HTML escaping of <,>,",& and URLs linkification.
*/