author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 17 Sep 2010 08:28:52 +0300 | |
changeset 58 | ed94e1e8390e |
parent 48 | af3740e3753f |
permissions | -rw-r--r-- |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
8192e5b5c935
Revision: 201019
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". |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Track List Widget for Music Player Media Wall. |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <QGraphicsSceneMouseEvent> |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
48
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
21 |
#ifndef UNIT_TESTING |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
22 |
#include <hbinstance.h> |
48
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
23 |
#else |
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
24 |
#include "hbinstancestub.h" |
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
25 |
#endif |
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
26 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
27 |
#include <hblistview.h> |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include <hbframeitem.h> |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include <hbmainwindow.h> |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
30 |
#include <hbstyleloader.h> |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
31 |
#include <hbscrollbar.h> |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
32 |
#include <hbcolorscheme.h> |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "mptracklistwidget.h" |
48
af3740e3753f
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
36 |
|
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
const int swipeAngleTolerance = 30; // angle is from 0 to 360 |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
39 |
const int tracklistOutlineSize = 1; // |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
41 |
/*! |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
42 |
\class MpTrackListWidget |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
43 |
\brief Widget with a list of tracks for Media Wall. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
44 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
45 |
This widget provides a list with custom style and a background. |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
47 |
*/ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
48 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
49 |
/*! |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
50 |
\fn void closed() |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
51 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
52 |
This signal is emitted when the track list is closed by the user with a |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
53 |
left swipe gesture. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
54 |
*/ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
55 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
56 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
57 |
/*! |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
58 |
Creates the MpTrackListWidget. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
59 |
*/ |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
MpTrackListWidget::MpTrackListWidget( QGraphicsItem *parent ) : HbWidget( parent ) |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
{ |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
62 |
setFlag( QGraphicsItem::ItemHasNoContents, false ); |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
63 |
// Register the custorm css path for the list items. |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
64 |
HbStyleLoader::registerFilePath( ":/css/mpcustomlistitem.css" ); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
65 |
HbStyleLoader::registerFilePath( ":/css/mpcustomlistitem.hblistviewitem.widgetml" ); |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
66 |
mList = new HbListView( this ); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
67 |
// set layout name that matches the custom list item layout. |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
68 |
mList->setLayoutName( "mpmwtracklist" ); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
69 |
HbScrollBar *scrollbar = mList->verticalScrollBar(); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
70 |
scrollbar->show(); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
71 |
scrollbar->setInteractive( true ); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
72 |
mList->setVerticalScrollBarPolicy( HbScrollArea::ScrollBarAlwaysOn ); |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
74 |
//grab the gesture for close. |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
grabGesture(Qt::SwipeGesture); |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
76 |
|
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
mFrameItem = new HbFrameItem( this ); |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
78 |
mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece ); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
79 |
mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_popup_c" ); //replace for qtg_graf_mediawall_list_bg when available. |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
80 |
mFrameItem->setFlag(QGraphicsItem::ItemStacksBehindParent); |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
/*! |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
84 |
Destructs the track list widget. |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
*/ |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
86 |
MpTrackListWidget::~MpTrackListWidget() |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
{ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
/*! |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
Returns the HbListView instance. |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
*/ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
HbListView *MpTrackListWidget::list() |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
{ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
return mList; |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
/*! |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
99 |
\reimp |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
*/ |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
101 |
void MpTrackListWidget::resizeEvent(QGraphicsSceneResizeEvent *event) |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
{ |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
103 |
mFrameItem->setGeometry( rect() ); |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
104 |
qreal margin = tracklistOutlineSize; |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
105 |
mList->setGeometry( rect().adjusted( margin, margin, -margin, -margin ) ); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
106 |
HbWidget::resizeEvent( event ); |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
/*! |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
\reimp |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
*/ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
void MpTrackListWidget::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
{ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
if ( event->button() == Qt::LeftButton ) { |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
event->accept(); |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
else { |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
event->ignore(); |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
|
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
/*! |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
\reimp |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
*/ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
void MpTrackListWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
{ |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
if ( event->button() == Qt::LeftButton ) { |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
event->accept(); |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
else { |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
event->ignore(); |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
} |
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
135 |
/*! |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
136 |
\reimp |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
137 |
*/ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
138 |
void MpTrackListWidget::gestureEvent(QGestureEvent *event) |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
139 |
{ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
140 |
QGesture* gesture = event->gesture(Qt::SwipeGesture); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
141 |
if (gesture) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
142 |
QSwipeGesture* swipe = static_cast<QSwipeGesture *>(gesture); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
143 |
if (swipe->state() == Qt::GestureFinished && |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
144 |
swipeAngleToDirection (swipe->swipeAngle()) == QSwipeGesture::Left ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
145 |
//Left gesture is the direction in wich the track list slides to close. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
146 |
emit closed(); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
147 |
event->accept(Qt::SwipeGesture); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
148 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
149 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
150 |
} |
29
8192e5b5c935
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
|
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
152 |
/*! |
58
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
153 |
\reimp |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
154 |
*/ |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
155 |
void MpTrackListWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
156 |
{ |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
157 |
Q_UNUSED( widget ) |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
158 |
Q_UNUSED( option ) |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
159 |
painter->save(); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
160 |
qreal outlineWidth(tracklistOutlineSize); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
161 |
painter->setPen(QPen(HbColorScheme::color("qtc_view_normal_secondary"), outlineWidth,Qt::SolidLine,Qt::FlatCap,Qt::MiterJoin)); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
162 |
painter->drawRect( rect().adjusted(outlineWidth/2,outlineWidth/2,-outlineWidth/2,-outlineWidth/2) ); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
163 |
painter->restore(); |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
164 |
} |
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
165 |
|
ed94e1e8390e
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
48
diff
changeset
|
166 |
/*! |
41
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
167 |
Maps swipe \a angle to QSwipeGesture::SwipeDirection based on a tolerance |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
168 |
parameter and orientation. This funtions helps to identify a swipe even |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
169 |
if it is not sharp movement from 180 to 0 degrees on the righ swipe |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
170 |
gesture for instance. Since gesture events are mesured on device |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
171 |
cordinates this also helps to correct the gesture to local cordinates |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
172 |
bases on device orientation, wich is done using QT transformations, |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
173 |
meaning local cordinates and device cordinates are not always aligned. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
174 |
*/ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
175 |
QSwipeGesture::SwipeDirection MpTrackListWidget::swipeAngleToDirection( |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
176 |
int angle ) |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
177 |
{ |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
178 |
int delta = swipeAngleTolerance; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
179 |
if ( hbInstance->allMainWindows()[0]->orientation() == Qt::Horizontal ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
180 |
//correction for transformation on rotation. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
181 |
#ifdef __WINS__ //wincw with forced rotation is to the right. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
182 |
angle += ( angle < 90 ) ? 270 : -90; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
183 |
#else//currently hardware rotations is to the left. |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
184 |
angle += 90; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
185 |
if ( angle > 360 ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
186 |
angle -= 360; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
187 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
188 |
#endif |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
189 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
190 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
191 |
QSwipeGesture::SwipeDirection direction( QSwipeGesture::NoDirection ); |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
192 |
if ( ( angle > 90 - delta) && ( angle < 90 + delta ) ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
193 |
direction = QSwipeGesture::Up; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
194 |
} else if ( ( angle > 270 - delta ) && (angle < 270 + delta ) ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
195 |
direction = QSwipeGesture::Down; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
196 |
} else if ( ( ( angle >= 0 ) && ( angle < delta ) ) |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
197 |
|| ( ( angle > 360 - delta ) && ( angle <= 360 ) ) ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
198 |
direction = QSwipeGesture::Right; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
199 |
} else if ( ( angle > 180 - delta ) && ( angle < 180 + delta ) ) { |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
200 |
direction = QSwipeGesture::Left; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
201 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
202 |
return direction; |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
203 |
} |
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
204 |
|
ea59c434026a
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
205 |
//EOF |