From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/qt_connection_util.h | 69 ++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'lib/qt_connection_util.h') diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h index c2bde8df..0f36424f 100644 --- a/lib/qt_connection_util.h +++ b/lib/qt_connection_util.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once @@ -24,11 +24,12 @@ namespace QMatrixClient { namespace _impl { - template - inline QMetaObject::Connection connectUntil( - SenderT* sender, SignalT signal, ContextT* context, - std::function slot, Qt::ConnectionType connType) + template + inline QMetaObject::Connection + connectUntil(SenderT* sender, SignalT signal, ContextT* context, + std::function slot, + Qt::ConnectionType connType) { // See https://bugreports.qt.io/browse/QTBUG-60339 #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) @@ -37,23 +38,27 @@ namespace QMatrixClient { auto pc = std::make_unique(); #endif auto& c = *pc; // Resolve a reference before pc is moved to lambda - c = QObject::connect(sender, signal, context, - [pc=std::move(pc),slot] (ArgTs... args) { - Q_ASSERT(*pc); // If it's been triggered, it should exist - if (slot(std::forward(args)...)) - QObject::disconnect(*pc); - }, connType); + c = QObject::connect( + sender, signal, context, + [pc = std::move(pc), slot](ArgTs... args) { + Q_ASSERT( + *pc); // If it's been triggered, it should exist + if (slot(std::forward(args)...)) + QObject::disconnect(*pc); + }, + connType); return c; } } - template + template inline auto connectUntil(SenderT* sender, SignalT signal, ContextT* context, const FunctorT& slot, Qt::ConnectionType connType = Qt::AutoConnection) { - return _impl::connectUntil(sender, signal, context, + return _impl::connectUntil( + sender, signal, context, typename function_traits::function_type(slot), connType); } @@ -63,8 +68,8 @@ namespace QMatrixClient { * * Only supports DirectConnection type. */ - template + template inline auto connectSingleShot(SenderT* sender, SignalT signal, ReceiverT* receiver, SlotT slot) { @@ -84,24 +89,24 @@ namespace QMatrixClient { * disconnected from signals of the underlying pointer upon the guard's * destruction. */ - template - class ConnectionsGuard : public QPointer + 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=; + 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; + QObject* subscriber; }; } -- cgit v1.2.3