Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (37 sloc) 0.986 kb
01069b2 @bmcdorman Changing everything
bmcdorman authored
1 #include "activatable.hpp"
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
2 #include <QDebug>
3 #include <QMetaMethod>
4
01069b2 @bmcdorman Changing everything
bmcdorman authored
5 ActivatableObject::ActivatableObject()
6 : m_connected(0)
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
7 {
8
9 }
10
11 ActivatableObject::~ActivatableObject()
12 {
13
14 }
15
16 void ActivatableObject::activated()
17 {
01069b2 @bmcdorman Changing everything
bmcdorman authored
18 QObject *us = dynamic_cast<QObject *>(this);
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
19 if(!us) return;
20
01069b2 @bmcdorman Changing everything
bmcdorman authored
21 QObject *connect = active();
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
22 const QMetaObject* meta = connect->metaObject();
23 if(meta->indexOfSignal("updateActivatable()") < 0) {
24 qWarning() << "?";
25 return;
26 }
27 m_connected = connect;
28
29 QMetaObject::invokeMethod(us, "update");
30 QObject::connect(m_connected, SIGNAL(updateActivatable()), us, SLOT(update()));
31 }
32
33 void ActivatableObject::deactivated()
34 {
35 m_connected = 0;
01069b2 @bmcdorman Changing everything
bmcdorman authored
36 QObject *us = dynamic_cast<QObject *>(this);
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
37 if(!us) return;
38 if(!m_connected) return;
39
40 const QMetaObject* meta = m_connected->metaObject();
41
01069b2 @bmcdorman Changing everything
bmcdorman authored
42 if(meta->indexOfSignal(SIGNAL(updateActivatable())) < 0) {
b31d01f @bmcdorman Changes. Changes everywhere.
bmcdorman authored
43 qWarning() << "?";
44 return;
45 }
46
47 QObject::disconnect(m_connected, SIGNAL(updateActivatable()), us, SLOT(update()));
48 }
Something went wrong with that request. Please try again.