File indexing completed on 2024-04-21 14:52:16

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2010 Intel Corporation
0005     SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
0006 
0007     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0008 */
0009 
0010 #include "comment.h"
0011 
0012 #include <QMap>
0013 
0014 using namespace Attica;
0015 
0016 QString Comment::commentTypeToString(const Comment::Type type)
0017 {
0018     switch (type) {
0019     case ContentComment:
0020         return QStringLiteral("1");
0021     case ForumComment:
0022         return QStringLiteral("4");
0023     case KnowledgeBaseComment:
0024         return QStringLiteral("7");
0025     case EventComment:
0026         return QStringLiteral("8");
0027     }
0028 
0029     Q_ASSERT(false);
0030     return QString();
0031 }
0032 
0033 class Q_DECL_HIDDEN Comment::Private : public QSharedData
0034 {
0035 public:
0036     QString m_id;
0037     QString m_subject;
0038     QString m_text;
0039     int m_childCount;
0040     QString m_user;
0041     QDateTime m_date;
0042     int m_score;
0043     QList<Comment> m_children;
0044 
0045     Private()
0046         : m_childCount(0)
0047         , m_score(0)
0048     {
0049     }
0050 };
0051 
0052 Comment::Comment()
0053     : d(new Private)
0054 {
0055 }
0056 
0057 Comment::Comment(const Comment &other)
0058     : d(other.d)
0059 {
0060 }
0061 
0062 Comment &Comment::operator=(const Attica::Comment &other)
0063 {
0064     d = other.d;
0065     return *this;
0066 }
0067 
0068 Comment::~Comment()
0069 {
0070 }
0071 
0072 void Comment::setId(const QString &id)
0073 {
0074     d->m_id = id;
0075 }
0076 
0077 QString Comment::id() const
0078 {
0079     return d->m_id;
0080 }
0081 
0082 void Comment::setSubject(const QString &subject)
0083 {
0084     d->m_subject = subject;
0085 }
0086 
0087 QString Comment::subject() const
0088 {
0089     return d->m_subject;
0090 }
0091 
0092 void Comment::setText(const QString &text)
0093 {
0094     d->m_text = text;
0095 }
0096 
0097 QString Comment::text() const
0098 {
0099     return d->m_text;
0100 }
0101 
0102 void Comment::setChildCount(const int childCount)
0103 {
0104     d->m_childCount = childCount;
0105 }
0106 
0107 int Comment::childCount() const
0108 {
0109     return d->m_childCount;
0110 }
0111 
0112 void Comment::setUser(const QString &user)
0113 {
0114     d->m_user = user;
0115 }
0116 
0117 QString Comment::user() const
0118 {
0119     return d->m_user;
0120 }
0121 
0122 void Comment::setDate(const QDateTime &date)
0123 {
0124     d->m_date = date;
0125 }
0126 
0127 QDateTime Comment::date() const
0128 {
0129     return d->m_date;
0130 }
0131 
0132 void Comment::setScore(const int score)
0133 {
0134     d->m_score = score;
0135 }
0136 
0137 int Comment::score() const
0138 {
0139     return d->m_score;
0140 }
0141 
0142 void Comment::setChildren(QList<Comment> children)
0143 {
0144     d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move
0145 }
0146 
0147 QList<Comment> Comment::children() const
0148 {
0149     return d->m_children;
0150 }
0151 
0152 bool Comment::isValid() const
0153 {
0154     return !(d->m_id.isEmpty());
0155 }