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