|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
19 |
|
20 |
|
21 #include <QModelIndex> |
|
22 #include <qdatetime.h> |
|
23 #include <QDebug> |
|
24 #include <HbAnchorLayout.h> |
|
25 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
26 |
|
27 #include <hblabel.h> |
|
28 #include <hbdataform.h> |
|
29 #include <hbinstance.h> |
|
30 #include <hbiconitem.h> |
|
31 #include <hbframeitem.h> |
|
32 #include <hbpushbutton.h> |
|
33 #include <hbdataformmodel.h> |
|
34 #include <hbdocumentloader.h> |
|
35 #include <hbdataformmodelitem.h> |
|
36 #include <hbdataformviewitem.h> |
|
37 #include <hbparameterlengthlimiter.h> |
|
38 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
39 #include "glxviewids.h" |
|
40 #include "glxicondefs.h" //Contains the icon names/Ids |
|
41 #include "glxmodelparm.h" |
|
42 #include "glxmediamodel.h" |
|
43 #include "glxdetailsview.h" |
|
44 #include "glxfavmediamodel.h" |
|
45 #include "glxdocloaderdefs.h" |
|
46 #include <glxcommandhandlers.hrh> |
|
47 #include "glxlocalisationstrings.h" |
|
48 #include "glxdetailstextedit.h" |
|
49 #include "glxdetailsicon.h" |
|
50 |
|
51 |
|
52 #include "glxviewdocloader.h" |
|
53 #include <glxcollectionpluginalbums.hrh> |
|
54 |
|
55 #include "glxlog.h" |
|
56 #include "glxloggerenabler.h" |
|
57 |
|
58 |
|
59 #include "OstTraceDefinitions.h" |
|
60 #ifdef OST_TRACE_COMPILER_IN_USE |
|
61 #include "glxdetailsviewTraces.h" |
|
62 #endif |
|
63 |
|
64 //SIZE OF THE IMAGE , LAYOUTS TEAM NEED TO GIVER THE SIZE IN UNITS |
|
65 #define GLX_IMAGE_WIDTH 333 |
|
66 #define GLX_IMAGE_HEIGHT 215 |
|
67 const int KBytesInKB = 1024; |
|
68 const int KBytesInMB = 1024 * 1024; |
|
69 const int KBytesInGB = 1024 * 1024 * 1024; |
|
70 |
|
71 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
72 //GlxDetailsView |
|
73 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
74 GlxDetailsView::GlxDetailsView(HbMainWindow *window) |
|
75 : GlxView( GLX_DETAILSVIEW_ID ), |
|
76 mDetailsIcon( NULL ), |
|
77 mFavIcon( NULL ), |
|
78 mModel( NULL ), |
|
79 mFavModel( NULL ), |
|
80 mWindow( window ), |
|
81 mSelIndex( 0 ), |
|
82 mDocLoader( NULL ), |
|
83 mImageName( NULL ), |
|
84 mDescriptions( NULL ), |
|
85 mDateLabel( NULL ), |
|
86 mSizeLabel( NULL ), |
|
87 mTimeLabel( NULL ) |
|
88 { |
|
89 GLX_LOG_INFO("GlxDetailsView::GlxDetailsView"); |
|
90 OstTraceFunctionEntry0( GLXDETAILSVIEW_GLXDETAILSVIEW_ENTRY ); |
|
91 setContentFullScreen(true);//for smooth transtion between grid to full screen and vice versa |
|
92 OstTraceFunctionExit0( GLXDETAILSVIEW_GLXDETAILSVIEW_EXIT ); |
|
93 } |
|
94 |
|
95 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
96 //~GlxDetailsView |
|
97 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
98 GlxDetailsView::~GlxDetailsView() |
|
99 { |
|
100 OstTrace0( TRACE_IMPORTANT, GLXDETAILSVIEW_GLXDETAILSVIEW, "GlxDetailsView::~GlxDetailsView" ); |
|
101 |
|
102 delete mDocLoader; |
|
103 mDocLoader = NULL; |
|
104 |
|
105 cleanUp(); |
|
106 } |
|
107 |
|
108 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
109 //activate |
|
110 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
111 void GlxDetailsView::activate() |
|
112 { |
|
113 OstTraceFunctionEntry0( GLXDETAILSVIEW_ACTIVATE_ENTRY ); |
|
114 //create and set the Favourite Model |
|
115 if(getSubState() != IMAGEVIEWER_DETAIL_S) { |
|
116 setFavModel(); |
|
117 } |
|
118 |
|
119 //fill the data |
|
120 FillDetails(); |
|
121 |
|
122 //Initialze the Model |
|
123 initializeNewModel(); |
|
124 |
|
125 //make the connections |
|
126 setConnections(); |
|
127 |
|
128 //Set context mode to fetch descriptions |
|
129 mModel->setData(QModelIndex(), (int) GlxContextComment, GlxContextRole); |
|
130 |
|
131 OstTraceFunctionExit0( GLXDETAILSVIEW_ACTIVATE_EXIT ); |
|
132 } |
|
133 |
|
134 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
135 //initializeView |
|
136 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
137 void GlxDetailsView::initializeView( QAbstractItemModel *model, GlxView *preView) |
|
138 { |
|
139 Q_UNUSED( preView ) |
|
140 OstTraceFunctionEntry0( GLXDETAILSVIEW_INITIALIZEVIEW_ENTRY ); |
|
141 bool loaded = false; |
|
142 |
|
143 if(!mDocLoader) |
|
144 { |
|
145 mDocLoader = new GlxDetailsViewDocLoader(); |
|
146 } |
|
147 |
|
148 //Load the docml |
|
149 mDocLoader->load(GLX_DETAILSVIEW_DOCMLPATH, &loaded); |
|
150 |
|
151 HbView *mView = static_cast<HbView*> (mDocLoader->findWidget( |
|
152 GLX_DETAILSVIEW_VIEW)); |
|
153 |
|
154 mDetailsIcon = static_cast<HbLabel*> (mDocLoader->findWidget( |
|
155 GLX_DETAILSVIEW_IMAGE)); |
|
156 mFavIcon = static_cast<GlxDetailsIcon*> (mDocLoader->findWidget( |
|
157 GLX_DETAILSVIEW_FAVICON)); |
|
158 |
|
159 |
|
160 mDescriptions = static_cast<GlxDetailsTextEdit*> (mDocLoader->findWidget( |
|
161 GLX_DETAILSVIEW_DESCRPTIONTEXT)); |
|
162 |
|
163 mImageName = static_cast<GlxDetailsTextEdit*> (mDocLoader->findWidget( |
|
164 GLX_DETAILSVIEW_IMGNAME)); |
|
165 |
|
166 mDateLabel = static_cast<HbLabel*> (mDocLoader->findWidget( |
|
167 GLX_DETAILSVIEW_DATETEXT)); |
|
168 |
|
169 mTimeLabel = static_cast<HbLabel*> (mDocLoader->findWidget( |
|
170 GLX_DETAILSVIEW_TIMETEXT)); |
|
171 |
|
172 mSizeLabel = static_cast<HbLabel*> (mDocLoader->findWidget( |
|
173 GLX_DETAILSVIEW_SIZETEXT)); |
|
174 |
|
175 mFavIconEnabled = HbIcon(GLXICON_ADD_TO_FAV); |
|
176 mFavIconDisabled = HbIcon(GLXICON_REMOVE_FAV); |
|
177 |
|
178 //Set the Model |
|
179 mModel = model; |
|
180 if(getSubState() == IMAGEVIEWER_DETAIL_S) { |
|
181 mFavIcon->hide(); |
|
182 } |
|
183 else |
|
184 { |
|
185 mFavIcon->setItemIcon(HbIcon(GLXICON_REMOVE_FAV)); |
|
186 } |
|
187 |
|
188 setWidget(mView); |
|
189 |
|
190 //Set the Layout Correspondingly. |
|
191 updateLayout(mWindow->orientation()); |
|
192 |
|
193 OstTraceFunctionExit0( GLXDETAILSVIEW_INITIALIZEVIEW_EXIT ); |
|
194 } |
|
195 |
|
196 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
197 //resetView |
|
198 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
199 void GlxDetailsView::resetView() |
|
200 { |
|
201 GLX_LOG_INFO("GlxDetailsView::resetView"); |
|
202 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_RESETVIEW, "GlxDetailsView::resetView" ); |
|
203 } |
|
204 |
|
205 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
206 //deActivate |
|
207 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
208 void GlxDetailsView::deActivate() |
|
209 { |
|
210 GLX_LOG_INFO("GlxDetailsView::deActivate"); |
|
211 OstTraceFunctionEntry0( GLXDETAILSVIEW_DEACTIVATE_ENTRY ); |
|
212 |
|
213 //Remove the context created to update details |
|
214 mModel->setData(QModelIndex(), (int) GlxContextComment, |
|
215 GlxRemoveContextRole); |
|
216 cleanUp(); |
|
217 |
|
218 OstTraceFunctionExit0( GLXDETAILSVIEW_DEACTIVATE_EXIT ); |
|
219 } |
|
220 |
|
221 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
222 //cleanUp |
|
223 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
224 void GlxDetailsView::cleanUp() |
|
225 { |
|
226 qDebug("GlxDetailsView::cleanUp Enter"); |
|
227 //clear the connections |
|
228 clearConnections(); |
|
229 |
|
230 clearCurrentModel(); |
|
231 |
|
232 delete mFavModel; |
|
233 mFavModel = NULL; |
|
234 |
|
235 delete mFavIcon; |
|
236 mFavIcon = NULL; |
|
237 |
|
238 delete mDetailsIcon; |
|
239 mDetailsIcon = NULL; |
|
240 } |
|
241 |
|
242 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
243 //setModel |
|
244 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
245 void GlxDetailsView::setModel(QAbstractItemModel *model) |
|
246 { |
|
247 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETMODEL, "GlxDetailsView::setModel" ); |
|
248 if (mModel == model) |
|
249 { |
|
250 return; |
|
251 } |
|
252 clearCurrentModel(); |
|
253 mModel = model; |
|
254 initializeNewModel(); |
|
255 } |
|
256 |
|
257 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
258 //setFavModel |
|
259 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
260 void GlxDetailsView::setFavModel() |
|
261 { |
|
262 GlxModelParm modelParm; |
|
263 QString imagePath = (mModel->data(mModel->index(mModel->data( |
|
264 mModel->index(0, 0), GlxFocusIndexRole).value<int> (), 0), |
|
265 GlxUriRole)).value<QString> (); |
|
266 |
|
267 if (mFavModel == NULL) { |
|
268 modelParm.setCollection(KGlxCollectionPluginFavoritesAlbumId); |
|
269 modelParm.setContextMode(GlxContextFavorite); |
|
270 modelParm.setPath(imagePath); |
|
271 mFavModel = new GlxFavMediaModel(modelParm); |
|
272 } |
|
273 } |
|
274 |
|
275 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
276 //initializeNewModel |
|
277 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
278 void GlxDetailsView::initializeNewModel() |
|
279 { |
|
280 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_INITIALIZENEWMODEL, "GlxDetailsView::initializeNewModel" ); |
|
281 |
|
282 if (mModel) { |
|
283 connect( mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
|
284 connect( mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() )); |
|
285 connect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) ); |
|
286 } |
|
287 } |
|
288 |
|
289 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
290 //clearCurrentModel |
|
291 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
292 void GlxDetailsView::clearCurrentModel() |
|
293 { |
|
294 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_CLEARCURRENTMODEL, "GlxDetailsView::clearCurrentModel" ); |
|
295 |
|
296 if (mModel) { |
|
297 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
|
298 disconnect(mModel, SIGNAL( updateDetailsView() ), this, SLOT( FillDetails() )); |
|
299 disconnect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) ); |
|
300 mModel = NULL; |
|
301 } |
|
302 } |
|
303 |
|
304 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
305 //setConnections |
|
306 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
307 void GlxDetailsView::setConnections() |
|
308 { |
|
309 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, |
|
310 SLOT(updateLayout(Qt::Orientation))); |
|
311 |
|
312 if(getSubState() != IMAGEVIEWER_DETAIL_S) { |
|
313 connect(mFavIcon, SIGNAL(updateFavourites()), this, SLOT(updateFavourites())); |
|
314 |
|
315 connect(mDescriptions, SIGNAL(labelPressed()), this, |
|
316 SLOT(UpdateDescription())); |
|
317 |
|
318 connect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), |
|
319 this, SLOT( dataChanged(QModelIndex,QModelIndex) )); |
|
320 } |
|
321 } |
|
322 |
|
323 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
324 //clearConnections |
|
325 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
326 void GlxDetailsView::clearConnections() |
|
327 { |
|
328 |
|
329 qDebug("GlxDetailsView:: clearConnections"); |
|
330 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, |
|
331 SLOT(updateLayout(Qt::Orientation))); |
|
332 |
|
333 if(mModel && getSubState() != IMAGEVIEWER_DETAIL_S) { |
|
334 disconnect(mFavIcon, SIGNAL(updateFavourites()), this, SLOT(updateFavourites())); |
|
335 disconnect(mDescriptions, SIGNAL(labelPressed()), this, |
|
336 SLOT(UpdateDescription())); |
|
337 disconnect(mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), |
|
338 this, SLOT( dataChanged(QModelIndex,QModelIndex) )); |
|
339 } |
|
340 } |
|
341 |
|
342 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
343 //getAnimationItem |
|
344 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
345 QGraphicsItem * GlxDetailsView::getAnimationItem(GlxEffect transtionEffect) |
|
346 { |
|
347 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_GETANIMATIONITEM, "GlxDetailsView::getAnimationItem" ); |
|
348 if (transtionEffect == FULLSCREEN_TO_DETAIL || transtionEffect |
|
349 == DETAIL_TO_FULLSCREEN) |
|
350 { |
|
351 return this; |
|
352 } |
|
353 return NULL; |
|
354 } |
|
355 |
|
356 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
357 //updateLayout |
|
358 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
359 void GlxDetailsView::updateLayout(Qt::Orientation orient) |
|
360 { |
|
361 OstTrace1( TRACE_NORMAL, GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout;orient=%d", orient ); |
|
362 GLX_LOG_INFO("GlxDetailsView::updateLayout "); |
|
363 bool loaded = false; |
|
364 QString section; |
|
365 |
|
366 //Load the widgets accroding to the current Orientation |
|
367 if (orient == Qt::Horizontal) |
|
368 { |
|
369 section = GLX_DETAILSVIEW_LSSECTION; |
|
370 } |
|
371 else |
|
372 { |
|
373 section = GLX_DETAILSVIEW_PTSECTION; |
|
374 } |
|
375 |
|
376 //Load the Sections |
|
377 mDocLoader->load(GLX_DETAILSVIEW_DOCMLPATH, section, &loaded); |
|
378 |
|
379 showImage(); |
|
380 //This is just to over come the bug in docloader,once that is fixed we can remove the |
|
381 //below lines of code |
|
382 FillDetails(); |
|
383 |
|
384 GLX_LOG_INFO1("GlxDetailsView::updateLayout =%d\n",loaded); |
|
385 } |
|
386 |
|
387 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
388 //rowsRemoved |
|
389 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
390 void GlxDetailsView::rowsRemoved(const QModelIndex &parent, int start, |
|
391 int end) |
|
392 { |
|
393 Q_UNUSED(parent); |
|
394 Q_UNUSED(start); |
|
395 Q_UNUSED(end); |
|
396 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_ROWSREMOVED, "GlxDetailsView::rowsRemoved" ); |
|
397 |
|
398 if (mModel->rowCount() <= 0) |
|
399 { |
|
400 return emit actionTriggered(EGlxCmdEmptyData); |
|
401 } |
|
402 |
|
403 if (start <= mSelIndex && end >= mSelIndex) |
|
404 { |
|
405 return emit actionTriggered(EGlxCmdBack); |
|
406 } |
|
407 } |
|
408 |
|
409 void GlxDetailsView::modelDestroyed() |
|
410 { |
|
411 mModel = NULL; |
|
412 } |
|
413 |
|
414 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
415 //FillData |
|
416 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
417 void GlxDetailsView::FillDetails() |
|
418 { |
|
419 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETFORMDATA, "GlxDetailsView::setFormData" ); |
|
420 |
|
421 qDebug("GlxDetailsView::FillDetails"); |
|
422 //Call to set the Image Name |
|
423 setImageName(); |
|
424 |
|
425 //Call to set the description |
|
426 setDesc(); |
|
427 |
|
428 //Call to set the date in the from |
|
429 setDate(); |
|
430 |
|
431 //Call to set the time |
|
432 setTime(); |
|
433 |
|
434 //Call to set the size |
|
435 setSize(); |
|
436 |
|
437 } |
|
438 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
439 //showImage |
|
440 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
441 void GlxDetailsView::showImage() |
|
442 { |
|
443 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SHOWIMAGE, "GlxDetailsView::showImage" ); |
|
444 |
|
445 QVariant variant = mModel->data(mModel->index(0, 0), GlxFocusIndexRole); |
|
446 if (variant.isValid() && variant.canConvert<int> ()) |
|
447 { |
|
448 mSelIndex = variant.value<int> (); |
|
449 } |
|
450 |
|
451 variant = mModel->data(mModel->index(mSelIndex, 0), GlxFsImageRole); |
|
452 |
|
453 if (variant.isValid() && variant.canConvert<HbIcon> ()) |
|
454 { |
|
455 mDetailsIcon->setIcon(variant.value<HbIcon> ()); |
|
456 } |
|
457 } |
|
458 |
|
459 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
460 //setImageName |
|
461 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
462 void GlxDetailsView::setImageName() |
|
463 { |
|
464 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETIMAGENAME_ENTRY ); |
|
465 QString imagePath = (mModel->data(mModel->index(mModel->data( |
|
466 mModel->index(0, 0), GlxFocusIndexRole).value<int> (), 0), |
|
467 GlxUriRole)).value<QString> (); |
|
468 QString imageName = imagePath.section('\\', -1); |
|
469 |
|
470 mImageName->setItemText(imageName); |
|
471 OstTraceFunctionExit0( GLXDETAILSVIEW_SETIMAGENAME_EXIT ); |
|
472 } |
|
473 |
|
474 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
475 //setImageName |
|
476 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
477 void GlxDetailsView::setDesc() |
|
478 { |
|
479 |
|
480 //This is a hack , Initialize to some characters and then set the text |
|
481 //as of know if the description text is Null , we cant see the Description edit box |
|
482 //The issue has been informed to Application designer team. |
|
483 mDescriptions->setItemText("a"); |
|
484 QString description = (mModel->data(mModel->index(mModel->data( |
|
485 mModel->index(0, 0), GlxFocusIndexRole).value<int> (), 0), |
|
486 GlxDescRole)).value<QString> (); |
|
487 mDescriptions->setItemText(description); |
|
488 } |
|
489 |
|
490 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
491 //setDate |
|
492 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
493 void GlxDetailsView::setDate() |
|
494 { |
|
495 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETDATE_ENTRY ); |
|
496 |
|
497 QString datestring; |
|
498 QString dateFormat("dd.MM.yyyy"); |
|
499 QDate date = (mModel->data(mModel->index(mModel->data( |
|
500 mModel->index(0, 0), GlxFocusIndexRole).value<int> (), 0), |
|
501 GlxDateRole)).value<QDate> (); |
|
502 |
|
503 if (date.isNull() == FALSE) |
|
504 { |
|
505 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETDATE, "GlxDetailsView::setDate is not NULL" ); |
|
506 QString dateStringValue = date.toString(dateFormat); |
|
507 datestring = hbTrId(GLX_DETAILS_DATE).arg(dateStringValue); |
|
508 } |
|
509 |
|
510 mDateLabel->setPlainText(datestring); |
|
511 |
|
512 OstTraceFunctionExit0( GLXDETAILSVIEW_SETDATE_EXIT ); |
|
513 } |
|
514 |
|
515 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
516 //setTime |
|
517 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
518 void GlxDetailsView::setTime() |
|
519 { |
|
520 QString timestring; |
|
521 QString timeFormat("h:m ap"); |
|
522 QTime timevalue = (mModel->data(mModel->index(mModel->data(mModel->index( |
|
523 0, 0), GlxFocusIndexRole).value<int> (), 0), GlxTimeRole)).value< |
|
524 QTime> (); |
|
525 |
|
526 if (timevalue.isNull() == FALSE) |
|
527 { |
|
528 QString timeStringValue = timevalue.toString(timeFormat); |
|
529 timestring = hbTrId(GLX_DETAILS_TIME).arg(timeStringValue); |
|
530 } |
|
531 mTimeLabel->setPlainText(timestring); |
|
532 } |
|
533 |
|
534 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
535 //setSize |
|
536 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
537 void GlxDetailsView::setSize() |
|
538 { |
|
539 int size = 0; |
|
540 size = (mModel->data(mModel->index(mModel->data(mModel->index(0, 0), |
|
541 GlxFocusIndexRole).value<int> (), 0), GlxSizeRole)).value<int> (); |
|
542 |
|
543 QString sizeString; |
|
544 sizeString = sizeinStrings(size); |
|
545 mSizeLabel->setPlainText(sizeString); |
|
546 |
|
547 } |
|
548 |
|
549 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
550 //dataChanged |
|
551 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
552 void GlxDetailsView::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
|
553 { |
|
554 Q_UNUSED(endIndex); |
|
555 |
|
556 QVariant variant = mFavModel->data(startIndex, GlxFavorites); |
|
557 if (variant.isValid() && variant.canConvert<bool> ()) |
|
558 { |
|
559 if (variant.value<bool> ()) |
|
560 { |
|
561 mFavIcon->setItemIcon(mFavIconEnabled); |
|
562 } |
|
563 else |
|
564 { |
|
565 mFavIcon->setItemIcon(mFavIconDisabled); |
|
566 } |
|
567 } |
|
568 } |
|
569 |
|
570 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
571 //UpdateDescription |
|
572 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
573 void GlxDetailsView::UpdateDescription() |
|
574 { |
|
575 GLX_LOG_INFO("GlxDetailsView::UpdateDescription "); |
|
576 qDebug("GlxDetailsView::UpdateDescription"); |
|
577 emit actionTriggered(EGlxCmdComment); |
|
578 } |
|
579 |
|
580 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
581 //updateFavourites |
|
582 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
583 void GlxDetailsView::updateFavourites() |
|
584 { |
|
585 QVariant variant = mFavModel->data(mFavModel->index(0, 0), GlxFavorites); |
|
586 if (variant.isValid() && variant.canConvert<bool> ()) |
|
587 { |
|
588 if (variant.value<bool> ()) |
|
589 { |
|
590 emit actionTriggered(EGlxCmdRemoveFromFav); |
|
591 } |
|
592 else |
|
593 { |
|
594 emit actionTriggered(EGlxCmdAddToFav); |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
600 //sizeinStrings |
|
601 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
602 QString GlxDetailsView::sizeinStrings(int size) |
|
603 { |
|
604 QString sizeString; |
|
605 if (size >= KBytesInGB) |
|
606 { |
|
607 int gbSize = size / KBytesInGB; // Size in GB |
|
608 sizeString = HbParameterLengthLimiter(GLX_DETAILS_SIZE_GB, gbSize); |
|
609 } |
|
610 else if (size >= KBytesInMB) |
|
611 { |
|
612 int mbSize = size / KBytesInMB; // Size in MB |
|
613 sizeString = HbParameterLengthLimiter(GLX_DETAILS_SIZE_MB, mbSize); |
|
614 } |
|
615 else if (size >= KBytesInKB) |
|
616 { |
|
617 int kbSize = size / KBytesInKB; // Size in KB |
|
618 sizeString = HbParameterLengthLimiter(GLX_DETAILS_SIZE_KB, kbSize); |
|
619 } |
|
620 else |
|
621 { |
|
622 sizeString = HbParameterLengthLimiter(GLX_DETAILS_SIZE_BYTES, size); |
|
623 } |
|
624 return sizeString; |
|
625 } |
|
626 |
|
627 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
628 //getSubState |
|
629 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
630 int GlxDetailsView::getSubState() |
|
631 { |
|
632 int substate = NO_DETAIL_S; |
|
633 |
|
634 if (mModel) { |
|
635 QVariant variant = mModel->data(mModel->index(0, 0), GlxSubStateRole); |
|
636 |
|
637 if (variant.isValid() && variant.canConvert<int> ()) { |
|
638 substate = variant.value<int> (); |
|
639 } |
|
640 } |
|
641 return substate; |
|
642 } |