Changeset View
Changeset View
Standalone View
Standalone View
src/core/author.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | Lesser General Public License for more details. | 14 | Lesser General Public License for more details. | ||
15 | 15 | | |||
16 | You should have received a copy of the GNU Lesser General Public | 16 | You should have received a copy of the GNU Lesser General Public | ||
17 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 17 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "author.h" | 20 | #include "author.h" | ||
21 | 21 | | |||
22 | #include <QHash> | ||||
23 | | ||||
24 | // BCI: Add a real d-pointer | ||||
25 | namespace KNSCore { | ||||
26 | struct AuthorPrivate { | ||||
27 | public: | ||||
28 | QString id; | ||||
29 | QString profilepage; | ||||
30 | QUrl avatarUrl; | ||||
31 | QString description; | ||||
32 | }; | ||||
33 | } | ||||
34 | | ||||
22 | using namespace KNSCore; | 35 | using namespace KNSCore; | ||
23 | 36 | | |||
37 | typedef QHash<const Author *, AuthorPrivate*> AuthorPrivateHash; | ||||
38 | Q_GLOBAL_STATIC(AuthorPrivateHash, d_func) | ||||
39 | | ||||
40 | static AuthorPrivate *d(const Author *author) | ||||
41 | { | ||||
42 | AuthorPrivate *ret = d_func()->value(author); | ||||
43 | if (!ret) { | ||||
44 | ret = new AuthorPrivate; | ||||
45 | d_func()->insert(author, ret); | ||||
46 | } | ||||
47 | return ret; | ||||
48 | } | ||||
49 | | ||||
50 | static void delete_d(const Author *author) | ||||
51 | { | ||||
52 | if (auto d = d_func()) { | ||||
53 | delete d->take(author); | ||||
54 | } | ||||
55 | } | ||||
56 | | ||||
57 | Author::Author() | ||||
58 | { | ||||
59 | } | ||||
60 | | ||||
61 | KNSCore::Author::Author(const KNSCore::Author &other) | ||||
62 | { | ||||
63 | this->setAvatarUrl(other.avatarUrl()); | ||||
64 | this->setDescription(other.description()); | ||||
65 | this->setEmail(other.email()); | ||||
66 | this->setHomepage(other.homepage()); | ||||
67 | this->setId(other.id()); | ||||
68 | this->setJabber(other.jabber()); | ||||
69 | this->setName(other.name()); | ||||
70 | this->setProfilepage(other.profilepage()); | ||||
71 | } | ||||
72 | | ||||
73 | Author::~Author() | ||||
74 | { | ||||
75 | delete_d(this); | ||||
76 | } | ||||
77 | | ||||
78 | void KNSCore::Author::setId(const QString &id) | ||||
79 | { | ||||
80 | d(this)->id = id; | ||||
81 | } | ||||
82 | | ||||
83 | QString KNSCore::Author::id() const | ||||
84 | { | ||||
85 | return d(this)->id; | ||||
86 | } | ||||
87 | | ||||
24 | void Author::setName(const QString &_name) | 88 | void Author::setName(const QString &_name) | ||
25 | { | 89 | { | ||
26 | mName = _name; | 90 | mName = _name; | ||
27 | } | 91 | } | ||
28 | 92 | | |||
29 | QString Author::name() const | 93 | QString Author::name() const | ||
30 | { | 94 | { | ||
31 | return mName; | 95 | return mName; | ||
Show All 24 Lines | 119 | { | |||
56 | mHomepage = _homepage; | 120 | mHomepage = _homepage; | ||
57 | } | 121 | } | ||
58 | 122 | | |||
59 | QString Author::homepage() const | 123 | QString Author::homepage() const | ||
60 | { | 124 | { | ||
61 | return mHomepage; | 125 | return mHomepage; | ||
62 | } | 126 | } | ||
63 | 127 | | |||
128 | void Author::setProfilepage(const QString &profilepage) | ||||
129 | { | ||||
130 | d(this)->profilepage = profilepage; | ||||
131 | } | ||||
132 | | ||||
133 | QString Author::profilepage() const | ||||
134 | { | ||||
135 | return d(this)->profilepage; | ||||
136 | } | ||||
137 | | ||||
138 | void Author::setAvatarUrl(const QUrl &avatarUrl) | ||||
139 | { | ||||
140 | d(this)->avatarUrl = avatarUrl; | ||||
141 | } | ||||
142 | | ||||
143 | QUrl Author::avatarUrl() const | ||||
144 | { | ||||
145 | return d(this)->avatarUrl; | ||||
146 | } | ||||
147 | | ||||
148 | void Author::setDescription(const QString &description) | ||||
149 | { | ||||
150 | d(this)->description = description; | ||||
151 | } | ||||
152 | | ||||
153 | QString Author::description() const | ||||
154 | { | ||||
155 | return d(this)->description; | ||||
156 | } |