LeechCraft
0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
lambdaeventfilter.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <type_traits>
12
#include <QObject>
13
#include "
typegetter.h
"
14
15
namespace
LC
16
{
17
namespace
Util
18
{
19
namespace
detail
20
{
21
template
<
typename
F>
22
class
LambdaEventFilter
:
public
QObject
23
{
24
const
F
F_;
25
26
using
EventType_t = std::remove_pointer_t<std::decay_t<ArgType_t<F, 0>>>;
27
public
:
28
LambdaEventFilter
(
F
&& f, QObject *parent =
nullptr
)
29
: QObject { parent }
30
, F_ {
std
::
move
(f) }
31
{
32
}
33
34
bool
eventFilter
(QObject*,
QEvent
*
srcEv
)
override
35
{
36
const
auto
ev
=
dynamic_cast<
EventType_t*
>
(
srcEv
);
37
if
(!
ev
)
38
return
false
;
39
40
return
F_ (
ev
);
41
}
42
};
43
}
44
45
template
<
typename
F>
46
auto
MakeLambdaEventFilter
(
F
&& f, QObject *parent =
nullptr
)
47
{
48
return
new
detail::LambdaEventFilter<std::decay_t<F>
> { std::forward<F> (f), parent };
49
}
50
}
51
}
LC::Util::detail::LambdaEventFilter
Definition
lambdaeventfilter.h:23
LC::Util::detail::LambdaEventFilter::LambdaEventFilter
LambdaEventFilter(F &&f, QObject *parent=nullptr)
Definition
lambdaeventfilter.h:28
LC::Util::detail::LambdaEventFilter::eventFilter
bool eventFilter(QObject *, QEvent *srcEv) override
Definition
lambdaeventfilter.h:34
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:155
LC::Util::MakeLambdaEventFilter
auto MakeLambdaEventFilter(F &&f, QObject *parent=nullptr)
Definition
lambdaeventfilter.h:46
LC
Definition
constants.h:15
std
STL namespace.
LC::Util::detail::Filter
Definition
typelist.h:103
typegetter.h
src
util
sll
lambdaeventfilter.h
Generated by
1.10.0