emailuis/nmhswidget/src/nmhswidgettitlerow.cpp
author hgs
Thu, 24 Jun 2010 14:32:18 +0300
changeset 47 f83bd4ae1fe3
parent 43 99bcbff212ad
child 49 00c7ae862740
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
578830873419 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
578830873419 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"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
578830873419 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".
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description: 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    18
#include <QtGui>
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <QGraphicsLinearLayout>
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <hbdocumentloader.h>
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <hblabel.h>
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    22
#include <HbPushButton>
43
hgs
parents: 23
diff changeset
    23
#include <HbColorScheme>
hgs
parents: 23
diff changeset
    24
#include <HbEvent>
47
hgs
parents: 43
diff changeset
    25
#include <hbframedrawer.h>
hgs
parents: 43
diff changeset
    26
#include <hbframeitem.h>
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "nmicons.h"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "nmhswidgettitlerow.h"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "nmhswidgetconsts.h"
43
hgs
parents: 23
diff changeset
    30
#include "emailtrace.h"
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    32
NmHsWidgetTitleRow::NmHsWidgetTitleRow(QGraphicsItem *parent, Qt::WindowFlags flags) :
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    33
    HbWidget(parent, flags), 
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    34
    mMailboxIcon(0), 
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    35
    mMailboxInfo(0), 
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    36
    mUnreadCountLabel(0),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    37
    mCollapseExpIconLabel(0), 
43
hgs
parents: 23
diff changeset
    38
    mAccountName(),
47
hgs
parents: 43
diff changeset
    39
    mUnreadCount(0),
hgs
parents: 43
diff changeset
    40
    mBackgroundLayoutItem(0)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
{
43
hgs
parents: 23
diff changeset
    42
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    46
 Destructor
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    47
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
NmHsWidgetTitleRow::~NmHsWidgetTitleRow()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
{
47
hgs
parents: 43
diff changeset
    50
    NM_FUNCTION; 
hgs
parents: 43
diff changeset
    51
}
hgs
parents: 43
diff changeset
    52
hgs
parents: 43
diff changeset
    53
/*!
hgs
parents: 43
diff changeset
    54
 \fn QPainterPath NmHsWidgetTitleRow::shape()
hgs
parents: 43
diff changeset
    55
hgs
parents: 43
diff changeset
    56
 Called by home screen fw to check widget boundaries, needed to draw
hgs
parents: 43
diff changeset
    57
 outside widget boundingRect.
hgs
parents: 43
diff changeset
    58
 /return QPainterPath path describing actual boundaries of widget 
hgs
parents: 43
diff changeset
    59
  including child items
hgs
parents: 43
diff changeset
    60
 */
hgs
parents: 43
diff changeset
    61
QPainterPath NmHsWidgetTitleRow::shape() const
hgs
parents: 43
diff changeset
    62
{
43
hgs
parents: 23
diff changeset
    63
    NM_FUNCTION;
47
hgs
parents: 43
diff changeset
    64
    
hgs
parents: 43
diff changeset
    65
    QPainterPath path;
hgs
parents: 43
diff changeset
    66
    path.setFillRule(Qt::WindingFill);
hgs
parents: 43
diff changeset
    67
    
hgs
parents: 43
diff changeset
    68
    path.addRect(this->geometry());
hgs
parents: 43
diff changeset
    69
    if (mMailboxIcon){
hgs
parents: 43
diff changeset
    70
        path.addRect(mMailboxIcon->geometry());
hgs
parents: 43
diff changeset
    71
    }    
hgs
parents: 43
diff changeset
    72
    return path.simplified();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
}
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    74
47
hgs
parents: 43
diff changeset
    75
/*
hgs
parents: 43
diff changeset
    76
 Setup email row ui
hgs
parents: 43
diff changeset
    77
  Must be called after constructor.
hgs
parents: 43
diff changeset
    78
   /return true if loading succeeded, otherwise false. False indicates that object is unusable.
hgs
parents: 43
diff changeset
    79
 */
hgs
parents: 43
diff changeset
    80
bool NmHsWidgetTitleRow::setupUI()
hgs
parents: 43
diff changeset
    81
    {
hgs
parents: 43
diff changeset
    82
    NM_FUNCTION;
hgs
parents: 43
diff changeset
    83
hgs
parents: 43
diff changeset
    84
    if(!loadDocML() || !setupGraphics()){
hgs
parents: 43
diff changeset
    85
        return false;
hgs
parents: 43
diff changeset
    86
    }
hgs
parents: 43
diff changeset
    87
    return true;
hgs
parents: 43
diff changeset
    88
    }
hgs
parents: 43
diff changeset
    89
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    91
 Loads layout data and child items from docml file. Must be called after constructor.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    92
 /return true if loading succeeded, otherwise false. False indicates that object is unusable
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    93
 */
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    94
bool NmHsWidgetTitleRow::loadDocML()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
{
43
hgs
parents: 23
diff changeset
    96
    NM_FUNCTION;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    97
    QT_TRY{
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    98
        // Use document loader to load the contents
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    99
        HbDocumentLoader loader;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   100
        bool ok(false);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   101
        loader.load(KNmHsWidgetTitleRowDocML, &ok);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   102
        if (!ok) {
43
hgs
parents: 23
diff changeset
   103
            NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ loader");
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   104
            return false; //failure
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   105
        }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   106
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   107
        //Create layout
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   108
        QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   109
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   110
        layout->setContentsMargins(KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin,
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
            KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   112
        layout->setSpacing(KNmHsWidgetContentsMargin);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   113
        setLayout(layout); //pass the ownership
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   115
        // find container widget
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   116
        QGraphicsWidget *container = loader.findWidget(KNmHsWidgetTitleRowContainer);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   117
        if (!container) {
43
hgs
parents: 23
diff changeset
   118
            NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ container");
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   119
            return false;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   120
        }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   121
        layout->addItem(container);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   123
        //child items possible to update
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   124
        mMailboxIcon = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxIcon));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   125
        mMailboxInfo = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetTitleRowMailboxNameLabel));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   126
        mUnreadCountLabel = static_cast<HbLabel*> (loader.findWidget(
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   127
            KNmHsWidgetTitleRowUnreadCountLabel));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   128
        mCollapseExpIconLabel = static_cast<HbPushButton*> (loader.findWidget(
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   129
            KNmHsWidgetTitleRowCollapseExpandIconLabel));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   131
        if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) {
43
hgs
parents: 23
diff changeset
   132
            NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ icons & labels");
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   133
            return false;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   134
        }
47
hgs
parents: 43
diff changeset
   135
		
hgs
parents: 43
diff changeset
   136
		//Expand collapse button
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   137
        connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed()));
47
hgs
parents: 43
diff changeset
   138
		
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   139
        return true;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   140
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   141
    QT_CATCH(...){
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   142
        return false;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   143
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
47
hgs
parents: 43
diff changeset
   146
/*
hgs
parents: 43
diff changeset
   147
 Setup graphics that cannot be loaded from docml.
hgs
parents: 43
diff changeset
   148
  /return true if loading succeeded, otherwise false. False indicates that object is unusable.
hgs
parents: 43
diff changeset
   149
 */
hgs
parents: 43
diff changeset
   150
bool NmHsWidgetTitleRow::setupGraphics()
hgs
parents: 43
diff changeset
   151
    {
hgs
parents: 43
diff changeset
   152
    NM_FUNCTION;
hgs
parents: 43
diff changeset
   153
    
hgs
parents: 43
diff changeset
   154
    HbFrameDrawer* backgroundFrameDrawer = 0;
hgs
parents: 43
diff changeset
   155
    QT_TRY{
hgs
parents: 43
diff changeset
   156
        //pressed background
hgs
parents: 43
diff changeset
   157
        backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces);
hgs
parents: 43
diff changeset
   158
        mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer );
hgs
parents: 43
diff changeset
   159
        setBackgroundItem( mBackgroundLayoutItem );
hgs
parents: 43
diff changeset
   160
		mBackgroundLayoutItem->hide();
hgs
parents: 43
diff changeset
   161
        
hgs
parents: 43
diff changeset
   162
        //set fonts color
hgs
parents: 43
diff changeset
   163
		setHighlighedFontsColor(false);
hgs
parents: 43
diff changeset
   164
hgs
parents: 43
diff changeset
   165
        return true;
hgs
parents: 43
diff changeset
   166
    }
hgs
parents: 43
diff changeset
   167
    QT_CATCH(...){
hgs
parents: 43
diff changeset
   168
        if(!mBackgroundLayoutItem && backgroundFrameDrawer){
hgs
parents: 43
diff changeset
   169
            delete backgroundFrameDrawer;
hgs
parents: 43
diff changeset
   170
            backgroundFrameDrawer = NULL;
hgs
parents: 43
diff changeset
   171
        }
hgs
parents: 43
diff changeset
   172
hgs
parents: 43
diff changeset
   173
        return false;
hgs
parents: 43
diff changeset
   174
    }
hgs
parents: 43
diff changeset
   175
    
hgs
parents: 43
diff changeset
   176
    }
hgs
parents: 43
diff changeset
   177
hgs
parents: 43
diff changeset
   178
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   180
 Slot for updating account name, calls updateData to update ui.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   181
 */
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   182
void NmHsWidgetTitleRow::updateAccountName(const QString& accountName)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   183
{
43
hgs
parents: 23
diff changeset
   184
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    mAccountName = accountName;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    updateData();
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   187
}
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   190
 Set account icon name
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   191
 */
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   192
void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   193
{
43
hgs
parents: 23
diff changeset
   194
    NM_FUNCTION;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   195
    mMailboxIcon->setIcon(accountIconName);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   196
}
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   197
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   198
/*!
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   199
 Slot for updating unread count, calls updateData to update ui.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   200
 */
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   201
void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   202
{
43
hgs
parents: 23
diff changeset
   203
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    mUnreadCount = unreadCount;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
    updateData();
43
hgs
parents: 23
diff changeset
   206
}
hgs
parents: 23
diff changeset
   207
hgs
parents: 23
diff changeset
   208
hgs
parents: 23
diff changeset
   209
/*!
hgs
parents: 23
diff changeset
   210
 Slot for updating expand collapse icon
hgs
parents: 23
diff changeset
   211
 */
hgs
parents: 23
diff changeset
   212
void NmHsWidgetTitleRow::setExpandCollapseIcon(const bool& expand)
hgs
parents: 23
diff changeset
   213
{
hgs
parents: 23
diff changeset
   214
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   215
    if(expand){
hgs
parents: 23
diff changeset
   216
        HbIcon icon("qtg_mono_arrow_up");
hgs
parents: 23
diff changeset
   217
        mCollapseExpIconLabel->setIcon(icon);
hgs
parents: 23
diff changeset
   218
    }
hgs
parents: 23
diff changeset
   219
    else{
hgs
parents: 23
diff changeset
   220
        HbIcon icon("qtg_mono_arrow_down");
hgs
parents: 23
diff changeset
   221
        mCollapseExpIconLabel->setIcon(icon);
hgs
parents: 23
diff changeset
   222
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   223
}
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   226
 Update the data displayed in the UI
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   227
 */
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
void NmHsWidgetTitleRow::updateData()
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   229
{
43
hgs
parents: 23
diff changeset
   230
    NM_FUNCTION;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   231
    mMailboxInfo->setPlainText(mAccountName);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   232
    //If unread count is -1, hide the unread count label completely.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   233
    //This indicates that there are no mails at all (or the initial sync is not done)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   234
    if (mUnreadCount != -1) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   235
        QString unreadCount(hbTrId("txt_mail_widget_list_l1").arg(mUnreadCount));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   236
        mUnreadCountLabel->setPlainText(unreadCount);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   237
        mUnreadCountLabel->setVisible(true);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   238
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   239
    else {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   240
        mUnreadCountLabel->setVisible(false);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   242
}
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   243
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   244
/*!
43
hgs
parents: 23
diff changeset
   245
    sets fonts color.
47
hgs
parents: 43
diff changeset
   246
    /param bool pressed indicates if row is pressed down or not
43
hgs
parents: 23
diff changeset
   247
*/
47
hgs
parents: 43
diff changeset
   248
void NmHsWidgetTitleRow::setHighlighedFontsColor( bool pressed )
43
hgs
parents: 23
diff changeset
   249
    {
hgs
parents: 23
diff changeset
   250
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   251
    QColor newFontColor;
hgs
parents: 23
diff changeset
   252
    
hgs
parents: 23
diff changeset
   253
    if(pressed){
hgs
parents: 23
diff changeset
   254
        newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed");
hgs
parents: 23
diff changeset
   255
    }
hgs
parents: 23
diff changeset
   256
    else{
hgs
parents: 23
diff changeset
   257
        newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal");
hgs
parents: 23
diff changeset
   258
    }
hgs
parents: 23
diff changeset
   259
 
hgs
parents: 23
diff changeset
   260
    mMailboxInfo->setTextColor(newFontColor);
hgs
parents: 23
diff changeset
   261
    mUnreadCountLabel->setTextColor(newFontColor);
hgs
parents: 23
diff changeset
   262
    }
hgs
parents: 23
diff changeset
   263
47
hgs
parents: 43
diff changeset
   264
/*!
hgs
parents: 43
diff changeset
   265
    change background pressed state
hgs
parents: 43
diff changeset
   266
    /param bool show if true then shown, false hide
hgs
parents: 43
diff changeset
   267
*/
hgs
parents: 43
diff changeset
   268
void NmHsWidgetTitleRow::showHighlight( bool show )
hgs
parents: 43
diff changeset
   269
    {
hgs
parents: 43
diff changeset
   270
    NM_FUNCTION;;
hgs
parents: 43
diff changeset
   271
    
hgs
parents: 43
diff changeset
   272
    if(show){
hgs
parents: 43
diff changeset
   273
        mBackgroundLayoutItem->show();
hgs
parents: 43
diff changeset
   274
    }
hgs
parents: 43
diff changeset
   275
    else{
hgs
parents: 43
diff changeset
   276
        mBackgroundLayoutItem->hide();
hgs
parents: 43
diff changeset
   277
    }
hgs
parents: 43
diff changeset
   278
    }
43
hgs
parents: 23
diff changeset
   279
hgs
parents: 23
diff changeset
   280
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   281
 mousePressEvent(QGraphicsSceneMouseEvent *event)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   282
 */
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   283
void NmHsWidgetTitleRow::mousePressEvent(QGraphicsSceneMouseEvent *event)
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   284
{
43
hgs
parents: 23
diff changeset
   285
    NM_FUNCTION;
47
hgs
parents: 43
diff changeset
   286
	
hgs
parents: 43
diff changeset
   287
	//to avoid opening email account mistakenly  when tabbing expand/collapse button
hgs
parents: 43
diff changeset
   288
	//we dont handle events that are on the top, down or right side of the button
hgs
parents: 43
diff changeset
   289
    if(event->pos().x() < mUnreadCountLabel->geometry().right())
hgs
parents: 43
diff changeset
   290
        {
hgs
parents: 43
diff changeset
   291
        setHighlighedFontsColor(true);
hgs
parents: 43
diff changeset
   292
        showHighlight(true);
hgs
parents: 43
diff changeset
   293
        }
43
hgs
parents: 23
diff changeset
   294
}
hgs
parents: 23
diff changeset
   295
hgs
parents: 23
diff changeset
   296
/*!
hgs
parents: 23
diff changeset
   297
    mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
hgs
parents: 23
diff changeset
   298
*/
hgs
parents: 23
diff changeset
   299
void NmHsWidgetTitleRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
hgs
parents: 23
diff changeset
   300
{
hgs
parents: 23
diff changeset
   301
    NM_FUNCTION;
47
hgs
parents: 43
diff changeset
   302
	
hgs
parents: 43
diff changeset
   303
	//to avoid opening email account mistakenly when tabbing expand/collapse button
hgs
parents: 43
diff changeset
   304
	//we dont handle events that are on the top, down or right side of the button
hgs
parents: 43
diff changeset
   305
    if(event->pos().x() < mUnreadCountLabel->geometry().right())
hgs
parents: 43
diff changeset
   306
        {
hgs
parents: 43
diff changeset
   307
        setHighlighedFontsColor(false);
hgs
parents: 43
diff changeset
   308
        showHighlight(false);
hgs
parents: 43
diff changeset
   309
        emit mailboxLaunchTriggered();
hgs
parents: 43
diff changeset
   310
        }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   311
}
43
hgs
parents: 23
diff changeset
   312
hgs
parents: 23
diff changeset
   313
/*
hgs
parents: 23
diff changeset
   314
 * NmHsWidgetTitleRow::event()
hgs
parents: 23
diff changeset
   315
 */
hgs
parents: 23
diff changeset
   316
bool NmHsWidgetTitleRow::event( QEvent *event )
hgs
parents: 23
diff changeset
   317
{
hgs
parents: 23
diff changeset
   318
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   319
    QEvent::Type eventType = event->type();
hgs
parents: 23
diff changeset
   320
    if( eventType == HbEvent::ThemeChanged ){
47
hgs
parents: 43
diff changeset
   321
        setHighlighedFontsColor(false);
43
hgs
parents: 23
diff changeset
   322
        return true;
hgs
parents: 23
diff changeset
   323
    }
hgs
parents: 23
diff changeset
   324
    return HbWidget::event(event);
hgs
parents: 23
diff changeset
   325
}