author | hgs |
Fri, 02 Jul 2010 15:55:16 +0300 | |
changeset 49 | 00c7ae862740 |
parent 47 | f83bd4ae1fe3 |
child 62 | a8c646b56683 |
permissions | -rw-r--r-- |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
18
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 |
#include <QtGui> |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <QGraphicsLinearLayout> |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <hbcolorscheme.h> |
49 | 20 |
#include <hbdocumentloader.h> |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
21 |
#include <QTranslator> |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
22 |
#include <hbframedrawer.h> |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
23 |
#include <hbframeitem.h> |
47 | 24 |
#include <hblabel.h> |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
25 |
#include "nmcommon.h" |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include "nmhswidget.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include "nmhswidgetemailengine.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "nmmessageenvelope.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include "nmhswidgettitlerow.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "nmhswidgetemailrow.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "nmhswidgetconsts.h" |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
32 |
#include "nmhswidgetdatetimeobserver.h" |
43 | 33 |
#include "emailtrace.h" |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
NmHsWidget::NmHsWidget(QGraphicsItem *parent, Qt::WindowFlags flags) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
: HbWidget(parent, flags), |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
37 |
mEngine(0), |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
38 |
mTitleRow(0), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
39 |
mAccountId(0), |
43 | 40 |
mAccountIconName(), |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
41 |
mTranslator(0), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
42 |
mBackgroundFrameDrawer(0), |
43 | 43 |
mIsExpanded(false), |
47 | 44 |
mDateObserver(0), |
49 | 45 |
mNoMailsLabel(0), |
46 |
mWidgetContainer(0), |
|
47 |
mContentContainer(0), |
|
48 |
mContentLayout(0) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
{ |
43 | 50 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
/*! |
47 | 54 |
Destructor |
55 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
NmHsWidget::~NmHsWidget() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
{ |
43 | 58 |
NM_FUNCTION; |
59 |
||
60 |
delete mTranslator; |
|
61 |
mTranslator = NULL; |
|
62 |
||
63 |
delete mEngine; |
|
64 |
mEngine = NULL; |
|
65 |
||
66 |
delete mBackgroundFrameDrawer; |
|
67 |
mBackgroundFrameDrawer = NULL; |
|
68 |
||
69 |
delete mDateObserver; |
|
70 |
mDateObserver = NULL; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
/*! |
47 | 74 |
\fn QPainterPath NmHsWidget::shape() |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
75 |
|
47 | 76 |
Called by home screen fw to check widget boundaries, needed to draw |
77 |
outside widget boundingRect. |
|
78 |
/return QPainterPath path describing actual boundaries of widget |
|
79 |
including child items |
|
80 |
*/ |
|
81 |
QPainterPath NmHsWidget::shape() const |
|
82 |
{ |
|
83 |
NM_FUNCTION; |
|
84 |
||
85 |
QPainterPath path; |
|
86 |
path.setFillRule(Qt::WindingFill); |
|
87 |
||
88 |
path.addRect(this->rect()); |
|
89 |
if (mTitleRow){ |
|
90 |
path.addPath(mTitleRow->shape()); |
|
91 |
} |
|
92 |
return path.simplified(); |
|
93 |
} |
|
94 |
||
95 |
/*! |
|
96 |
\fn void NmHsWidget::onShow() |
|
97 |
||
98 |
called by home screen fw when widget gets visible |
|
99 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
100 |
void NmHsWidget::onShow() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
101 |
{ |
43 | 102 |
NM_FUNCTION; |
47 | 103 |
if (mEngine) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
104 |
mEngine->activate(); |
47 | 105 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
106 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
107 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
108 |
/*! |
47 | 109 |
\fn void NmHsWidget::onHide() |
110 |
||
111 |
called by home screen fw when widget gets hidden |
|
112 |
*/ |
|
113 |
void NmHsWidget::onHide() |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
114 |
{ |
43 | 115 |
NM_FUNCTION; |
47 | 116 |
if (mEngine) { |
117 |
mEngine->suspend(); |
|
118 |
} |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
119 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
120 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
121 |
/*! |
49 | 122 |
\fn bool NmHsWidget::loadDocML(HbDocumentLoader &loader) |
123 |
||
124 |
loads layout data and child items from docml file. Must be called after constructor. |
|
125 |
/return true if loading succeeded, otherwise false. False indicates that object is unusable |
|
126 |
*/ |
|
127 |
bool NmHsWidget::loadDocML(HbDocumentLoader &loader) |
|
128 |
{ |
|
129 |
NM_FUNCTION; |
|
130 |
||
131 |
bool ok(false); |
|
132 |
loader.load(KNmHsWidgetDocML, &ok); |
|
133 |
||
134 |
if(ok) { |
|
135 |
mWidgetContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContainer)); |
|
136 |
mContentContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContentContainer)); |
|
137 |
mNoMailsLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetNoMailsLabel)); |
|
138 |
if (!mWidgetContainer || !mContentContainer || !mNoMailsLabel) { |
|
139 |
//something failed in documentloader, no point to continue |
|
140 |
NM_ERROR(1,"NmHsWidget::loadDocML fail @ containers or label"); |
|
141 |
ok = false; |
|
142 |
} |
|
143 |
} |
|
144 |
return ok; |
|
145 |
} |
|
146 |
||
147 |
/*! |
|
47 | 148 |
Initializes Localization. |
149 |
/post mTranslator constructed & localization file loaded |
|
150 |
*/ |
|
151 |
void NmHsWidget::setupLocalization() |
|
152 |
{ |
|
153 |
NM_FUNCTION; |
|
154 |
||
155 |
//Use correct localisation |
|
156 |
mTranslator = new QTranslator(); |
|
157 |
QString lang = QLocale::system().name(); |
|
158 |
mTranslator->load(KNmHsWidgetLocFileName + lang, KNmHsWidgetLocLocation); |
|
159 |
QCoreApplication::installTranslator(mTranslator); |
|
160 |
} |
|
161 |
||
162 |
/*! |
|
163 |
Initializes UI. Everything that is not done in docml files should be here. |
|
164 |
return true if ok, in error false. |
|
165 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
166 |
void NmHsWidget::setupUi() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
167 |
{ |
43 | 168 |
NM_FUNCTION; |
47 | 169 |
|
49 | 170 |
//main level layout needed to control docml objects |
171 |
QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
172 |
widgetLayout->setContentsMargins(KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin, |
|
173 |
KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin); |
|
174 |
widgetLayout->setSpacing(KNmHsWidgetContentsMargin); |
|
175 |
widgetLayout->addItem(mWidgetContainer); |
|
176 |
this->setLayout(widgetLayout); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
177 |
|
49 | 178 |
//fetch pointer to content container layout |
179 |
//to be able to add/remove email rows and no mails label |
|
180 |
mContentLayout = (QGraphicsLinearLayout*) mContentContainer->layout(); |
|
181 |
||
182 |
//set noMailsLabel properties not supported by doc loader |
|
183 |
QColor newFontColor; |
|
184 |
newFontColor = HbColorScheme::color("qtc_hs_list_item_content_normal"); |
|
185 |
mNoMailsLabel->setTextColor(newFontColor); |
|
186 |
mNoMailsLabel->setVisible(true); |
|
187 |
||
188 |
mContentLayout->removeItem(mNoMailsLabel); |
|
189 |
||
190 |
//widget background |
|
47 | 191 |
mBackgroundFrameDrawer = new HbFrameDrawer(KNmHsWidgetBackgroundImage, |
192 |
HbFrameDrawer::NinePieces); |
|
193 |
HbFrameItem* backgroundLayoutItem = new HbFrameItem(mBackgroundFrameDrawer); |
|
194 |
//set to NULL to indicate that ownership transferred |
|
195 |
mBackgroundFrameDrawer = NULL; |
|
49 | 196 |
setBackgroundItem(backgroundLayoutItem); |
197 |
} |
|
47 | 198 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
199 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
200 |
/*! |
47 | 201 |
Initializes the widget. |
202 |
||
203 |
called by home screen fw when widget is added to home screen |
|
204 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
void NmHsWidget::onInitialize() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
{ |
43 | 207 |
NM_FUNCTION; |
47 | 208 |
|
209 |
QT_TRY { |
|
49 | 210 |
|
211 |
// Use document loader to load the contents |
|
212 |
HbDocumentLoader loader; |
|
213 |
||
214 |
//load containers and mNoMailsLabel |
|
215 |
if (!loadDocML(loader)) { |
|
216 |
NM_ERROR(1,"NmHsWidget::onInitialize Fail @ loader"); |
|
217 |
emit error(); //failure, no point to continue |
|
218 |
return; |
|
219 |
} |
|
220 |
||
221 |
//construct title row |
|
222 |
mTitleRow = new NmHsWidgetTitleRow(this); |
|
223 |
if (!mTitleRow->setupUI(loader)) { |
|
224 |
//title row creation failed |
|
225 |
NM_ERROR(1,"NmHsWidget::onInitialize fail @ titlerow"); |
|
226 |
emit error(); //failure, no point to continue |
|
227 |
return; |
|
228 |
} |
|
229 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
230 |
setupUi(); |
47 | 231 |
setupLocalization(); |
232 |
||
233 |
//Engine construction is 2 phased. |
|
234 |
mEngine = new NmHsWidgetEmailEngine(mAccountId); |
|
235 |
//Client must connect to exception signals before calling the initialize function |
|
236 |
//because we don't want to miss any signals. |
|
237 |
connect(mEngine, SIGNAL( exceptionOccured(const int&) ), this, |
|
238 |
SLOT( onEngineException(const int&) )); |
|
239 |
if (!mEngine->initialize()) { |
|
240 |
//engine construction failed. Give up. |
|
49 | 241 |
NM_ERROR(1,"NmHsWidget::onInitialize fail @ engine"); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
242 |
emit error(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
243 |
return; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
244 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
245 |
|
49 | 246 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
247 |
mTitleRow->updateAccountName(mEngine->accountName()); |
47 | 248 |
|
249 |
//create observer for date/time change events |
|
250 |
mDateObserver = new NmHsWidgetDateTimeObserver(); |
|
251 |
||
252 |
//Crete MailRows and associated connections |
|
253 |
createMailRowsList(); |
|
254 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
255 |
updateMailData(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
256 |
mTitleRow->updateUnreadCount(mEngine->unreadCount()); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
257 |
mTitleRow->setAccountIcon(mAccountIconName); |
43 | 258 |
mTitleRow->setExpandCollapseIcon(mIsExpanded); |
47 | 259 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
260 |
//Get signals about changes in mail data |
47 | 261 |
connect(mEngine, SIGNAL( mailDataChanged() ), this, SLOT( updateMailData() )); |
262 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
263 |
//Get Signals about changes in unread count |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
264 |
connect(mEngine, SIGNAL( unreadCountChanged(const int&) ) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
265 |
,mTitleRow, SLOT( updateUnreadCount(const int&) ) ); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
266 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
267 |
//Get signals about account name changes |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
268 |
connect(mEngine, SIGNAL( accountNameChanged(const QString&) ) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
269 |
,mTitleRow, SLOT( updateAccountName(const QString&) ) ); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
270 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
271 |
//Get signals about user actions |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
272 |
connect(mTitleRow, SIGNAL( mailboxLaunchTriggered() ) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
273 |
,mEngine, SLOT( launchMailAppInboxView() ) ); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
274 |
connect(mTitleRow, SIGNAL( expandCollapseButtonPressed() ) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
275 |
,this, SLOT( handleExpandCollapseEvent() ) ); |
49 | 276 |
|
277 |
setMinimumSize(mTitleRow->minimumSize()); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
278 |
} |
47 | 279 |
QT_CATCH(...) { |
49 | 280 |
NM_ERROR(1,"NmHsWidget::onInitialize fail @ catch"); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
281 |
emit error(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
282 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
283 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
284 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
285 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
286 |
/*! |
47 | 287 |
updateMailData slot |
288 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
289 |
void NmHsWidget::updateMailData() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
290 |
{ |
43 | 291 |
NM_FUNCTION; |
47 | 292 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
293 |
QList<NmMessageEnvelope> envelopes; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
294 |
int count = 0; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
295 |
if (mIsExpanded) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
296 |
count = mEngine->getEnvelopes(envelopes, KMaxNumberOfMailsShown); |
47 | 297 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
298 |
|
47 | 299 |
updateLayout(count); |
300 |
//count is safe for envelopes and mMailRows |
|
301 |
for (int i = 0; i < count; i++) { |
|
302 |
mMailRows.at(i)->updateMailData(envelopes.at(i)); |
|
303 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
305 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
306 |
/*! |
47 | 307 |
Sets monitored account id from given string |
308 |
Needed for home screen framework which supports only QString type properties |
|
309 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
310 |
void NmHsWidget::setAccountId(const QString &text) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
311 |
{ |
43 | 312 |
NM_FUNCTION; |
47 | 313 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
314 |
bool ok; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
315 |
quint64 id = text.toULongLong(&ok); |
47 | 316 |
if (!ok) { |
317 |
NM_ERROR(1, "NmHsWidget::setAccountId: invalid account ID data, signal finished()!!!"); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
318 |
//No valid account id so give up |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
319 |
emit finished(); |
47 | 320 |
return; |
321 |
} |
|
322 |
||
323 |
mAccountId.setId(id); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
324 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
325 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
326 |
/*! |
47 | 327 |
Returns monitored account id as a string |
328 |
Needed for home screen framework which supports only QString type properties |
|
329 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
330 |
QString NmHsWidget::accountId() const |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
331 |
{ |
43 | 332 |
NM_FUNCTION; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
333 |
return QString::number(mAccountId.id()); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
334 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
335 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
336 |
/*! |
47 | 337 |
Sets monitored account icon name from given string |
338 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
339 |
void NmHsWidget::setAccountIconName(const QString &text) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
340 |
{ |
43 | 341 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
342 |
mAccountIconName = text; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
343 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
344 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
345 |
/*! |
47 | 346 |
Returns monitored account icon name |
347 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
348 |
QString NmHsWidget::accountIconName() const |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
349 |
{ |
43 | 350 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
351 |
return mAccountIconName; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
352 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
353 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
354 |
/*! |
47 | 355 |
Slot to handle expand/collapse trigger event |
356 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
357 |
void NmHsWidget::handleExpandCollapseEvent() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
358 |
{ |
43 | 359 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
360 |
toggleExpansionState(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
361 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
362 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
363 |
/*! |
47 | 364 |
Sets widget expand/collapse state |
365 |
/post widget expansion state is changed |
|
366 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
367 |
void NmHsWidget::toggleExpansionState() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
368 |
{ |
43 | 369 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
370 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
371 |
mIsExpanded = !mIsExpanded; |
47 | 372 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
373 |
//save new state to home screen |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
374 |
QStringList propertiesList; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
375 |
propertiesList.append("widgetState"); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
376 |
emit setPreferences(propertiesList); |
47 | 377 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
378 |
//handle state change drawing |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
379 |
updateMailData(); |
47 | 380 |
|
43 | 381 |
mTitleRow->setExpandCollapseIcon(mIsExpanded); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
382 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
383 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
384 |
/*! |
47 | 385 |
Sets expand/collapse state from given string (needed by homescreen) |
386 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
387 |
void NmHsWidget::setWidgetStateProperty(QString value) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
388 |
{ |
43 | 389 |
NM_FUNCTION; |
47 | 390 |
if (value == KNmHsWidgetStateCollapsed) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
391 |
mIsExpanded = false; |
47 | 392 |
} |
393 |
else { |
|
394 |
mIsExpanded = true; |
|
395 |
} |
|
396 |
} |
|
397 |
||
398 |
/*! |
|
399 |
Returns widget expand/collapse state as string (needed by homescreen) |
|
400 |
*/ |
|
401 |
QString NmHsWidget::widgetStateProperty() |
|
402 |
{ |
|
403 |
NM_FUNCTION; |
|
404 |
if (mIsExpanded) { |
|
405 |
return KNmHsWidgetStateExpanded; |
|
406 |
} |
|
407 |
else { |
|
408 |
return KNmHsWidgetStateCollapsed; |
|
409 |
} |
|
410 |
} |
|
411 |
||
412 |
/*! |
|
413 |
Updates mMailRows list to include KMaxNumberOfMailsShown mail row widgets |
|
414 |
/post mMailRows contains KMaxNumberOfMailsShown mailRows |
|
415 |
*/ |
|
416 |
void NmHsWidget::createMailRowsList() |
|
417 |
{ |
|
418 |
NM_FUNCTION; |
|
419 |
||
420 |
//make sure that there are as many email rows as needed |
|
421 |
while (mMailRows.count() < KMaxNumberOfMailsShown) { |
|
422 |
NmHsWidgetEmailRow *row = new NmHsWidgetEmailRow(this); |
|
423 |
if (!row->setupUI()) { |
|
424 |
NM_ERROR(1, "NmHsWidget::createMailRowsList row->setUpUI() fails"); |
|
425 |
//if setupUI fails no point to proceed |
|
426 |
emit error(); |
|
427 |
return; |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
428 |
} |
47 | 429 |
connect(row, SIGNAL(mailViewerLaunchTriggered(const NmId&)), mEngine, |
430 |
SLOT(launchMailAppMailViewer(const NmId&))); |
|
431 |
connect(mDateObserver, SIGNAL(dateTimeChanged()), row, SLOT(updateDateTime())); |
|
432 |
mMailRows.append(row); |
|
433 |
} |
|
434 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
435 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
436 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
437 |
/*! |
47 | 438 |
Updates the Layout to contain the right items |
439 |
/param mailCount defines how many emails is to be shown |
|
440 |
/post If widget is collapsed, the layout contains only titleRow widget. |
|
441 |
If widget is expanded and mailCount is 0 layout will contain |
|
442 |
titlerow & noMailsLabel. |
|
443 |
If widget is expanded and mailCount is greter |
|
444 |
than zero, layout will contain titlerow and KMaxNumberOfMailsShown times |
|
445 |
emailrow(s) |
|
446 |
*/ |
|
447 |
void NmHsWidget::updateLayout(const int mailCount) |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
448 |
{ |
43 | 449 |
NM_FUNCTION; |
49 | 450 |
|
47 | 451 |
if (mIsExpanded) { |
49 | 452 |
//set container height to content height |
453 |
qreal contentHeight = KMaxNumberOfMailsShown |
|
454 |
* mMailRows.first()->maximumHeight(); |
|
455 |
mContentContainer->setMaximumHeight(contentHeight); |
|
456 |
mContentContainer->setVisible(true); |
|
47 | 457 |
if (mailCount == 0) { |
458 |
addNoMailsLabelToLayout(); |
|
459 |
removeEmailRowsFromLayout(); |
|
460 |
} |
|
461 |
else { |
|
462 |
removeNoMailsLabelFromLayout(); |
|
463 |
addEmailRowsToLayout(); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
464 |
} |
47 | 465 |
} |
466 |
else { |
|
467 |
removeNoMailsLabelFromLayout(); |
|
468 |
removeEmailRowsFromLayout(); |
|
49 | 469 |
mContentContainer->setVisible(false); |
470 |
mContentContainer->setMaximumHeight(0); |
|
47 | 471 |
} |
472 |
||
473 |
//resize the widget to new layout size |
|
49 | 474 |
qreal totalHeight = mTitleRow->preferredHeight() + mContentContainer->maximumHeight(); |
475 |
//set maximum size, otherwise widget will stay huge also when collapsed |
|
476 |
this->setMaximumHeight(totalHeight); |
|
477 |
//resize here or widget cannot draw mail rows when expanding |
|
478 |
this->resize(mTitleRow->preferredWidth(), totalHeight); |
|
47 | 479 |
|
480 |
updateMailRowsVisibility(mailCount); |
|
481 |
} |
|
482 |
||
483 |
/*! |
|
484 |
Updates mNoMailsLabel visibility based on widget state |
|
485 |
/param mailCount defines how many mail rows is needed |
|
486 |
/post if mail count is 0 and mIsExpanded equals true, then |
|
49 | 487 |
the mNoMailLabel is added to the mContentLayout. |
47 | 488 |
*/ |
489 |
void NmHsWidget::addNoMailsLabelToLayout() |
|
490 |
{ |
|
491 |
NM_FUNCTION; |
|
49 | 492 |
|
47 | 493 |
if (mNoMailsLabel->isVisible() || mMailRows.isEmpty()) { |
494 |
return; |
|
495 |
} |
|
496 |
//Add mNoMailsLabel to layout if not yet there and show it |
|
49 | 497 |
mContentLayout->addItem(mNoMailsLabel); |
47 | 498 |
//resize the widget to new layout size |
499 |
mNoMailsLabel->show(); |
|
500 |
} |
|
501 |
||
502 |
/*! |
|
503 |
removeNoMailsLabelFromLayout removes mNoMailsLabel from the layout |
|
49 | 504 |
/post mNoMailsLabel is not in mContentLayout |
47 | 505 |
*/ |
506 |
void NmHsWidget::removeNoMailsLabelFromLayout() |
|
507 |
{ |
|
508 |
NM_FUNCTION; |
|
509 |
//remove mNoMailsLabel from Layout and hide it |
|
49 | 510 |
mContentLayout->removeItem(mNoMailsLabel); |
47 | 511 |
mNoMailsLabel->hide(); |
512 |
} |
|
513 |
||
514 |
/*! |
|
515 |
addEmailRowsToLayout adds every emailrow to the layout |
|
49 | 516 |
/post all elements in mMailRows are added to mContentLayout |
47 | 517 |
*/ |
518 |
void NmHsWidget::addEmailRowsToLayout() |
|
519 |
{ |
|
520 |
NM_FUNCTION; |
|
521 |
foreach(NmHsWidgetEmailRow *row, mMailRows) |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
522 |
{ |
49 | 523 |
mContentLayout->addItem(row); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
524 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
525 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
526 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
527 |
/*! |
47 | 528 |
removeEmailRowsFromLayout removes every emailrow from the layout |
49 | 529 |
/post none of the elements in mMailRows are in mContentLayout |
47 | 530 |
*/ |
531 |
void NmHsWidget::removeEmailRowsFromLayout() |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
{ |
43 | 533 |
NM_FUNCTION; |
47 | 534 |
foreach(NmHsWidgetEmailRow *row, mMailRows) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
{ |
49 | 536 |
mContentLayout->removeItem(row); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
537 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
538 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
539 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
540 |
/*! |
47 | 541 |
Updates mail row visibilities in static widget |
542 |
/param visibleCount defines how many items do have mail data |
|
543 |
/post all row items having mail data are visible, other rows are hidden |
|
544 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
545 |
void NmHsWidget::updateMailRowsVisibility(const int visibleCount) |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
546 |
{ |
43 | 547 |
NM_FUNCTION; |
47 | 548 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
549 |
// set visible as many rows as requested by visibleCount param |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
550 |
bool isVisible; |
47 | 551 |
|
552 |
for (int i = 0; i < mMailRows.count(); i++) { |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
553 |
isVisible = false; |
47 | 554 |
if ((mIsExpanded) && (i < visibleCount)) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
555 |
isVisible = true; |
47 | 556 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
557 |
mMailRows.at(i)->setVisible(isVisible); |
47 | 558 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
559 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
560 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
561 |
/*! |
47 | 562 |
onEngineException (NmHsWidgetEmailEngineExceptionCode exc) |
563 |
signals widget to be finalized |
|
564 |
/param exc exception type |
|
565 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
566 |
void NmHsWidget::onEngineException(const int& exc) |
47 | 567 |
{ |
43 | 568 |
NM_FUNCTION; |
47 | 569 |
switch (exc) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
570 |
case (NmEngineExcAccountDeleted): |
47 | 571 |
emit finished(); //succesful ending |
572 |
break; |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
573 |
case (NmEngineExcFailure): |
47 | 574 |
emit error(); //failure |
575 |
break; |
|
576 |
default: |
|
577 |
break; |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
578 |
} |
47 | 579 |
} |