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 picture class represents an instance of a picture |
|
17 * |
|
18 */ |
|
19 |
|
20 #include "smfpicture.h" |
|
21 #include "smfpicture_p.h" |
|
22 |
|
23 /** |
|
24 * Constructor with default argument |
|
25 */ |
|
26 SmfPicture::SmfPicture(/*bool aDownloaded*/) |
|
27 { |
|
28 d = new SmfPicturePrivate; |
|
29 //d->isDownloaded = aDownloaded; |
|
30 } |
|
31 |
|
32 /** |
|
33 * Copy Constructor |
|
34 * @param aOther The reference object |
|
35 */ |
|
36 SmfPicture::SmfPicture( const SmfPicture &aOther ) |
|
37 : d( aOther.d ) |
|
38 { |
|
39 } |
|
40 |
|
41 /** |
|
42 * CConstructs SmfPicture from QImage |
|
43 * @param aOther The QImage |
|
44 */ |
|
45 SmfPicture::SmfPicture( const QImage &aImage ) |
|
46 { |
|
47 d = new SmfPicturePrivate(aImage); |
|
48 } |
|
49 |
|
50 /** |
|
51 * Overloaded = operator |
|
52 * @param aOther The reference object |
|
53 * @return The target reference value |
|
54 */ |
|
55 SmfPicture& SmfPicture::operator=( const SmfPicture &aOther ) |
|
56 { |
|
57 d->m_photoId = aOther.d->m_photoId; |
|
58 d->m_owner = aOther.d->m_owner; |
|
59 d->m_title = aOther.d->m_title; |
|
60 d->m_description = aOther.d->m_description; |
|
61 d->m_picVisibility = aOther.d->m_picVisibility; |
|
62 d->m_postedOn = aOther.d->m_postedOn; |
|
63 d->m_comments = aOther.d->m_comments; |
|
64 d->m_tags = aOther.d->m_tags; |
|
65 d->m_url = aOther.d->m_url; |
|
66 d->m_picture = aOther.d->m_picture; |
|
67 return *this; |
|
68 } |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 SmfPicture::~SmfPicture( ) |
|
74 { |
|
75 } |
|
76 |
|
77 /** |
|
78 * Method to get a picture owner |
|
79 * @return The owner of the picture |
|
80 */ |
|
81 QString SmfPicture::owner( ) const |
|
82 { |
|
83 return d->m_owner; |
|
84 } |
|
85 |
|
86 /** |
|
87 * Method to get a picture title |
|
88 * @return The title of the picture |
|
89 */ |
|
90 QString SmfPicture::title( ) const |
|
91 { |
|
92 return d->m_title; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Method to get a picture description |
|
97 * @return The description of the picture |
|
98 */ |
|
99 QString SmfPicture::description( ) const |
|
100 { |
|
101 return d->m_description; |
|
102 } |
|
103 |
|
104 /** |
|
105 * Method to get a visibility of a picture for public |
|
106 * @return The visibility mode of this picture for others |
|
107 */ |
|
108 SmfPictureVisibility SmfPicture::visibility( ) const |
|
109 { |
|
110 return d->m_picVisibility; |
|
111 } |
|
112 |
|
113 /** |
|
114 * Method to get the date of posting the picture |
|
115 * @return The posted date of the picture |
|
116 */ |
|
117 QDateTime SmfPicture::postedDate( ) const |
|
118 { |
|
119 return d->m_postedOn; |
|
120 } |
|
121 |
|
122 /** |
|
123 * Method to get the comments for the picture |
|
124 * @return The comments for the picture |
|
125 */ |
|
126 QList<SmfComment> SmfPicture::comments( ) const |
|
127 { |
|
128 return d->m_comments; |
|
129 } |
|
130 |
|
131 /** |
|
132 * Method to get the tags for the picture |
|
133 * @return The tags for the picture |
|
134 */ |
|
135 QStringList SmfPicture::tags( ) const |
|
136 { |
|
137 return d->m_tags; |
|
138 } |
|
139 |
|
140 /** |
|
141 * Method to get the url of the picture |
|
142 * @return The url of the picture |
|
143 */ |
|
144 QUrl SmfPicture::url( ) const |
|
145 { |
|
146 return d->m_url; |
|
147 } |
|
148 |
|
149 /** |
|
150 * Method to get the picture data as QImage |
|
151 * @return The picture as QImage |
|
152 */ |
|
153 QImage SmfPicture::picture( ) const |
|
154 { |
|
155 return d->m_picture; |
|
156 } |
|
157 |
|
158 /** |
|
159 * Method to get the id of the picture |
|
160 * @return The ID value |
|
161 */ |
|
162 QString SmfPicture::id( ) const |
|
163 { |
|
164 return d->m_photoId; |
|
165 } |
|
166 bool SmfPicture::downloadFlag() |
|
167 { |
|
168 return d->isDownloaded; |
|
169 } |
|
170 /** |
|
171 * Method to set a picture owner |
|
172 * @param aOwner The owner of the picture |
|
173 */ |
|
174 void SmfPicture::setOwner( const QString &aOwner ) |
|
175 { |
|
176 d->m_owner = aOwner; |
|
177 } |
|
178 |
|
179 /** |
|
180 * Method to set a picture title |
|
181 * @param aTitle The title of the picture |
|
182 */ |
|
183 void SmfPicture::setTitle( const QString &aTitle ) |
|
184 { |
|
185 d->m_title = aTitle; |
|
186 } |
|
187 |
|
188 /** |
|
189 * Method to set a picture description |
|
190 * @param aDescription The description of the picture |
|
191 */ |
|
192 void SmfPicture::setDescription( const QString &aDescription ) |
|
193 { |
|
194 d->m_description = aDescription; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Method to set a visibility of a picture for public |
|
199 * @param aVisibility aVisibility The visibility mode of |
|
200 * this picture for others |
|
201 */ |
|
202 void SmfPicture::setVisibility( const SmfPictureVisibility &aVisibility ) |
|
203 { |
|
204 d->m_picVisibility = aVisibility; |
|
205 } |
|
206 |
|
207 /** |
|
208 * Method to set the date of posting the picture |
|
209 * @param aDate The post date of the picture |
|
210 */ |
|
211 void SmfPicture::setPostedDate( const QDateTime &aDate ) |
|
212 { |
|
213 d->m_postedOn = aDate; |
|
214 } |
|
215 |
|
216 /** |
|
217 * Method to add comment on the picture |
|
218 * @param aComment The comment for the picture |
|
219 */ |
|
220 void SmfPicture::addComment( const SmfComment &aComment ) |
|
221 { |
|
222 d->m_comments.append(aComment); |
|
223 } |
|
224 |
|
225 /** |
|
226 * Method to add tags for the picture |
|
227 * @param aTag The tag for the picture |
|
228 */ |
|
229 void SmfPicture::addTags( const QStringList &aTags ) |
|
230 { |
|
231 d->m_tags = aTags; |
|
232 } |
|
233 |
|
234 /** |
|
235 * Method to set the url of the picture |
|
236 * @param aUrl The url of the picture |
|
237 */ |
|
238 void SmfPicture::setUrl( const QUrl &aUrl ) |
|
239 { |
|
240 d->m_url = aUrl; |
|
241 } |
|
242 |
|
243 /** |
|
244 * Method to set the picture data as QImage |
|
245 * @param aData The picture as QImage |
|
246 */ |
|
247 void SmfPicture::setPicture( const QImage &aData ) |
|
248 { |
|
249 d->m_picture = aData; |
|
250 } |
|
251 |
|
252 /** |
|
253 * Method to set the id of the picture |
|
254 * @param aId The ID value |
|
255 */ |
|
256 void SmfPicture::setId( const QString &aId ) |
|
257 { |
|
258 d->m_photoId = aId; |
|
259 } |
|
260 |
|
261 |
|
262 /** |
|
263 * Method for Externalization. Writes the SmfPicture object to |
|
264 * the stream and returns a reference to the stream. |
|
265 * @param aDataStream Stream to be written |
|
266 * @param aPic The SmfPicture object to be externalized |
|
267 * @return reference to the written stream |
|
268 */ |
|
269 QDataStream& operator<<( QDataStream &aDataStream, |
|
270 const SmfPicture &aPic ) |
|
271 { |
|
272 // Serialize d->m_photoId |
|
273 aDataStream<<aPic.d->m_photoId; |
|
274 |
|
275 // Serialize d->m_owner |
|
276 aDataStream<<aPic.d->m_owner; |
|
277 |
|
278 // Serialize d->m_title |
|
279 aDataStream<<aPic.d->m_title; |
|
280 |
|
281 // Serialize d->m_description |
|
282 aDataStream<<aPic.d->m_description; |
|
283 |
|
284 // Serialize d->m_picVisibility |
|
285 aDataStream<<aPic.d->m_picVisibility; |
|
286 |
|
287 // Serialize d->m_postedOn |
|
288 aDataStream<<aPic.d->m_postedOn; |
|
289 |
|
290 // Serialize d->m_comments |
|
291 aDataStream<<aPic.d->m_comments; |
|
292 |
|
293 // Serialize d->m_tags |
|
294 aDataStream<<aPic.d->m_tags; |
|
295 |
|
296 // Serialize d->m_url |
|
297 aDataStream<<aPic.d->m_url; |
|
298 |
|
299 // Serialize d->m_picture |
|
300 aDataStream<<aPic.d->m_picture; |
|
301 |
|
302 return aDataStream; |
|
303 } |
|
304 |
|
305 /** |
|
306 * Method for Internalization. Reads a SmfPicture object from |
|
307 * the stream and returns a reference to the stream. |
|
308 * @param aDataStream Stream to be read |
|
309 * @param aPic The SmfPicture object to be internalized |
|
310 * @return reference to the stream |
|
311 */ |
|
312 QDataStream& operator>>( QDataStream &aDataStream, |
|
313 SmfPicture &aPic) |
|
314 { |
|
315 // Deserialize d->m_photoId |
|
316 aDataStream>>aPic.d->m_photoId; |
|
317 |
|
318 // Deserialize d->m_owner |
|
319 aDataStream>>aPic.d->m_owner; |
|
320 |
|
321 // Deserialize d->m_title |
|
322 aDataStream>>aPic.d->m_title; |
|
323 |
|
324 // Deserialize d->m_description |
|
325 aDataStream>>aPic.d->m_description; |
|
326 |
|
327 // Deserialize d->m_picVisibility |
|
328 quint32 val = 0; |
|
329 aDataStream>>val; |
|
330 aPic.d->m_picVisibility = (SmfPictureVisibility)val; |
|
331 |
|
332 // Deserialize d->m_postedOn |
|
333 aDataStream>>aPic.d->m_postedOn; |
|
334 |
|
335 // Deserialize d->m_comments |
|
336 aDataStream>>aPic.d->m_comments; |
|
337 |
|
338 // Deserialize d->m_tags |
|
339 aDataStream>>aPic.d->m_tags; |
|
340 |
|
341 // Deserialize d->m_url |
|
342 aDataStream>>aPic.d->m_url; |
|
343 |
|
344 // Deserialize d->m_picture |
|
345 aDataStream>>aPic.d->m_picture; |
|
346 |
|
347 return aDataStream; |
|
348 } |
|