1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(model): return connection from interface macro

connection is normally returned from Qt's connect, and the caller may want to
track the connection to manually disconnect it.

(cherry picked from commit 41b2b35ce3)
This commit is contained in:
Anthony Bilinski 2019-10-10 02:53:41 -07:00
parent dfeca3e906
commit 40e43586f1
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -20,6 +20,8 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QMetaObject>
#include <functional>
/**
@ -48,7 +50,7 @@
*/
#define DECLARE_SIGNAL(name, ...) \
using Slot_##name = std::function<void (__VA_ARGS__)>; \
virtual void connectTo_##name(Slot_##name slot) const = 0
virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0
/**
* @def DECLARE_SIGNAL
@ -56,7 +58,7 @@
*/
#define DECLARE_SIGNAL(name, ...) \
using Slot_##name = std::function<void (__VA_ARGS__)>; \
virtual void connectTo_##name(Slot_##name slot) const = 0
virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0
/**
* @def SIGNAL_IMPL
@ -65,7 +67,7 @@
#define SIGNAL_IMPL(classname, name, ...) \
using Slot_##name = std::function<void (__VA_ARGS__)>; \
Q_SIGNAL void name(__VA_ARGS__); \
void connectTo_##name(Slot_##name slot) const override { \
QMetaObject::Connection connectTo_##name(Slot_##name slot) const override { \
connect(this, &classname::name, slot); \
}