| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2012~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 |
#include <QDBusMetaType> |
| 21 |
|
| 22 |
#include "fcitxqtformattedpreedit.h" |
| 23 |
|
| 24 |
void FcitxQtFormattedPreedit::registerMetaType() { |
| 25 |
qRegisterMetaType<FcitxQtFormattedPreedit>("FcitxQtFormattedPreedit"); |
| 26 |
qDBusRegisterMetaType<FcitxQtFormattedPreedit>(); |
| 27 |
qRegisterMetaType<FcitxQtFormattedPreeditList>( |
| 28 |
"FcitxQtFormattedPreeditList"); |
| 29 |
qDBusRegisterMetaType<FcitxQtFormattedPreeditList>(); |
| 30 |
} |
| 31 |
|
| 32 |
qint32 FcitxQtFormattedPreedit::format() const { return m_format; } |
| 33 |
|
| 34 |
const QString &FcitxQtFormattedPreedit::string() const { return m_string; } |
| 35 |
|
| 36 |
void FcitxQtFormattedPreedit::setFormat(qint32 format) { m_format = format; } |
| 37 |
|
| 38 |
void FcitxQtFormattedPreedit::setString(const QString &str) { m_string = str; } |
| 39 |
|
| 40 |
bool FcitxQtFormattedPreedit::operator==( |
| 41 |
const FcitxQtFormattedPreedit &preedit) const { |
| 42 |
return (preedit.m_format == m_format) && (preedit.m_string == m_string); |
| 43 |
} |
| 44 |
|
| 45 |
FCITXQTDBUSADDONS_EXPORT |
| 46 |
QDBusArgument &operator<<(QDBusArgument &argument, |
| 47 |
const FcitxQtFormattedPreedit &preedit) { |
| 48 |
argument.beginStructure(); |
| 49 |
argument << preedit.string(); |
| 50 |
argument << preedit.format(); |
| 51 |
argument.endStructure(); |
| 52 |
return argument; |
| 53 |
} |
| 54 |
|
| 55 |
FCITXQTDBUSADDONS_EXPORT |
| 56 |
const QDBusArgument &operator>>(const QDBusArgument &argument, |
| 57 |
FcitxQtFormattedPreedit &preedit) { |
| 58 |
QString str; |
| 59 |
qint32 format; |
| 60 |
argument.beginStructure(); |
| 61 |
argument >> str >> format; |
| 62 |
argument.endStructure(); |
| 63 |
preedit.setString(str); |
| 64 |
preedit.setFormat(format); |
| 65 |
return argument; |
| 66 |
} |