Attica

comment.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2010 Intel Corporation
5  SPDX-FileContributor: Mateu Batle Sastre <[email protected]>
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 
14 using namespace Attica;
15 
16 QString 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 
33 class Q_DECL_HIDDEN Comment::Private : public QSharedData
34 {
35 public:
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 
52 Comment::Comment()
53  : d(new Private)
54 {
55 }
56 
57 Comment::Comment(const Comment &other)
58  : d(other.d)
59 {
60 }
61 
62 Comment &Comment::operator=(const Attica::Comment &other)
63 {
64  d = other.d;
65  return *this;
66 }
67 
68 Comment::~Comment()
69 {
70 }
71 
72 void Comment::setId(const QString &id)
73 {
74  d->m_id = id;
75 }
76 
77 QString Comment::id() const
78 {
79  return d->m_id;
80 }
81 
82 void Comment::setSubject(const QString &subject)
83 {
84  d->m_subject = subject;
85 }
86 
87 QString Comment::subject() const
88 {
89  return d->m_subject;
90 }
91 
92 void Comment::setText(const QString &text)
93 {
94  d->m_text = text;
95 }
96 
97 QString Comment::text() const
98 {
99  return d->m_text;
100 }
101 
102 void Comment::setChildCount(const int childCount)
103 {
104  d->m_childCount = childCount;
105 }
106 
107 int Comment::childCount() const
108 {
109  return d->m_childCount;
110 }
111 
112 void Comment::setUser(const QString &user)
113 {
114  d->m_user = user;
115 }
116 
117 QString Comment::user() const
118 {
119  return d->m_user;
120 }
121 
122 void Comment::setDate(const QDateTime &date)
123 {
124  d->m_date = date;
125 }
126 
127 QDateTime Comment::date() const
128 {
129  return d->m_date;
130 }
131 
132 void Comment::setScore(const int score)
133 {
134  d->m_score = score;
135 }
136 
137 int Comment::score() const
138 {
139  return d->m_score;
140 }
141 
142 void 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 
147 QList<Comment> Comment::children() const
148 {
149  return d->m_children;
150 }
151 
152 bool Comment::isValid() const
153 {
154  return !(d->m_id.isEmpty());
155 }
void setScore(const int score)
This is for internal usage,.
Definition: comment.cpp:132
The Attica namespace,.
int score() const
Returns score of this comment.
Definition: comment.cpp:137
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:05:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.