QObject parent semantic in Device

This commit is contained in:
Samoilenko Yuri 2014-01-23 02:31:27 +04:00
parent d9018cb9f8
commit b0c9f48efc
3 changed files with 10 additions and 8 deletions

View file

@ -99,7 +99,7 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
const KConfigGroup& known = config->group("trusted_devices"); const KConfigGroup& known = config->group("trusted_devices");
const QStringList& list = known.groupList(); const QStringList& list = known.groupList();
Q_FOREACH(const QString& id, list) { Q_FOREACH(const QString& id, list) {
Device* device = new Device(id); Device* device = new Device(this, id);
connect(device, SIGNAL(reachableStatusChanged()), connect(device, SIGNAL(reachableStatusChanged()),
this, SLOT(onDeviceReachableStatusChanged())); this, SLOT(onDeviceReachableStatusChanged()));
mDevices[id] = device; mDevices[id] = device;
@ -166,7 +166,7 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
} else { } else {
//kDebug(kdeconnect_kded()) << "It is a new device"; //kDebug(kdeconnect_kded()) << "It is a new device";
Device* device = new Device(identityPackage, dl); Device* device = new Device(this, identityPackage, dl);
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged())); connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged()));
mDevices[id] = device; mDevices[id] = device;

View file

@ -21,8 +21,9 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QFile> #include <QFile>
Device::Device(const QString& id) Device::Device(QObject* parent, const QString& id)
: m_deviceId(id) : QObject(parent)
, m_deviceId(id)
, m_pairStatus(Device::Paired) , m_pairStatus(Device::Paired)
, m_protocolVersion(NetworkPackage::ProtocolVersion) //We don't know it yet , m_protocolVersion(NetworkPackage::ProtocolVersion) //We don't know it yet
{ {
@ -45,8 +46,9 @@ Device::Device(const QString& id)
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
} }
Device::Device(const NetworkPackage& identityPackage, DeviceLink* dl) Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLink* dl)
: m_deviceId(identityPackage.get<QString>("deviceId")) : QObject(parent)
, m_deviceId(identityPackage.get<QString>("deviceId"))
, m_deviceName(identityPackage.get<QString>("deviceName")) , m_deviceName(identityPackage.get<QString>("deviceName"))
, m_deviceType(str2type(identityPackage.get<QString>("deviceType"))) , m_deviceType(str2type(identityPackage.get<QString>("deviceType")))
, m_pairStatus(Device::NotPaired) , m_pairStatus(Device::NotPaired)

View file

@ -64,14 +64,14 @@ public:
* *
* We already know it but we need to wait for an incoming DeviceLink to communicate * We already know it but we need to wait for an incoming DeviceLink to communicate
*/ */
Device(const QString& id); Device(QObject* parent, const QString& id);
/** /**
* Device known via an incoming connection sent to us via a devicelink. * Device known via an incoming connection sent to us via a devicelink.
* *
* We know everything but we don't trust it yet * We know everything but we don't trust it yet
*/ */
Device(const NetworkPackage& np, DeviceLink* dl); Device(QObject* parent, const NetworkPackage& np, DeviceLink* dl);
virtual ~Device(); virtual ~Device();