equal
deleted
inserted
replaced
23 static const int PROGRESSBAR_MIN = 0; |
23 static const int PROGRESSBAR_MIN = 0; |
24 static const int PROGRESSBAR_MAX = 100; |
24 static const int PROGRESSBAR_MAX = 100; |
25 static const int PROGRESSBAR_HIDE_COUNTDOWN = 500; |
25 static const int PROGRESSBAR_HIDE_COUNTDOWN = 500; |
26 static const int LONGPRESS_TIMER = 2000; |
26 static const int LONGPRESS_TIMER = 2000; |
27 |
27 |
|
28 // Hardcoded file size length. Maximum (999.9 Mb) fits into size field. |
|
29 static const int FILE_SIZE_FIELD_LENGTH = 120; |
28 |
30 |
29 /*! |
31 /*! |
30 @nmailuiwidgets |
32 @nmailuiwidgets |
31 \class NmAttachmentListItem |
33 \class NmAttachmentListItem |
32 |
34 |
96 if (mFileSizeText){ |
98 if (mFileSizeText){ |
97 if (mTextColor.isValid()){ |
99 if (mTextColor.isValid()){ |
98 mFileSizeText->setTextColor(mTextColor); |
100 mFileSizeText->setTextColor(mTextColor); |
99 } |
101 } |
100 mFileSizeText->setTextWrapping(Hb::TextNoWrap); |
102 mFileSizeText->setTextWrapping(Hb::TextNoWrap); |
101 mFileSizeText->setText(fileSize); |
103 mFileSizeText->setText(fileSize); |
102 } |
104 } |
|
105 } |
|
106 |
|
107 /*! |
|
108 Set the length of the filename field. |
|
109 */ |
|
110 void NmAttachmentListItem::resetFileNameLength(Qt::Orientation orientation) |
|
111 { |
|
112 QSizeF reso = screenSize(orientation); |
|
113 |
|
114 if (orientation == Qt::Horizontal) { |
|
115 mFileNameText->setPreferredWidth(reso.width() / 2 - FILE_SIZE_FIELD_LENGTH); |
|
116 } |
|
117 else { |
|
118 mFileNameText->setPreferredWidth(reso.width() - FILE_SIZE_FIELD_LENGTH); |
|
119 } |
103 } |
120 } |
104 |
121 |
105 /*! |
122 /*! |
106 Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden |
123 Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden |
107 */ |
124 */ |
112 removeProgressBar(); |
129 removeProgressBar(); |
113 return; |
130 return; |
114 } |
131 } |
115 |
132 |
116 if ( !mProgressBar ){ |
133 if ( !mProgressBar ){ |
117 mProgressBar = new HbProgressBar(HbProgressBar::SimpleProgressBar, this); |
134 mProgressBar = new HbProgressBar(this); |
118 mProgressBar->setObjectName("attachmentlistitem_progress"); |
135 mProgressBar->setObjectName("attachmentlistitem_progress"); |
119 mProgressBar->setRange(PROGRESSBAR_MIN,PROGRESSBAR_MAX); |
136 mProgressBar->setRange(PROGRESSBAR_MIN,PROGRESSBAR_MAX); |
120 HbStyle::setItemName( mProgressBar, "progressbar" ); |
137 HbStyle::setItemName( mProgressBar, "progressbar" ); |
121 repolish(); |
138 repolish(); |
122 } |
139 } |
123 mProgressBar->setProgressValue(value); |
140 mProgressBar->setProgressValue(value); |
124 |
141 |
125 //start hiding count down |
142 //start hiding count down |
126 if(PROGRESSBAR_MAX <= value){ |
143 if(PROGRESSBAR_MAX <= value){ |
127 QTimer::singleShot(PROGRESSBAR_HIDE_COUNTDOWN,this, SLOT(removeProgressBar())); |
144 hideProgressBar(); |
128 } |
145 } |
129 } |
146 } |
130 |
147 |
131 /*! |
148 /*! |
132 Get the download progress bar value |
149 Get the download progress bar value |
140 |
157 |
141 return ret; |
158 return ret; |
142 } |
159 } |
143 |
160 |
144 /*! |
161 /*! |
|
162 Hides progress bar, used if download is cancelled before 100 precent is reached |
|
163 */ |
|
164 void NmAttachmentListItem::hideProgressBar() |
|
165 { |
|
166 QTimer::singleShot(PROGRESSBAR_HIDE_COUNTDOWN,this, SLOT(removeProgressBar())); |
|
167 } |
|
168 |
|
169 /*! |
145 Initialize |
170 Initialize |
146 */ |
171 */ |
147 void NmAttachmentListItem::init( ) |
172 void NmAttachmentListItem::init( ) |
148 { |
173 { |
149 constructUi(); |
174 constructUi(); |
152 setFlag(QGraphicsItem::ItemIsFocusable); |
177 setFlag(QGraphicsItem::ItemIsFocusable); |
153 setFlag(QGraphicsItem::ItemIsSelectable); |
178 setFlag(QGraphicsItem::ItemIsSelectable); |
154 |
179 |
155 //set temporary longpress timer |
180 //set temporary longpress timer |
156 mTimer = new QTimer(this); |
181 mTimer = new QTimer(this); |
|
182 mTimer->setSingleShot(true); |
157 connect(mTimer, SIGNAL(timeout()), this, SLOT(longPressedActivated())); |
183 connect(mTimer, SIGNAL(timeout()), this, SLOT(longPressedActivated())); |
158 } |
184 } |
159 |
185 |
160 /*! |
186 /*! |
161 Constructs the UI, sets style itemnames etc. |
187 Constructs the UI, sets style itemnames etc. |
167 HbStyleLoader::registerFilePath(FILE_PATH_CSS); |
193 HbStyleLoader::registerFilePath(FILE_PATH_CSS); |
168 |
194 |
169 mFileNameText = new HbTextItem(this); |
195 mFileNameText = new HbTextItem(this); |
170 mFileNameText->setObjectName("nmattachmentlistitem_filenametext"); |
196 mFileNameText->setObjectName("nmattachmentlistitem_filenametext"); |
171 HbStyle::setItemName( mFileNameText, "filename" ); |
197 HbStyle::setItemName( mFileNameText, "filename" ); |
|
198 mFileNameText->setElideMode(Qt::ElideRight); |
172 |
199 |
173 mFileSizeText = new HbTextItem(this); |
200 mFileSizeText = new HbTextItem(this); |
174 mFileSizeText->setObjectName("nmattachmentlistitem_filenamesize"); |
201 mFileSizeText->setObjectName("nmattachmentlistitem_filenamesize"); |
175 HbStyle::setItemName( mFileSizeText, "filesize" ); |
202 HbStyle::setItemName( mFileSizeText, "filesize" ); |
176 mFileSizeText->setElideMode(Qt::ElideNone); |
203 mFileSizeText->setElideMode(Qt::ElideNone); |
177 |
|
178 } |
204 } |
179 |
205 |
180 |
206 |
181 /*! |
207 /*! |
182 \reimp |
208 \reimp |
230 emit itemLongPressed(mLongPressedPoint); |
256 emit itemLongPressed(mLongPressedPoint); |
231 mButtonPressed = false; |
257 mButtonPressed = false; |
232 } |
258 } |
233 } |
259 } |
234 |
260 |
|
261 /*! |
|
262 This function returns screen size depending on the orientation. |
|
263 Function is copied from NmApplication. |
|
264 */ |
|
265 QSize NmAttachmentListItem::screenSize(Qt::Orientation orientation) |
|
266 { |
|
267 QSize ret(0,0); |
|
268 HbDeviceProfile currentP = HbDeviceProfile::current(); |
|
269 HbDeviceProfile altP(currentP.alternateProfileName()); |
|
270 QSize curPSize = currentP.logicalSize(); |
|
271 QSize altPSize = altP.logicalSize(); |
|
272 if (orientation == Qt::Horizontal) { |
|
273 // Get wide profile size in landscape |
|
274 if (curPSize.width() > altPSize.width()) { |
|
275 ret = curPSize; |
|
276 } |
|
277 else{ |
|
278 ret = altPSize; |
|
279 } |
|
280 } |
|
281 else { |
|
282 // Get narrow profile size in portrait |
|
283 if (curPSize.width() < altPSize.width()) { |
|
284 ret = curPSize; |
|
285 } |
|
286 else{ |
|
287 ret = altPSize; |
|
288 } |
|
289 } |
|
290 return ret; |
|
291 } |
|
292 |