File indexing completed on 2024-04-28 15:28:54

0001 /*
0002     This file is part of KNewStuff2.
0003     SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org>
0004     SPDX-FileCopyrightText: 2003-2007 Josef Spillner <spillner@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #include "author.h"
0010 
0011 #include <QHash>
0012 
0013 // BCI: Add a real d-pointer
0014 namespace KNSCore
0015 {
0016 struct AuthorPrivate {
0017 public:
0018     QString id;
0019     QString profilepage;
0020     QUrl avatarUrl;
0021     QString description;
0022 };
0023 }
0024 
0025 using namespace KNSCore;
0026 
0027 typedef QHash<const Author *, AuthorPrivate *> AuthorPrivateHash;
0028 Q_GLOBAL_STATIC(AuthorPrivateHash, d_func)
0029 
0030 static AuthorPrivate *d(const Author *author)
0031 {
0032     AuthorPrivate *ret = d_func()->value(author);
0033     if (!ret) {
0034         ret = new AuthorPrivate;
0035         d_func()->insert(author, ret);
0036     }
0037     return ret;
0038 }
0039 
0040 static void delete_d(const Author *author)
0041 {
0042     if (auto d = d_func()) {
0043         delete d->take(author);
0044     }
0045 }
0046 
0047 Author::Author()
0048 {
0049 }
0050 
0051 KNSCore::Author::Author(const KNSCore::Author &other)
0052 {
0053     this->setAvatarUrl(other.avatarUrl());
0054     this->setDescription(other.description());
0055     this->setEmail(other.email());
0056     this->setHomepage(other.homepage());
0057     this->setId(other.id());
0058     this->setJabber(other.jabber());
0059     this->setName(other.name());
0060     this->setProfilepage(other.profilepage());
0061 }
0062 
0063 Author::~Author()
0064 {
0065     delete_d(this);
0066 }
0067 
0068 void KNSCore::Author::setId(const QString &id)
0069 {
0070     d(this)->id = id;
0071 }
0072 
0073 QString KNSCore::Author::id() const
0074 {
0075     return d(this)->id;
0076 }
0077 
0078 void Author::setName(const QString &_name)
0079 {
0080     mName = _name;
0081 }
0082 
0083 QString Author::name() const
0084 {
0085     return mName;
0086 }
0087 
0088 void Author::setEmail(const QString &_email)
0089 {
0090     mEmail = _email;
0091 }
0092 
0093 QString Author::email() const
0094 {
0095     return mEmail;
0096 }
0097 
0098 void Author::setJabber(const QString &_jabber)
0099 {
0100     mJabber = _jabber;
0101 }
0102 
0103 QString Author::jabber() const
0104 {
0105     return mJabber;
0106 }
0107 
0108 void Author::setHomepage(const QString &_homepage)
0109 {
0110     mHomepage = _homepage;
0111 }
0112 
0113 QString Author::homepage() const
0114 {
0115     return mHomepage;
0116 }
0117 
0118 void Author::setProfilepage(const QString &profilepage)
0119 {
0120     d(this)->profilepage = profilepage;
0121 }
0122 
0123 QString Author::profilepage() const
0124 {
0125     return d(this)->profilepage;
0126 }
0127 
0128 void Author::setAvatarUrl(const QUrl &avatarUrl)
0129 {
0130     d(this)->avatarUrl = avatarUrl;
0131 }
0132 
0133 QUrl Author::avatarUrl() const
0134 {
0135     return d(this)->avatarUrl;
0136 }
0137 
0138 void Author::setDescription(const QString &description)
0139 {
0140     d(this)->description = description;
0141 }
0142 
0143 QString Author::description() const
0144 {
0145     return d(this)->description;
0146 }