Browse Source

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.
reviewable/pr5545/r2
Anthony Bilinski 6 years ago
parent
commit
41b2b35ce3
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 8
      src/model/interface.h

8
src/model/interface.h

@ -20,6 +20,8 @@ @@ -20,6 +20,8 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QMetaObject>
#include <functional>
/**
@ -48,7 +50,7 @@ @@ -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 @@ @@ -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 @@ @@ -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); \
}

Loading…
Cancel
Save