summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforminputcontexts/ibus/main.cpp1
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibustypes.cpp166
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibustypes.h53
3 files changed, 114 insertions, 106 deletions
diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp
index b47c0b40de..2846f52c8c 100644
--- a/src/plugins/platforminputcontexts/ibus/main.cpp
+++ b/src/plugins/platforminputcontexts/ibus/main.cpp
@@ -59,7 +59,6 @@ QIBusPlatformInputContext *QIbusPlatformInputContextPlugin::create(const QString
Q_UNUSED(paramList);
if (system.compare(system, QLatin1String("ibus"), Qt::CaseInsensitive) == 0) {
- qDBusRegisterMetaType<QIBusSerializable>();
qDBusRegisterMetaType<QIBusAttribute>();
qDBusRegisterMetaType<QIBusAttributeList>();
qDBusRegisterMetaType<QIBusText>();
diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
index a168836a06..9d219ff8c1 100644
--- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
@@ -54,9 +54,9 @@ QIBusSerializable::~QIBusSerializable()
{
}
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable &object)
+void QIBusSerializable::deserializeFrom(const QDBusArgument &argument)
{
- argument >> object.name;
+ argument >> name;
argument.beginMap();
while (!argument.atEnd()) {
@@ -66,19 +66,18 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable
argument >> key;
argument >> value;
argument.endMapEntry();
- object.attachments[key] = value.variant().value<QDBusArgument>();
+ attachments[key] = value.variant().value<QDBusArgument>();
}
argument.endMap();
- return argument;
}
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &object)
+void QIBusSerializable::serializeTo(QDBusArgument &argument) const
{
- argument << object.name;
+ argument << name;
argument.beginMap(qMetaTypeId<QString>(), qMetaTypeId<QDBusVariant>());
- QHashIterator<QString, QDBusArgument> i(object.attachments);
+ QHashIterator<QString, QDBusArgument> i(attachments);
while (i.hasNext()) {
i.next();
@@ -91,7 +90,6 @@ QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &obje
argument.endMapEntry();
}
argument.endMap();
- return argument;
}
QIBusAttribute::QIBusAttribute()
@@ -107,39 +105,35 @@ QIBusAttribute::~QIBusAttribute()
{
}
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute)
+void QIBusAttribute::serializeTo(QDBusArgument &argument) const
{
argument.beginStructure();
- argument << static_cast<const QIBusSerializable &>(attribute);
+ QIBusSerializable::serializeTo(argument);
- quint32 t = (quint32) attribute.type;
+ quint32 t = (quint32) type;
argument << t;
- argument << attribute.value;
- argument << attribute.start;
- argument << attribute.end;
+ argument << value;
+ argument << start;
+ argument << end;
argument.endStructure();
-
- return argument;
}
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute)
+void QIBusAttribute::deserializeFrom(const QDBusArgument &argument)
{
argument.beginStructure();
- argument >> static_cast<QIBusSerializable &>(attribute);
+ QIBusSerializable::deserializeFrom(argument);
quint32 t;
argument >> t;
- attribute.type = (QIBusAttribute::Type) t;
- argument >> attribute.value;
- argument >> attribute.start;
- argument >> attribute.end;
+ type = (QIBusAttribute::Type) t;
+ argument >> value;
+ argument >> start;
+ argument >> end;
argument.endStructure();
-
- return argument;
}
QTextCharFormat QIBusAttribute::format() const
@@ -191,30 +185,30 @@ QIBusAttributeList::~QIBusAttributeList()
{
}
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attrList)
+void QIBusAttributeList::serializeTo(QDBusArgument &argument) const
{
argument.beginStructure();
- argument << static_cast<const QIBusSerializable &>(attrList);
+ QIBusSerializable::serializeTo(argument);
argument.beginArray(qMetaTypeId<QDBusVariant>());
- for (int i = 0; i < attrList.attributes.size(); ++i) {
+ for (int i = 0; i < attributes.size(); ++i) {
QVariant variant;
- variant.setValue(attrList.attributes.at(i));
+ variant.setValue(attributes.at(i));
argument << QDBusVariant (variant);
}
argument.endArray();
argument.endStructure();
- return argument;
}
-const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &attrList)
+void QIBusAttributeList::deserializeFrom(const QDBusArgument &arg)
{
qCDebug(qtQpaInputMethodsSerialize) << "QIBusAttributeList::fromDBusArgument()" << arg.currentSignature();
+
arg.beginStructure();
- arg >> static_cast<QIBusSerializable &>(attrList);
+ QIBusSerializable::deserializeFrom(arg);
arg.beginArray();
while (!arg.atEnd()) {
@@ -223,12 +217,11 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &at
QIBusAttribute attr;
var.variant().value<QDBusArgument>() >> attr;
- attrList.attributes.append(attr);
+ attributes.append(attr);
}
arg.endArray();
arg.endStructure();
- return arg;
}
QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const
@@ -273,31 +266,30 @@ QIBusText::~QIBusText()
{
}
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text)
+void QIBusText::serializeTo(QDBusArgument &argument) const
{
argument.beginStructure();
- argument << static_cast<const QIBusSerializable &>(text);
+ QIBusSerializable::serializeTo(argument);
- argument << text.text << text.attributes;
+ argument << text << attributes;
argument.endStructure();
- return argument;
}
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text)
+void QIBusText::deserializeFrom(const QDBusArgument &argument)
{
qCDebug(qtQpaInputMethodsSerialize) << "QIBusText::fromDBusArgument()" << argument.currentSignature();
+
argument.beginStructure();
- argument >> static_cast<QIBusSerializable &>(text);
+ QIBusSerializable::deserializeFrom(argument);
- argument >> text.text;
+ argument >> text;
QDBusVariant variant;
argument >> variant;
- variant.variant().value<QDBusArgument>() >> text.attributes;
+ variant.variant().value<QDBusArgument>() >> attributes;
argument.endStructure();
- return argument;
}
QIBusEngineDesc::QIBusEngineDesc()
@@ -326,81 +318,79 @@ QIBusEngineDesc::~QIBusEngineDesc()
{
}
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc)
+void QIBusEngineDesc::serializeTo(QDBusArgument &argument) const
{
argument.beginStructure();
- argument << static_cast<const QIBusSerializable &>(desc);
-
- argument << desc.engine_name;
- argument << desc.longname;
- argument << desc.description;
- argument << desc.language;
- argument << desc.license;
- argument << desc.author;
- argument << desc.icon;
- argument << desc.layout;
- argument << desc.rank;
- argument << desc.hotkeys;
- argument << desc.symbol;
- argument << desc.setup;
- argument << desc.layout_variant;
- argument << desc.layout_option;
- argument << desc.version;
- argument << desc.textdomain;
- argument << desc.iconpropkey;
+ QIBusSerializable::serializeTo(argument);
+
+ argument << engine_name;
+ argument << longname;
+ argument << description;
+ argument << language;
+ argument << license;
+ argument << author;
+ argument << icon;
+ argument << layout;
+ argument << rank;
+ argument << hotkeys;
+ argument << symbol;
+ argument << setup;
+ argument << layout_variant;
+ argument << layout_option;
+ argument << version;
+ argument << textdomain;
+ argument << iconpropkey;
argument.endStructure();
- return argument;
}
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc)
+void QIBusEngineDesc::deserializeFrom(const QDBusArgument &argument)
{
qCDebug(qtQpaInputMethodsSerialize) << "QIBusEngineDesc::fromDBusArgument()" << argument.currentSignature();
argument.beginStructure();
- argument >> static_cast<QIBusSerializable &>(desc);
-
- argument >> desc.engine_name;
- argument >> desc.longname;
- argument >> desc.description;
- argument >> desc.language;
- argument >> desc.license;
- argument >> desc.author;
- argument >> desc.icon;
- argument >> desc.layout;
- argument >> desc.rank;
- argument >> desc.hotkeys;
- argument >> desc.symbol;
- argument >> desc.setup;
+ QIBusSerializable::deserializeFrom(argument);
+
+ argument >> engine_name;
+ argument >> longname;
+ argument >> description;
+ argument >> language;
+ argument >> license;
+ argument >> author;
+ argument >> icon;
+ argument >> layout;
+ argument >> rank;
+ argument >> hotkeys;
+ argument >> symbol;
+ argument >> setup;
// Previous IBusEngineDesc supports the arguments between engine_name
// and setup.
if (argument.currentSignature() == "") {
argument.endStructure();
- return argument;
+ return;
}
- argument >> desc.layout_variant;
- argument >> desc.layout_option;
+ argument >> layout_variant;
+ argument >> layout_option;
// Previous IBusEngineDesc supports the arguments between engine_name
// and layout_option.
if (argument.currentSignature() == "") {
argument.endStructure();
- return argument;
+ return;
}
- argument >> desc.version;
+ argument >> version;
if (argument.currentSignature() == "") {
argument.endStructure();
- return argument;
+ return;
}
- argument >> desc.textdomain;
+ argument >> textdomain;
if (argument.currentSignature() == "") {
argument.endStructure();
- return argument;
+ return;
}
- argument >> desc.iconpropkey;
+ argument >> iconpropkey;
argument.endStructure();
- return argument;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.h b/src/plugins/platforminputcontexts/ibus/qibustypes.h
index 9dca7e3903..9f2b0eb41f 100644
--- a/src/plugins/platforminputcontexts/ibus/qibustypes.h
+++ b/src/plugins/platforminputcontexts/ibus/qibustypes.h
@@ -54,13 +54,16 @@ class QIBusSerializable
{
public:
QIBusSerializable();
- virtual ~QIBusSerializable();
+ ~QIBusSerializable();
+
+ void serializeTo(QDBusArgument &argument) const;
+ void deserializeFrom(const QDBusArgument &argument);
QString name;
QHash<QString, QDBusArgument> attachments;
};
-class QIBusAttribute : public QIBusSerializable
+class QIBusAttribute : private QIBusSerializable
{
public:
enum Type {
@@ -83,13 +86,16 @@ public:
QTextCharFormat format() const;
+ void serializeTo(QDBusArgument &argument) const;
+ void deserializeFrom(const QDBusArgument &argument);
+
Type type;
quint32 value;
quint32 start;
quint32 end;
};
-class QIBusAttributeList : public QIBusSerializable
+class QIBusAttributeList : private QIBusSerializable
{
public:
QIBusAttributeList();
@@ -97,25 +103,34 @@ public:
QList<QInputMethodEvent::Attribute> imAttributes() const;
+ void serializeTo(QDBusArgument &argument) const;
+ void deserializeFrom(const QDBusArgument &argument);
+
QVector<QIBusAttribute> attributes;
};
-class QIBusText : public QIBusSerializable
+class QIBusText : private QIBusSerializable
{
public:
QIBusText();
~QIBusText();
+ void serializeTo(QDBusArgument &argument) const;
+ void deserializeFrom(const QDBusArgument &argument);
+
QString text;
QIBusAttributeList attributes;
};
-class QIBusEngineDesc : public QIBusSerializable
+class QIBusEngineDesc : private QIBusSerializable
{
public:
QIBusEngineDesc();
~QIBusEngineDesc();
+ void serializeTo(QDBusArgument &argument) const;
+ void deserializeFrom(const QDBusArgument &argument);
+
QString engine_name;
QString longname;
QString description;
@@ -135,24 +150,28 @@ public:
QString iconpropkey;
};
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusSerializable &object);
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusSerializable &object);
-
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute);
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute);
+inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute)
+{ attribute.serializeTo(argument); return argument; }
+inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute)
+{ attribute.deserializeFrom(argument); return argument; }
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList);
-const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &attrList);
+inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList)
+{ attributeList.serializeTo(argument); return argument; }
+inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttributeList &attributeList)
+{ attributeList.deserializeFrom(argument); return argument; }
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text);
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text);
+inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text)
+{ text.serializeTo(argument); return argument; }
+inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text)
+{ text.deserializeFrom(argument); return argument; }
-QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc);
-const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc);
+inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc)
+{ desc.serializeTo(argument); return argument; }
+inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc)
+{ desc.deserializeFrom(argument); return argument; }
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QIBusSerializable)
Q_DECLARE_METATYPE(QIBusAttribute)
Q_DECLARE_METATYPE(QIBusAttributeList)
Q_DECLARE_METATYPE(QIBusText)