Attica

comment.cpp
1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2010 Intel Corporation
5 SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8*/
9
10#include "comment.h"
11
12#include <QMap>
13
14using namespace Attica;
15
16QString Comment::commentTypeToString(const Comment::Type type)
17{
18 switch (type) {
19 case ContentComment:
20 return QStringLiteral("1");
21 case ForumComment:
22 return QStringLiteral("4");
23 case KnowledgeBaseComment:
24 return QStringLiteral("7");
25 case EventComment:
26 return QStringLiteral("8");
27 }
28
29 Q_ASSERT(false);
30 return QString();
31}
32
33class Q_DECL_HIDDEN Comment::Private : public QSharedData
34{
35public:
36 QString m_id;
37 QString m_subject;
38 QString m_text;
39 int m_childCount;
40 QString m_user;
41 QDateTime m_date;
42 int m_score;
43 QList<Comment> m_children;
44
45 Private()
46 : m_childCount(0)
47 , m_score(0)
48 {
49 }
50};
51
52Comment::Comment()
53 : d(new Private)
54{
55}
56
57Comment::Comment(const Comment &other)
58 : d(other.d)
59{
60}
61
62Comment &Comment::operator=(const Attica::Comment &other)
63{
64 d = other.d;
65 return *this;
66}
67
68Comment::~Comment()
69{
70}
71
72void Comment::setId(const QString &id)
73{
74 d->m_id = id;
75}
76
77QString Comment::id() const
78{
79 return d->m_id;
80}
81
82void Comment::setSubject(const QString &subject)
83{
84 d->m_subject = subject;
85}
86
87QString Comment::subject() const
88{
89 return d->m_subject;
90}
91
92void Comment::setText(const QString &text)
93{
94 d->m_text = text;
95}
96
97QString Comment::text() const
98{
99 return d->m_text;
100}
101
102void Comment::setChildCount(const int childCount)
103{
104 d->m_childCount = childCount;
105}
106
107int Comment::childCount() const
108{
109 return d->m_childCount;
110}
111
112void Comment::setUser(const QString &user)
113{
114 d->m_user = user;
115}
116
117QString Comment::user() const
118{
119 return d->m_user;
120}
121
122void Comment::setDate(const QDateTime &date)
123{
124 d->m_date = date;
125}
126
127QDateTime Comment::date() const
128{
129 return d->m_date;
130}
131
132void Comment::setScore(const int score)
133{
134 d->m_score = score;
135}
136
137int Comment::score() const
138{
139 return d->m_score;
140}
141
142void Comment::setChildren(QList<Comment> children)
143{
144 d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move
145}
146
147QList<Comment> Comment::children() const
148{
149 return d->m_children;
150}
151
152bool Comment::isValid() const
153{
154 return !(d->m_id.isEmpty());
155}
Represents a comment.
Definition comment.h:29
int score() const
Returns score of this comment.
Definition comment.cpp:137
void setScore(const int score)
This is for internal usage,.
Definition comment.cpp:132
The Attica namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:58:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.