|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This widget holds the message details and silde contents. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "univiewslidewidget.h" |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include <QGraphicsLinearLayout> |
|
22 #include <HbGroupBox> |
|
23 |
|
24 // USER INCLUDES |
|
25 #include "univieweraddresscontainer.h" |
|
26 #include "univiewerattachmentcontainer.h" |
|
27 #include "univiewerdetailswidget.h" |
|
28 #include "univiewerbodywidget.h" |
|
29 #include "convergedmessage.h" |
|
30 #include "univiewerfeeder.h" |
|
31 |
|
32 #include "nativemessageconsts.h" |
|
33 //--------------------------------------------------------------- |
|
34 //UniViewSlideWidget :: UniViewSlideWidget |
|
35 // @see header file |
|
36 //--------------------------------------------------------------- |
|
37 UniViewSlideWidget::UniViewSlideWidget(UniViewerFeeder* feeder, int slideNumber, |
|
38 QGraphicsItem * parent) : |
|
39 HbWidget(parent), mInsideLayout(false), mSlideNumber(slideNumber), mViewerDetails(NULL), |
|
40 mViewFeeder(feeder), mHeaderGroupBox(NULL), mAddressContainer(NULL), mAttachmentContainer( |
|
41 NULL) |
|
42 |
|
43 { |
|
44 |
|
45 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
46 mBody = new UniViewerBodyWidget(this); |
|
47 |
|
48 connect(mBody,SIGNAL(sendMessage(const QString&)), |
|
49 this, SIGNAL(sendMessage(const QString&))); |
|
50 |
|
51 // If its a first slide create the headers and attach |
|
52 // to the main layout |
|
53 if (mSlideNumber == 0) { |
|
54 // Creation of address group box and adding address container |
|
55 mHeaderGroupBox = new HbGroupBox(this); |
|
56 mHeaderGroupBox->setCollapsed(true); |
|
57 mHeaderGroupBox->setCollapsable(true); |
|
58 |
|
59 mAddressContainer = new UniViewerAddressContainer(mHeaderGroupBox); |
|
60 |
|
61 mHeaderGroupBox->setContentWidget(mAddressContainer); |
|
62 |
|
63 mViewerDetails = new UniViewerDetailsWidget(this); |
|
64 |
|
65 mAttachmentContainer = new UniViewerAttachmentContainer(this); |
|
66 |
|
67 //Always connect to populate sms content |
|
68 connect(mViewFeeder, SIGNAL(msgBody(QString)), mBody, SLOT(setTextContent(QString))); |
|
69 |
|
70 //Add address group box and insert into layout |
|
71 mViewerDetails->sizePolicy().setVerticalPolicy(QSizePolicy::Fixed); |
|
72 mMainLayout->addItem(mHeaderGroupBox); |
|
73 mMainLayout->addItem(mViewerDetails); |
|
74 mMainLayout->addItem(mAttachmentContainer); |
|
75 } |
|
76 |
|
77 mMainLayout->addItem(mBody); |
|
78 |
|
79 mMainLayout->setSpacing(0); |
|
80 mMainLayout->setContentsMargins(0, 0, 0, 0); |
|
81 |
|
82 setLayout(mMainLayout); |
|
83 } |
|
84 |
|
85 //--------------------------------------------------------------- |
|
86 //UniViewSlideWidget::~UniViewSlideWidget |
|
87 // @see header file |
|
88 //--------------------------------------------------------------- |
|
89 UniViewSlideWidget::~UniViewSlideWidget() |
|
90 { |
|
91 |
|
92 } |
|
93 |
|
94 //--------------------------------------------------------------- |
|
95 //UniViewSlideWidget::clearContent |
|
96 // @see header file |
|
97 //--------------------------------------------------------------- |
|
98 void UniViewSlideWidget::clearContent() |
|
99 { |
|
100 if (mViewerDetails) { |
|
101 mViewerDetails->clearContent(); |
|
102 } |
|
103 if (mAddressContainer) { |
|
104 mAddressContainer->clearContent(); |
|
105 } |
|
106 if (mAttachmentContainer) { |
|
107 mAttachmentContainer->clearContent(); |
|
108 } |
|
109 if (mBody) { |
|
110 mBody->clearContent(); |
|
111 } |
|
112 } |
|
113 |
|
114 //--------------------------------------------------------------- |
|
115 //UniViewSlideWidget::populateContent |
|
116 // @see header file |
|
117 //--------------------------------------------------------------- |
|
118 void UniViewSlideWidget::populateContent() |
|
119 { |
|
120 if (mSlideNumber == 0) { |
|
121 mViewFeeder->fetchDetails(); |
|
122 populateFirstSlide(); |
|
123 } |
|
124 |
|
125 if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue |
|
126 && mViewFeeder->slideCount() > 0) |
|
127 { |
|
128 QString slideString; |
|
129 slideString = QString("%1 %2/%3").arg(tr("Slide")). arg(mSlideNumber + 1).arg( |
|
130 mViewFeeder->slideCount()); |
|
131 mBody->setSlideContents(mViewFeeder->slideContent(mSlideNumber), slideString); |
|
132 |
|
133 } |
|
134 } |
|
135 |
|
136 //--------------------------------------------------------------- |
|
137 //UniViewSlideWidget::populateFirstSlide |
|
138 // @see header file |
|
139 //--------------------------------------------------------------- |
|
140 void UniViewSlideWidget::populateFirstSlide() |
|
141 { |
|
142 //Populate the name for the groupbox |
|
143 ConvergedMessageAddressList toList = mViewFeeder->toAddressList(); |
|
144 ConvergedMessageAddressList ccList = mViewFeeder->ccAddressList(); |
|
145 |
|
146 if (!mViewFeeder->isIncoming()) |
|
147 { |
|
148 QString address = QString(); |
|
149 if (toList.count() > 0) |
|
150 { |
|
151 if (! (toList[0]->alias().isEmpty())) |
|
152 { |
|
153 address.append(toList[0]->alias()); |
|
154 } |
|
155 else |
|
156 { |
|
157 address.append(toList[0]->address()); |
|
158 } |
|
159 } |
|
160 for (int i = 1; i < toList.count(); ++i) |
|
161 { |
|
162 if (! (toList[i]->alias().isEmpty())) |
|
163 { |
|
164 address.append(", "); |
|
165 address.append(toList[i]->alias()); |
|
166 } |
|
167 else |
|
168 { |
|
169 address.append(", "); |
|
170 address.append(toList[i]->address()); |
|
171 } |
|
172 } |
|
173 |
|
174 if (ccList.count() > 0) |
|
175 { |
|
176 if (toList.count() > 0) |
|
177 { |
|
178 address.append(", "); |
|
179 } |
|
180 if (! (ccList[0]->alias().isEmpty())) |
|
181 { |
|
182 address.append(ccList[0]->alias()); |
|
183 } |
|
184 else |
|
185 { |
|
186 address.append(ccList[0]->address()); |
|
187 } |
|
188 } |
|
189 |
|
190 for (int j = 1; j < ccList.count(); ++j) |
|
191 { |
|
192 if (! (ccList[j]->alias().isEmpty())) |
|
193 { |
|
194 address.append(", "); |
|
195 address.append(ccList[j]->alias()); |
|
196 |
|
197 } |
|
198 else |
|
199 { |
|
200 address.append(", "); |
|
201 address.append(ccList[j]->address()); |
|
202 |
|
203 } |
|
204 } |
|
205 mHeaderGroupBox->setHeading(address); |
|
206 mHeaderGroupBox->setCollapsed(false); |
|
207 } |
|
208 else |
|
209 { |
|
210 QString from = QString(); |
|
211 QString alias = QString(); |
|
212 mViewFeeder->fromAddressAndAlias(from, alias); |
|
213 if (alias.isEmpty()) |
|
214 { |
|
215 mHeaderGroupBox->setHeading(from); |
|
216 } |
|
217 else |
|
218 { |
|
219 mHeaderGroupBox->setHeading(alias); |
|
220 } |
|
221 |
|
222 mHeaderGroupBox->setCollapsed(true); |
|
223 } |
|
224 |
|
225 // Set the From fields details |
|
226 if (mViewFeeder->isIncoming()) |
|
227 { |
|
228 QString from = QString(); |
|
229 QString alias = QString(); |
|
230 mViewFeeder->fromAddressAndAlias(from, alias); |
|
231 mAddressContainer->setFromField(from, alias); |
|
232 } |
|
233 |
|
234 // Set the To/Cc fields details |
|
235 if (mViewFeeder->msgType() == KSenduiMtmSmsUidValue) |
|
236 { |
|
237 if (!mViewFeeder->isIncoming()) |
|
238 { |
|
239 mAddressContainer->setToField(toList); |
|
240 } |
|
241 } |
|
242 else if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) |
|
243 { |
|
244 mViewerDetails->setSubject(mViewFeeder->subject()); |
|
245 mViewerDetails->setPriorityIcon(mViewFeeder->priority()); |
|
246 |
|
247 if (!toList.isEmpty()) |
|
248 { |
|
249 mAddressContainer->setToField(toList); |
|
250 } |
|
251 if (!ccList.isEmpty()) |
|
252 { |
|
253 mAddressContainer->setCcField(ccList); |
|
254 } |
|
255 |
|
256 UniMessageInfoList attachList = mViewFeeder->attachmentsList(); |
|
257 int count = attachList.count(); |
|
258 |
|
259 for (int a = 0; a < count; ++a) |
|
260 { |
|
261 UniMessageInfo* info = attachList.at(a); |
|
262 QString type = info->mimetype(); |
|
263 |
|
264 mAttachmentContainer->addAttachmentWidget(type, info->path()); |
|
265 delete info; |
|
266 } |
|
267 } |
|
268 // Time stamp |
|
269 |
|
270 mViewerDetails->setTimeStamp(mViewFeeder->timeStamp()); |
|
271 } |
|
272 |
|
273 //--------------------------------------------------------------- |
|
274 //UniViewSlideWidget::insideLayout |
|
275 // @see header file |
|
276 //--------------------------------------------------------------- |
|
277 bool UniViewSlideWidget::insideLayout() |
|
278 { |
|
279 return mInsideLayout; |
|
280 } |
|
281 |
|
282 //--------------------------------------------------------------- |
|
283 //UniViewSlideWidget::setInsideLayout |
|
284 // @see header file |
|
285 //--------------------------------------------------------------- |
|
286 void UniViewSlideWidget::setInsideLayout(bool inside) |
|
287 { |
|
288 mInsideLayout = inside; |
|
289 } |
|
290 |
|
291 // EOF |