17 |
17 |
18 #include "univiewslidewidget.h" |
18 #include "univiewslidewidget.h" |
19 |
19 |
20 // SYSTEM INCLUDES |
20 // SYSTEM INCLUDES |
21 #include <QGraphicsLinearLayout> |
21 #include <QGraphicsLinearLayout> |
22 #include <HbGroupBox> |
|
23 |
22 |
24 // USER INCLUDES |
23 // USER INCLUDES |
25 #include "univieweraddresscontainer.h" |
|
26 #include "univiewerattachmentcontainer.h" |
|
27 #include "univiewerdetailswidget.h" |
|
28 #include "univiewerbodywidget.h" |
24 #include "univiewerbodywidget.h" |
29 #include "convergedmessage.h" |
|
30 #include "univiewerfeeder.h" |
25 #include "univiewerfeeder.h" |
|
26 #include "univiewerheadercontainer.h" |
|
27 #include "nativemessageconsts.h" |
31 |
28 |
32 #include "nativemessageconsts.h" |
29 #define LOC_SLIDE_COUNTER hbTrId("txt_messaging_formlabel_slide_l1l2") |
|
30 |
33 //--------------------------------------------------------------- |
31 //--------------------------------------------------------------- |
34 //UniViewSlideWidget :: UniViewSlideWidget |
32 // UniViewSlideWidget :: UniViewSlideWidget |
35 // @see header file |
33 // @see header file |
36 //--------------------------------------------------------------- |
34 //--------------------------------------------------------------- |
37 UniViewSlideWidget::UniViewSlideWidget(UniViewerFeeder* feeder, int slideNumber, |
35 UniViewSlideWidget::UniViewSlideWidget(UniViewerFeeder* feeder, int slideNumber, |
38 QGraphicsItem * parent) : |
36 QGraphicsItem * parent) : |
39 HbWidget(parent), mInsideLayout(false), mSlideNumber(slideNumber), mViewerDetails(NULL), |
37 HbWidget(parent), mInsideLayout(false), mSlideNumber(slideNumber), mViewFeeder(feeder), |
40 mViewFeeder(feeder), mHeaderGroupBox(NULL), mAddressContainer(NULL), mAttachmentContainer( |
38 mHeaderContainer(0) |
41 NULL) |
|
42 |
39 |
43 { |
40 { |
|
41 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
42 mMainLayout->setSpacing(0); |
|
43 mMainLayout->setContentsMargins(0, 0, 0, 0); |
44 |
44 |
45 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
46 mBody = new UniViewerBodyWidget(this); |
45 mBody = new UniViewerBodyWidget(this); |
47 |
|
48 connect(mBody,SIGNAL(sendMessage(const QString&)), |
|
49 this, SIGNAL(sendMessage(const QString&))); |
|
50 |
46 |
51 // If its a first slide create the headers and attach |
47 connect(mBody, SIGNAL(sendMessage(const QString&)), this, SIGNAL(sendMessage(const QString&))); |
52 // to the main layout |
48 |
|
49 /** |
|
50 * If its a first slide create the headers and attach to the main layout |
|
51 */ |
53 if (mSlideNumber == 0) { |
52 if (mSlideNumber == 0) { |
54 // Creation of address group box and adding address container |
53 mHeaderContainer = new UniViewerHeaderContainer(mViewFeeder, this); |
55 mHeaderGroupBox = new HbGroupBox(this); |
|
56 mHeaderGroupBox->setCollapsed(true); |
|
57 mHeaderGroupBox->setCollapsable(true); |
|
58 |
54 |
59 mAddressContainer = new UniViewerAddressContainer(mHeaderGroupBox); |
55 // Always connect to populate sms content |
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))); |
56 connect(mViewFeeder, SIGNAL(msgBody(QString)), mBody, SLOT(setTextContent(QString))); |
69 |
57 |
70 //Add address group box and insert into layout |
58 mMainLayout->addItem(mHeaderContainer); |
71 mViewerDetails->sizePolicy().setVerticalPolicy(QSizePolicy::Fixed); |
|
72 mMainLayout->addItem(mHeaderGroupBox); |
|
73 mMainLayout->addItem(mViewerDetails); |
|
74 mMainLayout->addItem(mAttachmentContainer); |
|
75 } |
59 } |
76 |
60 |
77 mMainLayout->addItem(mBody); |
61 mMainLayout->addItem(mBody); |
78 |
|
79 mMainLayout->setSpacing(0); |
|
80 mMainLayout->setContentsMargins(0, 0, 0, 0); |
|
81 |
62 |
82 setLayout(mMainLayout); |
63 setLayout(mMainLayout); |
83 } |
64 } |
84 |
65 |
85 //--------------------------------------------------------------- |
66 //--------------------------------------------------------------- |
86 //UniViewSlideWidget::~UniViewSlideWidget |
67 // UniViewSlideWidget::~UniViewSlideWidget |
87 // @see header file |
68 // @see header file |
88 //--------------------------------------------------------------- |
69 //--------------------------------------------------------------- |
89 UniViewSlideWidget::~UniViewSlideWidget() |
70 UniViewSlideWidget::~UniViewSlideWidget() |
90 { |
71 { |
91 |
72 |
95 //UniViewSlideWidget::clearContent |
76 //UniViewSlideWidget::clearContent |
96 // @see header file |
77 // @see header file |
97 //--------------------------------------------------------------- |
78 //--------------------------------------------------------------- |
98 void UniViewSlideWidget::clearContent() |
79 void UniViewSlideWidget::clearContent() |
99 { |
80 { |
100 if (mViewerDetails) { |
81 if (mHeaderContainer) { |
101 mViewerDetails->clearContent(); |
82 mHeaderContainer->clearContent(); |
102 } |
|
103 if (mAddressContainer) { |
|
104 mAddressContainer->clearContent(); |
|
105 } |
|
106 if (mAttachmentContainer) { |
|
107 mAttachmentContainer->clearContent(); |
|
108 } |
83 } |
109 if (mBody) { |
84 if (mBody) { |
110 mBody->clearContent(); |
85 mBody->clearContent(); |
111 } |
86 } |
112 } |
87 } |
113 |
88 |
114 //--------------------------------------------------------------- |
89 //--------------------------------------------------------------- |
115 //UniViewSlideWidget::populateContent |
90 // UniViewSlideWidget::populateContent |
116 // @see header file |
91 // @see header file |
117 //--------------------------------------------------------------- |
92 //--------------------------------------------------------------- |
118 void UniViewSlideWidget::populateContent() |
93 void UniViewSlideWidget::populateContent() |
119 { |
94 { |
120 if (mSlideNumber == 0) { |
95 if (mSlideNumber == 0) { |
121 mViewFeeder->fetchDetails(); |
96 mViewFeeder->fetchDetails(); |
122 populateFirstSlide(); |
97 populateFirstSlide(); |
123 } |
98 } |
124 |
99 |
125 if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue |
100 if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) { |
126 && mViewFeeder->slideCount() > 0) |
|
127 { |
|
128 QString slideString; |
101 QString slideString; |
129 slideString = QString("%1 %2/%3").arg(tr("Slide")). arg(mSlideNumber + 1).arg( |
102 if (mViewFeeder->slideCount() > 1) { |
130 mViewFeeder->slideCount()); |
103 slideString = QString(LOC_SLIDE_COUNTER).arg(mSlideNumber + 1).arg( |
|
104 mViewFeeder->slideCount()); |
|
105 } |
131 mBody->setSlideContents(mViewFeeder->slideContent(mSlideNumber), slideString); |
106 mBody->setSlideContents(mViewFeeder->slideContent(mSlideNumber), slideString); |
132 |
|
133 } |
107 } |
134 } |
108 } |
135 |
109 |
136 //--------------------------------------------------------------- |
110 //--------------------------------------------------------------- |
137 //UniViewSlideWidget::populateFirstSlide |
111 // UniViewSlideWidget::populateFirstSlide |
138 // @see header file |
112 // @see header file |
139 //--------------------------------------------------------------- |
113 //--------------------------------------------------------------- |
140 void UniViewSlideWidget::populateFirstSlide() |
114 void UniViewSlideWidget::populateFirstSlide() |
141 { |
115 { |
142 //Populate the name for the groupbox |
116 mHeaderContainer->populateContent(); |
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 } |
117 } |
272 |
118 |
273 //--------------------------------------------------------------- |
119 //--------------------------------------------------------------- |
274 //UniViewSlideWidget::insideLayout |
120 // UniViewSlideWidget::insideLayout |
275 // @see header file |
121 // @see header file |
276 //--------------------------------------------------------------- |
122 //--------------------------------------------------------------- |
277 bool UniViewSlideWidget::insideLayout() |
123 bool UniViewSlideWidget::insideLayout() |
278 { |
124 { |
279 return mInsideLayout; |
125 return mInsideLayout; |
280 } |
126 } |
281 |
127 |
282 //--------------------------------------------------------------- |
128 //--------------------------------------------------------------- |
283 //UniViewSlideWidget::setInsideLayout |
129 // UniViewSlideWidget::setInsideLayout |
284 // @see header file |
130 // @see header file |
285 //--------------------------------------------------------------- |
131 //--------------------------------------------------------------- |
286 void UniViewSlideWidget::setInsideLayout(bool inside) |
132 void UniViewSlideWidget::setInsideLayout(bool inside) |
287 { |
133 { |
288 mInsideLayout = inside; |
134 mInsideLayout = inside; |