[kdeconnect-kde] core: Revert "Drop NetworkPackage QObject heritage"
Aleix Pol
aleixpol at kde.org
Sat Jun 27 18:57:09 UTC 2015
Git commit 7d6912c11f06935202446915e3211dd8f698f958 by Aleix Pol.
Committed on 27/06/2015 at 18:54.
Pushed by apol into branch 'master'.
Revert "Drop NetworkPackage QObject heritage"
It makes us depend on unreleased Qt 5.5. Will un-revert it
when Qt 5.5 is a dependency we can take.
CCMAIL: kdeconnect at kde.org
This reverts commit 1a2f569a4797c325e18b2f2fecd2bfa6d854707e.
M +9 -11 core/networkpackage.cpp
M +3 -2 core/networkpackage.h
http://commits.kde.org/kdeconnect-kde/7d6912c11f06935202446915e3211dd8f698f958
diff --git a/core/networkpackage.cpp b/core/networkpackage.cpp
index eed65b2..64cfab7 100644
--- a/core/networkpackage.cpp
+++ b/core/networkpackage.cpp
@@ -65,14 +65,13 @@ void NetworkPackage::createIdentityPackage(NetworkPackage* np)
//qCDebug(KDECONNECT_CORE) << "createIdentityPackage" << np->serialize();
}
-template<class T>
-QVariantMap qobject2qvariant(const T* object)
+QVariantMap qobject2qvariant(const QObject* object)
{
QVariantMap map;
- auto metaObject = T::staticMetaObject;
- for(int i = metaObject.propertyOffset(); i < metaObject.propertyCount(); ++i) {
- QMetaProperty prop = metaObject.property(i);
- map.insert(QString::fromLatin1(prop.name()), prop.readOnGadget(object));
+ auto metaObject = object->metaObject();
+ for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i) {
+ const char *name = metaObject->property(i).name();
+ map.insert(QString::fromLatin1(name), object->property(name));
}
return map;
@@ -108,19 +107,18 @@ QByteArray NetworkPackage::serialize() const
return json;
}
-template <class T>
-void qvariant2qobject(const QVariantMap& variant, T* object)
+void qvariant2qobject(const QVariantMap& variant, QObject* object)
{
for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
{
- const int propertyIndex = T::staticMetaObject.indexOfProperty(iter.key().toLatin1());
+ const int propertyIndex = object->metaObject()->indexOfProperty(iter.key().toLatin1());
if (propertyIndex < 0) {
qCWarning(KDECONNECT_CORE) << "missing property" << object << iter.key();
continue;
}
- QMetaProperty property = T::staticMetaObject.property(propertyIndex);
- bool ret = property.writeOnGadget(object, *iter);
+ QMetaProperty property = object->metaObject()->property(propertyIndex);
+ bool ret = property.write(object, *iter);
if (!ret) {
qCWarning(KDECONNECT_CORE) << "couldn't set" << object << "->" << property.name() << '=' << *iter;
}
diff --git a/core/networkpackage.h b/core/networkpackage.h
index 909bb6e..6a0bf9c 100644
--- a/core/networkpackage.h
+++ b/core/networkpackage.h
@@ -37,9 +37,10 @@
class FileTransferJob;
-class KDECONNECTCORE_EXPORT NetworkPackage
+// TODO: investigate if we can turn into Q_GADGET, drop QObject
+class KDECONNECTCORE_EXPORT NetworkPackage : public QObject
{
- Q_GADGET
+ Q_OBJECT
Q_PROPERTY( QString id READ id WRITE setId )
Q_PROPERTY( QString type READ type WRITE setType )
Q_PROPERTY( QVariantMap body READ body WRITE setBody )
More information about the KDEConnect
mailing list