Debian Codegraph @

qt5/dbusaddons/fcitxqtinputmethoditem.cpp

raw
1 /***************************************************************************
2 * Copyright (C) 2011~2012 by CSSlayer *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19
20 // Qt
21 #include <QDBusArgument>
22 #include <QDBusMetaType>
23
24 // self
25 #include "fcitxqtinputmethoditem.h"
26
27 bool FcitxQtInputMethodItem::enabled() const { return m_enabled; }
28 const QString &FcitxQtInputMethodItem::langCode() const { return m_langCode; }
29 const QString &FcitxQtInputMethodItem::name() const { return m_name; }
30 const QString &FcitxQtInputMethodItem::uniqueName() const {
31 return m_uniqueName;
32 }
33 void FcitxQtInputMethodItem::setEnabled(bool enable) { m_enabled = enable; }
34 void FcitxQtInputMethodItem::setLangCode(const QString &lang) {
35 m_langCode = lang;
36 }
37 void FcitxQtInputMethodItem::setName(const QString &name) { m_name = name; }
38 void FcitxQtInputMethodItem::setUniqueName(const QString &name) {
39 m_uniqueName = name;
40 }
41
42 void FcitxQtInputMethodItem::registerMetaType() {
43 qRegisterMetaType<FcitxQtInputMethodItem>("FcitxQtInputMethodItem");
44 qDBusRegisterMetaType<FcitxQtInputMethodItem>();
45 qRegisterMetaType<FcitxQtInputMethodItemList>("FcitxQtInputMethodItemList");
46 qDBusRegisterMetaType<FcitxQtInputMethodItemList>();
47 }
48
49 FCITXQTDBUSADDONS_EXPORT
50 QDBusArgument &operator<<(QDBusArgument &argument,
51 const FcitxQtInputMethodItem &im) {
52 argument.beginStructure();
53 argument << im.name();
54 argument << im.uniqueName();
55 argument << im.langCode();
56 argument << im.enabled();
57 argument.endStructure();
58 return argument;
59 }
60
61 FCITXQTDBUSADDONS_EXPORT
62 const QDBusArgument &operator>>(const QDBusArgument &argument,
63 FcitxQtInputMethodItem &im) {
64 QString name;
65 QString uniqueName;
66 QString langCode;
67 bool enabled;
68 argument.beginStructure();
69 argument >> name >> uniqueName >> langCode >> enabled;
70 argument.endStructure();
71 im.setName(name);
72 im.setUniqueName(uniqueName);
73 im.setLangCode(langCode);
74 im.setEnabled(enabled);
75 return argument;
76 }