17 |
17 |
18 #include <QGraphicsLinearLayout> |
18 #include <QGraphicsLinearLayout> |
19 #include <hbdocumentloader.h> |
19 #include <hbdocumentloader.h> |
20 #include <hblabel.h> |
20 #include <hblabel.h> |
21 #include <hbextendedlocale.h> |
21 #include <hbextendedlocale.h> |
22 #include <HbFrameDrawer> |
22 #include <hbframedrawer.h> |
23 #include <HbFrameItem> |
23 #include <hbframeitem.h> |
24 #include <HbColorScheme> |
24 #include <hbcolorscheme.h> |
25 #include <HbEvent> |
25 #include <hbevent.h> |
26 #include "nmicons.h" |
26 #include "nmicons.h" |
27 #include "nmcommon.h" |
27 #include "nmcommon.h" |
28 #include "nmhswidgetemailrow.h" |
28 #include "nmhswidgetemailrow.h" |
29 #include "nmhswidgetconsts.h" |
29 #include "nmhswidgetconsts.h" |
30 #include "emailtrace.h" |
30 #include "emailtrace.h" |
57 NM_FUNCTION; |
58 NM_FUNCTION; |
58 return mMessageId; |
59 return mMessageId; |
59 |
60 |
60 } |
61 } |
61 |
62 |
62 /*! |
63 /* |
63 Loads layout data and child items from docml file |
64 Setup email row ui |
64 Must be called after constructor. |
65 Must be called after constructor. |
|
66 /return true if loading succeeded, otherwise false. False indicates that object is unusable. |
|
67 */ |
|
68 bool NmHsWidgetEmailRow::setupUI() |
|
69 { |
|
70 NM_FUNCTION; |
|
71 |
|
72 if(!loadDocML() || !setupGraphics()){ |
|
73 return false; |
|
74 } |
|
75 return true; |
|
76 } |
|
77 |
|
78 |
|
79 |
|
80 /*! |
|
81 Loads layout data and child items from docml file |
65 /return true if loading succeeded, otherwise false. False indicates that object is unusable. |
82 /return true if loading succeeded, otherwise false. False indicates that object is unusable. |
66 */ |
83 */ |
67 bool NmHsWidgetEmailRow::loadDocML() |
84 bool NmHsWidgetEmailRow::loadDocML() |
68 { |
85 { |
69 NM_FUNCTION; |
86 NM_FUNCTION; |
70 |
87 |
71 HbFrameDrawer* backgroundFrameDrawer = 0; |
|
72 HbFrameItem* backgroundLayoutItem = 0; |
|
73 QT_TRY{ |
88 QT_TRY{ |
74 // Use document loader to load the contents |
89 // Use document loader to load the contents |
75 HbDocumentLoader loader; |
90 HbDocumentLoader loader; |
76 bool ok(false); |
91 bool ok(false); |
77 loader.load(KNmHsWidgetMailRowDocML, &ok); |
92 loader.load(KNmHsWidgetMailRowDocML, &ok); |
118 NM_ERROR(1,"NmHsWidgetEmailRow::loadDocML fail @ labels & icons"); |
133 NM_ERROR(1,"NmHsWidgetEmailRow::loadDocML fail @ labels & icons"); |
119 return false; |
134 return false; |
120 } |
135 } |
121 //Verify all mStatusIcons |
136 //Verify all mStatusIcons |
122 for (int i = 0; i < mStatusIcons.length(); i++) { |
137 for (int i = 0; i < mStatusIcons.length(); i++) { |
123 if (!mStatusIcons[i]) { |
138 if (!mStatusIcons.at(i)) { |
124 return false; |
139 return false; |
125 } |
140 } |
126 } |
141 } |
127 |
142 |
|
143 return true; |
|
144 } |
|
145 QT_CATCH(...){ |
|
146 return false; |
|
147 } |
|
148 } |
|
149 |
|
150 /* |
|
151 Setup graphics that cannot be loaded from docml. |
|
152 /return true if loading succeeded, otherwise false. False indicates that object is unusable. |
|
153 */ |
|
154 bool NmHsWidgetEmailRow::setupGraphics() |
|
155 { |
|
156 NM_FUNCTION; |
|
157 |
|
158 HbFrameDrawer* newMailIconFrameDrawer = 0; |
|
159 HbFrameItem* newMailIconFrameItem = 0; |
|
160 HbFrameDrawer* backgroundFrameDrawer = 0; |
|
161 QT_TRY{ |
128 //separator icon |
162 //separator icon |
129 HbIcon separatorIcon("qtg_graf_divider_h_thin"); |
163 HbIcon separatorIcon("qtg_graf_divider_h_thin"); |
130 mSeparatorIcon->setIcon(separatorIcon); |
164 mSeparatorIcon->setIcon(separatorIcon); |
131 |
165 |
132 //new email icon |
166 //new email icon |
133 backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_list_new_item", |
167 newMailIconFrameDrawer = new HbFrameDrawer("qtg_fr_list_new_item", |
134 HbFrameDrawer::ThreePiecesVertical); |
168 HbFrameDrawer::ThreePiecesVertical); |
135 backgroundLayoutItem = new HbFrameItem(backgroundFrameDrawer); |
169 newMailIconFrameItem = new HbFrameItem(newMailIconFrameDrawer); |
136 mNewMailIcon->setBackgroundItem(backgroundLayoutItem); |
170 mNewMailIcon->setBackgroundItem(newMailIconFrameItem); |
137 |
171 |
138 //hide all the icons first to avoid blinking |
172 //hide all the icons first to avoid blinking |
139 hideIcons(); |
173 hideIcons(); |
140 |
174 |
|
175 //pressed background |
|
176 backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces); |
|
177 mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer ); |
|
178 setBackgroundItem( mBackgroundLayoutItem ); |
|
179 mBackgroundLayoutItem->hide(); |
|
180 |
141 return true; |
181 return true; |
142 } |
182 } |
143 QT_CATCH(...){ |
183 QT_CATCH(...){ |
144 if(!backgroundLayoutItem && backgroundFrameDrawer){ |
184 if(!newMailIconFrameItem && newMailIconFrameDrawer){ |
|
185 delete newMailIconFrameDrawer; |
|
186 newMailIconFrameDrawer = NULL; |
|
187 } |
|
188 if(!mBackgroundLayoutItem && backgroundFrameDrawer){ |
145 delete backgroundFrameDrawer; |
189 delete backgroundFrameDrawer; |
146 backgroundFrameDrawer = NULL; |
190 backgroundFrameDrawer = NULL; |
147 } |
191 } |
148 return false; |
192 return false; |
149 } |
193 } |
181 //set new icons to widget based on the data |
225 //set new icons to widget based on the data |
182 setIconsToWidget( envelope ); |
226 setIconsToWidget( envelope ); |
183 |
227 |
184 //set fonts color and size |
228 //set fonts color and size |
185 setFontsSize(mEnvelope.isRead()); |
229 setFontsSize(mEnvelope.isRead()); |
186 setFontsColor(false); |
230 setHighlighedFontsColor(false); |
187 } |
231 } |
188 |
232 |
189 /*! |
233 /*! |
190 updateDateTime to label using correct locale |
234 updateDateTime to label using correct locale |
191 */ |
235 */ |
260 iconList.append(NmIcons::getIcon(NmIcons::NmIconAttachment)); |
304 iconList.append(NmIcons::getIcon(NmIcons::NmIconAttachment)); |
261 } |
305 } |
262 |
306 |
263 // Here we show icons added to the iconList in the order they have been added. |
307 // Here we show icons added to the iconList in the order they have been added. |
264 for (int count = 0; count < iconList.count(); count++) { |
308 for (int count = 0; count < iconList.count(); count++) { |
265 mStatusIcons[count]->setIcon(iconList[count]); |
309 mStatusIcons.at(count)->setIcon(iconList.at(count)); |
266 mStatusIcons[count]->show(); |
310 mStatusIcons.at(count)->show(); |
267 } |
311 } |
268 } |
312 } |
269 |
313 |
270 |
314 |
271 /*! |
315 /*! |
317 mSenderLabel->setTextColor(newFontColor); |
362 mSenderLabel->setTextColor(newFontColor); |
318 mSubjectLabel->setTextColor(newFontColor); |
363 mSubjectLabel->setTextColor(newFontColor); |
319 mTimeLabel->setTextColor(newFontColor); |
364 mTimeLabel->setTextColor(newFontColor); |
320 } |
365 } |
321 |
366 |
|
367 /*! |
|
368 change background highlight |
|
369 /param bool show if true then shown, false hide |
|
370 */ |
|
371 void NmHsWidgetEmailRow::showHighlight( bool show ) |
|
372 { |
|
373 NM_FUNCTION; |
|
374 |
|
375 if(show){ |
|
376 mBackgroundLayoutItem->show(); |
|
377 } |
|
378 else{ |
|
379 mBackgroundLayoutItem->hide(); |
|
380 } |
|
381 } |
322 |
382 |
323 /*! |
383 /*! |
324 mousePressEvent(QGraphicsSceneMouseEvent *event) |
384 mousePressEvent(QGraphicsSceneMouseEvent *event) |
325 */ |
385 */ |
326 void NmHsWidgetEmailRow::mousePressEvent(QGraphicsSceneMouseEvent *event) |
386 void NmHsWidgetEmailRow::mousePressEvent(QGraphicsSceneMouseEvent *event) |
327 { |
387 { |
328 NM_FUNCTION; |
388 NM_FUNCTION; |
329 Q_UNUSED(event); |
389 Q_UNUSED(event); |
330 setFontsColor(true); |
390 setHighlighedFontsColor(true); |
|
391 showHighlight(true); |
331 } |
392 } |
332 |
393 |
333 /*! |
394 /*! |
334 mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
395 mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
335 */ |
396 */ |
336 void NmHsWidgetEmailRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
397 void NmHsWidgetEmailRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
337 { |
398 { |
338 NM_FUNCTION; |
399 NM_FUNCTION; |
339 Q_UNUSED(event); |
400 Q_UNUSED(event); |
340 setFontsColor(false); |
401 setHighlighedFontsColor(false); |
|
402 showHighlight(false); |
341 emit mailViewerLaunchTriggered(mMessageId); |
403 emit mailViewerLaunchTriggered(mMessageId); |
342 } |
404 } |
343 |
405 |
344 /* |
406 /* |
345 * NmHsWidgetEmailRow::event() |
407 * NmHsWidgetEmailRow::event() |
347 bool NmHsWidgetEmailRow::event( QEvent *event ) |
409 bool NmHsWidgetEmailRow::event( QEvent *event ) |
348 { |
410 { |
349 NM_FUNCTION; |
411 NM_FUNCTION; |
350 QEvent::Type eventType = event->type(); |
412 QEvent::Type eventType = event->type(); |
351 if( eventType == HbEvent::ThemeChanged ){ |
413 if( eventType == HbEvent::ThemeChanged ){ |
352 setFontsColor(false); |
414 setHighlighedFontsColor(false); |
353 return true; |
415 return true; |
354 } |
416 } |
355 return HbWidget::event(event); |
417 return HbWidget::event(event); |
356 } |
418 } |