]> git.lyx.org Git - lyx.git/blob - src/support/SignalSlot.cpp
add signal/slot implementation 'framework'
[lyx.git] / src / support / SignalSlot.cpp
1 // -*- C++ -*-
2 /**
3  * \file SignalSlot.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include "SignalSlot.h"
13 #include "SignalSlotPrivate.h"
14
15 namespace lyx {
16
17 /////////////////////////////////////////////////////////////////////
18 //
19 // Signal
20 //
21 /////////////////////////////////////////////////////////////////////
22
23 Signal::Signal()
24         : impl(new SignalImpl)
25 {}
26
27
28 Signal::~Signal()
29 {
30         delete impl;
31 }
32
33
34 void Signal::fire()
35 {
36         impl->fire();
37 }
38
39
40 /////////////////////////////////////////////////////////////////////
41 //
42 // Slot
43 //
44 /////////////////////////////////////////////////////////////////////
45
46 void SlotImpl::called()
47 {
48         owner_.called();
49 }
50
51 Slot::Slot()
52         : impl(new SlotImpl(*this))
53 {}
54
55 Slot::~Slot()
56 {
57         delete impl;
58 }
59
60
61 /////////////////////////////////////////////////////////////////////
62 //
63 // Connect
64 //
65 /////////////////////////////////////////////////////////////////////
66
67 void connect(Signal & sig, Slot & slot)
68 {
69         QObject::connect(sig.impl, SIGNAL(fire()), slot.impl, SLOT(called()));
70 }
71
72 } // namespace lyx