|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The post class represents an instance of a post to a SN site |
|
17 * |
|
18 */ |
|
19 |
|
20 #include "smfpost.h" |
|
21 #include "smfpost_p.h" |
|
22 |
|
23 /** |
|
24 * Constructor with default argument |
|
25 * @param text Text |
|
26 */ |
|
27 SmfPost::SmfPost( ) |
|
28 { |
|
29 d = new SmfPostPrivate(); |
|
30 } |
|
31 |
|
32 /** |
|
33 * Constructor |
|
34 * @param aText The post's text |
|
35 * @param aImage The post's image |
|
36 * @param aUrl The post's url |
|
37 */ |
|
38 SmfPost::SmfPost( SmfContact aOwner,QString aTitle, QString aDesc, QImage aImage, QUrl aUrl ) |
|
39 { |
|
40 d = new SmfPostPrivate(aOwner,aTitle, aDesc, aImage, aUrl); |
|
41 } |
|
42 |
|
43 /** |
|
44 * Copy Constructor |
|
45 * @param aOther The reference object |
|
46 */ |
|
47 SmfPost::SmfPost( const SmfPost &aOther ) |
|
48 : d( aOther.d ) |
|
49 { |
|
50 } |
|
51 |
|
52 /** |
|
53 * Overloaded = operator |
|
54 * @param aOther The reference object |
|
55 * @return The target reference value |
|
56 */ |
|
57 SmfPost& SmfPost::operator=( const SmfPost &aOther ) |
|
58 { |
|
59 d->m_title = aOther.d->m_title; |
|
60 d->m_desc = aOther.d->m_desc; |
|
61 d->m_image = aOther.d->m_image; |
|
62 d->m_url = aOther.d->m_url; |
|
63 d->m_postId = aOther.d->m_postId; |
|
64 return *this; |
|
65 } |
|
66 |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 SmfPost::~SmfPost( ) |
|
71 { |
|
72 } |
|
73 |
|
74 /** |
|
75 * Returns the owner(who posted this message) |
|
76 */ |
|
77 SmfContact SmfPost::owner() const |
|
78 { |
|
79 return d->m_owner; |
|
80 } |
|
81 |
|
82 /** |
|
83 * Method to get the title of the post |
|
84 * @return The post's title |
|
85 */ |
|
86 QString SmfPost::title( ) const |
|
87 { |
|
88 return d->m_title; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Method to get the description of the post |
|
93 * @return The post's description |
|
94 */ |
|
95 QString SmfPost::description( ) const |
|
96 { |
|
97 return d->m_desc; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Method to get the image of the post |
|
102 * @return The post's image |
|
103 */ |
|
104 QImage SmfPost::image( ) const |
|
105 { |
|
106 return d->m_image; |
|
107 } |
|
108 |
|
109 /** |
|
110 * Method to get the url of the post |
|
111 * @return The post's url |
|
112 */ |
|
113 QUrl SmfPost::url( ) const |
|
114 { |
|
115 return d->m_url; |
|
116 } |
|
117 |
|
118 /** |
|
119 * Method to get the posted date and time of the post |
|
120 * @return The post's date and time of posting |
|
121 */ |
|
122 QDateTime SmfPost::postedDateTime() const |
|
123 { |
|
124 return d->m_date; |
|
125 } |
|
126 |
|
127 /** |
|
128 * Method to get the id of the post |
|
129 * @return The ID value |
|
130 */ |
|
131 QString SmfPost::id( ) const |
|
132 { |
|
133 return d->m_postId; |
|
134 } |
|
135 |
|
136 /** |
|
137 * sets the owner of the post |
|
138 */ |
|
139 void SmfPost::setOwner(const SmfContact& aOwner) |
|
140 { |
|
141 d->m_owner = aOwner; |
|
142 } |
|
143 |
|
144 /** |
|
145 * Method to set the title of the post |
|
146 * @param aTitle The post's new title |
|
147 */ |
|
148 void SmfPost::setTitle( const QString &aTitle ) |
|
149 { |
|
150 d->m_title = aTitle; |
|
151 } |
|
152 |
|
153 /** |
|
154 * Method to set the description of the post |
|
155 * @param aDesc The post's new description |
|
156 */ |
|
157 void SmfPost::setDescription( const QString &aDesc ) |
|
158 { |
|
159 d->m_desc = aDesc; |
|
160 } |
|
161 |
|
162 /** |
|
163 * Method to set the image of the post |
|
164 * @param aPic The post's image |
|
165 */ |
|
166 void SmfPost::setImage( const QImage& aPic ) |
|
167 { |
|
168 d->m_image = aPic; |
|
169 } |
|
170 |
|
171 /** |
|
172 * Method to set the url of the post |
|
173 * @param aUrl The post's url |
|
174 */ |
|
175 void SmfPost::setUrl( QUrl& aUrl ) |
|
176 { |
|
177 d->m_url = aUrl; |
|
178 } |
|
179 |
|
180 /** |
|
181 * Method to set the posted date and time of the post |
|
182 * @param aDate The post's date and time of posting |
|
183 */ |
|
184 void SmfPost::setPostedDateTime( QDateTime &aDate ) |
|
185 { |
|
186 d->m_date = aDate; |
|
187 } |
|
188 |
|
189 /** |
|
190 * Method to get the id of the post |
|
191 */ |
|
192 void SmfPost::setId(QString aPostId) |
|
193 { |
|
194 d->m_postId = aPostId; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Method for Externalization. Writes the SmfPost object to |
|
199 * the stream and returns a reference to the stream. |
|
200 * @param aDataStream Stream to be written |
|
201 * @param aPost The SmfPost object to be externalized |
|
202 * @return reference to the written stream |
|
203 */ |
|
204 QDataStream &operator<<( QDataStream &aDataStream, |
|
205 const SmfPost &aPost ) |
|
206 { |
|
207 aDataStream<<aPost.owner(); |
|
208 aDataStream<<aPost.title(); |
|
209 aDataStream<<aPost.description(); |
|
210 aDataStream<<aPost.image(); |
|
211 aDataStream<<aPost.url(); |
|
212 aDataStream<<aPost.id(); |
|
213 return aDataStream; |
|
214 } |
|
215 |
|
216 /** |
|
217 * Method for Internalization. Reads a SmfPost object from |
|
218 * the stream and returns a reference to the stream. |
|
219 * @param aDataStream Stream to be read |
|
220 * @param aPost The SmfPost object to be internalized |
|
221 * @return reference to the stream |
|
222 */ |
|
223 QDataStream &operator>>( QDataStream &aDataStream, |
|
224 SmfPost &aPost) |
|
225 { |
|
226 SmfContact owner; |
|
227 aDataStream>>owner; |
|
228 aPost.setOwner(owner); |
|
229 QString title; |
|
230 aDataStream>>title; |
|
231 aPost.setTitle(title); |
|
232 |
|
233 QString desc; |
|
234 aDataStream>>desc; |
|
235 aPost.setDescription(desc); |
|
236 |
|
237 QImage img; |
|
238 aDataStream>>img; |
|
239 aPost.setImage(img); |
|
240 |
|
241 QUrl url; |
|
242 aDataStream>>url; |
|
243 aPost.setUrl(url); |
|
244 |
|
245 QString id; |
|
246 aDataStream>>id; |
|
247 aPost.setId(id); |
|
248 |
|
249 return aDataStream; |
|
250 } |