diff --git a/src/comment.cpp b/src/comment.cpp index 5e424dc..4a9b64a 100644 --- a/src/comment.cpp +++ b/src/comment.cpp @@ -1,170 +1,170 @@ /* This file is part of KDE. Copyright (c) 2010 Intel Corporation Author: Mateu Batle Sastre This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "comment.h" #include using namespace Attica; QString Comment::commentTypeToString(const Comment::Type type) { switch (type) { case ContentComment: return QStringLiteral("1"); case ForumComment: return QStringLiteral("4"); case KnowledgeBaseComment: return QStringLiteral("7"); case EventComment: return QStringLiteral("8"); } Q_ASSERT(false); return QString(); } class Comment::Private : public QSharedData { public: QString m_id; QString m_subject; QString m_text; int m_childCount; QString m_user; QDateTime m_date; int m_score; QList m_children; Private() : m_childCount(0), m_score(0) { } }; Comment::Comment() : d(new Private) { } Comment::Comment(const Comment &other) : d(other.d) { } Comment &Comment::operator=(const Attica::Comment &other) { d = other.d; return *this; } Comment::~Comment() { } void Comment::setId(const QString &id) { d->m_id = id; } QString Comment::id() const { return d->m_id; } void Comment::setSubject(const QString &subject) { d->m_subject = subject; } QString Comment::subject() const { return d->m_subject; } void Comment::setText(const QString &text) { d->m_text = text; } QString Comment::text() const { return d->m_text; } void Comment::setChildCount(const int childCount) { d->m_childCount = childCount; } int Comment::childCount() const { return d->m_childCount; } void Comment::setUser(const QString &user) { d->m_user = user; } QString Comment::user() const { return d->m_user; } void Comment::setDate(const QDateTime &date) { d->m_date = date; } QDateTime Comment::date() const { return d->m_date; } void Comment::setScore(const int score) { d->m_score = score; } int Comment::score() const { return d->m_score; } void Comment::setChildren(QList children) { - d->m_children = children; + d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move } QList Comment::children() const { return d->m_children; } bool Comment::isValid() const { return !(d->m_id.isEmpty()); } diff --git a/src/content.cpp b/src/content.cpp index a68a93c..011952a 100644 --- a/src/content.cpp +++ b/src/content.cpp @@ -1,341 +1,341 @@ /* This file is part of KDE. Copyright (c) 2008 Cornelius Schumacher This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "content.h" #include using namespace Attica; class Content::Private : public QSharedData { public: QString m_id; QString m_name; int m_downloads; int m_numberOfComments; int m_rating; QDateTime m_created; QDateTime m_updated; QList m_icons; QList m_videos; QStringList m_tags; QMap m_extendedAttributes; Private() : m_downloads(0), m_numberOfComments(0), m_rating(0) { } }; Content::Content() : d(new Private) { } Content::Content(const Attica::Content &other) : d(other.d) { } Content &Content::operator=(const Attica::Content &other) { d = other.d; return *this; } Content::~Content() { } void Content::setId(const QString &u) { d->m_id = u; } QString Content::id() const { return d->m_id; } void Content::setName(const QString &name) { d->m_name = name; } QString Content::name() const { return d->m_name; } void Content::setRating(int v) { d->m_rating = v; } int Content::rating() const { return d->m_rating; } void Content::setDownloads(int v) { d->m_downloads = v; } int Content::downloads() const { return d->m_downloads; } void Content::setNumberOfComments(int v) { d->m_numberOfComments = v; } int Content::numberOfComments() const { return d->m_numberOfComments; } void Content::setCreated(const QDateTime &date) { d->m_created = date; } QDateTime Content::created() const { return d->m_created; } void Content::setUpdated(const QDateTime &date) { d->m_updated = date; } QDateTime Content::updated() const { return d->m_updated; } void Content::addAttribute(const QString &key, const QString &value) { d->m_extendedAttributes.insert(key, value); } QString Content::attribute(const QString &key) const { return d->m_extendedAttributes.value(key); } QMap Content::attributes() const { return d->m_extendedAttributes; } bool Content::isValid() const { return !(d->m_id.isEmpty()); } QString Content::summary() const { return attribute(QStringLiteral("summary")); } QString Content::description() const { return attribute(QStringLiteral("description")); } QUrl Content::detailpage() const { return QUrl(attribute(QStringLiteral("detailpage"))); } QString Attica::Content::changelog() const { return attribute(QStringLiteral("changelog")); } QString Attica::Content::depend() const { return attribute(QStringLiteral("depend")); } QList Attica::Content::downloadUrlDescriptions() const { QList descriptions; QMap::const_iterator iter = d->m_extendedAttributes.constBegin(); while (iter != d->m_extendedAttributes.constEnd()) { QString key = iter.key(); if (key.startsWith(QLatin1String("downloadname"))) { bool ok; // remove "downloadlink", get the rest as number int num = key.rightRef(key.size() - 12).toInt(&ok); if (ok) { // check if the download actually has a name if (!iter.value().isEmpty()) { descriptions.append(downloadUrlDescription(num)); } } } ++iter; } return descriptions; } Attica::DownloadDescription Attica::Content::downloadUrlDescription(int number) const { QString num(QString::number(number)); DownloadDescription desc; Attica::DownloadDescription::Type downloadType = Attica::DownloadDescription::LinkDownload; if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('0')) { downloadType = Attica::DownloadDescription::FileDownload; } else if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('1')) { downloadType = Attica::DownloadDescription::LinkDownload; } else if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('2')) { downloadType = Attica::DownloadDescription::PackageDownload; } desc.setType(downloadType); desc.setId(number); desc.setName(attribute(QLatin1String("downloadname") + num)); desc.setDistributionType(attribute(QLatin1String("downloadtype") + num)); desc.setHasPrice(attribute(QLatin1String("downloadbuy") + num) == QLatin1Char('1')); desc.setLink(attribute(QLatin1String("downloadlink") + num)); desc.setPriceReason(attribute(QLatin1String("downloadreason") + num)); desc.setPriceAmount(attribute(QLatin1String("downloadprice") + num)); desc.setSize(attribute(QLatin1String("downloadsize") + num).toUInt()); desc.setGpgFingerprint(attribute(QLatin1String("downloadgpgfingerprint") + num)); desc.setGpgSignature(attribute(QLatin1String("downloadgpgsignature") + num)); desc.setPackageName(attribute(QLatin1String("downloadpackagename") + num)); desc.setRepository(attribute(QLatin1String("downloadrepository") + num)); desc.setTags(attribute(QLatin1String("downloadtags") + num).split(QLatin1Char(','))); return desc; } QList Attica::Content::homePageEntries() { QList homepages; QMap::const_iterator iter = d->m_extendedAttributes.constBegin(); while (iter != d->m_extendedAttributes.constEnd()) { QString key = iter.key(); if (key.startsWith(QLatin1String("homepagetype"))) { bool ok; // remove "homepage", get the rest as number int num = key.rightRef(key.size() - 12).toInt(&ok); if (ok) { // check if the homepage actually has a valid type if (!iter.value().isEmpty()) { homepages.append(homePageEntry(num)); } } } ++iter; } return homepages; } Attica::HomePageEntry Attica::Content::homePageEntry(int number) const { QString num(QString::number(number)); HomePageEntry homepage; if (number == 1 && attribute(QStringLiteral("homepage1")).isEmpty()) { num.clear(); } homepage.setType(attribute(QLatin1String("homepagetype") + num)); homepage.setUrl(QUrl(attribute(QLatin1String("homepage") + num))); return homepage; } QString Attica::Content::version() const { return attribute(QStringLiteral("version")); } QString Attica::Content::author() const { return attribute(QStringLiteral("personid")); } QString Attica::Content::license() const { return attribute(QStringLiteral("licensetype")); } QString Attica::Content::licenseName() const { return attribute(QStringLiteral("license")); } QString Attica::Content::previewPicture(const QString &number) const { return attribute(QLatin1String("previewpic") + number); } QString Attica::Content::smallPreviewPicture(const QString &number) const { return attribute(QLatin1String("smallpreviewpic") + number); } QList Attica::Content::icons() { return d->m_icons; } QList Attica::Content::icons() const { return d->m_icons; } void Attica::Content::setIcons(QList icons) { - d->m_icons = icons; + d->m_icons = std::move(icons); // TODO KF6 Make QList const & and remove the std::move } QList Attica::Content::videos() { return d->m_videos; } void Attica::Content::setVideos(QList videos) { - d->m_videos = videos; + d->m_videos = std::move(videos); } QStringList Attica::Content::tags() const { return d->m_tags; } void Attica::Content::setTags(const QStringList &tags) { d->m_tags = tags; } diff --git a/src/forum.cpp b/src/forum.cpp index b9f3255..59f796b 100644 --- a/src/forum.cpp +++ b/src/forum.cpp @@ -1,150 +1,150 @@ /* This file is part of KDE. Copyright (c) 2011 Laszlo Papp This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "forum.h" using namespace Attica; class Forum::Private : public QSharedData { public: QString m_id; QString m_name; QString m_description; QDateTime m_date; QUrl m_icon; int m_childCount; int m_topics; QList m_children; Private() : m_childCount(0), m_topics(0) { } }; Forum::Forum() : d(new Private) { } Forum::Forum(const Forum &other) : d(other.d) { } Forum &Forum::operator=(const Attica::Forum &other) { d = other.d; return *this; } Forum::~Forum() { } void Forum::setId(const QString &id) { d->m_id = id; } QString Forum::id() const { return d->m_id; } void Forum::setName(const QString &name) { d->m_name = name; } QString Forum::name() const { return d->m_name; } void Forum::setDescription(const QString &description) { d->m_description = description; } QString Forum::description() const { return d->m_description; } void Forum::setDate(const QDateTime &date) { d->m_date = date; } QDateTime Forum::date() const { return d->m_date; } void Forum::setIcon(const QUrl &icon) { d->m_icon = icon; } QUrl Forum::icon() const { return d->m_icon; } void Forum::setChildCount(const int childCount) { d->m_childCount = childCount; } int Forum::childCount() const { return d->m_childCount; } void Forum::setChildren(QList children) { - d->m_children = children; + d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move } QList Forum::children() const { return d->m_children; } void Forum::setTopics(const int topics) { d->m_topics = topics; } int Forum::topics() const { return d->m_topics; } bool Forum::isValid() const { return !(d->m_id.isEmpty()); } diff --git a/src/knowledgebaseentry.cpp b/src/knowledgebaseentry.cpp index e47b5b2..a2e03f1 100644 --- a/src/knowledgebaseentry.cpp +++ b/src/knowledgebaseentry.cpp @@ -1,191 +1,191 @@ /* This file is part of KDE. Copyright (C) 2009 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "knowledgebaseentry.h" #include using namespace Attica; class KnowledgeBaseEntry::Private : public QSharedData { public: QString m_id; int m_contentId; QString m_user; QString m_status; QDateTime m_changed; QString m_name; QString m_description; QString m_answer; int m_comments; QUrl m_detailPage; QMap m_extendedAttributes; Private() : m_contentId(0), m_comments(0) { } }; KnowledgeBaseEntry::KnowledgeBaseEntry() : d(new Private) { } KnowledgeBaseEntry::KnowledgeBaseEntry(const KnowledgeBaseEntry &other) : d(other.d) { } KnowledgeBaseEntry &KnowledgeBaseEntry::operator=(const Attica::KnowledgeBaseEntry &other) { d = other.d; return *this; } KnowledgeBaseEntry::~KnowledgeBaseEntry() { } void KnowledgeBaseEntry::setId(QString id) { - d->m_id = id; + d->m_id = std::move(id); // TODO KF6 Make QString const & and remove the std::move } QString KnowledgeBaseEntry::id() const { return d->m_id; } void KnowledgeBaseEntry::setContentId(int id) { d->m_contentId = id; } int KnowledgeBaseEntry::contentId() const { return d->m_contentId; } void KnowledgeBaseEntry::setUser(const QString &user) { d->m_user = user; } QString KnowledgeBaseEntry::user() const { return d->m_user; } void KnowledgeBaseEntry::setStatus(const QString &status) { d->m_status = status; } QString KnowledgeBaseEntry::status() const { return d->m_status; } void KnowledgeBaseEntry::setChanged(const QDateTime &changed) { d->m_changed = changed; } QDateTime KnowledgeBaseEntry::changed() const { return d->m_changed; } void KnowledgeBaseEntry::setName(const QString &name) { d->m_name = name; } QString KnowledgeBaseEntry::name() const { return d->m_name; } void KnowledgeBaseEntry::setDescription(const QString &description) { d->m_description = description; } QString KnowledgeBaseEntry::description() const { return d->m_description; } void KnowledgeBaseEntry::setAnswer(const QString &answer) { d->m_answer = answer; } QString KnowledgeBaseEntry::answer() const { return d->m_answer; } void KnowledgeBaseEntry::setComments(int comments) { d->m_comments = comments; } int KnowledgeBaseEntry::comments() const { return d->m_comments; } void KnowledgeBaseEntry::setDetailPage(const QUrl &detailPage) { d->m_detailPage = detailPage; } QUrl KnowledgeBaseEntry::detailPage() const { return d->m_detailPage; } void KnowledgeBaseEntry::addExtendedAttribute(const QString &key, const QString &value) { d->m_extendedAttributes.insert(key, value); } QString KnowledgeBaseEntry::extendedAttribute(const QString &key) const { return d->m_extendedAttributes.value(key); } QMap KnowledgeBaseEntry::extendedAttributes() const { return d->m_extendedAttributes; } bool KnowledgeBaseEntry::isValid() const { return !(d->m_id.isEmpty()); }