author | hgs |
Fri, 06 Aug 2010 23:19:50 +0530 | |
changeset 51 | 3507212d340e |
parent 46 | b1f0785c289d |
permissions | -rw-r--r-- |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
238255e8b033
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 |
238255e8b033
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" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
238255e8b033
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". |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: This widget displays the body of the viewer |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "univiewerbodywidget.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
37 | 20 |
// SYSTEM INCLUDES |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <QFile> |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <HbTextItem> |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <HbMainWindow> |
41 | 24 |
#include <HbIconItem> |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
|
37 | 26 |
// USER INCLUDES |
27 |
#include "univiewertextitem.h" |
|
28 |
#include "univiewerpixmapwidget.h" |
|
29 |
#include "univieweraudiowidget.h" |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
// LOCAL CONSTANTS |
37 | 32 |
const QString IMAGE_MIMETYPE("image"); |
33 |
const QString AUDIO_MIMETYPE("audio"); |
|
34 |
const QString VIDEO_MIMETYPE("video"); |
|
35 |
const QString TEXT_MIMETYPE("text"); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
|
51 | 37 |
static const char VIDEO_ICON[] = "qtg_large_video_player"; |
38 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
//UniViewerBodyWidget::UniViewerBodyWidget |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
// @see header file |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
UniViewerBodyWidget::UniViewerBodyWidget(QGraphicsItem *parent) : |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
44 |
HbWidget(parent), mHasText(false), mHasPixmap(false), mTextItem(0), mSlideCounter(0), |
41 | 45 |
mPixmapItem(0), mAudioItem(0), mOverlayItem(0) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
{ |
37 | 47 |
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
//UniViewerBodyWidget::~UniViewerBodyWidget |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
// @see header file |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
UniViewerBodyWidget::~UniViewerBodyWidget() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
//--------------------------------------------------------------- |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
59 |
// UniViewerBodyWidget::setHasText |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
60 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
61 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
62 |
void UniViewerBodyWidget::setHasText(bool text) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
63 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
64 |
mHasText = text; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
65 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
66 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
67 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
68 |
// UniViewerBodyWidget::hasText |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
69 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
70 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
71 |
bool UniViewerBodyWidget::hasText() |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
72 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
73 |
return mHasText; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
74 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
75 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
76 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
77 |
// UniViewerBodyWidget::setHasPixmap |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
78 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
79 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
80 |
void UniViewerBodyWidget::setHasPixmap(bool pixmap) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
81 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
82 |
mHasPixmap = pixmap; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
83 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
84 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
85 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
86 |
// UniViewerBodyWidget::hasPixmap |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
87 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
88 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
89 |
bool UniViewerBodyWidget::hasPixmap() |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
90 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
91 |
return mHasPixmap; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
92 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
93 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
94 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
95 |
// UniViewerBodyWidget::setSlideContents |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
96 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
97 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
98 |
void UniViewerBodyWidget::setSlideContents(UniMessageInfoList objList, QString slideString) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
99 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
100 |
if (!slideString.isEmpty()) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
101 |
setSlideCounter(slideString); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
102 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
103 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
104 |
int count = objList.count(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
105 |
for (int a = 0; a < count; ++a) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
106 |
UniMessageInfo* info = objList.at(a); |
37 | 107 |
QString mimeType = info->mimetype(); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
108 |
|
37 | 109 |
if (mimeType.contains(TEXT_MIMETYPE)) { |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
110 |
QFile file(info->path()); |
37 | 111 |
if (file.open(QIODevice::ReadOnly)) { |
46 | 112 |
QString textContent; |
113 |
QByteArray textArray; |
|
114 |
textArray = file.readAll(); |
|
115 |
char *data = new char[textArray.size()+1]; |
|
116 |
strcpy(data,textArray.data()); |
|
117 |
//This is needed since MMS text content |
|
118 |
//is stored in UTF8 format |
|
119 |
textContent = textContent.fromUtf8(data,strlen(data)); |
|
120 |
file.close(); |
|
121 |
delete []data; |
|
37 | 122 |
setText(textContent); |
123 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
124 |
} |
37 | 125 |
else if (mimeType.contains(AUDIO_MIMETYPE)) { |
126 |
setAudio(info); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
127 |
} |
37 | 128 |
else if (mimeType.contains(VIDEO_MIMETYPE)) { |
129 |
setVideo(info); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
130 |
} |
37 | 131 |
else if (mimeType.contains(IMAGE_MIMETYPE)) { |
132 |
setPixmap(info); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
133 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
134 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
135 |
delete info; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
136 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
137 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
138 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
139 |
//--------------------------------------------------------------- |
41 | 140 |
// UniViewerBodyWidget :: clearContent |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
141 |
// @see header file |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
142 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
143 |
void UniViewerBodyWidget::clearContent() |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
144 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
145 |
// delete the temp items(pixmap) & clear permanent items(text) |
37 | 146 |
if (mPixmapItem) { |
147 |
mPixmapItem->setParent(NULL); |
|
148 |
delete mPixmapItem; |
|
149 |
mPixmapItem = NULL; |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
150 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
151 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
152 |
if (mAudioItem) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
153 |
mAudioItem->setParent(NULL); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
154 |
delete mAudioItem; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
155 |
mAudioItem = NULL; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
156 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
157 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
158 |
if (mTextItem) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
159 |
mTextItem->setParent(NULL); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
160 |
delete mTextItem; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
161 |
mTextItem = NULL; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
162 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
163 |
|
41 | 164 |
if (mOverlayItem) { |
165 |
mOverlayItem->setParent(NULL); |
|
166 |
delete mOverlayItem; |
|
167 |
mOverlayItem = NULL; |
|
168 |
} |
|
169 |
||
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
170 |
setHasText(false); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
171 |
setHasPixmap(false); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
172 |
repolish(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
173 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
174 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
175 |
//--------------------------------------------------------------- |
51 | 176 |
// UniViewerBodyWidget::setText |
41 | 177 |
// @see header file |
178 |
//--------------------------------------------------------------- |
|
51 | 179 |
void UniViewerBodyWidget::setText(QString text) |
41 | 180 |
{ |
51 | 181 |
setHasText(true); |
182 |
||
183 |
if (!mTextItem) { |
|
184 |
mTextItem = new UniViewerTextItem(this); |
|
185 |
mTextItem->setObjectName("textItem"); |
|
186 |
HbStyle::setItemName(mTextItem, "textItem"); |
|
187 |
connect(mTextItem, SIGNAL(sendMessage(const QString&)), this, |
|
188 |
SIGNAL(sendMessage(const QString&))); |
|
41 | 189 |
} |
51 | 190 |
mTextItem->hide(); |
191 |
text.replace(QChar::ParagraphSeparator, QChar::LineSeparator); |
|
192 |
text.replace('\r', QChar::LineSeparator); |
|
193 |
mTextItem->setText(text); |
|
41 | 194 |
|
195 |
this->repolish(); |
|
196 |
} |
|
197 |
||
198 |
//--------------------------------------------------------------- |
|
37 | 199 |
//UniViewerBodyWidget::sizeHint |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
200 |
// @see header file |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
201 |
//--------------------------------------------------------------- |
37 | 202 |
QSizeF UniViewerBodyWidget::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
{ |
37 | 204 |
QSizeF szHint = HbWidget::sizeHint(which, constraint); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
|
37 | 206 |
HbMainWindow *mainWindow = this->mainWindow(); |
207 |
if (!mainWindow) { |
|
208 |
return szHint; |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
209 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
210 |
|
37 | 211 |
qreal screenWidth = 0.0; |
212 |
qreal screenHeight = 0.0; |
|
213 |
qreal leftMargin = 0.0; |
|
214 |
qreal rightMargin = 0.0; |
|
215 |
qreal chromeHeight = 0.0; |
|
216 |
qreal toolbarHeight = 0.0; |
|
217 |
qreal iconSize = 0.0; |
|
218 |
qreal spacing = 0.0; |
|
219 |
qreal unitSize = HbDeviceProfile::profile(mPixmapItem).unitValue(); |
|
220 |
style()->parameter("hb-param-screen-width", screenWidth); |
|
221 |
style()->parameter("hb-param-screen-height", screenHeight); |
|
222 |
style()->parameter("hb-param-margin-gene-left", leftMargin); |
|
223 |
style()->parameter("hb-param-margin-gene-right", rightMargin); |
|
224 |
style()->parameter("hb-param-widget-chrome-height", chromeHeight); |
|
225 |
style()->parameter("hb-param-widget-toolbar-height", toolbarHeight); |
|
226 |
style()->parameter("hb-param-graphic-size-primary-large", iconSize); |
|
227 |
style()->parameter("hb-param-margin-gene-middle-vertical", spacing); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
228 |
|
37 | 229 |
qreal maxWidth = 0.0; |
230 |
qreal maxHeight = 0.0; |
|
231 |
||
232 |
// Calculate max height & max width. |
|
233 |
if (mainWindow->orientation() == Qt::Horizontal) { |
|
234 |
qreal temp; |
|
235 |
temp = screenWidth; |
|
236 |
screenWidth = screenHeight; |
|
237 |
screenHeight = temp; |
|
238 |
||
239 |
if (mPixmapItem && mHasText) { |
|
240 |
maxWidth = (screenWidth / 2) - leftMargin - unitSize; |
|
241 |
} |
|
242 |
else { |
|
243 |
maxWidth = screenWidth - leftMargin - rightMargin; |
|
244 |
} |
|
245 |
maxHeight = screenHeight - chromeHeight - toolbarHeight; |
|
246 |
||
247 |
if (mAudioItem) { |
|
248 |
mAudioItem->setStretched(true); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
249 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
250 |
} |
37 | 251 |
else if (mainWindow->orientation() == Qt::Vertical) { |
252 |
maxWidth = screenWidth - leftMargin - rightMargin; |
|
253 |
maxHeight = screenHeight - chromeHeight - toolbarHeight; |
|
254 |
||
255 |
if (mAudioItem) { |
|
256 |
mAudioItem->setStretched(false); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
// Slide Counter |
|
261 |
QSizeF slideCounterSize(0, 0); |
|
262 |
if (mSlideCounter) { |
|
263 |
slideCounterSize = mSlideCounter->effectiveSizeHint(which, constraint); |
|
264 |
mSlideCounter->show(); |
|
265 |
} |
|
266 |
// Audio Item |
|
267 |
QSizeF audioSize(0, 0); |
|
268 |
if (mAudioItem) { |
|
269 |
audioSize = mAudioItem->effectiveSizeHint(which, constraint); |
|
270 |
mAudioItem->show(); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
271 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
272 |
|
37 | 273 |
// Text Item |
274 |
QSizeF textSize(0, 0); |
|
275 |
if (mTextItem) { |
|
276 |
textSize = mTextItem->effectiveSizeHint(which, constraint); |
|
277 |
mTextItem->show(); |
|
278 |
} |
|
279 |
||
280 |
// Pixmap Item |
|
281 |
QSizeF pixmapSize(0, 0); |
|
282 |
if (mPixmapItem) { |
|
283 |
qreal imageWidth = mPixmapItem->icon().defaultSize().width(); |
|
284 |
qreal imageHeight = mPixmapItem->icon().defaultSize().height(); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
285 |
|
37 | 286 |
qreal widthToSet = 0.0; |
287 |
qreal heightToSet = 0.0; |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
288 |
|
37 | 289 |
if (imageWidth < iconSize) { |
290 |
widthToSet = iconSize; |
|
291 |
heightToSet = iconSize; |
|
292 |
} |
|
293 |
else if (imageWidth <= maxWidth) { |
|
294 |
// resize not needed |
|
295 |
widthToSet = imageWidth; |
|
296 |
heightToSet = qMin(imageHeight, maxHeight); |
|
297 |
} |
|
298 |
else { |
|
299 |
// resize needed, keep aspect-ratio and resize |
|
300 |
widthToSet = maxWidth; |
|
301 |
heightToSet = maxWidth * (imageHeight / imageWidth); |
|
302 |
heightToSet = qMin(heightToSet, maxHeight); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
303 |
|
37 | 304 |
} |
305 |
if (heightToSet == maxHeight) { |
|
306 |
widthToSet = heightToSet * (imageWidth / imageHeight); |
|
307 |
} |
|
308 |
||
309 |
pixmapSize.setHeight(heightToSet); |
|
310 |
pixmapSize.setWidth(widthToSet); |
|
311 |
mPixmapItem->setPreferredSize(pixmapSize); |
|
312 |
mPixmapItem->show(); |
|
313 |
} |
|
314 |
||
41 | 315 |
if (mOverlayItem) { |
316 |
mOverlayItem->show(); |
|
317 |
} |
|
318 |
||
37 | 319 |
// Calculate the size hint to be returned. |
320 |
szHint.setHeight(0); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
321 |
|
37 | 322 |
if (!slideCounterSize.isNull()) { |
323 |
szHint.rheight() += (slideCounterSize.height() + spacing); |
|
324 |
} |
|
325 |
if (!audioSize.isNull()) { |
|
326 |
szHint.rheight() += (audioSize.height() + spacing); |
|
327 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
328 |
|
37 | 329 |
if (mainWindow->orientation() == Qt::Horizontal) { |
330 |
qreal remainingHeight = qMax(pixmapSize.height(), textSize.height()); |
|
331 |
if (remainingHeight > 0.0) { |
|
332 |
szHint.rheight() += (remainingHeight + spacing); |
|
333 |
} |
|
334 |
} |
|
335 |
else if (mainWindow->orientation() == Qt::Vertical) { |
|
336 |
if (!pixmapSize.isNull()) { |
|
337 |
szHint.rheight() += (pixmapSize.height() + spacing); |
|
338 |
} |
|
339 |
if (!textSize.isNull()) { |
|
340 |
szHint.rheight() += (textSize.height() + spacing); |
|
341 |
} |
|
342 |
} |
|
343 |
szHint.rheight() = qMax(maxHeight, szHint.height()); |
|
344 |
||
345 |
return szHint; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
346 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
|
51 | 348 |
//--------------------------------------------------------------- |
349 |
//UniViewerBodyWidget::setPixmap |
|
350 |
// @see header file |
|
351 |
//--------------------------------------------------------------- |
|
352 |
void UniViewerBodyWidget::setPixmap(UniMessageInfo *info) |
|
353 |
{ |
|
354 |
setHasPixmap(true); |
|
355 |
//create image item instance |
|
356 |
if (!mPixmapItem) { |
|
357 |
mPixmapItem = new UniViewerPixmapWidget(this); |
|
358 |
HbStyle::setItemName(mPixmapItem, "pixmap"); |
|
359 |
} |
|
360 |
mPixmapItem->hide(); |
|
361 |
mPixmapItem->populate(info); |
|
362 |
||
363 |
this->repolish(); |
|
364 |
} |
|
365 |
||
366 |
//--------------------------------------------------------------- |
|
367 |
//UniViewerBodyWidget::setAudio |
|
368 |
// @see header file |
|
369 |
//--------------------------------------------------------------- |
|
370 |
void UniViewerBodyWidget::setAudio(UniMessageInfo *info) |
|
371 |
{ |
|
372 |
if (!mAudioItem) { |
|
373 |
mAudioItem = new UniViewerAudioWidget(this); |
|
374 |
HbStyle::setItemName(mAudioItem, "audioItem"); |
|
375 |
} |
|
376 |
mAudioItem->hide(); |
|
377 |
mAudioItem->populate(info); |
|
378 |
||
379 |
this->repolish(); |
|
380 |
} |
|
381 |
||
382 |
//--------------------------------------------------------------- |
|
383 |
//UniViewerBodyWidget::setVideo |
|
384 |
// @see header file |
|
385 |
//--------------------------------------------------------------- |
|
386 |
void UniViewerBodyWidget::setVideo(UniMessageInfo *info) |
|
387 |
{ |
|
388 |
setHasPixmap(true); |
|
389 |
//create image item instance |
|
390 |
if (!mPixmapItem) { |
|
391 |
mPixmapItem = new UniViewerPixmapWidget(this); |
|
392 |
HbStyle::setItemName(mPixmapItem, "pixmap"); |
|
393 |
connect(mPixmapItem, SIGNAL(thumbnailFound(bool, UniMessageInfo*)), this, |
|
394 |
SLOT(onThumbnailFound(bool, UniMessageInfo*))); |
|
395 |
} |
|
396 |
mPixmapItem->hide(); |
|
397 |
mPixmapItem->populate(info); |
|
398 |
||
399 |
this->repolish(); |
|
400 |
} |
|
401 |
||
402 |
//--------------------------------------------------------------- |
|
403 |
// UniViewerBodyWidget::setSlideCounter |
|
404 |
// @see header file |
|
405 |
//--------------------------------------------------------------- |
|
406 |
void UniViewerBodyWidget::setSlideCounter(QString &slideCounter) |
|
407 |
{ |
|
408 |
if (!mSlideCounter) { |
|
409 |
mSlideCounter = new HbTextItem(this); |
|
410 |
HbStyle::setItemName(mSlideCounter, "slideCounter"); |
|
411 |
} |
|
412 |
||
413 |
mSlideCounter->hide(); |
|
414 |
mSlideCounter->setText(slideCounter); |
|
415 |
||
416 |
this->repolish(); |
|
417 |
} |
|
418 |
||
419 |
//--------------------------------------------------------------- |
|
420 |
// UniViewerBodyWidget::setOverlayIcon |
|
421 |
// @see header file |
|
422 |
//--------------------------------------------------------------- |
|
423 |
void UniViewerBodyWidget::setOverlayIcon(const QString &iconName) |
|
424 |
{ |
|
425 |
if (!mOverlayItem) { |
|
426 |
mOverlayItem = new HbIconItem(this); |
|
427 |
HbStyle::setItemName(mOverlayItem, "overlayItem"); |
|
428 |
} |
|
429 |
||
430 |
mOverlayItem->hide(); |
|
431 |
mOverlayItem->setIconName(iconName); |
|
432 |
||
433 |
this->repolish(); |
|
434 |
} |
|
435 |
||
436 |
//--------------------------------------------------------------- |
|
437 |
// UniViewerBodyWidget::onThumbnailFound |
|
438 |
// @see header file |
|
439 |
//--------------------------------------------------------------- |
|
440 |
void UniViewerBodyWidget::onThumbnailFound(bool result, UniMessageInfo *info) |
|
441 |
{ |
|
442 |
if (result) { |
|
443 |
// Thumbnail generation success |
|
444 |
setOverlayIcon(VIDEO_ICON); |
|
445 |
} |
|
446 |
else { |
|
447 |
// Show video content in audio widget. |
|
448 |
setAudio(info); |
|
449 |
||
450 |
// Remove the pixmap widget. |
|
451 |
setHasPixmap(false); |
|
452 |
if (mPixmapItem) { |
|
453 |
HbStyle::setItemName(mPixmapItem, ""); |
|
454 |
mPixmapItem->hide(); |
|
455 |
} |
|
456 |
} |
|
457 |
} |
|
458 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
459 |
// EOF |