author | hgs |
Thu, 14 Oct 2010 17:33:43 +0300 | |
changeset 76 | 38bf5461e270 |
parent 74 | 6c59112cfd31 |
permissions | -rw-r--r-- |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
49 | 18 |
#include <qgraphicslinearlayout.h> |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
19 |
#include <QtGui> |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <hbdocumentloader.h> |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <hblabel.h> |
49 | 22 |
#include <hbpushbutton.h> |
23 |
#include <hbcolorscheme.h> |
|
24 |
#include <hbevent.h> |
|
47 | 25 |
#include <hbframedrawer.h> |
26 |
#include <hbframeitem.h> |
|
62 | 27 |
#include <hbtapgesture.h> |
28 |
#include <hbinstantfeedback.h> |
|
74 | 29 |
#include <hbstringutil.h> |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "nmicons.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "nmhswidgettitlerow.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "nmhswidgetconsts.h" |
43 | 33 |
#include "emailtrace.h" |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
35 |
NmHsWidgetTitleRow::NmHsWidgetTitleRow(QGraphicsItem *parent, Qt::WindowFlags flags) : |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
36 |
HbWidget(parent, flags), |
62 | 37 |
mContainer(0), |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
38 |
mMailboxIcon(0), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
39 |
mMailboxInfo(0), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
40 |
mUnreadCountLabel(0), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
41 |
mCollapseExpIconLabel(0), |
43 | 42 |
mAccountName(), |
47 | 43 |
mUnreadCount(0), |
44 |
mBackgroundLayoutItem(0) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
{ |
43 | 46 |
NM_FUNCTION; |
62 | 47 |
grabGesture(Qt::TapGesture); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
51 |
Destructor |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
52 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
NmHsWidgetTitleRow::~NmHsWidgetTitleRow() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
{ |
47 | 55 |
NM_FUNCTION; |
56 |
} |
|
57 |
||
58 |
/*! |
|
59 |
\fn QPainterPath NmHsWidgetTitleRow::shape() |
|
60 |
||
61 |
Called by home screen fw to check widget boundaries, needed to draw |
|
62 |
outside widget boundingRect. |
|
63 |
/return QPainterPath path describing actual boundaries of widget |
|
64 |
including child items |
|
65 |
*/ |
|
66 |
QPainterPath NmHsWidgetTitleRow::shape() const |
|
67 |
{ |
|
43 | 68 |
NM_FUNCTION; |
47 | 69 |
|
70 |
QPainterPath path; |
|
71 |
path.setFillRule(Qt::WindingFill); |
|
62 | 72 |
if (mContainer){ |
73 |
path.addRect(mContainer->geometry()); |
|
74 |
} |
|
47 | 75 |
if (mMailboxIcon){ |
76 |
path.addRect(mMailboxIcon->geometry()); |
|
77 |
} |
|
78 |
return path.simplified(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
80 |
|
62 | 81 |
/*! |
82 |
\fn qreal NmHsWidgetTitleRow::containerHeight() |
|
83 |
||
84 |
/return qreal defining title row container height in pixels |
|
85 |
*/ |
|
86 |
qreal NmHsWidgetTitleRow::containerHeight() |
|
87 |
{ |
|
88 |
if (mContainer){ |
|
89 |
return mContainer->preferredHeight(); |
|
90 |
} |
|
91 |
return 0; |
|
92 |
} |
|
93 |
||
47 | 94 |
/* |
95 |
Setup email row ui |
|
96 |
Must be called after constructor. |
|
97 |
/return true if loading succeeded, otherwise false. False indicates that object is unusable. |
|
98 |
*/ |
|
49 | 99 |
bool NmHsWidgetTitleRow::setupUI(HbDocumentLoader &loader) |
47 | 100 |
{ |
101 |
NM_FUNCTION; |
|
102 |
||
49 | 103 |
if(!loadDocML(loader) || !setupGraphics()){ |
47 | 104 |
return false; |
105 |
} |
|
76 | 106 |
|
107 |
HbEffect::add(mBackgroundLayoutItem, "listviewitem_press", "pressed"); |
|
108 |
HbEffect::add(mBackgroundLayoutItem, "listviewitem_release", "released"); |
|
109 |
||
47 | 110 |
return true; |
111 |
} |
|
112 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
114 |
Loads layout data and child items from docml file. Must be called after constructor. |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
115 |
/return true if loading succeeded, otherwise false. False indicates that object is unusable |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
116 |
*/ |
49 | 117 |
bool NmHsWidgetTitleRow::loadDocML(HbDocumentLoader &loader) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
{ |
43 | 119 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
120 |
QT_TRY{ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
121 |
// find container widget |
62 | 122 |
mContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetTitleRowContainer)); |
123 |
if (!mContainer) { |
|
43 | 124 |
NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ container"); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
125 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
126 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
128 |
//child items possible to update |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
129 |
mMailboxIcon = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxIcon)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
130 |
mMailboxInfo = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxNameLabel)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
131 |
mUnreadCountLabel = static_cast<HbLabel*> (loader.findWidget( |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
132 |
KNmHsWidgetTitleRowUnreadCountLabel)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
133 |
mCollapseExpIconLabel = static_cast<HbPushButton*> (loader.findWidget( |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
134 |
KNmHsWidgetTitleRowCollapseExpandIconLabel)); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
136 |
if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) { |
43 | 137 |
NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ icons & labels"); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
138 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
139 |
} |
47 | 140 |
|
141 |
//Expand collapse button |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
142 |
connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed())); |
47 | 143 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
return true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
QT_CATCH(...){ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
147 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
148 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
|
47 | 151 |
/* |
152 |
Setup graphics that cannot be loaded from docml. |
|
153 |
/return true if loading succeeded, otherwise false. False indicates that object is unusable. |
|
154 |
*/ |
|
155 |
bool NmHsWidgetTitleRow::setupGraphics() |
|
49 | 156 |
{ |
47 | 157 |
NM_FUNCTION; |
158 |
||
159 |
HbFrameDrawer* backgroundFrameDrawer = 0; |
|
160 |
QT_TRY{ |
|
76 | 161 |
//default background |
162 |
backgroundFrameDrawer = new HbFrameDrawer(KNmHsWidgetBackgroundImage, HbFrameDrawer::NinePieces); |
|
47 | 163 |
mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer ); |
62 | 164 |
mContainer->setBackgroundItem( mBackgroundLayoutItem ); |
47 | 165 |
|
166 |
//set fonts color |
|
76 | 167 |
setFontsColor(); |
62 | 168 |
|
169 |
//to get gestures |
|
170 |
setGeometry(mContainer->childrenBoundingRect()); |
|
171 |
||
47 | 172 |
return true; |
173 |
} |
|
174 |
QT_CATCH(...){ |
|
175 |
if(!mBackgroundLayoutItem && backgroundFrameDrawer){ |
|
176 |
delete backgroundFrameDrawer; |
|
177 |
backgroundFrameDrawer = NULL; |
|
178 |
} |
|
179 |
||
180 |
return false; |
|
181 |
} |
|
182 |
||
49 | 183 |
} |
47 | 184 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
186 |
Slot for updating account name, calls updateData to update ui. |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
187 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
188 |
void NmHsWidgetTitleRow::updateAccountName(const QString& accountName) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
189 |
{ |
43 | 190 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
mAccountName = accountName; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
updateData(); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
193 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
196 |
Set account icon name |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
197 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
198 |
void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
199 |
{ |
43 | 200 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
201 |
mMailboxIcon->setIcon(accountIconName); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
202 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
203 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
204 |
/*! |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
205 |
Slot for updating unread count, calls updateData to update ui. |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
206 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
207 |
void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
208 |
{ |
43 | 209 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
210 |
mUnreadCount = unreadCount; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
updateData(); |
43 | 212 |
} |
213 |
||
214 |
||
215 |
/*! |
|
216 |
Slot for updating expand collapse icon |
|
217 |
*/ |
|
218 |
void NmHsWidgetTitleRow::setExpandCollapseIcon(const bool& expand) |
|
219 |
{ |
|
220 |
NM_FUNCTION; |
|
221 |
if(expand){ |
|
222 |
HbIcon icon("qtg_mono_arrow_up"); |
|
223 |
mCollapseExpIconLabel->setIcon(icon); |
|
224 |
} |
|
225 |
else{ |
|
226 |
HbIcon icon("qtg_mono_arrow_down"); |
|
227 |
mCollapseExpIconLabel->setIcon(icon); |
|
228 |
} |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
229 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
230 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
232 |
Update the data displayed in the UI |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
233 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
234 |
void NmHsWidgetTitleRow::updateData() |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
235 |
{ |
43 | 236 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
237 |
mMailboxInfo->setPlainText(mAccountName); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
238 |
//If unread count is -1, hide the unread count label completely. |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
239 |
//This indicates that there are no mails at all (or the initial sync is not done) |
49 | 240 |
if (mUnreadCount >= 0) { |
74 | 241 |
QString unreadCount(HbStringUtil::convertDigits(hbTrId("txt_mail_widget_list_l1").arg(mUnreadCount))); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
242 |
mUnreadCountLabel->setPlainText(unreadCount); |
49 | 243 |
QFontMetrics fm(mUnreadCountLabel->font()); |
244 |
qreal textWidth = fm.width(unreadCount); |
|
245 |
mUnreadCountLabel->setMaximumWidth(textWidth); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
246 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
247 |
else { |
76 | 248 |
//set empty string as nothing to show |
249 |
mUnreadCountLabel->setPlainText(QString()); |
|
49 | 250 |
mUnreadCountLabel->setMaximumWidth(0); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
252 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
253 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
254 |
/*! |
43 | 255 |
sets fonts color. |
256 |
*/ |
|
76 | 257 |
void NmHsWidgetTitleRow::setFontsColor() |
43 | 258 |
{ |
259 |
NM_FUNCTION; |
|
76 | 260 |
QColor newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal"); |
43 | 261 |
|
262 |
mMailboxInfo->setTextColor(newFontColor); |
|
263 |
mUnreadCountLabel->setTextColor(newFontColor); |
|
264 |
} |
|
265 |
||
47 | 266 |
/*! |
76 | 267 |
hide background |
47 | 268 |
*/ |
76 | 269 |
void NmHsWidgetTitleRow::hideHighlight(const HbEffect::EffectStatus &status) |
47 | 270 |
{ |
76 | 271 |
NM_FUNCTION; |
272 |
||
273 |
Q_UNUSED(status); |
|
274 |
mBackgroundLayoutItem->frameDrawer().setFrameGraphicsName(KNmHsWidgetBackgroundImage); |
|
47 | 275 |
} |
43 | 276 |
|
62 | 277 |
/* |
278 |
* NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event) |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
279 |
*/ |
62 | 280 |
void NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event) |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
281 |
{ |
43 | 282 |
NM_FUNCTION; |
62 | 283 |
|
284 |
if(!event){ |
|
285 |
return; |
|
286 |
} |
|
287 |
HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
|
288 |
if(!gesture){ |
|
289 |
return; |
|
290 |
} |
|
291 |
//to avoid opening email account mistakenly when tabbing expand/collapse button |
|
292 |
//we dont handle events that are on the top, down or right side of the button |
|
293 |
QPointF posFromScene = mapFromScene(event->mapToGraphicsScene(gesture->position())); |
|
68 | 294 |
bool inArea = false; |
295 |
||
296 |
if(this->layoutDirection() == Qt::LeftToRight && |
|
297 |
posFromScene.x() < mUnreadCountLabel->geometry().right()) { |
|
298 |
inArea = true; |
|
299 |
} |
|
300 |
else if(this->layoutDirection() == Qt::RightToLeft && |
|
301 |
posFromScene.x() > mUnreadCountLabel->geometry().right()) { |
|
302 |
inArea = true; |
|
303 |
} |
|
304 |
||
305 |
if (inArea) { |
|
62 | 306 |
switch (gesture->state()) { |
307 |
case Qt::GestureStarted: |
|
76 | 308 |
HbEffect::start( mBackgroundLayoutItem, "pressed"); |
309 |
mBackgroundLayoutItem->frameDrawer().setFrameGraphicsName("qtg_fr_hsitems_pressed"); |
|
62 | 310 |
break; |
311 |
case Qt::GestureCanceled: |
|
76 | 312 |
HbEffect::start( mBackgroundLayoutItem, "released", this, "hideHighlight"); |
62 | 313 |
break; |
314 |
case Qt::GestureFinished: |
|
76 | 315 |
HbEffect::start( mBackgroundLayoutItem, "released", this, "hideHighlight"); |
62 | 316 |
if (gesture->tapStyleHint() == HbTapGesture::Tap) { |
317 |
HbInstantFeedback::play(HbFeedback::BasicItem); |
|
318 |
emit mailboxLaunchTriggered(); |
|
319 |
} |
|
320 |
break; |
|
321 |
default: |
|
322 |
break; |
|
47 | 323 |
} |
62 | 324 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
325 |
} |
43 | 326 |
|
327 |
/* |
|
328 |
* NmHsWidgetTitleRow::event() |
|
329 |
*/ |
|
330 |
bool NmHsWidgetTitleRow::event( QEvent *event ) |
|
331 |
{ |
|
332 |
NM_FUNCTION; |
|
333 |
QEvent::Type eventType = event->type(); |
|
334 |
if( eventType == HbEvent::ThemeChanged ){ |
|
76 | 335 |
setFontsColor(); |
43 | 336 |
return true; |
337 |
} |
|
338 |
return HbWidget::event(event); |
|
339 |
} |