src/hbwidgets/sliders/hbprogresssliderhandle_p.cpp
author hgs
Mon, 18 Oct 2010 18:23:13 +0300
changeset 34 ed14f46c0e55
parent 6 c3690ec91ef8
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/****************************************************************************
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
** All rights reserved.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
** Contact: Nokia Corporation (developer.feedback@nokia.com)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
** This file is part of the HbWidgets module of the UI Extensions for Mobile.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
** GNU Lesser General Public License Usage
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
** This file may be used under the terms of the GNU Lesser General Public
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
** License version 2.1 as published by the Free Software Foundation and
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
** appearing in the file LICENSE.LGPL included in the packaging of this file.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
** Please review the following information to ensure the GNU Lesser General
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
** Public License version 2.1 requirements will be met:
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
** In addition, as a special exception, Nokia gives you certain additional
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
** rights.  These rights are described in the Nokia Qt LGPL Exception
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
** If you have questions regarding the use of this file, please contact
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
** Nokia at developer.feedback@nokia.com.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
****************************************************************************/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include "hbprogresssliderhandle_p.h"
34
hgs
parents: 6
diff changeset
    27
#include "hbstyle_p.h"
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <hbtooltip.h>
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    29
#include <hbstyleoptionprogresssliderhandle_p.h>
34
hgs
parents: 6
diff changeset
    30
#include <hbstyleprimitivedata.h>
hgs
parents: 6
diff changeset
    31
#include <hbstyleiconprimitivedata.h>
hgs
parents: 6
diff changeset
    32
#include <hbiconitem.h>
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    33
#include <hbextendedlocale.h>
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <QGraphicsSceneMouseEvent>
34
hgs
parents: 6
diff changeset
    35
#include <hbmessagebox.h>
hgs
parents: 6
diff changeset
    36
//#define ANIMATION_ON_TRACK_PRESS
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#define HBPROGRESSSLIDERHANDLE_TRACES
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#ifdef HBPROGRESSSLIDERHANDLE_TRACES
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include <QtDebug>
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#endif
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include <hbwidgetfeedback.h>
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#ifdef HB_EFFECTS
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include "hbeffect.h"
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "hbeffectinternal_p.h"
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#define HB_PRGRESSSLIDERHANDLE_ITEM_TYPE "HB_PROGRESSSLIDERHANDLE"
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#endif
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    50
#ifdef HB_GESTURE_FW
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    51
#include <hbtapgesture.h>
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    52
#include <hbpangesture.h>
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    53
#endif
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    54
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
#define   HandleMargin 0
34
hgs
parents: 6
diff changeset
    56
#define   EffectInterval 100
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    \reimp
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    \fn int HbProgressSliderHandle::type() const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
 */
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
HbProgressSliderHandle::HbProgressSliderHandle(HbHandleParent *parent) 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    :HbWidget(parent->parentGraphicsItem()),
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    q(parent),
34
hgs
parents: 6
diff changeset
    65
    mHandleIcon(),
hgs
parents: 6
diff changeset
    66
    mPressedState(false),
hgs
parents: 6
diff changeset
    67
    mTimeline(0)
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    mFlags = 0;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    mFlags |= TextVisible;
34
hgs
parents: 6
diff changeset
    71
    mOutOfBound = false;
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
34
hgs
parents: 6
diff changeset
    73
    mHandleIconItem = q->parentGraphicsWidget()->style()->createPrimitive(HbStyle::PT_IconItem, "handle-icon",this); 
hgs
parents: 6
diff changeset
    74
    qgraphicsitem_cast<HbIconItem*>(mHandleIconItem)->setIconName("qtg_graf_progslider_handle_normal");
hgs
parents: 6
diff changeset
    75
    qgraphicsitem_cast<HbIconItem*>(mHandleIconItem)->setAspectRatioMode(Qt::IgnoreAspectRatio);
hgs
parents: 6
diff changeset
    76
    
hgs
parents: 6
diff changeset
    77
    mTouchItem = q->parentGraphicsWidget()->style()->createPrimitive(HbStyle::PT_TouchArea, "handle-toucharea",this);
hgs
parents: 6
diff changeset
    78
    mTouchItem->setFlag(QGraphicsItem::ItemIsFocusable);
hgs
parents: 6
diff changeset
    79
    mTouchItem->setZValue(TOUCHAREA_ZVALUE);
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
34
hgs
parents: 6
diff changeset
    81
    setHandlesChildEvents(true);
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    setProperty("state","normal");
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
34
hgs
parents: 6
diff changeset
    84
    mTimeline = new QTimeLine(250,this);
hgs
parents: 6
diff changeset
    85
    mTimeline->setFrameRange(0,EffectInterval);
hgs
parents: 6
diff changeset
    86
    connect(mTimeline,SIGNAL(frameChanged(int)), this, SLOT(frameChanged(int)));
hgs
parents: 6
diff changeset
    87
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
#ifdef HB_EFFECTS
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    HbEffectInternal::add(HB_PRGRESSSLIDERHANDLE_ITEM_TYPE,"progressslider_handlepress", "progressslider_handlepress");
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    HbEffectInternal::add(HB_PRGRESSSLIDERHANDLE_ITEM_TYPE,"progressslider_handlerelease", "progressslider_handlerelease");
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    HbEffectInternal::add(HB_PRGRESSSLIDERHANDLE_ITEM_TYPE,"progressslider_handleoutofbound", "progressslider_handleoutofbound");
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
#endif
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    93
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    94
#ifdef HB_GESTURE_FW
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    95
    grabGesture(Qt::TapGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    96
    grabGesture(Qt::PanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    97
34
hgs
parents: 6
diff changeset
    98
    mTouchItem->grabGesture(Qt::TapGesture);
hgs
parents: 6
diff changeset
    99
    mTouchItem->grabGesture(Qt::PanGesture);
hgs
parents: 6
diff changeset
   100
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   101
#endif 
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
HbProgressSliderHandle::~HbProgressSliderHandle() 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   108
void HbProgressSliderHandle::setHandleIcon(const HbIcon& icon)
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
{
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   110
    mHandleIcon= icon;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   111
34
hgs
parents: 6
diff changeset
   112
   updatePrimitives();
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   115
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
void HbProgressSliderHandle::mousePressEvent(QGraphicsSceneMouseEvent *event) 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
{
34
hgs
parents: 6
diff changeset
   119
#ifndef HB_GESTURE_FW
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    HbWidget::mousePressEvent(event);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
#ifdef HB_EFFECTS
34
hgs
parents: 6
diff changeset
   123
    HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlepress");
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
#endif
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    mFlags |= HbProgressSliderHandle::MousePressed;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
34
hgs
parents: 6
diff changeset
   127
    mPressedState = true;
hgs
parents: 6
diff changeset
   128
hgs
parents: 6
diff changeset
   129
    updatePrimitives();
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   130
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    mMousePressPos = event->scenePos();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    mItemPosAtPress = pos();
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   133
   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   134
    HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantPressed, Hb::ModifierSliderHandle);
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   135
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   136
    event->accept();
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   137
    q->emitSliderPressed();   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   138
34
hgs
parents: 6
diff changeset
   139
     if(q->textVisible()) {  // User called it 
hgs
parents: 6
diff changeset
   140
         if(!q->toolTipText().isNull()) {
hgs
parents: 6
diff changeset
   141
             HbToolTip::showText(q->toolTipText(),this, QRectF(mItemPosAtPress,QSize(0,0)),q->textAlignment());            
hgs
parents: 6
diff changeset
   142
         }        
hgs
parents: 6
diff changeset
   143
      }
hgs
parents: 6
diff changeset
   144
      else {  // show default
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
34
hgs
parents: 6
diff changeset
   146
         HbExtendedLocale locale;
hgs
parents: 6
diff changeset
   147
         HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget();
hgs
parents: 6
diff changeset
   148
         HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment());
hgs
parents: 6
diff changeset
   149
hgs
parents: 6
diff changeset
   150
     }
hgs
parents: 6
diff changeset
   151
#else
hgs
parents: 6
diff changeset
   152
    Q_UNUSED(event)
hgs
parents: 6
diff changeset
   153
#endif 
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
void HbProgressSliderHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
{
34
hgs
parents: 6
diff changeset
   158
#ifndef HB_GESTURE_FW
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    HbWidget::mouseReleaseEvent(event);
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   160
34
hgs
parents: 6
diff changeset
   161
    mPressedState = false;
hgs
parents: 6
diff changeset
   162
hgs
parents: 6
diff changeset
   163
    updatePrimitives();
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   164
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    if (isHandleMoving()) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
      HbWidgetFeedback::continuousStopped(q->parentGraphicsWidget(), Hb::ContinuousDragged);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantReleased, Hb::ModifierSliderHandle);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
#ifdef HB_EFFECTS
34
hgs
parents: 6
diff changeset
   171
    HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlerelease");
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
#endif
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    mFlags &= ~HbProgressSliderHandle::MousePressed;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    mFlags &=~HandleMoving;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    event->accept();
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   176
    setHandlePosForValue(q->progressValue());   
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    q->emitSliderReleased();
34
hgs
parents: 6
diff changeset
   178
#else
hgs
parents: 6
diff changeset
   179
    Q_UNUSED(event)
hgs
parents: 6
diff changeset
   180
#endif 
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
void HbProgressSliderHandle::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
{
34
hgs
parents: 6
diff changeset
   185
#ifndef HB_GESTURE_FW
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    HbWidget::mouseMoveEvent(event);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
    mFlags |=HandleMoving;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    QPointF scenePos = event->scenePos();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    if(q->orientation() == Qt::Horizontal){
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
             mItemCurPos = QPointF((event->scenePos().x() - mMousePressPos.x()) + mItemPosAtPress.x(), pos().y());
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
             HbWidgetFeedback::continuousTriggered(qobject_cast<HbWidget*>(q->parentGraphicsWidget()), Hb::ContinuousDragged);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
             if(mItemCurPos.x()+boundingRect().width() < q->boundingRect().width()
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
                 && mItemCurPos.x()>HandleMargin){
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
                setPos(mItemCurPos);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
             }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
             else{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
                processItemChange(mItemCurPos);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
             }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
        }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
     if (!mTouchItem->boundingRect().contains(parentItem()->mapFromScene(scenePos))) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
        #ifdef HB_EFFECTS
34
hgs
parents: 6
diff changeset
   203
            HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handleoutofbound");
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
        #endif
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   207
    event->accept();
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   208
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   209
    q->emitSliderMoved(pointToValue(mItemCurPos));  
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   210
    
34
hgs
parents: 6
diff changeset
   211
     if(q->textVisible()) {  // User called it 
hgs
parents: 6
diff changeset
   212
         if(q->toolTipText().isNull()) {
hgs
parents: 6
diff changeset
   213
hgs
parents: 6
diff changeset
   214
             // Dont show any tooltip.
hgs
parents: 6
diff changeset
   215
             
hgs
parents: 6
diff changeset
   216
         }
hgs
parents: 6
diff changeset
   217
         else { 
hgs
parents: 6
diff changeset
   218
hgs
parents: 6
diff changeset
   219
             HbToolTip::showText(q->toolTipText(),this, QRectF(mItemPosAtPress,QSize(0,0)),q->textAlignment());
hgs
parents: 6
diff changeset
   220
            
hgs
parents: 6
diff changeset
   221
         }        
hgs
parents: 6
diff changeset
   222
      }
hgs
parents: 6
diff changeset
   223
      else {  // show default
hgs
parents: 6
diff changeset
   224
hgs
parents: 6
diff changeset
   225
         HbExtendedLocale locale;
hgs
parents: 6
diff changeset
   226
         HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget();
hgs
parents: 6
diff changeset
   227
         HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment());
hgs
parents: 6
diff changeset
   228
hgs
parents: 6
diff changeset
   229
     }
hgs
parents: 6
diff changeset
   230
#else
hgs
parents: 6
diff changeset
   231
    Q_UNUSED(event)
hgs
parents: 6
diff changeset
   232
#endif 
hgs
parents: 6
diff changeset
   233
}
hgs
parents: 6
diff changeset
   234
hgs
parents: 6
diff changeset
   235
void HbProgressSliderHandle::handleTrackRelease(QGestureEvent *event)
hgs
parents: 6
diff changeset
   236
{
hgs
parents: 6
diff changeset
   237
    Q_UNUSED(event);
hgs
parents: 6
diff changeset
   238
    setHandlePosForValue(q->progressValue());   
hgs
parents: 6
diff changeset
   239
}
hgs
parents: 6
diff changeset
   240
hgs
parents: 6
diff changeset
   241
void HbProgressSliderHandle::frameChanged(int val)
hgs
parents: 6
diff changeset
   242
{
hgs
parents: 6
diff changeset
   243
    QPointF myPoint(mStartPoint.x()+ (val*mIncrValue),mStartPoint.y());
hgs
parents: 6
diff changeset
   244
    setPos(myPoint);
hgs
parents: 6
diff changeset
   245
    processItemChange(myPoint);
hgs
parents: 6
diff changeset
   246
}
hgs
parents: 6
diff changeset
   247
hgs
parents: 6
diff changeset
   248
void HbProgressSliderHandle::handleTrackPress(QGestureEvent *event)
hgs
parents: 6
diff changeset
   249
{
hgs
parents: 6
diff changeset
   250
    HbTapGesture *gesture = static_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
hgs
parents: 6
diff changeset
   251
    QPointF newPos = q->parentGraphicsItem()->mapFromScene(event->mapToGraphicsScene(gesture->position()));
hgs
parents: 6
diff changeset
   252
hgs
parents: 6
diff changeset
   253
    if((newPos.x() >=  q->boundingRect().x()) && (newPos.x() <=  q->boundingRect().width())) {   
hgs
parents: 6
diff changeset
   254
        if(q->orientation() == Qt::Horizontal){
hgs
parents: 6
diff changeset
   255
            mItemCurPos = QPointF(newPos.x() - boundingRect().width()/2, pos().y());
hgs
parents: 6
diff changeset
   256
        }
hgs
parents: 6
diff changeset
   257
        else{
hgs
parents: 6
diff changeset
   258
            mItemCurPos = QPointF(pos().x(), newPos.y()-boundingRect().height()/2);
hgs
parents: 6
diff changeset
   259
        }
hgs
parents: 6
diff changeset
   260
hgs
parents: 6
diff changeset
   261
#ifdef ANIMATION_ON_TRACK_PRESS    
hgs
parents: 6
diff changeset
   262
        QPointF currentPt = pos();
hgs
parents: 6
diff changeset
   263
        mItemCurPos = normalizedPos(mItemCurPos,false);
hgs
parents: 6
diff changeset
   264
        qreal diff  = mItemCurPos.x() - currentPt.x();
hgs
parents: 6
diff changeset
   265
        mStartPoint = currentPt;
hgs
parents: 6
diff changeset
   266
        mIncrValue = (qreal)diff/EffectInterval;
hgs
parents: 6
diff changeset
   267
        if(mTimeline->state() == QTimeLine::Running) {
hgs
parents: 6
diff changeset
   268
            mTimeline->stop();
hgs
parents: 6
diff changeset
   269
        }
hgs
parents: 6
diff changeset
   270
        mTimeline->start();
hgs
parents: 6
diff changeset
   271
#else
hgs
parents: 6
diff changeset
   272
hgs
parents: 6
diff changeset
   273
        setPos(mItemCurPos);
hgs
parents: 6
diff changeset
   274
        processItemChange(mItemCurPos);
hgs
parents: 6
diff changeset
   275
#endif
hgs
parents: 6
diff changeset
   276
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
    }
34
hgs
parents: 6
diff changeset
   278
}
hgs
parents: 6
diff changeset
   279
hgs
parents: 6
diff changeset
   280
hgs
parents: 6
diff changeset
   281
/*!
hgs
parents: 6
diff changeset
   282
  reimp
hgs
parents: 6
diff changeset
   283
hgs
parents: 6
diff changeset
   284
*/
hgs
parents: 6
diff changeset
   285
void HbProgressSliderHandle::gestureEvent(QGestureEvent *event)
hgs
parents: 6
diff changeset
   286
{ 
hgs
parents: 6
diff changeset
   287
    if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
hgs
parents: 6
diff changeset
   288
        switch(tap->state()) {
hgs
parents: 6
diff changeset
   289
            case Qt::GestureStarted: {
hgs
parents: 6
diff changeset
   290
                mMousePressPos = mapFromScene(event->mapToGraphicsScene(tap->position( )));                
hgs
parents: 6
diff changeset
   291
                if(q->textVisible()) {  // User called it 
hgs
parents: 6
diff changeset
   292
                    HbToolTip::showText(q->toolTipText(),this, QRectF(mMousePressPos,QSize(0,0)),q->textAlignment());            
hgs
parents: 6
diff changeset
   293
                }
hgs
parents: 6
diff changeset
   294
                else {  // show default
hgs
parents: 6
diff changeset
   295
                    HbExtendedLocale locale;
hgs
parents: 6
diff changeset
   296
                    HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget();
hgs
parents: 6
diff changeset
   297
                    HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mMousePressPos,QSize(0,0)),q->textAlignment());
hgs
parents: 6
diff changeset
   298
                }
hgs
parents: 6
diff changeset
   299
                #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   300
                    HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlepress");
hgs
parents: 6
diff changeset
   301
                #endif
hgs
parents: 6
diff changeset
   302
                mFlags |= HbProgressSliderHandle::MousePressed;
hgs
parents: 6
diff changeset
   303
                mPressedState = true;
hgs
parents: 6
diff changeset
   304
                updatePrimitives();
hgs
parents: 6
diff changeset
   305
hgs
parents: 6
diff changeset
   306
                mMousePressPos = mapFromScene(event->mapToGraphicsScene(tap->position( )));
hgs
parents: 6
diff changeset
   307
                HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantPressed, Hb::ModifierSliderHandle);
hgs
parents: 6
diff changeset
   308
                event->accept();
hgs
parents: 6
diff changeset
   309
hgs
parents: 6
diff changeset
   310
                q->emitSliderPressed();  
hgs
parents: 6
diff changeset
   311
            }
hgs
parents: 6
diff changeset
   312
            break;
hgs
parents: 6
diff changeset
   313
            case Qt::GestureFinished:{
hgs
parents: 6
diff changeset
   314
                
hgs
parents: 6
diff changeset
   315
                if (isHandleMoving()) {
hgs
parents: 6
diff changeset
   316
                    HbWidgetFeedback::continuousStopped(q->parentGraphicsWidget(), Hb::ContinuousDragged);
hgs
parents: 6
diff changeset
   317
                }
hgs
parents: 6
diff changeset
   318
                HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantReleased, Hb::ModifierSliderHandle);
hgs
parents: 6
diff changeset
   319
                #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   320
                HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlerelease");
hgs
parents: 6
diff changeset
   321
                #endif
hgs
parents: 6
diff changeset
   322
                mPressedState = false;
hgs
parents: 6
diff changeset
   323
                updatePrimitives();
hgs
parents: 6
diff changeset
   324
                mFlags &= ~HbProgressSliderHandle::MousePressed;
hgs
parents: 6
diff changeset
   325
                mFlags &=~HandleMoving;
hgs
parents: 6
diff changeset
   326
                event->accept();
hgs
parents: 6
diff changeset
   327
                setHandlePosForValue(q->progressValue());   
hgs
parents: 6
diff changeset
   328
                q->emitSliderReleased();
hgs
parents: 6
diff changeset
   329
            }
hgs
parents: 6
diff changeset
   330
            break;
hgs
parents: 6
diff changeset
   331
            default:
hgs
parents: 6
diff changeset
   332
                break;                                  
hgs
parents: 6
diff changeset
   333
        }
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   334
    }
34
hgs
parents: 6
diff changeset
   335
    if (HbPanGesture *panGesture = qobject_cast<HbPanGesture*>(event->gesture(Qt::PanGesture))) {
hgs
parents: 6
diff changeset
   336
        switch(panGesture->state( )) {
hgs
parents: 6
diff changeset
   337
            case Qt::GestureStarted: 
hgs
parents: 6
diff changeset
   338
                {
hgs
parents: 6
diff changeset
   339
                    if(!mPressedState) {
hgs
parents: 6
diff changeset
   340
                        #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   341
                            HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlepress");
hgs
parents: 6
diff changeset
   342
                        #endif
hgs
parents: 6
diff changeset
   343
                        mPressedState = true;
hgs
parents: 6
diff changeset
   344
                        updatePrimitives();
hgs
parents: 6
diff changeset
   345
                        q->emitSliderPressed();
hgs
parents: 6
diff changeset
   346
                    }
hgs
parents: 6
diff changeset
   347
                }
hgs
parents: 6
diff changeset
   348
            case Qt::GestureUpdated:{
hgs
parents: 6
diff changeset
   349
                    mFlags |=HandleMoving;
hgs
parents: 6
diff changeset
   350
                    QPointF scenePos =mapToParent( mapFromScene(panGesture->sceneOffset( )+panGesture->sceneStartPos( )));
hgs
parents: 6
diff changeset
   351
                    if(scenePos.x() == oldCord.x()) {
hgs
parents: 6
diff changeset
   352
                        return;
hgs
parents: 6
diff changeset
   353
                    }
hgs
parents: 6
diff changeset
   354
                    oldCord = scenePos;
hgs
parents: 6
diff changeset
   355
                    if(mOutOfBound){
hgs
parents: 6
diff changeset
   356
                        HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlepress");
hgs
parents: 6
diff changeset
   357
                        mOutOfBound = false;
hgs
parents: 6
diff changeset
   358
                    }
hgs
parents: 6
diff changeset
   359
                
hgs
parents: 6
diff changeset
   360
                    mItemCurPos = QPointF((scenePos.x() - mMousePressPos.x()), pos().y());
hgs
parents: 6
diff changeset
   361
                    HbWidgetFeedback::continuousTriggered(qobject_cast<HbWidget*>(q->parentGraphicsWidget()), Hb::ContinuousDragged);
hgs
parents: 6
diff changeset
   362
                    if(mItemCurPos.x()+boundingRect().width() < q->boundingRect().width() && mItemCurPos.x()>q->boundingRect().topLeft().x() ){
hgs
parents: 6
diff changeset
   363
                        setPos(mItemCurPos);
hgs
parents: 6
diff changeset
   364
                    }
hgs
parents: 6
diff changeset
   365
                    else{
hgs
parents: 6
diff changeset
   366
                        #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   367
                        HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handleoutofbound");
hgs
parents: 6
diff changeset
   368
                        mOutOfBound = true;
hgs
parents: 6
diff changeset
   369
                        #endif
hgs
parents: 6
diff changeset
   370
                    }
hgs
parents: 6
diff changeset
   371
hgs
parents: 6
diff changeset
   372
                    if(q->textVisible()) {  // User called it 
hgs
parents: 6
diff changeset
   373
                        HbToolTip::showText(q->toolTipText(),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment());                      
hgs
parents: 6
diff changeset
   374
                    }
hgs
parents: 6
diff changeset
   375
                    else {  // show default
hgs
parents: 6
diff changeset
   376
                        HbExtendedLocale locale;
hgs
parents: 6
diff changeset
   377
                        HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget();
hgs
parents: 6
diff changeset
   378
                        HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment());
hgs
parents: 6
diff changeset
   379
                    } 
hgs
parents: 6
diff changeset
   380
                    q->emitSliderMoved(pointToValue(mItemCurPos));
hgs
parents: 6
diff changeset
   381
hgs
parents: 6
diff changeset
   382
                    event->accept();
hgs
parents: 6
diff changeset
   383
                }
hgs
parents: 6
diff changeset
   384
            break;
hgs
parents: 6
diff changeset
   385
            case Qt::GestureFinished:
hgs
parents: 6
diff changeset
   386
            case Qt::GestureCanceled: {
hgs
parents: 6
diff changeset
   387
                if(mPressedState) {
hgs
parents: 6
diff changeset
   388
                    mPressedState = false;           
hgs
parents: 6
diff changeset
   389
                    updatePrimitives();
hgs
parents: 6
diff changeset
   390
hgs
parents: 6
diff changeset
   391
                    if (isHandleMoving()) {
hgs
parents: 6
diff changeset
   392
                        HbWidgetFeedback::continuousStopped(q->parentGraphicsWidget(), Hb::ContinuousDragged);
hgs
parents: 6
diff changeset
   393
                    }
hgs
parents: 6
diff changeset
   394
                    else {
hgs
parents: 6
diff changeset
   395
                        HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantReleased, Hb::ModifierSliderHandle);
hgs
parents: 6
diff changeset
   396
                    }
hgs
parents: 6
diff changeset
   397
                    #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   398
                    HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlerelease");
hgs
parents: 6
diff changeset
   399
                    #endif
hgs
parents: 6
diff changeset
   400
                    mFlags &= ~HbProgressSliderHandle::MousePressed;
hgs
parents: 6
diff changeset
   401
                    mFlags &=~HandleMoving;
hgs
parents: 6
diff changeset
   402
                    event->accept();
hgs
parents: 6
diff changeset
   403
                    setHandlePosForValue(q->progressValue());   
hgs
parents: 6
diff changeset
   404
                    q->emitSliderReleased();
hgs
parents: 6
diff changeset
   405
                }
hgs
parents: 6
diff changeset
   406
            }
hgs
parents: 6
diff changeset
   407
            break;
hgs
parents: 6
diff changeset
   408
            default:
hgs
parents: 6
diff changeset
   409
                break;
hgs
parents: 6
diff changeset
   410
        }
hgs
parents: 6
diff changeset
   411
    }
hgs
parents: 6
diff changeset
   412
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
int HbProgressSliderHandle::pointToValue(QPointF point) const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    QRectF rect = q->boundingRect();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    qreal effectiveWidth;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
    point = normalizedPos(point,q->invertedAppearance());
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    qreal givenPixel;
34
hgs
parents: 6
diff changeset
   421
 
hgs
parents: 6
diff changeset
   422
    effectiveWidth = rect.width() - boundingRect().width();
hgs
parents: 6
diff changeset
   423
    givenPixel = point.x();
hgs
parents: 6
diff changeset
   424
    
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    qreal tickPerPixel = (qreal)(q->maximum()-q->minimum())/effectiveWidth;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    qreal tickForGivenPixel = givenPixel * tickPerPixel;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    tickForGivenPixel = qRound(tickForGivenPixel);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    int value;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    if(!q->invertedAppearance()) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
        value = q->minimum() + (int)tickForGivenPixel;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    } else {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
        value = q->maximum() - (int)tickForGivenPixel;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    if(value>q->maximum()) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
        return q->maximum();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    else if(value<q->minimum()) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
        return q->minimum();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
    return value;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
// converts value to handle coordinates
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
QPointF HbProgressSliderHandle::valueToHandlePos(int value) const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    QRectF r1 = q->boundingRect();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
    QRectF r2 = boundingRect();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    qreal width;
34
hgs
parents: 6
diff changeset
   452
    width = r1.width() - r2.width();
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    if(q->maximum() != q->minimum()){
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        qreal pixelpertick = width/(qreal)(q->maximum()-q->minimum());
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
        qreal noOfTicks = qreal(value - q->minimum());
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
        qreal xpos =  noOfTicks * pixelpertick;
34
hgs
parents: 6
diff changeset
   457
        return QPointF(xpos, r1.top());
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    else{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
        return QPointF(0,0);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
QPointF HbProgressSliderHandle::normalizedPos(const QPointF&  pos,bool inverted) const 
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
    Q_UNUSED(inverted);
34
hgs
parents: 6
diff changeset
   467
    
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
    QPointF newPos = pos;
34
hgs
parents: 6
diff changeset
   469
    
hgs
parents: 6
diff changeset
   470
    if (newPos.x() < HandleMargin) {
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
            newPos.setX( HandleMargin );
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
34
hgs
parents: 6
diff changeset
   474
    if (newPos.x() > q->boundingRect().width() - boundingRect().width() - HandleMargin) {
hgs
parents: 6
diff changeset
   475
            newPos.setX(q->boundingRect().width() - boundingRect().width() - HandleMargin);
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
    }
34
hgs
parents: 6
diff changeset
   477
    
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    return newPos;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
bool HbProgressSliderHandle::isHandlePressed() const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
    return mFlags.testFlag(HbProgressSliderHandle::MousePressed);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
bool HbProgressSliderHandle::isHandleMoving() const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    return mFlags.testFlag(HbProgressSliderHandle::HandleMoving);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
}
34
hgs
parents: 6
diff changeset
   491
/*!
hgs
parents: 6
diff changeset
   492
    \reimp
hgs
parents: 6
diff changeset
   493
 */
hgs
parents: 6
diff changeset
   494
void HbProgressSliderHandle::setGeometry(const QRectF & rect)
hgs
parents: 6
diff changeset
   495
{
hgs
parents: 6
diff changeset
   496
    HbWidget::setGeometry(rect);
hgs
parents: 6
diff changeset
   497
    QPointF point = pos();
hgs
parents: 6
diff changeset
   498
    qreal x = q->boundingRect().height();
hgs
parents: 6
diff changeset
   499
    qreal y = size().height();
hgs
parents: 6
diff changeset
   500
    qreal a = qreal (x-y)/2;
hgs
parents: 6
diff changeset
   501
    setPos(point.x(),a);
hgs
parents: 6
diff changeset
   502
}
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
QVariant HbProgressSliderHandle::processItemChange(const QVariant &value)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
{
34
hgs
parents: 6
diff changeset
   506
    // value is the new position
hgs
parents: 6
diff changeset
   507
    QPointF pt = value.toPointF();
hgs
parents: 6
diff changeset
   508
    int newValue = pointToValue(pt);
hgs
parents: 6
diff changeset
   509
    pt.setY(q->boundingRect().top());
hgs
parents: 6
diff changeset
   510
    q->emitSliderMoved(newValue);
hgs
parents: 6
diff changeset
   511
    QPointF newPos = pt;
hgs
parents: 6
diff changeset
   512
    return normalizedPos(newPos,false);
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
void HbProgressSliderHandle::setHandlePosForValue(int progressValue)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    if(!mFlags.testFlag(HbProgressSliderHandle::MousePressed)){
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
        QPointF newPos = valueToHandlePos(progressValue);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
        QPointF pos = normalizedPos(newPos,q->invertedAppearance());
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
        if(q->invertedAppearance()) {
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
                qreal xVal = q->boundingRect().width() - pos.x() - boundingRect().width();
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
                pos.setX(xVal);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
        }
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
        qreal yPos = qreal (q->boundingRect().height()-boundingRect().height()) /2 ;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
        setPos(pos.x(),yPos);
34
hgs
parents: 6
diff changeset
   527
    }    
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
void  HbProgressSliderHandle::updatePrimitives()
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
{    
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    if (mHandleIconItem) {
34
hgs
parents: 6
diff changeset
   534
        HbStyleIconPrimitiveData data;
hgs
parents: 6
diff changeset
   535
        initPrimitiveData(&data, mHandleIconItem);
hgs
parents: 6
diff changeset
   536
        style()->updatePrimitive(mHandleIconItem,&data,this);
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   537
    }
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   538
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   539
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   540
/*!
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   541
    Initializes \a option with the values from this HbProgressSliderHandle. 
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   542
    This method is useful for subclasses when they need a HbStyleOptionProgressSliderHandle,
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   543
    but don't want to fill in all the information themselves.
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   544
 */
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   545
void HbProgressSliderHandle::initStyleOption(HbStyleOptionProgressSliderHandle *option) const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   546
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   547
    HbWidget::initStyleOption(option);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   548
    option->handleIcon = mHandleIcon;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   549
    option->pressedState = false;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   550
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   551
34
hgs
parents: 6
diff changeset
   552
/*!
hgs
parents: 6
diff changeset
   553
    \reimp
hgs
parents: 6
diff changeset
   554
*/
hgs
parents: 6
diff changeset
   555
void HbProgressSliderHandle::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive)
hgs
parents: 6
diff changeset
   556
{
hgs
parents: 6
diff changeset
   557
    HbWidgetBase::initPrimitiveData(primitiveData, primitive);
hgs
parents: 6
diff changeset
   558
    QString itemName = HbStyle::itemName(primitive);
hgs
parents: 6
diff changeset
   559
    if (itemName == "handle-icon") {
hgs
parents: 6
diff changeset
   560
        HbStyleIconPrimitiveData *data = hbstyleprimitivedata_cast<HbStyleIconPrimitiveData*>(primitiveData);
hgs
parents: 6
diff changeset
   561
        HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget();
hgs
parents: 6
diff changeset
   562
        data->icon = slider->handleIcon();
hgs
parents: 6
diff changeset
   563
hgs
parents: 6
diff changeset
   564
        if(data->icon.value().isNull()) {
hgs
parents: 6
diff changeset
   565
            if(mPressedState)
hgs
parents: 6
diff changeset
   566
                data->icon = HbIcon(QLatin1String("qtg_graf_progslider_handle_pressed"));
hgs
parents: 6
diff changeset
   567
            else
hgs
parents: 6
diff changeset
   568
                data->icon = HbIcon(QLatin1String("qtg_graf_progslider_handle_normal"));
hgs
parents: 6
diff changeset
   569
        }
hgs
parents: 6
diff changeset
   570
        else
hgs
parents: 6
diff changeset
   571
        {
hgs
parents: 6
diff changeset
   572
            data->icon = slider->handleIcon();
hgs
parents: 6
diff changeset
   573
        }        
hgs
parents: 6
diff changeset
   574
    }
hgs
parents: 6
diff changeset
   575
}
hgs
parents: 6
diff changeset
   576
hgs
parents: 6
diff changeset
   577
void HbProgressSliderHandle::setHandleNormalState()
hgs
parents: 6
diff changeset
   578
{
hgs
parents: 6
diff changeset
   579
    if(mPressedState) {
hgs
parents: 6
diff changeset
   580
        mPressedState=false;
hgs
parents: 6
diff changeset
   581
        #ifdef HB_EFFECTS
hgs
parents: 6
diff changeset
   582
             HbEffect::start(mHandleIconItem, HB_PRGRESSSLIDERHANDLE_ITEM_TYPE, "progressslider_handlerelease");
hgs
parents: 6
diff changeset
   583
        #endif
hgs
parents: 6
diff changeset
   584
        updatePrimitives();
hgs
parents: 6
diff changeset
   585
    }
hgs
parents: 6
diff changeset
   586
}
hgs
parents: 6
diff changeset
   587
/*!
hgs
parents: 6
diff changeset
   588
    reimp
hgs
parents: 6
diff changeset
   589
*/
hgs
parents: 6
diff changeset
   590
QGraphicsItem *HbProgressSliderHandle::primitive(const QString &itemName) const
hgs
parents: 6
diff changeset
   591
{
hgs
parents: 6
diff changeset
   592
    if(!itemName.compare(QString("handle-icon"))){
hgs
parents: 6
diff changeset
   593
        return mHandleIconItem;
hgs
parents: 6
diff changeset
   594
    }
hgs
parents: 6
diff changeset
   595
    if(!itemName.compare(QString("handle-toucharea"))){
hgs
parents: 6
diff changeset
   596
        return mTouchItem;
hgs
parents: 6
diff changeset
   597
    }
hgs
parents: 6
diff changeset
   598
hgs
parents: 6
diff changeset
   599
    return HbWidget::primitive(itemName);
hgs
parents: 6
diff changeset
   600
}