Debian Codegraph @

qt5/platforminputcontext/fcitxqtdbustypes.cpp

raw
1 /*
2 * Copyright (C) 2017~2017 by CSSlayer
3 * [email protected]
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above Copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above Copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the authors nor the names of its contributors
17 * may be used to endorse or promote products derived from this
18 * software without specific prior written permission.
19 */
20
21 #include <QDBusMetaType>
22
23 #include "fcitxqtdbustypes.h"
24
25 void FcitxFormattedPreedit::registerMetaType() {
26 qRegisterMetaType<FcitxFormattedPreedit>("FcitxFormattedPreedit");
27 qDBusRegisterMetaType<FcitxFormattedPreedit>();
28 qRegisterMetaType<FcitxFormattedPreeditList>("FcitxFormattedPreeditList");
29 qDBusRegisterMetaType<FcitxFormattedPreeditList>();
30 }
31
32 qint32 FcitxFormattedPreedit::format() const { return m_format; }
33
34 const QString &FcitxFormattedPreedit::string() const { return m_string; }
35
36 void FcitxFormattedPreedit::setFormat(qint32 format) { m_format = format; }
37
38 void FcitxFormattedPreedit::setString(const QString &str) { m_string = str; }
39
40 bool FcitxFormattedPreedit::operator==(
41 const FcitxFormattedPreedit &preedit) const {
42 return (preedit.m_format == m_format) && (preedit.m_string == m_string);
43 }
44
45 QDBusArgument &operator<<(QDBusArgument &argument,
46 const FcitxFormattedPreedit &preedit) {
47 argument.beginStructure();
48 argument << preedit.string();
49 argument << preedit.format();
50 argument.endStructure();
51 return argument;
52 }
53
54 const QDBusArgument &operator>>(const QDBusArgument &argument,
55 FcitxFormattedPreedit &preedit) {
56 QString str;
57 qint32 format;
58 argument.beginStructure();
59 argument >> str >> format;
60 argument.endStructure();
61 preedit.setString(str);
62 preedit.setFormat(format);
63 return argument;
64 }
65
66 void FcitxInputContextArgument::registerMetaType() {
67 qRegisterMetaType<FcitxInputContextArgument>("FcitxInputContextArgument");
68 qDBusRegisterMetaType<FcitxInputContextArgument>();
69 qRegisterMetaType<FcitxInputContextArgumentList>(
70 "FcitxInputContextArgumentList");
71 qDBusRegisterMetaType<FcitxInputContextArgumentList>();
72 }
73
74 const QString &FcitxInputContextArgument::name() const { return m_name; }
75
76 void FcitxInputContextArgument::setName(const QString &name) { m_name = name; }
77
78 const QString &FcitxInputContextArgument::value() const { return m_value; }
79
80 void FcitxInputContextArgument::setValue(const QString &value) {
81 m_value = value;
82 }
83
84 QDBusArgument &operator<<(QDBusArgument &argument,
85 const FcitxInputContextArgument &arg) {
86 argument.beginStructure();
87 argument << arg.name();
88 argument << arg.value();
89 argument.endStructure();
90 return argument;
91 }
92
93 const QDBusArgument &operator>>(const QDBusArgument &argument,
94 FcitxInputContextArgument &arg) {
95 QString name, value;
96 argument.beginStructure();
97 argument >> name >> value;
98 argument.endStructure();
99 arg.setName(name);
100 arg.setValue(value);
101 return argument;
102 }