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