author | hgs |
Fri, 03 Sep 2010 14:07:42 +0300 | |
changeset 66 | 084b5b1f02a7 |
parent 62 | a8c646b56683 |
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: Attachment list item widget |
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 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "nmailuiwidgetsheaders.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
static const QString FILE_PATH_WIDGETML = ":nmattachmentlistitem.widgetml"; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
static const QString FILE_PATH_CSS = ":nmattachmentlistitem.css"; |
62 | 22 |
static const QString LIST_ITEM_BG_FRAME_NORMAL ("qtg_fr_list_normal"); |
23 |
static const QString LIST_ITEM_BG_FRAME_PRESSED("qtg_fr_list_pressed"); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
static const int PROGRESSBAR_MIN = 0; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
static const int PROGRESSBAR_MAX = 100; |
66 | 27 |
static const int PROGRESSBAR_HIDE_COUNTDOWN = 500; // Milliseconds |
28 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
/*! |
66 | 31 |
@nmailuiwidgets |
32 |
||
33 |
\class NmAttachmentListItem |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
66 | 35 |
\brief NmAttachmentListItem is a widget used for displaying a single |
36 |
attachment with the attachment file size and download progress in |
|
37 |
the attachment list. |
|
38 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
Constructs a new NmAttachmentListItem with \a parent. |
66 | 43 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
NmAttachmentListItem::NmAttachmentListItem(QGraphicsItem *parent) |
66 | 45 |
: HbWidget( parent ), |
46 |
mFileNameText(NULL), |
|
47 |
mFileSizeText(NULL), |
|
48 |
mProgressBar(NULL), |
|
49 |
mBackground(NULL) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
{ |
43 | 51 |
NM_FUNCTION; |
66 | 52 |
|
53 |
init(); |
|
43 | 54 |
|
55 |
// Informs GestureFramework that NmAttachmentListItem widget is interested |
|
66 | 56 |
// in Tap and TapAndHold gestures. |
43 | 57 |
grabGesture(Qt::TapGesture); |
62 | 58 |
HbEffect::add("mailAttachmentWidget", "listviewitem_press", "pressed"); |
59 |
HbEffect::add("mailAttachmentWidget", "listviewitem_release", "released"); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
Destructor. |
66 | 65 |
*/ |
66 |
NmAttachmentListItem::~NmAttachmentListItem() |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
{ |
43 | 68 |
NM_FUNCTION; |
69 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
HbStyleLoader::unregisterFilePath(FILE_PATH_CSS); |
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 |
|
66 | 74 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
/*! |
66 | 76 |
Setter for items text color override. This method can be used if the theme |
77 |
background is not used and text needs to be shown with a different color. |
|
78 |
||
79 |
\param color The new test color. |
|
80 |
*/ |
|
81 |
void NmAttachmentListItem::setTextColor(const QColor color) |
|
82 |
{ |
|
83 |
NM_FUNCTION; |
|
84 |
||
85 |
mTextColor = color; |
|
86 |
||
87 |
if (mTextColor.isValid() && mFileNameText) { |
|
88 |
mFileNameText->setTextColor(mTextColor); |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
||
93 |
/*! |
|
94 |
Sets the background color. This method can be used to override the |
|
95 |
default background color set by the current theme. Because of the effect, |
|
96 |
the implementation "smoke and mirrors" but it works. |
|
97 |
||
98 |
\param color The new background color. |
|
99 |
*/ |
|
100 |
void NmAttachmentListItem::setBackgroundColor(const QColor color) |
|
101 |
{ |
|
102 |
NM_FUNCTION; |
|
103 |
||
104 |
if (!color.isValid()) { |
|
105 |
// Invalid color! |
|
106 |
return; |
|
107 |
} |
|
108 |
||
109 |
mBackgroundColor = color; |
|
110 |
||
111 |
// The effect color is the opposite color of the background color. |
|
112 |
QColor effectColor(qAbs(color.red() - 255), |
|
113 |
qAbs(color.green() - 255), |
|
114 |
qAbs(color.blue() - 255)); |
|
115 |
||
116 |
QPalette palette = QApplication::palette(); |
|
117 |
QBrush brush(effectColor); |
|
118 |
palette.setBrush(QPalette::Window, effectColor); |
|
119 |
setPalette(palette); |
|
120 |
setAutoFillBackground(true); |
|
121 |
||
122 |
if (mBackground) { |
|
123 |
// Set the background color for the background item. |
|
124 |
brush.setColor(mBackgroundColor); |
|
125 |
palette.setBrush(QPalette::Window, brush); |
|
126 |
mBackground->setPalette(palette); |
|
127 |
mBackground->setAutoFillBackground(true); |
|
128 |
mBackground->frameDrawer().setFrameType(HbFrameDrawer::OnePiece); |
|
129 |
} |
|
130 |
||
131 |
repolish(); |
|
132 |
} |
|
133 |
||
134 |
||
135 |
/*! |
|
136 |
Sets the text to be displayed in the file name item. |
|
137 |
||
138 |
\param filename The filename. |
|
139 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
140 |
void NmAttachmentListItem::setFileNameText(const QString &fileName) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
{ |
43 | 142 |
NM_FUNCTION; |
143 |
||
66 | 144 |
if (mFileNameText) { |
145 |
if (mTextColor.isValid()) { |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
mFileNameText->setTextColor(mTextColor); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
147 |
} |
66 | 148 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
149 |
mFileNameText->setTextWrapping(Hb::TextNoWrap); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
150 |
mFileNameText->setText(fileName); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
151 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
|
66 | 154 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
155 |
/*! |
66 | 156 |
Sets the value of the text for displaying the attachment file size. |
157 |
||
158 |
\param fileSize The file size as a string. |
|
159 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
160 |
void NmAttachmentListItem::setFileSizeText(const QString &fileSize) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
161 |
{ |
43 | 162 |
NM_FUNCTION; |
163 |
||
66 | 164 |
if (mFileSizeText) { |
165 |
if (mTextColor.isValid()) { |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
166 |
mFileSizeText->setTextColor(mTextColor); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
167 |
} |
66 | 168 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
169 |
mFileSizeText->setTextWrapping(Hb::TextNoWrap); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
170 |
mFileSizeText->setText(fileSize); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
171 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
172 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
173 |
|
66 | 174 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
175 |
/*! |
66 | 176 |
Set the download progress bar value (0 - 100 %). If the given value is 0, |
177 |
the progress bar is hidden. |
|
178 |
||
179 |
\param value The progress bar value. |
|
180 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
181 |
void NmAttachmentListItem::setProgressBarValue(const int value) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
{ |
43 | 183 |
NM_FUNCTION; |
184 |
||
66 | 185 |
// First check if the value is 0 or below -> hide progressbar. |
186 |
if (0 >= value) { |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
removeProgressBar(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
return; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
189 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
|
66 | 191 |
if (!mProgressBar) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
192 |
mProgressBar = new HbProgressBar(this); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
193 |
mProgressBar->setObjectName("attachmentlistitem_progress"); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
mProgressBar->setRange(PROGRESSBAR_MIN,PROGRESSBAR_MAX); |
66 | 195 |
HbStyle::setItemName(mProgressBar, "progressbar"); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
repolish(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
} |
66 | 198 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
mProgressBar->setProgressValue(value); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
200 |
|
66 | 201 |
// Start hiding the count down. |
202 |
if (PROGRESSBAR_MAX <= value){ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
203 |
hideProgressBar(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
|
66 | 207 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
208 |
/*! |
66 | 209 |
\return The value of the download progress bar. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
210 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
int NmAttachmentListItem::progressBarValue() const |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
212 |
{ |
43 | 213 |
NM_FUNCTION; |
214 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
215 |
int ret = 0; |
66 | 216 |
|
217 |
if (mProgressBar) { |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
218 |
ret = mProgressBar->progressValue(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
219 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
220 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
221 |
return ret; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
223 |
|
66 | 224 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
225 |
/*! |
66 | 226 |
Hides the progress bar. Used if the download is cancelled before 100 |
227 |
percent is reached. |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
228 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
229 |
void NmAttachmentListItem::hideProgressBar() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
230 |
{ |
43 | 231 |
NM_FUNCTION; |
232 |
||
66 | 233 |
QTimer::singleShot(PROGRESSBAR_HIDE_COUNTDOWN, this, SLOT(removeProgressBar())); |
234 |
} |
|
235 |
||
236 |
||
237 |
/*! |
|
238 |
Displays a visual effect according to the current pressed state. |
|
239 |
||
240 |
\param pressed True, if the item was pressed. |
|
241 |
*/ |
|
242 |
void NmAttachmentListItem::setPressed(bool pressed) |
|
243 |
{ |
|
244 |
if (pressed) { |
|
245 |
setProperty("state", "pressed"); |
|
246 |
mBackground->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_PRESSED); |
|
247 |
HbEffect::cancel(mBackground, "released"); |
|
248 |
HbEffect::start(mBackground, "mailAttachmentWidget", "pressed"); |
|
249 |
} |
|
250 |
else { |
|
251 |
setProperty("state", "normal"); |
|
252 |
mBackground->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_NORMAL); |
|
253 |
HbEffect::cancel(mBackground, "pressed"); |
|
254 |
HbEffect::start(mBackground, "mailAttachmentWidget", "released"); |
|
255 |
} |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
256 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
257 |
|
66 | 258 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
259 |
/*! |
66 | 260 |
Handles the given gesture event. |
261 |
||
262 |
\param event The event to handle. |
|
263 |
*/ |
|
264 |
void NmAttachmentListItem::gestureEvent(QGestureEvent *event) |
|
265 |
{ |
|
266 |
NM_FUNCTION; |
|
267 |
||
268 |
if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
|
269 |
switch (tap->tapStyleHint()) { |
|
270 |
case HbTapGesture::Tap: { |
|
271 |
Qt::GestureState state = tap->state(); |
|
272 |
HbInstantFeedback::play(HbFeedback::Basic); |
|
273 |
setPressed(true); |
|
274 |
||
275 |
if (state == Qt::GestureFinished) { |
|
276 |
emit itemActivated(); |
|
277 |
setPressed(false); |
|
278 |
} |
|
279 |
else if (state == Qt::GestureCanceled) { |
|
280 |
setPressed(false); |
|
281 |
} |
|
282 |
||
283 |
break; |
|
284 |
} |
|
285 |
case HbTapGesture::TapAndHold: { |
|
286 |
emit itemLongPressed(event->mapToGraphicsScene(tap->position())); |
|
287 |
setPressed(false); |
|
288 |
break; |
|
289 |
} |
|
290 |
} // switch |
|
291 |
} |
|
292 |
else { |
|
293 |
// Let the HbWidget handle the event. |
|
294 |
HbWidget::gestureEvent(event); |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
||
299 |
/*! |
|
300 |
Hides and deletes the download progress bar. |
|
301 |
*/ |
|
302 |
void NmAttachmentListItem::removeProgressBar() |
|
303 |
{ |
|
304 |
NM_FUNCTION; |
|
305 |
||
306 |
if (mProgressBar) { |
|
307 |
HbStyle::setItemName(mProgressBar, ""); |
|
308 |
mProgressBar->deleteLater(); |
|
309 |
mProgressBar = 0; |
|
310 |
repolish(); |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
||
315 |
/*! |
|
316 |
Initializes the widget. |
|
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 |
void NmAttachmentListItem::init( ) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
{ |
43 | 320 |
NM_FUNCTION; |
321 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
322 |
constructUi(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
323 |
|
66 | 324 |
// Set the default flag values. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
setFlag(QGraphicsItem::ItemIsFocusable); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
setFlag(QGraphicsItem::ItemIsSelectable); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
327 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
|
66 | 329 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
330 |
/*! |
66 | 331 |
Constructs the UI, sets style item names etc. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
333 |
void NmAttachmentListItem::constructUi() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
{ |
43 | 335 |
NM_FUNCTION; |
336 |
||
66 | 337 |
// Background |
338 |
QScopedPointer<HbFrameItem> background(new HbFrameItem(this)); |
|
339 |
background->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_NORMAL); |
|
340 |
background->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
341 |
setBackgroundItem(background.data()); |
|
342 |
||
343 |
// The ownership was transferred to the base class. |
|
344 |
mBackground = background.take(); |
|
62 | 345 |
|
66 | 346 |
// Construct the default UI. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
HbStyleLoader::registerFilePath(FILE_PATH_CSS); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
349 |
|
62 | 350 |
QScopedPointer<HbTextItem> fileNameText(new HbTextItem(this)); |
351 |
fileNameText->setObjectName("nmattachmentlistitem_filenametext"); |
|
66 | 352 |
HbStyle::setItemName(fileNameText.data(), "filename"); |
62 | 353 |
fileNameText->setElideMode(Qt::ElideRight); |
354 |
||
355 |
QScopedPointer<HbTextItem> fileSizeText(new HbTextItem(this)); |
|
356 |
fileSizeText->setObjectName("nmattachmentlistitem_filenamesize"); |
|
66 | 357 |
HbStyle::setItemName(fileSizeText.data(), "filesize"); |
62 | 358 |
fileSizeText->setElideMode(Qt::ElideNone); |
359 |
||
66 | 360 |
// The ownership was transferred to this instance. |
62 | 361 |
mFileSizeText = fileSizeText.take(); |
362 |
mFileNameText = fileNameText.take(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
363 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
364 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
365 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
366 |
|
66 | 367 |
// End of file. |