author | hgs |
Thu, 30 Sep 2010 11:43:07 +0300 | |
changeset 74 | 6c59112cfd31 |
parent 68 | 83cc6bae1de8 |
child 76 | 38bf5461e270 |
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 |
} |
|
106 |
return true; |
|
107 |
} |
|
108 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
110 |
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
|
111 |
/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
|
112 |
*/ |
49 | 113 |
bool NmHsWidgetTitleRow::loadDocML(HbDocumentLoader &loader) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
{ |
43 | 115 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
116 |
QT_TRY{ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
117 |
// find container widget |
62 | 118 |
mContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetTitleRowContainer)); |
119 |
if (!mContainer) { |
|
43 | 120 |
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
|
121 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
122 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
124 |
//child items possible to update |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
125 |
mMailboxIcon = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxIcon)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
126 |
mMailboxInfo = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxNameLabel)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
127 |
mUnreadCountLabel = static_cast<HbLabel*> (loader.findWidget( |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
128 |
KNmHsWidgetTitleRowUnreadCountLabel)); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
129 |
mCollapseExpIconLabel = static_cast<HbPushButton*> (loader.findWidget( |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
130 |
KNmHsWidgetTitleRowCollapseExpandIconLabel)); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
132 |
if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) { |
43 | 133 |
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
|
134 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
135 |
} |
47 | 136 |
|
137 |
//Expand collapse button |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
138 |
connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed())); |
47 | 139 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
140 |
return true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
141 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
142 |
QT_CATCH(...){ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
143 |
return false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
|
47 | 147 |
/* |
148 |
Setup graphics that cannot be loaded from docml. |
|
149 |
/return true if loading succeeded, otherwise false. False indicates that object is unusable. |
|
150 |
*/ |
|
151 |
bool NmHsWidgetTitleRow::setupGraphics() |
|
49 | 152 |
{ |
47 | 153 |
NM_FUNCTION; |
154 |
||
155 |
HbFrameDrawer* backgroundFrameDrawer = 0; |
|
156 |
QT_TRY{ |
|
157 |
//pressed background |
|
158 |
backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces); |
|
159 |
mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer ); |
|
62 | 160 |
mContainer->setBackgroundItem( mBackgroundLayoutItem ); |
47 | 161 |
mBackgroundLayoutItem->hide(); |
162 |
||
163 |
//set fonts color |
|
164 |
setHighlighedFontsColor(false); |
|
62 | 165 |
|
166 |
//to get gestures |
|
167 |
setGeometry(mContainer->childrenBoundingRect()); |
|
168 |
||
47 | 169 |
return true; |
170 |
} |
|
171 |
QT_CATCH(...){ |
|
172 |
if(!mBackgroundLayoutItem && backgroundFrameDrawer){ |
|
173 |
delete backgroundFrameDrawer; |
|
174 |
backgroundFrameDrawer = NULL; |
|
175 |
} |
|
176 |
||
177 |
return false; |
|
178 |
} |
|
179 |
||
49 | 180 |
} |
47 | 181 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
183 |
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
|
184 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
185 |
void NmHsWidgetTitleRow::updateAccountName(const QString& accountName) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
186 |
{ |
43 | 187 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
mAccountName = accountName; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
189 |
updateData(); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
190 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
193 |
Set account icon name |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
194 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
195 |
void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
196 |
{ |
43 | 197 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
198 |
mMailboxIcon->setIcon(accountIconName); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
199 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
200 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
201 |
/*! |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
202 |
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
|
203 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
204 |
void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
205 |
{ |
43 | 206 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
mUnreadCount = unreadCount; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
208 |
updateData(); |
43 | 209 |
} |
210 |
||
211 |
||
212 |
/*! |
|
213 |
Slot for updating expand collapse icon |
|
214 |
*/ |
|
215 |
void NmHsWidgetTitleRow::setExpandCollapseIcon(const bool& expand) |
|
216 |
{ |
|
217 |
NM_FUNCTION; |
|
218 |
if(expand){ |
|
219 |
HbIcon icon("qtg_mono_arrow_up"); |
|
220 |
mCollapseExpIconLabel->setIcon(icon); |
|
221 |
} |
|
222 |
else{ |
|
223 |
HbIcon icon("qtg_mono_arrow_down"); |
|
224 |
mCollapseExpIconLabel->setIcon(icon); |
|
225 |
} |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
226 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
228 |
/*! |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
229 |
Update the data displayed in the UI |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
230 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
void NmHsWidgetTitleRow::updateData() |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
232 |
{ |
43 | 233 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
234 |
mMailboxInfo->setPlainText(mAccountName); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
235 |
//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
|
236 |
//This indicates that there are no mails at all (or the initial sync is not done) |
49 | 237 |
if (mUnreadCount >= 0) { |
74 | 238 |
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
|
239 |
mUnreadCountLabel->setPlainText(unreadCount); |
49 | 240 |
QFontMetrics fm(mUnreadCountLabel->font()); |
241 |
qreal textWidth = fm.width(unreadCount); |
|
242 |
mUnreadCountLabel->setMaximumWidth(textWidth); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
243 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
244 |
else { |
49 | 245 |
mUnreadCountLabel->setMaximumWidth(0); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
247 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
248 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
249 |
/*! |
43 | 250 |
sets fonts color. |
47 | 251 |
/param bool pressed indicates if row is pressed down or not |
43 | 252 |
*/ |
47 | 253 |
void NmHsWidgetTitleRow::setHighlighedFontsColor( bool pressed ) |
43 | 254 |
{ |
255 |
NM_FUNCTION; |
|
256 |
QColor newFontColor; |
|
257 |
||
258 |
if(pressed){ |
|
259 |
newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed"); |
|
260 |
} |
|
261 |
else{ |
|
262 |
newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal"); |
|
263 |
} |
|
264 |
||
265 |
mMailboxInfo->setTextColor(newFontColor); |
|
266 |
mUnreadCountLabel->setTextColor(newFontColor); |
|
267 |
} |
|
268 |
||
47 | 269 |
/*! |
270 |
change background pressed state |
|
271 |
/param bool show if true then shown, false hide |
|
272 |
*/ |
|
273 |
void NmHsWidgetTitleRow::showHighlight( bool show ) |
|
274 |
{ |
|
275 |
NM_FUNCTION;; |
|
276 |
||
277 |
if(show){ |
|
278 |
mBackgroundLayoutItem->show(); |
|
279 |
} |
|
280 |
else{ |
|
281 |
mBackgroundLayoutItem->hide(); |
|
282 |
} |
|
283 |
} |
|
43 | 284 |
|
62 | 285 |
/* |
286 |
* NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event) |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
287 |
*/ |
62 | 288 |
void NmHsWidgetTitleRow::gestureEvent(QGestureEvent *event) |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
289 |
{ |
43 | 290 |
NM_FUNCTION; |
62 | 291 |
|
292 |
if(!event){ |
|
293 |
return; |
|
294 |
} |
|
295 |
HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
|
296 |
if(!gesture){ |
|
297 |
return; |
|
298 |
} |
|
299 |
//to avoid opening email account mistakenly when tabbing expand/collapse button |
|
300 |
//we dont handle events that are on the top, down or right side of the button |
|
301 |
QPointF posFromScene = mapFromScene(event->mapToGraphicsScene(gesture->position())); |
|
68 | 302 |
bool inArea = false; |
303 |
||
304 |
if(this->layoutDirection() == Qt::LeftToRight && |
|
305 |
posFromScene.x() < mUnreadCountLabel->geometry().right()) { |
|
306 |
inArea = true; |
|
307 |
} |
|
308 |
else if(this->layoutDirection() == Qt::RightToLeft && |
|
309 |
posFromScene.x() > mUnreadCountLabel->geometry().right()) { |
|
310 |
inArea = true; |
|
311 |
} |
|
312 |
||
313 |
if (inArea) { |
|
62 | 314 |
switch (gesture->state()) { |
315 |
case Qt::GestureStarted: |
|
316 |
setHighlighedFontsColor(true); |
|
317 |
showHighlight(true); |
|
318 |
break; |
|
319 |
case Qt::GestureCanceled: |
|
320 |
setHighlighedFontsColor(false); |
|
321 |
showHighlight(false); |
|
322 |
break; |
|
323 |
case Qt::GestureFinished: |
|
324 |
setHighlighedFontsColor(false); |
|
325 |
showHighlight(false); |
|
326 |
if (gesture->tapStyleHint() == HbTapGesture::Tap) { |
|
327 |
HbInstantFeedback::play(HbFeedback::BasicItem); |
|
328 |
emit mailboxLaunchTriggered(); |
|
329 |
} |
|
330 |
break; |
|
331 |
default: |
|
332 |
break; |
|
47 | 333 |
} |
62 | 334 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
335 |
} |
43 | 336 |
|
337 |
/* |
|
338 |
* NmHsWidgetTitleRow::event() |
|
339 |
*/ |
|
340 |
bool NmHsWidgetTitleRow::event( QEvent *event ) |
|
341 |
{ |
|
342 |
NM_FUNCTION; |
|
343 |
QEvent::Type eventType = event->type(); |
|
344 |
if( eventType == HbEvent::ThemeChanged ){ |
|
47 | 345 |
setHighlighedFontsColor(false); |
43 | 346 |
return true; |
347 |
} |
|
348 |
return HbWidget::event(event); |
|
349 |
} |