messagingapp/msgui/unifiedviewer/src/univiewerbodywidget.cpp
author hgs
Fri, 09 Jul 2010 14:46:10 +0530
changeset 41 25fe1fe642e3
parent 37 518b245aa84c
child 46 b1f0785c289d
permissions -rw-r--r--
201027_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
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
//UniViewerBodyWidget::UniViewerBodyWidget
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
UniViewerBodyWidget::UniViewerBodyWidget(QGraphicsItem *parent) :
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    42
    HbWidget(parent), mHasText(false), mHasPixmap(false), mTextItem(0), mSlideCounter(0),
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
    43
        mPixmapItem(0), mAudioItem(0), mOverlayItem(0)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
{
37
hgs
parents: 25
diff changeset
    45
    this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
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
//UniViewerBodyWidget::~UniViewerBodyWidget
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
UniViewerBodyWidget::~UniViewerBodyWidget()
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
}
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
//UniViewerBodyWidget::setImage
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
    60
void UniViewerBodyWidget::setPixmap(UniMessageInfo *info)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    62
    setHasPixmap(true);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    //create image item instance
37
hgs
parents: 25
diff changeset
    64
    if (!mPixmapItem) {
hgs
parents: 25
diff changeset
    65
        mPixmapItem = new UniViewerPixmapWidget(this);
hgs
parents: 25
diff changeset
    66
        HbStyle::setItemName(mPixmapItem, "pixmap");
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    }
37
hgs
parents: 25
diff changeset
    68
    mPixmapItem->hide();
hgs
parents: 25
diff changeset
    69
    mPixmapItem->populate(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    70
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    this->repolish();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
//UniViewerBodyWidget::setAudio
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
    78
void UniViewerBodyWidget::setAudio(UniMessageInfo *info)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    if (!mAudioItem) {
37
hgs
parents: 25
diff changeset
    81
        mAudioItem = new UniViewerAudioWidget(this);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
        HbStyle::setItemName(mAudioItem, "audioItem");
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    }
37
hgs
parents: 25
diff changeset
    84
    mAudioItem->hide();
hgs
parents: 25
diff changeset
    85
    mAudioItem->populate(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    86
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    this->repolish();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
//UniViewerBodyWidget::setVideo
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
    94
void UniViewerBodyWidget::setVideo(UniMessageInfo *info)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
{
37
hgs
parents: 25
diff changeset
    96
    setHasPixmap(true);
hgs
parents: 25
diff changeset
    97
    //create image item instance
hgs
parents: 25
diff changeset
    98
    if (!mPixmapItem) {
hgs
parents: 25
diff changeset
    99
       mPixmapItem = new UniViewerPixmapWidget(this);
hgs
parents: 25
diff changeset
   100
       HbStyle::setItemName(mPixmapItem, "pixmap");
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   101
       connect(mPixmapItem, SIGNAL(setOverlayIcon(QString)), this, SLOT(setOverlayIcon(QString)));
37
hgs
parents: 25
diff changeset
   102
    }
hgs
parents: 25
diff changeset
   103
    mPixmapItem->hide();
hgs
parents: 25
diff changeset
   104
    mPixmapItem->populate(info);
hgs
parents: 25
diff changeset
   105
    
hgs
parents: 25
diff changeset
   106
    this->repolish();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   110
//UniViewerBodyWidget::setText
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   111
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   112
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   113
void UniViewerBodyWidget::setText(QString text)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   114
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   115
    setHasText(true);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   116
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   117
    if (!mTextItem) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   118
        mTextItem = new UniViewerTextItem(this);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   119
        HbStyle::setItemName(mTextItem, "textItem");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   120
        connect(mTextItem, SIGNAL(sendMessage(const QString&)), this,
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   121
            SIGNAL(sendMessage(const QString&)));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   122
    }
37
hgs
parents: 25
diff changeset
   123
    mTextItem->hide();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   124
    text.replace(QChar::ParagraphSeparator, QChar::LineSeparator);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   125
    text.replace('\r', QChar::LineSeparator);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   126
    mTextItem->setText(text);
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   127
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   128
    this->repolish();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   129
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   130
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   131
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   132
// UniViewerBodyWidget::setSlideCounter
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   133
// @see header file
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
void UniViewerBodyWidget::setSlideCounter(QString &slideCounter)
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
    if (!mSlideCounter) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   138
        mSlideCounter = new HbTextItem(this);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   139
        HbStyle::setItemName(mSlideCounter, "slideCounter");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   140
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   141
37
hgs
parents: 25
diff changeset
   142
    mSlideCounter->hide();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   143
    mSlideCounter->setText(slideCounter);
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   144
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   145
    this->repolish();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   146
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   147
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   148
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   149
// UniViewerBodyWidget::setHasText
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   150
// @see header file
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
void UniViewerBodyWidget::setHasText(bool text)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   153
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   154
    mHasText = text;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   155
}
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
// UniViewerBodyWidget::hasText
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   159
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   160
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   161
bool UniViewerBodyWidget::hasText()
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
    return mHasText;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   164
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   165
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   166
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   167
// UniViewerBodyWidget::setHasPixmap
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   168
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   169
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   170
void UniViewerBodyWidget::setHasPixmap(bool pixmap)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   171
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   172
    mHasPixmap = pixmap;
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
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   176
// UniViewerBodyWidget::hasPixmap
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   177
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   178
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   179
bool UniViewerBodyWidget::hasPixmap()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   180
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   181
    return mHasPixmap;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   182
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   183
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   184
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   185
// UniViewerBodyWidget::setSlideContents
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   186
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   187
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   188
void UniViewerBodyWidget::setSlideContents(UniMessageInfoList objList, QString slideString)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   189
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   190
    if (!slideString.isEmpty()) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   191
        setSlideCounter(slideString);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   192
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   193
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   194
    int count = objList.count();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   195
    for (int a = 0; a < count; ++a) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   196
        UniMessageInfo* info = objList.at(a);
37
hgs
parents: 25
diff changeset
   197
        QString mimeType = info->mimetype();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   198
37
hgs
parents: 25
diff changeset
   199
        if (mimeType.contains(TEXT_MIMETYPE)) {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   200
            QFile file(info->path());
37
hgs
parents: 25
diff changeset
   201
            if (file.open(QIODevice::ReadOnly)) {
hgs
parents: 25
diff changeset
   202
                QString textContent(file.readAll());
hgs
parents: 25
diff changeset
   203
                setText(textContent);
hgs
parents: 25
diff changeset
   204
            }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   205
        }
37
hgs
parents: 25
diff changeset
   206
        else if (mimeType.contains(AUDIO_MIMETYPE)) {
hgs
parents: 25
diff changeset
   207
            setAudio(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   208
        }
37
hgs
parents: 25
diff changeset
   209
        else if (mimeType.contains(VIDEO_MIMETYPE)) {
hgs
parents: 25
diff changeset
   210
            setVideo(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   211
        }
37
hgs
parents: 25
diff changeset
   212
        else if (mimeType.contains(IMAGE_MIMETYPE)) {
hgs
parents: 25
diff changeset
   213
            setPixmap(info);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   214
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   215
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   216
        delete info;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   217
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   218
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   219
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   220
//---------------------------------------------------------------
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   221
// UniViewerBodyWidget :: clearContent
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   222
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   223
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   224
void UniViewerBodyWidget::clearContent()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   225
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   226
    // delete the temp items(pixmap) & clear permanent items(text)
37
hgs
parents: 25
diff changeset
   227
    if (mPixmapItem) {
hgs
parents: 25
diff changeset
   228
        mPixmapItem->setParent(NULL);
hgs
parents: 25
diff changeset
   229
        delete mPixmapItem;
hgs
parents: 25
diff changeset
   230
        mPixmapItem = NULL;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   231
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   232
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   233
    if (mAudioItem) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   234
        mAudioItem->setParent(NULL);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   235
        delete mAudioItem;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   236
        mAudioItem = NULL;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   237
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   238
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   239
    if (mTextItem) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   240
        mTextItem->setParent(NULL);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   241
        delete mTextItem;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   242
        mTextItem = NULL;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   243
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   244
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   245
    if (mOverlayItem) {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   246
        mOverlayItem->setParent(NULL);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   247
        delete mOverlayItem;
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   248
        mOverlayItem = NULL;
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   249
    }
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   250
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   251
    setHasText(false);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   252
    setHasPixmap(false);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   253
    repolish();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   254
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   255
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   256
//---------------------------------------------------------------
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   257
// UniViewerBodyWidget::setOverlayIcon
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   258
// @see header file
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   259
//---------------------------------------------------------------
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   260
void UniViewerBodyWidget::setOverlayIcon(const QString &iconName)
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   261
{
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   262
    if (!mOverlayItem) {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   263
        mOverlayItem = new HbIconItem(this);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   264
        HbStyle::setItemName(mOverlayItem, "overlayItem");
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   265
    }
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   266
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   267
    mOverlayItem->hide();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   268
    mOverlayItem->setIconName(iconName);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   269
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   270
    this->repolish();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   271
}
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   272
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   273
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   274
//UniViewerBodyWidget::sizeHint
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   277
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
   278
{
37
hgs
parents: 25
diff changeset
   279
    QSizeF szHint = HbWidget::sizeHint(which, constraint);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
37
hgs
parents: 25
diff changeset
   281
    HbMainWindow *mainWindow = this->mainWindow();
hgs
parents: 25
diff changeset
   282
    if (!mainWindow) {
hgs
parents: 25
diff changeset
   283
        return szHint;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   284
    }
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 screenWidth = 0.0;
hgs
parents: 25
diff changeset
   287
    qreal screenHeight = 0.0;
hgs
parents: 25
diff changeset
   288
    qreal leftMargin = 0.0;
hgs
parents: 25
diff changeset
   289
    qreal rightMargin = 0.0;
hgs
parents: 25
diff changeset
   290
    qreal chromeHeight = 0.0;
hgs
parents: 25
diff changeset
   291
    qreal toolbarHeight = 0.0;
hgs
parents: 25
diff changeset
   292
    qreal iconSize = 0.0;
hgs
parents: 25
diff changeset
   293
    qreal spacing = 0.0;
hgs
parents: 25
diff changeset
   294
    qreal unitSize = HbDeviceProfile::profile(mPixmapItem).unitValue();
hgs
parents: 25
diff changeset
   295
    style()->parameter("hb-param-screen-width", screenWidth);
hgs
parents: 25
diff changeset
   296
    style()->parameter("hb-param-screen-height", screenHeight);
hgs
parents: 25
diff changeset
   297
    style()->parameter("hb-param-margin-gene-left", leftMargin);
hgs
parents: 25
diff changeset
   298
    style()->parameter("hb-param-margin-gene-right", rightMargin);
hgs
parents: 25
diff changeset
   299
    style()->parameter("hb-param-widget-chrome-height", chromeHeight);
hgs
parents: 25
diff changeset
   300
    style()->parameter("hb-param-widget-toolbar-height", toolbarHeight);
hgs
parents: 25
diff changeset
   301
    style()->parameter("hb-param-graphic-size-primary-large", iconSize);
hgs
parents: 25
diff changeset
   302
    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
   303
37
hgs
parents: 25
diff changeset
   304
    qreal maxWidth = 0.0;
hgs
parents: 25
diff changeset
   305
    qreal maxHeight = 0.0;
hgs
parents: 25
diff changeset
   306
hgs
parents: 25
diff changeset
   307
    // Calculate max height & max width.
hgs
parents: 25
diff changeset
   308
    if (mainWindow->orientation() == Qt::Horizontal) {
hgs
parents: 25
diff changeset
   309
        qreal temp;
hgs
parents: 25
diff changeset
   310
        temp = screenWidth;
hgs
parents: 25
diff changeset
   311
        screenWidth = screenHeight;
hgs
parents: 25
diff changeset
   312
        screenHeight = temp;
hgs
parents: 25
diff changeset
   313
hgs
parents: 25
diff changeset
   314
        if (mPixmapItem && mHasText) {
hgs
parents: 25
diff changeset
   315
            maxWidth = (screenWidth / 2) - leftMargin - unitSize;
hgs
parents: 25
diff changeset
   316
        }
hgs
parents: 25
diff changeset
   317
        else {
hgs
parents: 25
diff changeset
   318
            maxWidth = screenWidth - leftMargin - rightMargin;
hgs
parents: 25
diff changeset
   319
        }
hgs
parents: 25
diff changeset
   320
        maxHeight = screenHeight - chromeHeight - toolbarHeight;
hgs
parents: 25
diff changeset
   321
hgs
parents: 25
diff changeset
   322
        if (mAudioItem) {
hgs
parents: 25
diff changeset
   323
            mAudioItem->setStretched(true);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   324
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   325
    }
37
hgs
parents: 25
diff changeset
   326
    else if (mainWindow->orientation() == Qt::Vertical) {
hgs
parents: 25
diff changeset
   327
        maxWidth = screenWidth - leftMargin - rightMargin;
hgs
parents: 25
diff changeset
   328
        maxHeight = screenHeight - chromeHeight - toolbarHeight;
hgs
parents: 25
diff changeset
   329
hgs
parents: 25
diff changeset
   330
        if (mAudioItem) {
hgs
parents: 25
diff changeset
   331
            mAudioItem->setStretched(false);
hgs
parents: 25
diff changeset
   332
        }
hgs
parents: 25
diff changeset
   333
    }
hgs
parents: 25
diff changeset
   334
hgs
parents: 25
diff changeset
   335
    // Slide Counter
hgs
parents: 25
diff changeset
   336
    QSizeF slideCounterSize(0, 0);
hgs
parents: 25
diff changeset
   337
    if (mSlideCounter) {
hgs
parents: 25
diff changeset
   338
        slideCounterSize = mSlideCounter->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   339
        mSlideCounter->show();
hgs
parents: 25
diff changeset
   340
    }
hgs
parents: 25
diff changeset
   341
    // Audio Item
hgs
parents: 25
diff changeset
   342
    QSizeF audioSize(0, 0);
hgs
parents: 25
diff changeset
   343
    if (mAudioItem) {
hgs
parents: 25
diff changeset
   344
        audioSize = mAudioItem->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   345
        mAudioItem->show();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   346
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   347
37
hgs
parents: 25
diff changeset
   348
    // Text Item
hgs
parents: 25
diff changeset
   349
    QSizeF textSize(0, 0);
hgs
parents: 25
diff changeset
   350
    if (mTextItem) {
hgs
parents: 25
diff changeset
   351
        textSize = mTextItem->effectiveSizeHint(which, constraint);
hgs
parents: 25
diff changeset
   352
        mTextItem->show();
hgs
parents: 25
diff changeset
   353
    }
hgs
parents: 25
diff changeset
   354
hgs
parents: 25
diff changeset
   355
    // Pixmap Item
hgs
parents: 25
diff changeset
   356
    QSizeF pixmapSize(0, 0);
hgs
parents: 25
diff changeset
   357
    if (mPixmapItem) {
hgs
parents: 25
diff changeset
   358
        qreal imageWidth = mPixmapItem->icon().defaultSize().width();
hgs
parents: 25
diff changeset
   359
        qreal imageHeight = mPixmapItem->icon().defaultSize().height();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   360
37
hgs
parents: 25
diff changeset
   361
        qreal widthToSet = 0.0;
hgs
parents: 25
diff changeset
   362
        qreal heightToSet = 0.0;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   363
37
hgs
parents: 25
diff changeset
   364
        if (imageWidth < iconSize) {
hgs
parents: 25
diff changeset
   365
            widthToSet = iconSize;
hgs
parents: 25
diff changeset
   366
            heightToSet = iconSize;
hgs
parents: 25
diff changeset
   367
        }
hgs
parents: 25
diff changeset
   368
        else if (imageWidth <= maxWidth) {
hgs
parents: 25
diff changeset
   369
            // resize not needed
hgs
parents: 25
diff changeset
   370
            widthToSet = imageWidth;
hgs
parents: 25
diff changeset
   371
            heightToSet = qMin(imageHeight, maxHeight);
hgs
parents: 25
diff changeset
   372
        }
hgs
parents: 25
diff changeset
   373
        else {
hgs
parents: 25
diff changeset
   374
            // resize needed, keep aspect-ratio and resize
hgs
parents: 25
diff changeset
   375
            widthToSet = maxWidth;
hgs
parents: 25
diff changeset
   376
            heightToSet = maxWidth * (imageHeight / imageWidth);
hgs
parents: 25
diff changeset
   377
            heightToSet = qMin(heightToSet, maxHeight);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   378
37
hgs
parents: 25
diff changeset
   379
        }
hgs
parents: 25
diff changeset
   380
        if (heightToSet == maxHeight) {
hgs
parents: 25
diff changeset
   381
            widthToSet = heightToSet * (imageWidth / imageHeight);
hgs
parents: 25
diff changeset
   382
        }
hgs
parents: 25
diff changeset
   383
hgs
parents: 25
diff changeset
   384
        pixmapSize.setHeight(heightToSet);
hgs
parents: 25
diff changeset
   385
        pixmapSize.setWidth(widthToSet);
hgs
parents: 25
diff changeset
   386
        mPixmapItem->setPreferredSize(pixmapSize);
hgs
parents: 25
diff changeset
   387
        mPixmapItem->show();
hgs
parents: 25
diff changeset
   388
    }
hgs
parents: 25
diff changeset
   389
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   390
    if (mOverlayItem) {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   391
        mOverlayItem->show();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   392
    }
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   393
37
hgs
parents: 25
diff changeset
   394
    // Calculate the size hint to be returned.
hgs
parents: 25
diff changeset
   395
    szHint.setHeight(0);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   396
37
hgs
parents: 25
diff changeset
   397
    if (!slideCounterSize.isNull()) {
hgs
parents: 25
diff changeset
   398
        szHint.rheight() += (slideCounterSize.height() + spacing);
hgs
parents: 25
diff changeset
   399
    }
hgs
parents: 25
diff changeset
   400
    if (!audioSize.isNull()) {
hgs
parents: 25
diff changeset
   401
        szHint.rheight() += (audioSize.height() + spacing);
hgs
parents: 25
diff changeset
   402
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   403
37
hgs
parents: 25
diff changeset
   404
    if (mainWindow->orientation() == Qt::Horizontal) {
hgs
parents: 25
diff changeset
   405
        qreal remainingHeight = qMax(pixmapSize.height(), textSize.height());
hgs
parents: 25
diff changeset
   406
        if (remainingHeight > 0.0) {
hgs
parents: 25
diff changeset
   407
            szHint.rheight() += (remainingHeight + spacing);
hgs
parents: 25
diff changeset
   408
        }
hgs
parents: 25
diff changeset
   409
    }
hgs
parents: 25
diff changeset
   410
    else if (mainWindow->orientation() == Qt::Vertical) {
hgs
parents: 25
diff changeset
   411
        if (!pixmapSize.isNull()) {
hgs
parents: 25
diff changeset
   412
            szHint.rheight() += (pixmapSize.height() + spacing);
hgs
parents: 25
diff changeset
   413
        }
hgs
parents: 25
diff changeset
   414
        if (!textSize.isNull()) {
hgs
parents: 25
diff changeset
   415
            szHint.rheight() += (textSize.height() + spacing);
hgs
parents: 25
diff changeset
   416
        }
hgs
parents: 25
diff changeset
   417
    }
hgs
parents: 25
diff changeset
   418
    szHint.rheight() = qMax(maxHeight, szHint.height());
hgs
parents: 25
diff changeset
   419
hgs
parents: 25
diff changeset
   420
    return szHint;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
// EOF