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