messagingapp/msgui/unifiededitor/src/msgunieditorattachment.cpp
author hgs
Fri, 06 Aug 2010 23:19:50 +0530
changeset 51 3507212d340e
parent 48 4f501b74aeb1
child 56 f42d9a78f435
permissions -rw-r--r--
201031_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description:
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
// INCLUDES
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include "debugtraces.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <HbTextItem>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbIconItem>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <QFileInfo>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QFont>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbFrameDrawer>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbMenu>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <MsgMimeTypes.h>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    27
#include <HbFrameItem>
37
hgs
parents: 25
diff changeset
    28
#include <HbInstantFeedback>
hgs
parents: 25
diff changeset
    29
#include <HbTapGesture>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    30
#include <QGraphicsSceneMouseEvent>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    31
#include <HbWidgetFeedback>
37
hgs
parents: 25
diff changeset
    32
#include <HbEffect>
hgs
parents: 25
diff changeset
    33
#include <QTimer>
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
// USER INCLUDES
37
hgs
parents: 25
diff changeset
    36
#include "msgcontactsutil.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "msgunieditorattachment.h"
37
hgs
parents: 25
diff changeset
    38
#include "UniEditorGenUtils.h"
hgs
parents: 25
diff changeset
    39
#include <xqconversions.h>
hgs
parents: 25
diff changeset
    40
#include "msgunieditorutils.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
// Constants
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#define BYTES_TO_KBYTES_FACTOR 1024
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#define BG_FRAME "qtg_fr_groupbox"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    46
//Localized Constants for item specific menu
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    47
#define LOC_OPEN    hbTrId("txt_common_menu_open")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    48
#define LOC_REMOVE  hbTrId("txt_common_menu_remove")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    49
#define LOC_DETAILS hbTrId("txt_common_menu_details")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    50
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    51
const QString LIST_ITEM_BG_FRAME_NORMAL ("qtg_fr_list_normal");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    52
const QString LIST_ITEM_BG_FRAME_PRESSED("qtg_fr_list_pressed");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    53
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    54
const QString ATTACHMENT_ICON("qtg_small_attachment");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    55
37
hgs
parents: 25
diff changeset
    56
MsgUnifiedEditorAttachment::MsgUnifiedEditorAttachment( const QString& attachmentpath,
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
                                                        const int filesize,
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
                                                        QGraphicsItem *parent ) :
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
HbWidget(parent),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
mPath(attachmentpath),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
mSize(filesize),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
mAttachmentIcon(0),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
mAttachmentName(0),
37
hgs
parents: 25
diff changeset
    64
mMaxSmsSize(KFirstNormalSmsLength),
hgs
parents: 25
diff changeset
    65
mEditorUtils(0)
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
    this->grabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
    68
    setProperty("state", "normal");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    69
    
37
hgs
parents: 25
diff changeset
    70
    //back ground
hgs
parents: 25
diff changeset
    71
    mBackGround = new HbFrameItem(this);
hgs
parents: 25
diff changeset
    72
    mBackGround->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_NORMAL);
hgs
parents: 25
diff changeset
    73
    mBackGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
hgs
parents: 25
diff changeset
    74
    this->setBackgroundItem(mBackGround);        
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
37
hgs
parents: 25
diff changeset
    76
    mAttachmentIcon = new HbIconItem(ATTACHMENT_ICON, this);
hgs
parents: 25
diff changeset
    77
    HbStyle::setItemName(mAttachmentIcon,"attachmentIcon");
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
37
hgs
parents: 25
diff changeset
    79
    int at_size = 0;
hgs
parents: 25
diff changeset
    80
    TMsgMediaType mediaType = EMsgMediaUnknown;
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    81
    
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
    82
            
3507212d340e 201031_02
hgs
parents: 48
diff changeset
    83
    UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    84
    
37
hgs
parents: 25
diff changeset
    85
    TRAP_IGNORE(genUtils->getFileInfoL(mPath,at_size,
hgs
parents: 25
diff changeset
    86
        mMimeType,mediaType));
hgs
parents: 25
diff changeset
    87
    TRAP_IGNORE(mMaxSmsSize = genUtils->MaxSmsMsgSizeL()); 
hgs
parents: 25
diff changeset
    88
    delete genUtils;
hgs
parents: 25
diff changeset
    89
    QFileInfo fileinfo(attachmentpath);
hgs
parents: 25
diff changeset
    90
    QString filename = fileinfo.fileName();
hgs
parents: 25
diff changeset
    91
    mAttachmentName = new HbTextItem(filename,this);
hgs
parents: 25
diff changeset
    92
    HbStyle::setItemName(mAttachmentName,"attachmentName");
hgs
parents: 25
diff changeset
    93
    mAttachmentName->setElideMode(Qt::ElideRight);
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
    // for sms, pure size should be shown
hgs
parents: 25
diff changeset
    96
    // for mms, additional mimeheader size must be included
hgs
parents: 25
diff changeset
    97
    qreal displaySize = mSize;
hgs
parents: 25
diff changeset
    98
    if(!isMultimediaContent())
hgs
parents: 25
diff changeset
    99
    {
hgs
parents: 25
diff changeset
   100
        displaySize = fileinfo.size();
hgs
parents: 25
diff changeset
   101
    }
hgs
parents: 25
diff changeset
   102
    int sizeInKb = displaySize/BYTES_TO_KBYTES_FACTOR;
hgs
parents: 25
diff changeset
   103
    QString fileDetails;
hgs
parents: 25
diff changeset
   104
    // if size exceeds 1kb, then show kb or else only bytes
hgs
parents: 25
diff changeset
   105
    if(sizeInKb >= 1)
hgs
parents: 25
diff changeset
   106
    {
hgs
parents: 25
diff changeset
   107
        fileDetails = QString().append(QString("(%1 Kb)").arg(sizeInKb));
hgs
parents: 25
diff changeset
   108
    }
hgs
parents: 25
diff changeset
   109
    else
hgs
parents: 25
diff changeset
   110
    {
hgs
parents: 25
diff changeset
   111
        fileDetails = QString().append(QString("(%1 B)").arg(displaySize));
hgs
parents: 25
diff changeset
   112
    }
hgs
parents: 25
diff changeset
   113
hgs
parents: 25
diff changeset
   114
    mAttachmentDetails = new HbTextItem(fileDetails, this);
hgs
parents: 25
diff changeset
   115
    HbStyle::setItemName(mAttachmentDetails,"attachmentDetails");
hgs
parents: 25
diff changeset
   116
    mAttachmentDetails->setElideMode(Qt::ElideNone);
hgs
parents: 25
diff changeset
   117
    
hgs
parents: 25
diff changeset
   118
    HbEffect::add("attachmentWidget", "listviewitem_press", "pressed");
hgs
parents: 25
diff changeset
   119
    HbEffect::add("attachmentWidget", "listviewitem_release", "released");
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
MsgUnifiedEditorAttachment::~MsgUnifiedEditorAttachment()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
const QString& MsgUnifiedEditorAttachment::path()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    return mPath;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
qreal MsgUnifiedEditorAttachment::size()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    return mSize;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
const QString& MsgUnifiedEditorAttachment::mimeType()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
    return mMimeType;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
37
hgs
parents: 25
diff changeset
   141
void MsgUnifiedEditorAttachment::handleLongTap(QPointF position)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    HbMenu* menu = new HbMenu;
37
hgs
parents: 25
diff changeset
   144
    menu->addAction(LOC_OPEN, this, SLOT(handleOpen()));
hgs
parents: 25
diff changeset
   145
    menu->addAction(LOC_REMOVE, this, SLOT(handleRemove()));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   146
    menu->addAction(LOC_DETAILS, this, SLOT(viewDetails()));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    menu->setDismissPolicy(HbPopup::TapAnywhere);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    menu->setAttribute(Qt::WA_DeleteOnClose, true);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    menu->setPreferredPos(position);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    menu->show();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
37
hgs
parents: 25
diff changeset
   153
void MsgUnifiedEditorAttachment::handleRemove()
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    emit deleteMe(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
37
hgs
parents: 25
diff changeset
   158
void MsgUnifiedEditorAttachment::handleOpen()
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
{
37
hgs
parents: 25
diff changeset
   160
    this->ungrabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
   161
    
hgs
parents: 25
diff changeset
   162
    //open corresponding viewer app
hgs
parents: 25
diff changeset
   163
hgs
parents: 25
diff changeset
   164
    if (!mEditorUtils) 
hgs
parents: 25
diff changeset
   165
    {
hgs
parents: 25
diff changeset
   166
        mEditorUtils = new MsgUnifiedEditorUtils(this);
hgs
parents: 25
diff changeset
   167
    }
hgs
parents: 25
diff changeset
   168
    mEditorUtils->launchContentViewer(mMimeType, mPath);
hgs
parents: 25
diff changeset
   169
    
hgs
parents: 25
diff changeset
   170
    //fire timer to regrab gesture after some delay.
hgs
parents: 25
diff changeset
   171
    QTimer::singleShot(300,this,SLOT(regrabGesture()));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
void MsgUnifiedEditorAttachment::viewDetails()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    //open details view.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
bool MsgUnifiedEditorAttachment::isMultimediaContent()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    bool ret = true;
37
hgs
parents: 25
diff changeset
   182
    QString vcard = XQConversions::s60Desc8ToQString(KMsgMimeVCard());
hgs
parents: 25
diff changeset
   183
    QString vcal = XQConversions::s60Desc8ToQString(KMsgMimeVCal());
hgs
parents: 25
diff changeset
   184
    QString ical = XQConversions::s60Desc8ToQString(KMsgMimeICal());
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    if( !QString::compare(mMimeType, vcard, Qt::CaseInsensitive) ||
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
        !QString::compare(mMimeType, vcal, Qt::CaseInsensitive) ||
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
        !QString::compare(mMimeType, ical, Qt::CaseInsensitive) )
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   189
        QFileInfo fileinfo(mPath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   190
        int fSize = fileinfo.size();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   191
        
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   192
        // if filesize is within sms size-limit, then
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   193
        // it is not mm content, else it is mm attachment
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   194
        if(fSize <= mMaxSmsSize)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   195
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   196
            ret = false;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   197
        }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    return ret;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
37
hgs
parents: 25
diff changeset
   202
void MsgUnifiedEditorAttachment::gestureEvent(QGestureEvent *event)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   203
{
37
hgs
parents: 25
diff changeset
   204
    HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture));
hgs
parents: 25
diff changeset
   205
    if (tapGesture) {
hgs
parents: 25
diff changeset
   206
        switch (tapGesture->state()) {
hgs
parents: 25
diff changeset
   207
        case Qt::GestureStarted:
hgs
parents: 25
diff changeset
   208
        {
hgs
parents: 25
diff changeset
   209
            // Trigger haptic feedback.
hgs
parents: 25
diff changeset
   210
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   211
            setPressed(true);
hgs
parents: 25
diff changeset
   212
            break;
hgs
parents: 25
diff changeset
   213
        }
hgs
parents: 25
diff changeset
   214
        case Qt::GestureUpdated:
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   215
        {
37
hgs
parents: 25
diff changeset
   216
            if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) {
hgs
parents: 25
diff changeset
   217
                // Handle longtap.
hgs
parents: 25
diff changeset
   218
                setPressed(false);
hgs
parents: 25
diff changeset
   219
                handleLongTap(tapGesture->scenePosition());
hgs
parents: 25
diff changeset
   220
            }
hgs
parents: 25
diff changeset
   221
            break;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   222
        }
37
hgs
parents: 25
diff changeset
   223
        case Qt::GestureFinished:
hgs
parents: 25
diff changeset
   224
        {
hgs
parents: 25
diff changeset
   225
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   226
            if (HbTapGesture::Tap == tapGesture->tapStyleHint()) {
hgs
parents: 25
diff changeset
   227
                // Handle short tap.
hgs
parents: 25
diff changeset
   228
                setPressed(false);
hgs
parents: 25
diff changeset
   229
                handleShortTap();
hgs
parents: 25
diff changeset
   230
            }
hgs
parents: 25
diff changeset
   231
            break;
hgs
parents: 25
diff changeset
   232
        }
hgs
parents: 25
diff changeset
   233
        case Qt::GestureCanceled:
hgs
parents: 25
diff changeset
   234
        {
hgs
parents: 25
diff changeset
   235
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   236
            setPressed(false);
hgs
parents: 25
diff changeset
   237
            break;
hgs
parents: 25
diff changeset
   238
        }
hgs
parents: 25
diff changeset
   239
        }
hgs
parents: 25
diff changeset
   240
    }
hgs
parents: 25
diff changeset
   241
    else {
hgs
parents: 25
diff changeset
   242
        HbWidget::gestureEvent(event);
hgs
parents: 25
diff changeset
   243
    }
25
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
37
hgs
parents: 25
diff changeset
   246
void MsgUnifiedEditorAttachment::handleShortTap()
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   247
{
37
hgs
parents: 25
diff changeset
   248
    handleOpen();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   249
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   250
37
hgs
parents: 25
diff changeset
   251
void MsgUnifiedEditorAttachment::setPressed(bool pressed)
hgs
parents: 25
diff changeset
   252
{
hgs
parents: 25
diff changeset
   253
    if (pressed) 
hgs
parents: 25
diff changeset
   254
    {
hgs
parents: 25
diff changeset
   255
        setProperty("state", "pressed");
hgs
parents: 25
diff changeset
   256
        mBackGround->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_PRESSED);
hgs
parents: 25
diff changeset
   257
        HbEffect::cancel(mBackGround, "released");
hgs
parents: 25
diff changeset
   258
        HbEffect::start(mBackGround, "attachmentWidget", "pressed");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   259
37
hgs
parents: 25
diff changeset
   260
    }
hgs
parents: 25
diff changeset
   261
    else 
hgs
parents: 25
diff changeset
   262
    {
hgs
parents: 25
diff changeset
   263
        setProperty("state", "normal");
hgs
parents: 25
diff changeset
   264
        mBackGround->frameDrawer().setFrameGraphicsName(LIST_ITEM_BG_FRAME_NORMAL);
hgs
parents: 25
diff changeset
   265
        HbEffect::cancel(mBackGround, "pressed");
hgs
parents: 25
diff changeset
   266
        HbEffect::start(mBackGround, "attachmentWidget", "released");
hgs
parents: 25
diff changeset
   267
    }    
hgs
parents: 25
diff changeset
   268
}
hgs
parents: 25
diff changeset
   269
hgs
parents: 25
diff changeset
   270
void MsgUnifiedEditorAttachment::regrabGesture()
hgs
parents: 25
diff changeset
   271
{
hgs
parents: 25
diff changeset
   272
    this->grabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
   273
}
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
// EOF