|
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( QString aTitle, QString aDesc, QImage aImage, QUrl aUrl ) |
|
39 { |
|
40 d = new SmfPostPrivate(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 * Destructor |
|
68 */ |
|
69 SmfPost::~SmfPost( ) |
|
70 { |
|
71 } |
|
72 |
|
73 /** |
|
74 * Method to get the title of the post |
|
75 * @return The post's title |
|
76 */ |
|
77 QString SmfPost::title( ) const |
|
78 { |
|
79 return d->m_title; |
|
80 } |
|
81 |
|
82 /** |
|
83 * Method to get the description of the post |
|
84 * @return The post's description |
|
85 */ |
|
86 QString SmfPost::description( ) const |
|
87 { |
|
88 return d->m_desc; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Method to get the image of the post |
|
93 * @return The post's image |
|
94 */ |
|
95 QImage SmfPost::image( ) const |
|
96 { |
|
97 return d->m_image; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Method to get the url of the post |
|
102 * @return The post's url |
|
103 */ |
|
104 QUrl SmfPost::url( ) const |
|
105 { |
|
106 return d->m_url; |
|
107 } |
|
108 |
|
109 /** |
|
110 * Method to get the id of the post |
|
111 * @return The ID value |
|
112 */ |
|
113 QString SmfPost::id( ) const |
|
114 { |
|
115 return d->m_postId; |
|
116 } |
|
117 void SmfPost::setId(QString aPostId) |
|
118 { |
|
119 d->m_postId = aPostId; |
|
120 } |
|
121 /** |
|
122 * Method to set the title of the post |
|
123 * @param aTitle The post's new title |
|
124 */ |
|
125 void SmfPost::setTitle( const QString &aTitle ) |
|
126 { |
|
127 d->m_title = aTitle; |
|
128 } |
|
129 |
|
130 /** |
|
131 * Method to set the description of the post |
|
132 * @param aDesc The post's new description |
|
133 */ |
|
134 void SmfPost::setDescription( const QString &aDesc ) |
|
135 { |
|
136 d->m_desc = aDesc; |
|
137 } |
|
138 |
|
139 /** |
|
140 * Method to set the image of the post |
|
141 * @param aPic The post's image |
|
142 */ |
|
143 void SmfPost::setImage( const QImage& aPic ) |
|
144 { |
|
145 d->m_image = aPic; |
|
146 } |
|
147 |
|
148 /** |
|
149 * Method to set the url of the post |
|
150 * @param aUrl The post's url |
|
151 */ |
|
152 void SmfPost::setUrl( QUrl& aUrl ) |
|
153 { |
|
154 d->m_url = aUrl; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 /** |
|
160 * Method for Externalization. Writes the SmfPost object to |
|
161 * the stream and returns a reference to the stream. |
|
162 * @param aDataStream Stream to be written |
|
163 * @param aPost The SmfPost object to be externalized |
|
164 * @return reference to the written stream |
|
165 */ |
|
166 QDataStream &operator<<( QDataStream &aDataStream, |
|
167 const SmfPost &aPost ) |
|
168 { |
|
169 aDataStream<<aPost.title(); |
|
170 aDataStream<<aPost.description(); |
|
171 aDataStream<<aPost.image(); |
|
172 aDataStream<<aPost.url(); |
|
173 aDataStream<<aPost.id(); |
|
174 return aDataStream; |
|
175 } |
|
176 |
|
177 /** |
|
178 * Method for Internalization. Reads a SmfPost object from |
|
179 * the stream and returns a reference to the stream. |
|
180 * @param aDataStream Stream to be read |
|
181 * @param aPost The SmfPost object to be internalized |
|
182 * @return reference to the stream |
|
183 */ |
|
184 QDataStream &operator>>( QDataStream &aDataStream, |
|
185 SmfPost &aPost) |
|
186 { |
|
187 QString title; |
|
188 aDataStream>>title; |
|
189 aPost.setTitle(title); |
|
190 |
|
191 QString desc; |
|
192 aDataStream>>desc; |
|
193 aPost.setDescription(desc); |
|
194 |
|
195 QImage img; |
|
196 aDataStream>>img; |
|
197 aPost.setImage(img); |
|
198 |
|
199 QUrl url; |
|
200 aDataStream>>url; |
|
201 aPost.setUrl(url); |
|
202 |
|
203 QString id; |
|
204 aDataStream>>id; |
|
205 aPost.setId(id); |
|
206 |
|
207 return aDataStream; |
|
208 } |