diff --git a/src/emoji.cpp b/src/emoji.cpp index a81495b8..5f024470 100644 --- a/src/emoji.cpp +++ b/src/emoji.cpp @@ -1,71 +1,92 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emoji.h" #include Emoji::Emoji() { } Emoji::~Emoji() { } void Emoji::parseEmoji(const QJsonObject &emoji) { mIdentifier = emoji.value(QLatin1String("_id")).toString(); mExtension = emoji.value(QLatin1String("extension")).toString(); mName = emoji.value(QLatin1String("name")).toString(); //TODO add alias ? updated ? } QString Emoji::identifier() const { return mIdentifier; } void Emoji::setIdentifier(const QString &identifier) { mIdentifier = identifier; } QString Emoji::extension() const { return mExtension; } void Emoji::setExtension(const QString &extension) { mExtension = extension; } void Emoji::setName(const QString &name) { mName = name; } QString Emoji::name() const { return mName; } + +bool Emoji::operator==(const Emoji &other) const +{ + return (mName == other.name()) && (mExtension == other.extension()) && (mIdentifier == other.identifier()); +} + +Emoji &Emoji::operator=(const Emoji &other) +{ + mName = other.name(); + mExtension = other.extension(); + mIdentifier = other.identifier(); + return *this; +} + +QDebug operator <<(QDebug d, const Emoji &t) +{ + d << "Name: " << t.name(); + d << "Identifier: " << t.identifier(); + d << "extension: " << t.extension(); + return d; +} diff --git a/src/emoji.h b/src/emoji.h index 5e2542b4..4bd87547 100644 --- a/src/emoji.h +++ b/src/emoji.h @@ -1,51 +1,61 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EMOJI_H #define EMOJI_H #include #include +#include +#include #include "libruqola_private_export.h" class LIBRUQOLACORE_TESTS_EXPORT Emoji { + Q_GADGET public: Emoji(); ~Emoji(); void parseEmoji(const QJsonObject &emoji); QString identifier() const; void setIdentifier(const QString &identifier); QString extension() const; void setExtension(const QString &extension); void setName(const QString &name); QString name() const; + bool operator==(const Emoji &other) const; + + Emoji &operator=(const Emoji &other); + + private: QString mIdentifier; QString mExtension; QString mName; }; +Q_DECLARE_METATYPE(Emoji) +LIBRUQOLACORE_EXPORT QDebug operator <<(QDebug d, const Emoji &t); #endif // EMOJI_H