messagingapp/msgui/unifiedviewer/src/univiewerbodywidget.cpp
author hgs
Fri, 06 Aug 2010 23:19:50 +0530
changeset 51 3507212d340e
parent 46 b1f0785c289d
permissions -rw-r--r--
201031_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
hgs
parents: 25
diff changeset
    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
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
    24
#include <HbIconItem>
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
37
hgs
parents: 25
diff changeset
    26
// USER INCLUDES
hgs
parents: 25
diff changeset
    27
#include "univiewertextitem.h"
hgs
parents: 25
diff changeset
    28
#include "univiewerpixmapwidget.h"
hgs
parents: 25
diff changeset
    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
hgs
parents: 25
diff changeset
    32
const QString IMAGE_MIMETYPE("image");
hgs
parents: 25
diff changeset
    33
const QString AUDIO_MIMETYPE("audio");
hgs
parents: 25
diff changeset
    34
const QString VIDEO_MIMETYPE("video");
hgs
parents: 25
diff changeset
    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
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    37
static const char VIDEO_ICON[] = "qtg_large_video_player";
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    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
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
    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
hgs
parents: 25
diff changeset
    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
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   111
            if (file.open(QIODevice::ReadOnly)) {
46
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   112
                QString textContent;
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   113
                QByteArray textArray;
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   114
                textArray = file.readAll();
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   115
                char *data = new char[textArray.size()+1];
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   116
                strcpy(data,textArray.data());
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   117
                //This is needed since MMS text content 
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   118
                //is stored in UTF8 format
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   119
                textContent = textContent.fromUtf8(data,strlen(data));
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   120
                file.close();
b1f0785c289d 201027_03
hgs
parents: 41
diff changeset
   121
                delete []data;
37
hgs
parents: 25
diff changeset
   122
                setText(textContent);
hgs
parents: 25
diff changeset
   123
            }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   124
        }
37
hgs
parents: 25
diff changeset
   125
        else if (mimeType.contains(AUDIO_MIMETYPE)) {
hgs
parents: 25
diff changeset
   126
            setAudio(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   127
        }
37
hgs
parents: 25
diff changeset
   128
        else if (mimeType.contains(VIDEO_MIMETYPE)) {
hgs
parents: 25
diff changeset
   129
            setVideo(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   130
        }
37
hgs
parents: 25
diff changeset
   131
        else if (mimeType.contains(IMAGE_MIMETYPE)) {
hgs
parents: 25
diff changeset
   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
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   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
hgs
parents: 25
diff changeset
   146
    if (mPixmapItem) {
hgs
parents: 25
diff changeset
   147
        mPixmapItem->setParent(NULL);
hgs
parents: 25
diff changeset
   148
        delete mPixmapItem;
hgs
parents: 25
diff changeset
   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
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   164
    if (mOverlayItem) {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   165
        mOverlayItem->setParent(NULL);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   166
        delete mOverlayItem;
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   167
        mOverlayItem = NULL;
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   168
    }
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   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
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   176
// UniViewerBodyWidget::setText
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   177
// @see header file
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   178
//---------------------------------------------------------------
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   179
void UniViewerBodyWidget::setText(QString text)
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   180
{
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   181
    setHasText(true);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   182
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   183
    if (!mTextItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   184
        mTextItem = new UniViewerTextItem(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   185
        mTextItem->setObjectName("textItem");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   186
        HbStyle::setItemName(mTextItem, "textItem");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   187
        connect(mTextItem, SIGNAL(sendMessage(const QString&)), this,
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   188
            SIGNAL(sendMessage(const QString&)));
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   189
    }
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   190
    mTextItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   191
    text.replace(QChar::ParagraphSeparator, QChar::LineSeparator);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   192
    text.replace('\r', QChar::LineSeparator);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   193
    mTextItem->setText(text);
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   194
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   195
    this->repolish();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   196
}
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   197
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   198
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   206
    HbMainWindow *mainWindow = this->mainWindow();
hgs
parents: 25
diff changeset
   207
    if (!mainWindow) {
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   211
    qreal screenWidth = 0.0;
hgs
parents: 25
diff changeset
   212
    qreal screenHeight = 0.0;
hgs
parents: 25
diff changeset
   213
    qreal leftMargin = 0.0;
hgs
parents: 25
diff changeset
   214
    qreal rightMargin = 0.0;
hgs
parents: 25
diff changeset
   215
    qreal chromeHeight = 0.0;
hgs
parents: 25
diff changeset
   216
    qreal toolbarHeight = 0.0;
hgs
parents: 25
diff changeset
   217
    qreal iconSize = 0.0;
hgs
parents: 25
diff changeset
   218
    qreal spacing = 0.0;
hgs
parents: 25
diff changeset
   219
    qreal unitSize = HbDeviceProfile::profile(mPixmapItem).unitValue();
hgs
parents: 25
diff changeset
   220
    style()->parameter("hb-param-screen-width", screenWidth);
hgs
parents: 25
diff changeset
   221
    style()->parameter("hb-param-screen-height", screenHeight);
hgs
parents: 25
diff changeset
   222
    style()->parameter("hb-param-margin-gene-left", leftMargin);
hgs
parents: 25
diff changeset
   223
    style()->parameter("hb-param-margin-gene-right", rightMargin);
hgs
parents: 25
diff changeset
   224
    style()->parameter("hb-param-widget-chrome-height", chromeHeight);
hgs
parents: 25
diff changeset
   225
    style()->parameter("hb-param-widget-toolbar-height", toolbarHeight);
hgs
parents: 25
diff changeset
   226
    style()->parameter("hb-param-graphic-size-primary-large", iconSize);
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   229
    qreal maxWidth = 0.0;
hgs
parents: 25
diff changeset
   230
    qreal maxHeight = 0.0;
hgs
parents: 25
diff changeset
   231
hgs
parents: 25
diff changeset
   232
    // Calculate max height & max width.
hgs
parents: 25
diff changeset
   233
    if (mainWindow->orientation() == Qt::Horizontal) {
hgs
parents: 25
diff changeset
   234
        qreal temp;
hgs
parents: 25
diff changeset
   235
        temp = screenWidth;
hgs
parents: 25
diff changeset
   236
        screenWidth = screenHeight;
hgs
parents: 25
diff changeset
   237
        screenHeight = temp;
hgs
parents: 25
diff changeset
   238
hgs
parents: 25
diff changeset
   239
        if (mPixmapItem && mHasText) {
hgs
parents: 25
diff changeset
   240
            maxWidth = (screenWidth / 2) - leftMargin - unitSize;
hgs
parents: 25
diff changeset
   241
        }
hgs
parents: 25
diff changeset
   242
        else {
hgs
parents: 25
diff changeset
   243
            maxWidth = screenWidth - leftMargin - rightMargin;
hgs
parents: 25
diff changeset
   244
        }
hgs
parents: 25
diff changeset
   245
        maxHeight = screenHeight - chromeHeight - toolbarHeight;
hgs
parents: 25
diff changeset
   246
hgs
parents: 25
diff changeset
   247
        if (mAudioItem) {
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   251
    else if (mainWindow->orientation() == Qt::Vertical) {
hgs
parents: 25
diff changeset
   252
        maxWidth = screenWidth - leftMargin - rightMargin;
hgs
parents: 25
diff changeset
   253
        maxHeight = screenHeight - chromeHeight - toolbarHeight;
hgs
parents: 25
diff changeset
   254
hgs
parents: 25
diff changeset
   255
        if (mAudioItem) {
hgs
parents: 25
diff changeset
   256
            mAudioItem->setStretched(false);
hgs
parents: 25
diff changeset
   257
        }
hgs
parents: 25
diff changeset
   258
    }
hgs
parents: 25
diff changeset
   259
hgs
parents: 25
diff changeset
   260
    // Slide Counter
hgs
parents: 25
diff changeset
   261
    QSizeF slideCounterSize(0, 0);
hgs
parents: 25
diff changeset
   262
    if (mSlideCounter) {
hgs
parents: 25
diff changeset
   263
        slideCounterSize = mSlideCounter->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   264
        mSlideCounter->show();
hgs
parents: 25
diff changeset
   265
    }
hgs
parents: 25
diff changeset
   266
    // Audio Item
hgs
parents: 25
diff changeset
   267
    QSizeF audioSize(0, 0);
hgs
parents: 25
diff changeset
   268
    if (mAudioItem) {
hgs
parents: 25
diff changeset
   269
        audioSize = mAudioItem->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   273
    // Text Item
hgs
parents: 25
diff changeset
   274
    QSizeF textSize(0, 0);
hgs
parents: 25
diff changeset
   275
    if (mTextItem) {
hgs
parents: 25
diff changeset
   276
        textSize = mTextItem->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   277
        mTextItem->show();
hgs
parents: 25
diff changeset
   278
    }
hgs
parents: 25
diff changeset
   279
hgs
parents: 25
diff changeset
   280
    // Pixmap Item
hgs
parents: 25
diff changeset
   281
    QSizeF pixmapSize(0, 0);
hgs
parents: 25
diff changeset
   282
    if (mPixmapItem) {
hgs
parents: 25
diff changeset
   283
        qreal imageWidth = mPixmapItem->icon().defaultSize().width();
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   286
        qreal widthToSet = 0.0;
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   289
        if (imageWidth < iconSize) {
hgs
parents: 25
diff changeset
   290
            widthToSet = iconSize;
hgs
parents: 25
diff changeset
   291
            heightToSet = iconSize;
hgs
parents: 25
diff changeset
   292
        }
hgs
parents: 25
diff changeset
   293
        else if (imageWidth <= maxWidth) {
hgs
parents: 25
diff changeset
   294
            // resize not needed
hgs
parents: 25
diff changeset
   295
            widthToSet = imageWidth;
hgs
parents: 25
diff changeset
   296
            heightToSet = qMin(imageHeight, maxHeight);
hgs
parents: 25
diff changeset
   297
        }
hgs
parents: 25
diff changeset
   298
        else {
hgs
parents: 25
diff changeset
   299
            // resize needed, keep aspect-ratio and resize
hgs
parents: 25
diff changeset
   300
            widthToSet = maxWidth;
hgs
parents: 25
diff changeset
   301
            heightToSet = maxWidth * (imageHeight / imageWidth);
hgs
parents: 25
diff changeset
   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
hgs
parents: 25
diff changeset
   304
        }
hgs
parents: 25
diff changeset
   305
        if (heightToSet == maxHeight) {
hgs
parents: 25
diff changeset
   306
            widthToSet = heightToSet * (imageWidth / imageHeight);
hgs
parents: 25
diff changeset
   307
        }
hgs
parents: 25
diff changeset
   308
hgs
parents: 25
diff changeset
   309
        pixmapSize.setHeight(heightToSet);
hgs
parents: 25
diff changeset
   310
        pixmapSize.setWidth(widthToSet);
hgs
parents: 25
diff changeset
   311
        mPixmapItem->setPreferredSize(pixmapSize);
hgs
parents: 25
diff changeset
   312
        mPixmapItem->show();
hgs
parents: 25
diff changeset
   313
    }
hgs
parents: 25
diff changeset
   314
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   315
    if (mOverlayItem) {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   316
        mOverlayItem->show();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   317
    }
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   318
37
hgs
parents: 25
diff changeset
   319
    // Calculate the size hint to be returned.
hgs
parents: 25
diff changeset
   320
    szHint.setHeight(0);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   321
37
hgs
parents: 25
diff changeset
   322
    if (!slideCounterSize.isNull()) {
hgs
parents: 25
diff changeset
   323
        szHint.rheight() += (slideCounterSize.height() + spacing);
hgs
parents: 25
diff changeset
   324
    }
hgs
parents: 25
diff changeset
   325
    if (!audioSize.isNull()) {
hgs
parents: 25
diff changeset
   326
        szHint.rheight() += (audioSize.height() + spacing);
hgs
parents: 25
diff changeset
   327
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   328
37
hgs
parents: 25
diff changeset
   329
    if (mainWindow->orientation() == Qt::Horizontal) {
hgs
parents: 25
diff changeset
   330
        qreal remainingHeight = qMax(pixmapSize.height(), textSize.height());
hgs
parents: 25
diff changeset
   331
        if (remainingHeight > 0.0) {
hgs
parents: 25
diff changeset
   332
            szHint.rheight() += (remainingHeight + spacing);
hgs
parents: 25
diff changeset
   333
        }
hgs
parents: 25
diff changeset
   334
    }
hgs
parents: 25
diff changeset
   335
    else if (mainWindow->orientation() == Qt::Vertical) {
hgs
parents: 25
diff changeset
   336
        if (!pixmapSize.isNull()) {
hgs
parents: 25
diff changeset
   337
            szHint.rheight() += (pixmapSize.height() + spacing);
hgs
parents: 25
diff changeset
   338
        }
hgs
parents: 25
diff changeset
   339
        if (!textSize.isNull()) {
hgs
parents: 25
diff changeset
   340
            szHint.rheight() += (textSize.height() + spacing);
hgs
parents: 25
diff changeset
   341
        }
hgs
parents: 25
diff changeset
   342
    }
hgs
parents: 25
diff changeset
   343
    szHint.rheight() = qMax(maxHeight, szHint.height());
hgs
parents: 25
diff changeset
   344
hgs
parents: 25
diff changeset
   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
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   348
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   349
//UniViewerBodyWidget::setPixmap
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   350
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   351
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   352
void UniViewerBodyWidget::setPixmap(UniMessageInfo *info)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   353
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   354
    setHasPixmap(true);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   355
    //create image item instance
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   356
    if (!mPixmapItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   357
        mPixmapItem = new UniViewerPixmapWidget(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   358
        HbStyle::setItemName(mPixmapItem, "pixmap");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   359
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   360
    mPixmapItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   361
    mPixmapItem->populate(info);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   362
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   363
    this->repolish();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   364
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   365
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   366
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   367
//UniViewerBodyWidget::setAudio
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   368
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   369
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   370
void UniViewerBodyWidget::setAudio(UniMessageInfo *info)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   371
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   372
    if (!mAudioItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   373
        mAudioItem = new UniViewerAudioWidget(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   374
        HbStyle::setItemName(mAudioItem, "audioItem");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   375
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   376
    mAudioItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   377
    mAudioItem->populate(info);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   378
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   379
    this->repolish();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   380
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   381
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   382
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   383
//UniViewerBodyWidget::setVideo
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   384
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   385
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   386
void UniViewerBodyWidget::setVideo(UniMessageInfo *info)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   387
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   388
    setHasPixmap(true);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   389
    //create image item instance
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   390
    if (!mPixmapItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   391
        mPixmapItem = new UniViewerPixmapWidget(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   392
        HbStyle::setItemName(mPixmapItem, "pixmap");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   393
        connect(mPixmapItem, SIGNAL(thumbnailFound(bool, UniMessageInfo*)), this,
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   394
            SLOT(onThumbnailFound(bool, UniMessageInfo*)));
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   395
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   396
    mPixmapItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   397
    mPixmapItem->populate(info);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   398
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   399
    this->repolish();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   400
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   401
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   402
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   403
// UniViewerBodyWidget::setSlideCounter
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   404
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   405
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   406
void UniViewerBodyWidget::setSlideCounter(QString &slideCounter)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   407
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   408
    if (!mSlideCounter) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   409
        mSlideCounter = new HbTextItem(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   410
        HbStyle::setItemName(mSlideCounter, "slideCounter");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   411
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   412
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   413
    mSlideCounter->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   414
    mSlideCounter->setText(slideCounter);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   415
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   416
    this->repolish();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   417
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   418
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   419
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   420
// UniViewerBodyWidget::setOverlayIcon
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   421
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   422
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   423
void UniViewerBodyWidget::setOverlayIcon(const QString &iconName)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   424
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   425
    if (!mOverlayItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   426
        mOverlayItem = new HbIconItem(this);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   427
        HbStyle::setItemName(mOverlayItem, "overlayItem");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   428
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   429
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   430
    mOverlayItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   431
    mOverlayItem->setIconName(iconName);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   432
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   433
    this->repolish();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   434
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   435
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   436
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   437
// UniViewerBodyWidget::onThumbnailFound
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   438
// @see header file
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   439
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   440
void UniViewerBodyWidget::onThumbnailFound(bool result, UniMessageInfo *info)
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   441
{
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   442
    if (result) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   443
        // Thumbnail generation success
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   444
        setOverlayIcon(VIDEO_ICON);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   445
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   446
    else {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   447
        // Show video content in audio widget.
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   448
        setAudio(info);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   449
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   450
        // Remove the pixmap widget.
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   451
        setHasPixmap(false);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   452
        if (mPixmapItem) {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   453
            HbStyle::setItemName(mPixmapItem, "");
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   454
            mPixmapItem->hide();
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   455
        }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   456
    }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   457
}
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   458
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
// EOF