author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 19 | afea38384506 |
parent 33 | 11b6825f0862 |
permissions | -rw-r--r-- |
24 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <QPainter> |
|
20 |
#include <QStringListModel> |
|
21 |
#include <QGraphicsSceneResizeEvent> |
|
22 |
#include <QPen> |
|
23 |
#include <HbPushButton> |
|
24 |
#include <QTimer> |
|
25 |
#include <HbColorScheme> |
|
26 |
#include <HbEvent> |
|
27 |
#include <HbSwipeGesture> |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
28 |
#include <HbDeviceProfile> |
24 | 29 |
|
30 |
#include "radiofrequencystrip.h" |
|
31 |
#include "radiofrequencyitem.h" |
|
32 |
#include "radiouiengine.h" |
|
33 |
#include "radiostation.h" |
|
34 |
#include "radiostationmodel.h" |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
35 |
#include "radioutil.h" |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
36 |
#include "radiouiloader.h" |
24 | 37 |
#include "radiologger.h" |
38 |
||
39 |
// Frequency lines |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
40 |
const int TAB_HEIGHT_SMALL = 12; |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
41 |
const int TAB_HEIGHT_BIG = 18; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
42 |
const int PEN_WIDTH_FAVORITE = 4; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
43 |
const qreal INDICATOR_WIDTH = 2.0; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
44 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
45 |
const qreal ROUNDER = 0.5; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
46 |
const int SELECTOR_WIDTH = 2; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
47 |
const int SELECTOR_Z_POS = 100; |
24 | 48 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
49 |
const int HALF_HERTZ = ONE_HERTZ / 2; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
50 |
const int ONE_TAB_DISTANCE = 20; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
51 |
const uint ONE_TAB_IN_HZ = uint( 0.2 * ONE_HERTZ ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
52 |
const qreal PIXEL_IN_HZ = ONE_TAB_IN_HZ / ONE_TAB_DISTANCE; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
53 |
const qreal PIXMAP_OVERLAP = qreal( ONE_TAB_DISTANCE ) / 2; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
54 |
const int ITEM_WIDTH = ONE_TAB_DISTANCE * 5; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
55 |
const int PIXMAP_WIDTH = ITEM_WIDTH + (int)PIXMAP_OVERLAP; |
24 | 56 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
57 |
const uint ONE_HUNDRED_KHZ = 100000; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
58 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
59 |
const char* DECIMAL_TEXT = ".0"; |
24 | 60 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
61 |
#ifdef BUILD_WIN32 |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
const int FREQUENCY_FONT_SIZE = 12; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
63 |
const int DECIMAL_FONT_SIZE = 8; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
64 |
#else |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
65 |
const int FREQUENCY_FONT_SIZE = 6; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
66 |
const int DECIMAL_FONT_SIZE = 4; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
67 |
#endif // BUILD_WIN32 |
24 | 68 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
69 |
const QFont FREQUENCY_FONT( "", FREQUENCY_FONT_SIZE ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
70 |
const QFont DECIMAL_FONT( "", DECIMAL_FONT_SIZE ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
71 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
72 |
const char* SLIDE_TO_LEFT = "SlideToLeft"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
73 |
const char* SLIDE_FROM_LEFT = "SlideFromLeft"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
const char* SLIDE_TO_RIGHT = "SlideToRight"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
const char* SLIDE_FROM_RIGHT = "SlideFromRight"; |
24 | 76 |
const char* LEFT_BUTTON = "tv:left_button"; |
77 |
const char* RIGHT_BUTTON = "tv:right_button"; |
|
78 |
||
79 |
const char* TEXT_COLOR_ATTRIBUTE = "text"; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
80 |
const int MANUALSEEK_START_TIMEOUT = 400; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
const int MANUALSEEK_END_TIMEOUT = 2000; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
82 |
const int MANUALSEEK_SIGNAL_DELAY = 300; |
24 | 83 |
|
84 |
/*! |
|
85 |
* |
|
86 |
*/ |
|
87 |
RadioFrequencyStrip::RadioFrequencyStrip() : |
|
88 |
RadioStripBase(), |
|
89 |
mUiEngine( NULL ), |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
90 |
mItemHeight( 8 ), |
24 | 91 |
mMinFrequency( 87500000 ), |
92 |
mMaxFrequency( 108000000 ), |
|
93 |
mFrequencyStepSize( 100000 ), |
|
94 |
mFrequency( 87500000 ), |
|
95 |
mSelectorImage( new QGraphicsPixmapItem( this ) ), |
|
96 |
mSeparatorPos( 0.0 ), |
|
97 |
mMaxWidth( 0 ), |
|
98 |
mSelectorPos( 0.0 ), |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
99 |
mLeftButton( 0 ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
100 |
mRightButton( 0 ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
101 |
mManualSeekTimer( NULL ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
102 |
mManualSeekMode( false ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
103 |
mLastReportedFrequency( 0 ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
104 |
mManualSeekTimerId( 0 ), |
24 | 105 |
mForegroundColor( Qt::white )//HbColorScheme::color( TEXT_COLOR_ATTRIBUTE ) ) |
106 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
107 |
RadioUtil::setFrequencyStrip( this ); |
24 | 108 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
109 |
setScrollingStyle( HbScrollArea::PanWithFollowOn ); |
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
110 |
setItemSize( QSizeF( ITEM_WIDTH + PIXMAP_OVERLAP / 2, mItemHeight ) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
111 |
setOverlap( PIXMAP_OVERLAP / 2 ); |
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
112 |
} |
24 | 113 |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
114 |
/*! |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
115 |
* Property |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
116 |
*/ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
117 |
void RadioFrequencyStrip::setItemHeight( int itemHeight ) |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
118 |
{ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
119 |
mItemHeight = itemHeight; |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
120 |
} |
24 | 121 |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
122 |
/*! |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
123 |
* Property |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
124 |
*/ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
125 |
int RadioFrequencyStrip::itemHeight() const |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
126 |
{ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
127 |
return mItemHeight; |
24 | 128 |
} |
129 |
||
130 |
/*! |
|
131 |
* |
|
132 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
133 |
void RadioFrequencyStrip::init( RadioUiEngine* engine, RadioUiLoader& uiLoader ) |
24 | 134 |
{ |
135 |
mUiEngine = engine; |
|
136 |
mMinFrequency = mUiEngine->minFrequency(); |
|
137 |
mMaxFrequency = mUiEngine->maxFrequency(); |
|
138 |
mFrequencyStepSize = mUiEngine->frequencyStepSize(); |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
139 |
mFrequency = RadioUiEngine::lastTunedFrequency(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
140 |
|
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
141 |
initModel(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
142 |
initEmptyItems(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
143 |
initPositions(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
144 |
|
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
145 |
HbDeviceProfile deviceProfile; |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
146 |
mItemHeight = static_cast<int>( mItemHeight * deviceProfile.unitValue() ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
147 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
148 |
mLeftButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_PREV_BUTTON ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
149 |
mRightButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_NEXT_BUTTON ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
150 |
initButtons(); |
24 | 151 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
152 |
mManualSeekTimer = new QTimer( this ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
153 |
mManualSeekTimer->setInterval( MANUALSEEK_START_TIMEOUT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
154 |
mManualSeekTimer->setSingleShot( true ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
155 |
Radio::connect( mManualSeekTimer, SIGNAL(timeout()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
156 |
this, SLOT(toggleManualSeek()) ); |
24 | 157 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
158 |
Radio::connect( mLeftButton, SIGNAL(clicked()), |
24 | 159 |
this, SLOT(handleLeftButton()) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
160 |
Radio::connect( mRightButton, SIGNAL(clicked()), |
24 | 161 |
this, SLOT(handleRightButton()) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
162 |
Radio::connect( mLeftButton, SIGNAL(longPress(QPointF)), |
24 | 163 |
this, SLOT(handleLongLeftButton()) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
164 |
Radio::connect( mRightButton, SIGNAL(longPress(QPointF)), |
24 | 165 |
this, SLOT(handleLongRightButton()) ); |
166 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
167 |
Radio::connect( this, SIGNAL(scrollingEnded()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
168 |
this, SLOT(handleScrollingEnd()) ); |
24 | 169 |
|
170 |
grabGesture( Qt::SwipeGesture ); |
|
171 |
||
172 |
//TODO: Remove. Stepsize hardcoded to 100 Khz in europe region during demo |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
173 |
if ( mFrequencyStepSize < ONE_HUNDRED_KHZ ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
174 |
mFrequencyStepSize = ONE_HUNDRED_KHZ; |
24 | 175 |
} |
176 |
||
177 |
RadioStationModel* stationModel = &mUiEngine->stationModel(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
178 |
Radio::connect( stationModel, SIGNAL(rowsInserted(QModelIndex,int,int)), |
24 | 179 |
this, SLOT(updateStation(QModelIndex,int,int)) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
180 |
Radio::connect( stationModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
181 |
this, SLOT(removeStation(QModelIndex,int,int)) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
182 |
Radio::connect( stationModel, SIGNAL(modelReset()), |
24 | 183 |
this, SLOT(initEmptyItems()) ); |
184 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
185 |
updateAllItems(); |
24 | 186 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
187 |
showButtons(); |
24 | 188 |
} |
189 |
||
190 |
/*! |
|
191 |
* |
|
192 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
193 |
void RadioFrequencyStrip::setFrequency( const uint frequency, int reason, Scroll::Direction direction ) |
24 | 194 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
195 |
Q_UNUSED( reason ); |
24 | 196 |
LOG_FORMAT( "RadioFrequencyStrip::setFrequency, frequency: %d, reason: %d", frequency, reason ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
197 |
if ( mFrequencies.contains( frequency ) ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
198 |
if ( frequency != mFrequency || reason == TuneReason::Skip ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
199 |
scrollToFrequency( frequency, direction, mAutoScrollTime, RadioUtil::tuneReason( reason ) ); |
24 | 200 |
} |
201 |
} |
|
202 |
} |
|
203 |
||
204 |
/*! |
|
205 |
* |
|
206 |
*/ |
|
207 |
uint RadioFrequencyStrip::frequency() const |
|
208 |
{ |
|
209 |
return mFrequency; |
|
210 |
} |
|
211 |
||
212 |
/*! |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
213 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
214 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
bool RadioFrequencyStrip::isInManualSeekMode() const |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
216 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
217 |
return mManualSeekMode; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
218 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
219 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
220 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
221 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
222 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
223 |
void RadioFrequencyStrip::cancelManualSeek() |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
224 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
225 |
mManualSeekTimer->stop(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
226 |
if ( mManualSeekMode ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
227 |
toggleManualSeek(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
228 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
229 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
230 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
231 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
232 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
233 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
234 |
void RadioFrequencyStrip::addScannedStation( const RadioStation& station ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
235 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
236 |
FrequencyPos pos = mFrequencies.value( station.frequency() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
237 |
updateItem( pos.mItem, station.frequency() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
238 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
239 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
240 |
/*! |
24 | 241 |
* |
242 |
*/ |
|
243 |
void RadioFrequencyStrip::updateFavorite( const RadioStation& station ) |
|
244 |
{ |
|
245 |
LOG_SLOT_CALLER; |
|
246 |
FrequencyPos pos = mFrequencies.value( station.frequency() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
247 |
updateItem( pos.mItem ); |
24 | 248 |
} |
249 |
||
250 |
/*! |
|
251 |
* Public slot |
|
252 |
* |
|
253 |
*/ |
|
254 |
void RadioFrequencyStrip::setScanningMode( bool isScanning ) |
|
255 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
256 |
mManualSeekTimer->stop(); |
24 | 257 |
if ( isScanning ) { |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
258 |
initEmptyItems(); |
24 | 259 |
hideButtons(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
260 |
scrollToFrequency( mMinFrequency, Scroll::Shortest, mAutoScrollTime ); |
24 | 261 |
} else { |
262 |
showButtons(); |
|
263 |
} |
|
264 |
setEnabled( !isScanning ); |
|
265 |
} |
|
266 |
||
267 |
/*! |
|
268 |
* Private slot |
|
269 |
* |
|
270 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
271 |
void RadioFrequencyStrip::removeStation( const QModelIndex& parent, int first, int last ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
272 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
273 |
Q_UNUSED( parent ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
274 |
updateStationsInRange( first, last, true ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
275 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
276 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
277 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
278 |
* Private slot |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
279 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
280 |
*/ |
24 | 281 |
void RadioFrequencyStrip::updateStation( const QModelIndex& parent, int first, int last ) |
282 |
{ |
|
283 |
Q_UNUSED( parent ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
284 |
updateStationsInRange( first, last ); |
24 | 285 |
} |
286 |
||
287 |
/*! |
|
288 |
* Private slot |
|
289 |
* |
|
290 |
*/ |
|
291 |
void RadioFrequencyStrip::initEmptyItems() |
|
292 |
{ |
|
293 |
LOG_METHOD; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
294 |
//TODO: Remove the weird hack of checking the sender |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
295 |
if ( !sender() || RadioUtil::scanStatus() != Scan::ScanningInMainView ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
296 |
QList<RadioStation> emptyList; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
297 |
foreach ( RadioFrequencyItem* item, mFrequencyItems ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
298 |
QPixmap pixmap = drawPixmap( item->frequency(), emptyList, item ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
299 |
item->setPixmap( pixmap ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
300 |
} |
24 | 301 |
} |
302 |
} |
|
303 |
||
304 |
/*! |
|
305 |
* Private slot |
|
306 |
*/ |
|
307 |
void RadioFrequencyStrip::handleLeftButton() |
|
308 |
{ |
|
309 |
emit skipRequested( StationSkip::PreviousFavorite ); |
|
310 |
} |
|
311 |
||
312 |
/*! |
|
313 |
* Private slot |
|
314 |
*/ |
|
315 |
void RadioFrequencyStrip::handleLongLeftButton() |
|
316 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
317 |
emit seekRequested( Seek::Down ); |
24 | 318 |
} |
319 |
||
320 |
/*! |
|
321 |
* Private slot |
|
322 |
*/ |
|
323 |
void RadioFrequencyStrip::handleRightButton() |
|
324 |
{ |
|
325 |
emit skipRequested( StationSkip::NextFavorite ); |
|
326 |
} |
|
327 |
||
328 |
/*! |
|
329 |
* Private slot |
|
330 |
*/ |
|
331 |
void RadioFrequencyStrip::handleLongRightButton() |
|
332 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
333 |
emit seekRequested( Seek::Up ); |
24 | 334 |
} |
335 |
||
336 |
/*! |
|
337 |
* Private slot |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
338 |
* |
24 | 339 |
*/ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
340 |
void RadioFrequencyStrip::toggleManualSeek() |
24 | 341 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
342 |
mManualSeekMode = !mManualSeekMode; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
343 |
emit manualSeekChanged( mManualSeekMode ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
344 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
345 |
if ( mManualSeekMode ) { |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
346 |
grabMouse(); |
24 | 347 |
hideButtons(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
348 |
mManualSeekTimerId = startTimer( MANUALSEEK_SIGNAL_DELAY ); |
24 | 349 |
} else { |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
350 |
ungrabMouse(); |
24 | 351 |
showButtons(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
352 |
killTimer( mManualSeekTimerId ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
353 |
mManualSeekTimerId = 0; |
24 | 354 |
} |
355 |
} |
|
356 |
||
357 |
/*! |
|
358 |
* Private slot |
|
359 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
360 |
void RadioFrequencyStrip::handleScrollingEnd() |
24 | 361 |
{ |
362 |
// Check if the selector is in the invalid area where the strip loops around |
|
363 |
const int selectorPosition = selectorPos(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
364 |
if ( mManualSeekMode ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
365 |
if ( !mPositions.contains( selectorPosition ) ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
366 |
if ( selectorPosition < mMaxWidth - ITEM_WIDTH + mSeparatorPos ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
367 |
scrollToFrequency( mMaxFrequency, Scroll::Shortest, 500 ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
368 |
emit frequencyChanged( mMaxFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
369 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
370 |
scrollToFrequency( mMinFrequency, Scroll::Shortest, 500 ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
371 |
emit frequencyChanged( mMinFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
372 |
} |
24 | 373 |
} |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
374 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
375 |
mManualSeekTimer->start( MANUALSEEK_END_TIMEOUT ); |
24 | 376 |
} |
377 |
} |
|
378 |
||
379 |
/*! |
|
380 |
* \reimp |
|
381 |
*/ |
|
382 |
void RadioFrequencyStrip::updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex ) |
|
383 |
{ |
|
384 |
QGraphicsPixmapItem* item = static_cast<QGraphicsPixmapItem*>( itemToUpdate ); |
|
385 |
if ( itemIndex < mFrequencyItems.count() ) { |
|
386 |
item->setPixmap( mFrequencyItems.at( itemIndex )->updatePrimitive( item ) ); |
|
387 |
} |
|
388 |
} |
|
389 |
||
390 |
/*! |
|
391 |
* \reimp |
|
392 |
*/ |
|
393 |
QGraphicsItem* RadioFrequencyStrip::createItemPrimitive( QGraphicsItem* parent ) |
|
394 |
{ |
|
395 |
return new QGraphicsPixmapItem( parent ); |
|
396 |
} |
|
397 |
||
398 |
/*! |
|
399 |
* \reimp |
|
400 |
*/ |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
401 |
void RadioFrequencyStrip::scrollPosChanged() |
24 | 402 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
403 |
if ( mManualSeekMode ) { |
24 | 404 |
const int pos = selectorPos(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
405 |
const uint frequency = mPositions.value( pos ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
406 |
if ( frequency > 0 ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
407 |
mFrequency = mPositions.value( pos ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
408 |
emit frequencyChanged( mFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
409 |
} |
24 | 410 |
} |
411 |
} |
|
412 |
||
413 |
/*! |
|
414 |
* \reimp |
|
415 |
*/ |
|
416 |
void RadioFrequencyStrip::resizeEvent ( QGraphicsSceneResizeEvent* event ) |
|
417 |
{ |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
418 |
LOG_METHOD; |
24 | 419 |
RadioStripBase::resizeEvent( event ); |
420 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
421 |
initSelector(); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
422 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
423 |
const qreal height = event->newSize().height(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
424 |
const qreal width = event->newSize().width(); |
24 | 425 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
426 |
mSelectorPos = width / 2; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
427 |
mSelectorImage->setOffset( mSelectorPos - (INDICATOR_WIDTH / 2), 0.0 ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
428 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
429 |
if ( mLeftButton && mRightButton ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
430 |
mLeftButton->resize( height, height ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
431 |
mRightButton->resize( height, height ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
432 |
mRightButton->setPos( QPointF( width - height, 0 ) ); |
24 | 433 |
} |
434 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
435 |
scrollToFrequency( mFrequency ); |
24 | 436 |
} |
437 |
||
438 |
/*! |
|
439 |
* \reimp |
|
440 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
441 |
//void RadioFrequencyStrip::showEvent( QShowEvent* event ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
442 |
//{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
443 |
// RadioStripBase::showEvent( event ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
444 |
// scrollToFrequency( mFrequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
445 |
//} |
24 | 446 |
|
447 |
/*! |
|
448 |
* \reimp |
|
449 |
*/ |
|
450 |
void RadioFrequencyStrip::changeEvent( QEvent* event ) |
|
451 |
{ |
|
452 |
if ( event->type() == HbEvent::ThemeChanged ) { |
|
453 |
// Update the foreground color and redraw each item |
|
454 |
mForegroundColor = Qt::white;// HbColorScheme::color( TEXT_COLOR_ATTRIBUTE ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
455 |
updateAllItems(); |
24 | 456 |
} |
457 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
458 |
return RadioStripBase::changeEvent(event); |
24 | 459 |
} |
460 |
||
461 |
/*! |
|
462 |
* \reimp |
|
463 |
*/ |
|
464 |
void RadioFrequencyStrip::mousePressEvent( QGraphicsSceneMouseEvent* event ) |
|
465 |
{ |
|
466 |
RadioStripBase::mousePressEvent( event ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
467 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
468 |
mManualSeekTimer->stop(); |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
469 |
if ( mManualSeekMode ) { |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
470 |
const bool insideStrip = rect().contains( event->pos() ); |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
471 |
if ( !insideStrip ) { |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
472 |
toggleManualSeek(); |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
473 |
} |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
474 |
} else { |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
475 |
mManualSeekTimer->start( MANUALSEEK_START_TIMEOUT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
476 |
} |
24 | 477 |
} |
478 |
||
479 |
/*! |
|
480 |
* \reimp |
|
481 |
*/ |
|
482 |
void RadioFrequencyStrip::mouseReleaseEvent( QGraphicsSceneMouseEvent* event ) |
|
483 |
{ |
|
484 |
RadioStripBase::mouseReleaseEvent( event ); |
|
485 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
486 |
mManualSeekTimer->stop(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
487 |
if ( mManualSeekMode && !isScrolling() ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
488 |
mManualSeekTimer->start( MANUALSEEK_END_TIMEOUT ); |
24 | 489 |
} |
490 |
} |
|
491 |
||
492 |
/*! |
|
493 |
* \reimp |
|
494 |
*/ |
|
495 |
void RadioFrequencyStrip::gestureEvent( QGestureEvent* event ) |
|
496 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
497 |
HbSwipeGesture* swipeGesture = static_cast<HbSwipeGesture*>( event->gesture( Qt::SwipeGesture ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
498 |
if ( swipeGesture && !mManualSeekMode ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
499 |
if ( swipeGesture->state() == Qt::GestureFinished ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
500 |
if ( swipeGesture->horizontalDirection() == QSwipeGesture::Left ) { |
24 | 501 |
emit skipRequested( StationSkip::Next ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
502 |
} else if ( swipeGesture->horizontalDirection() == QSwipeGesture::Right ) { |
24 | 503 |
emit skipRequested( StationSkip::Previous ); |
504 |
} |
|
505 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
506 |
} else if ( mManualSeekMode ) { |
24 | 507 |
RadioStripBase::gestureEvent( event ); |
508 |
} |
|
509 |
} |
|
510 |
||
511 |
/*! |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
512 |
* \reimp |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
513 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
514 |
void RadioFrequencyStrip::timerEvent( QTimerEvent* event ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
515 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
516 |
Q_UNUSED( event ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
517 |
if ( mLastReportedFrequency != mFrequency ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
518 |
mLastReportedFrequency = mFrequency; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
519 |
emit frequencyChanged( mFrequency, TuneReason::ManualSeekTune, Scroll::Shortest ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
520 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
521 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
522 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
523 |
/*! |
24 | 524 |
* |
525 |
*/ |
|
526 |
void RadioFrequencyStrip::initModel() |
|
527 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
528 |
const uint minFreq = uint( qreal(mMinFrequency) / ONE_HERTZ + ROUNDER ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
529 |
const uint maxFreq = uint( qreal(mMaxFrequency) / ONE_HERTZ + 0.9 ); // always round up |
24 | 530 |
|
531 |
QStringList list; |
|
532 |
QString freqText; |
|
533 |
for ( uint i = minFreq; i <= maxFreq; ++i ) { |
|
534 |
freqText = QString::number( i ); |
|
535 |
list.append( freqText ); |
|
536 |
mFrequencyItems.append( new RadioFrequencyItem( freqText ) ); |
|
537 |
} |
|
538 |
mFrequencyItems.append( new RadioFrequencyItem( "" ) ); |
|
539 |
list.append( "" ); |
|
540 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
541 |
mMaxWidth = list.count() * ITEM_WIDTH; |
24 | 542 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
543 |
mSeparatorPos = qreal(ITEM_WIDTH) / 2; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
544 |
const uint minDrawableFreq = minFreq * ONE_HERTZ - HALF_HERTZ;; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
545 |
const uint maxDrawableFreq = maxFreq * ONE_HERTZ + HALF_HERTZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
546 |
mSeparatorPos += qreal( ( mMinFrequency - minDrawableFreq ) / 2 ) / PIXEL_IN_HZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
547 |
mSeparatorPos -= qreal( ( maxDrawableFreq - mMaxFrequency ) / 2 ) / PIXEL_IN_HZ; |
24 | 548 |
|
549 |
setModel( new QStringListModel( list, this ) ); |
|
550 |
} |
|
551 |
||
552 |
/*! |
|
553 |
* |
|
554 |
*/ |
|
555 |
void RadioFrequencyStrip::initSelector() |
|
556 |
{ |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
557 |
QPixmap selectorPixmap = QPixmap( QSize( SELECTOR_WIDTH, (int)size().height() ) ); |
24 | 558 |
selectorPixmap.fill( Qt::red ); |
559 |
mSelectorImage->setPixmap( selectorPixmap ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
560 |
mSelectorImage->setZValue( SELECTOR_Z_POS ); |
24 | 561 |
} |
562 |
||
563 |
/*! |
|
564 |
* |
|
565 |
*/ |
|
566 |
void RadioFrequencyStrip::initPositions() |
|
567 |
{ |
|
568 |
int prevPos = 0; |
|
569 |
int nextPos = 0; |
|
570 |
const int lastPos = mFrequencies.value( mMaxFrequency ).mPosition; |
|
571 |
for ( int i = mFrequencies.value( mMinFrequency ).mPosition; i < lastPos; ++i ) { |
|
572 |
if ( mPositions.contains( i ) ) { |
|
573 |
prevPos = i; |
|
574 |
const uint freq = mPositions.value( prevPos ) + mFrequencyStepSize; |
|
575 |
if ( mFrequencies.contains( freq ) ) { |
|
576 |
nextPos = mFrequencies.value( freq ).mPosition; |
|
577 |
} else { |
|
578 |
nextPos = prevPos; |
|
579 |
} |
|
580 |
} else { |
|
581 |
const int nearestHit = ( i - prevPos ) < ( nextPos - i ) ? prevPos : nextPos; |
|
582 |
mPositions.insert( i, mPositions.value( nearestHit ) ); |
|
583 |
} |
|
584 |
} |
|
585 |
} |
|
586 |
||
587 |
/*! |
|
588 |
* |
|
589 |
*/ |
|
590 |
void RadioFrequencyStrip::initButtons() |
|
591 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
592 |
mLeftButton->setZValue( SELECTOR_Z_POS ); |
24 | 593 |
mLeftButton->setObjectName( LEFT_BUTTON ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
594 |
mRightButton->setZValue( SELECTOR_Z_POS ); |
24 | 595 |
mRightButton->setObjectName( RIGHT_BUTTON ); |
596 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
597 |
const qreal height = size().height(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
598 |
const qreal width = size().width(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
599 |
mLeftButton->resize( height, height ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
600 |
mRightButton->resize( height, height ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
601 |
mRightButton->setPos( QPointF( width - height, 0 ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
602 |
|
24 | 603 |
QEffectList effectList; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
604 |
effectList.append( EffectInfo( mLeftButton, ":/effects/slide_to_left.fxml", SLIDE_TO_LEFT ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
605 |
effectList.append( EffectInfo( mLeftButton, ":/effects/slide_from_left.fxml", SLIDE_FROM_LEFT ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
606 |
effectList.append( EffectInfo( mRightButton, ":/effects/slide_to_right.fxml", SLIDE_TO_RIGHT ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
607 |
effectList.append( EffectInfo( mRightButton, ":/effects/slide_from_right.fxml", SLIDE_FROM_RIGHT ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
608 |
RadioUtil::addEffects( effectList ); |
24 | 609 |
} |
610 |
||
611 |
/*! |
|
612 |
* |
|
613 |
*/ |
|
614 |
void RadioFrequencyStrip::addFrequencyPos( int pos, uint frequency, RadioFrequencyItem* item ) |
|
615 |
{ |
|
616 |
mFrequencies.insert( frequency, FrequencyPos( pos, item ) ); |
|
617 |
mPositions.insert( pos, frequency ); |
|
618 |
} |
|
619 |
||
620 |
/*! |
|
621 |
* |
|
622 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
623 |
void RadioFrequencyStrip::updateStationsInRange( int first, int last, bool stationRemoved ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
624 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
625 |
if ( RadioUtil::scanStatus() != Scan::ScanningInMainView ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
626 |
RadioStationModel& model = mUiEngine->stationModel(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
627 |
uint frequency = 0; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
628 |
for ( int i = first; i <= last; ++i ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
629 |
frequency = model.data( model.index( i, 0, QModelIndex() ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
630 |
RadioRole::RadioStationRole ).value<RadioStation>().frequency(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
631 |
if ( mFrequencies.contains( frequency ) ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
632 |
FrequencyPos pos = mFrequencies.value( frequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
633 |
updateItem( pos.mItem, 0, stationRemoved ? frequency : 0 ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
634 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
635 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
636 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
637 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
638 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
639 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
640 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
641 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
642 |
void RadioFrequencyStrip::updateItem( RadioFrequencyItem* item, uint upperRange, uint ignoredFrequency ) |
24 | 643 |
{ |
644 |
if ( item ) { |
|
645 |
uint frequency = item->frequency(); |
|
646 |
QList<RadioStation> stations; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
647 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
648 |
if ( upperRange == 0 ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
649 |
upperRange = frequency + HALF_HERTZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
650 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
651 |
|
24 | 652 |
if ( mUiEngine ) { |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
653 |
stations = mUiEngine->stationsInRange( frequency - HALF_HERTZ, upperRange ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
654 |
for ( int i = stations.count() - 1; ignoredFrequency > 0 && i >= 0; --i ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
655 |
if ( stations[i].frequency() == ignoredFrequency ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
656 |
stations.removeAt( i ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
657 |
break; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
658 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
659 |
} |
24 | 660 |
} |
661 |
||
662 |
QPixmap pixmap = drawPixmap( frequency, stations, item ); |
|
663 |
item->setPixmap( pixmap ); |
|
664 |
||
665 |
foreach ( const RadioStation& station, stations ) { |
|
666 |
frequency = station.frequency(); |
|
667 |
FrequencyPos pos = mFrequencies.value( frequency ); |
|
668 |
mFrequencies.insert( frequency, pos ); |
|
669 |
} |
|
670 |
} |
|
671 |
} |
|
672 |
||
673 |
/*! |
|
674 |
* |
|
675 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
676 |
void RadioFrequencyStrip::updateAllItems() |
24 | 677 |
{ |
678 |
foreach ( RadioFrequencyItem* item, mFrequencyItems ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
679 |
updateItem( item ); |
24 | 680 |
} |
681 |
} |
|
682 |
||
683 |
/*! |
|
684 |
* |
|
685 |
*/ |
|
686 |
QPixmap RadioFrequencyStrip::drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item ) |
|
687 |
{ |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
688 |
QPixmap pixmap( PIXMAP_WIDTH, mItemHeight ); |
24 | 689 |
pixmap.fill( Qt::transparent ); |
690 |
QPainter painter( &pixmap ); |
|
691 |
QPen normalPen = painter.pen(); |
|
692 |
QPen favoritePen = normalPen; |
|
693 |
normalPen.setColor( mForegroundColor ); |
|
694 |
painter.setPen( normalPen ); |
|
695 |
||
696 |
if ( frequency == 0 ) { |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
697 |
painter.drawLine( makeTab( mSeparatorPos - 1 + ROUNDER, mItemHeight ) ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
698 |
painter.drawLine( makeTab( mSeparatorPos + ROUNDER, mItemHeight ) ); |
24 | 699 |
return pixmap; |
700 |
} |
|
701 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
702 |
const QString itemText = QString::number( frequency / ONE_HERTZ ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
703 |
const uint startFrequency = frequency - HALF_HERTZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
704 |
const uint endFrequency = startFrequency + ONE_HERTZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
705 |
const uint roundedMin = int( qreal(mMinFrequency) / ONE_HERTZ + ROUNDER ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
706 |
const uint freq = frequency / ONE_HERTZ; |
24 | 707 |
const int diff = freq - roundedMin; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
708 |
const qreal startPixel = diff * ITEM_WIDTH; |
24 | 709 |
qreal pixels = 0.0; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
710 |
const qreal leftOverlap = PIXMAP_OVERLAP / 2; |
24 | 711 |
|
712 |
for ( uint frequency = startFrequency; frequency <= endFrequency; frequency += mFrequencyStepSize ) { |
|
713 |
||
714 |
if ( frequency < mMinFrequency || frequency > mMaxFrequency ) { |
|
715 |
continue; |
|
716 |
} |
|
717 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
718 |
pixels = qreal( frequency - startFrequency ) / PIXEL_IN_HZ; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
719 |
if ( frequency % ONE_HERTZ == 0 ) { |
24 | 720 |
|
721 |
// Draw the high frequency tab and the frequency text for the even number |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
722 |
normalPen.setWidth( 3 ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
723 |
painter.setPen( normalPen ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
724 |
painter.drawLine( makeTab( pixels + leftOverlap - 1, TAB_HEIGHT_BIG ) ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
725 |
normalPen.setWidth( 1 ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
726 |
painter.setPen( normalPen ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
727 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
728 |
// Draw the frequency text and its 00 decimals |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
729 |
painter.setFont( DECIMAL_FONT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
730 |
const int decimalWidth = painter.fontMetrics().width( DECIMAL_TEXT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
731 |
const int decimalSpace = painter.fontMetrics().leftBearing( '.' ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
732 |
painter.setFont( FREQUENCY_FONT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
733 |
const int frequencyWidth = painter.fontMetrics().width( itemText ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
734 |
const int textPosX = int( pixels + leftOverlap - ( frequencyWidth + decimalSpace + decimalWidth ) / 2 ); |
24 | 735 |
painter.drawText( QPoint( textPosX, 20 ), itemText ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
736 |
painter.setFont( DECIMAL_FONT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
737 |
painter.drawText( QPoint( textPosX + frequencyWidth + decimalSpace, 20 ), DECIMAL_TEXT ); |
24 | 738 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
739 |
} else if ( frequency % ONE_TAB_IN_HZ == 0 ) { |
24 | 740 |
|
741 |
// Draw the low frequency tab for the uneven number |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
742 |
painter.drawLine( makeTab( pixels + leftOverlap, TAB_HEIGHT_SMALL ) ); |
24 | 743 |
|
744 |
} |
|
745 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
746 |
addFrequencyPos( int( startPixel + pixels + ROUNDER ), frequency, item ); |
24 | 747 |
} |
748 |
||
749 |
// Draw favorites and local stations |
|
750 |
favoritePen.setColor( Qt::yellow ); |
|
751 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
752 |
const int markerYPos = mItemHeight - 28; |
24 | 753 |
foreach ( const RadioStation& station, stations ) { |
754 |
const uint frequency = station.frequency(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
755 |
pixels = qreal( frequency - startFrequency ) / PIXEL_IN_HZ; |
24 | 756 |
|
757 |
if ( station.isFavorite() ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
758 |
favoritePen.setWidth( PEN_WIDTH_FAVORITE ); |
24 | 759 |
painter.setPen( favoritePen ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
760 |
painter.drawEllipse( int( pixels + leftOverlap - 3 ), markerYPos - 3, 6, 6 ); |
24 | 761 |
} else if ( station.isType( RadioStation::LocalStation ) ) { |
762 |
||
763 |
favoritePen.setWidth( 1 ); |
|
764 |
painter.setPen( favoritePen ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
765 |
painter.drawEllipse( int( pixels + leftOverlap - 4 ), markerYPos - 4, 8, 8 ); |
24 | 766 |
} |
767 |
} |
|
768 |
||
769 |
return pixmap; |
|
770 |
} |
|
771 |
||
772 |
/*! |
|
773 |
* |
|
774 |
*/ |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
775 |
QLineF RadioFrequencyStrip::makeTab( qreal pos, int height ) |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
776 |
{ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
777 |
return QLineF( pos, mItemHeight - height, pos, mItemHeight ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
778 |
} |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
779 |
|
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
780 |
/*! |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
781 |
* |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
782 |
*/ |
24 | 783 |
void RadioFrequencyStrip::emitFrequencyChanged( uint frequency ) |
784 |
{ |
|
785 |
if ( frequency > 0 && frequency != mFrequency ) { |
|
786 |
mFrequency = frequency; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
787 |
//TOD: Get direction |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
788 |
emit frequencyChanged( frequency, TuneReason::FrequencyStrip, Scroll::Shortest ); |
24 | 789 |
} |
790 |
} |
|
791 |
||
792 |
/*! |
|
793 |
* |
|
794 |
*/ |
|
795 |
int RadioFrequencyStrip::selectorPos() const |
|
796 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
797 |
const int pos = int( -contentWidget()->x() + mSelectorPos + ROUNDER ); |
24 | 798 |
return pos % mMaxWidth; |
799 |
} |
|
800 |
||
801 |
/*! |
|
802 |
* |
|
803 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
804 |
void RadioFrequencyStrip::scrollToFrequency( uint frequency, Scroll::Direction direction, int time, TuneReason::Reason reason ) |
24 | 805 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
806 |
int targetFreqPos = mFrequencies.value( frequency ).mPosition; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
807 |
const int currentFreqPos = mFrequencies.value( mFrequency ).mPosition; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
808 |
const int currentPos = int( -contentWidget()->x() + mSelectorPos + ROUNDER ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
809 |
const bool isInSecondHalf = currentPos >= mMaxWidth - ITEM_WIDTH + mSeparatorPos; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
810 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
811 |
// Special case: When there is only one favorite and the user presses skip |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
812 |
// the strip must scroll around to the same frequency. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
813 |
if ( mFrequency == frequency && reason == TuneReason::Skip ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
814 |
if ( direction == Scroll::Left ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
815 |
targetFreqPos += mMaxWidth; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
816 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
817 |
targetFreqPos -= mMaxWidth; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
818 |
} |
24 | 819 |
} |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
820 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
821 |
mFrequency = frequency; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
822 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
823 |
qreal newPos = targetFreqPos; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
824 |
if ( direction == Scroll::Left ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
825 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
826 |
if ( currentFreqPos > targetFreqPos ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
827 |
newPos += mMaxWidth; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
828 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
829 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
830 |
} else if ( direction == Scroll::Right ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
831 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
832 |
if ( currentFreqPos < targetFreqPos ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
833 |
newPos -= mMaxWidth; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
834 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
835 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
836 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
837 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
838 |
if ( isInSecondHalf ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
839 |
newPos += mMaxWidth; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
840 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
841 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
842 |
newPos -= mSelectorPos - ROUNDER; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
843 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
844 |
scrollContentsTo( QPointF( newPos, 0 ), time ); |
24 | 845 |
} |
846 |
||
847 |
/*! |
|
848 |
* |
|
849 |
*/ |
|
850 |
void RadioFrequencyStrip::hideButtons() |
|
851 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
852 |
HbEffect::start( mLeftButton, SLIDE_TO_LEFT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
853 |
HbEffect::start( mRightButton, SLIDE_TO_RIGHT ); |
24 | 854 |
} |
855 |
||
856 |
/*! |
|
857 |
* |
|
858 |
*/ |
|
859 |
void RadioFrequencyStrip::showButtons() |
|
860 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
861 |
HbEffect::start( mLeftButton, SLIDE_FROM_LEFT ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
862 |
HbEffect::start( mRightButton, SLIDE_FROM_RIGHT ); |
24 | 863 |
} |