author | hgs |
Thu, 08 Jul 2010 12:44:18 +0300 | |
changeset 36 | ba22309243a1 |
parent 34 | bc10a61bd7d3 |
child 38 | f8c3d4e6102c |
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 |
#ifndef RADIOSTATIONCAROUSEL_H |
|
19 |
#define RADIOSTATIONCAROUSEL_H |
|
20 |
||
21 |
// System includes |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
22 |
#include <HbScrollArea> |
24 | 23 |
#include <HbIcon> |
34 | 24 |
#include <QWeakPointer> |
24 | 25 |
|
26 |
// User includes |
|
34 | 27 |
#include "radiocarouselitemobserver.h" |
24 | 28 |
#include "radiowidgetsexport.h" |
29 |
#include "radio_global.h" |
|
30 |
||
31 |
// Forward declarations |
|
32 |
class RadioUiEngine; |
|
33 |
class RadioUiLoader; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
34 |
class RadioCarouselItem; |
24 | 35 |
class RadioStation; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
36 |
class RadioStationModel; |
24 | 37 |
class RadioStationCarousel; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
38 |
class RadioCarouselAnimator; |
24 | 39 |
class HbLabel; |
34 | 40 |
class HbMenu; |
24 | 41 |
|
42 |
namespace CarouselInfoText |
|
43 |
{ |
|
44 |
enum Type |
|
45 |
{ |
|
46 |
None, |
|
47 |
ConnectAntenna, |
|
48 |
NoFavorites, |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
49 |
FavoriteIconHint, |
24 | 50 |
Seeking, |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
51 |
Scanning, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
52 |
ManualSeek |
24 | 53 |
}; |
54 |
} |
|
55 |
||
56 |
// Class declaration |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
57 |
class WIDGETS_DLL_EXPORT RadioStationCarousel : public HbScrollArea |
34 | 58 |
, public RadioCarouselItemObserver |
24 | 59 |
{ |
60 |
Q_OBJECT |
|
61 |
Q_PROPERTY(HbIcon favoriteIcon READ favoriteIcon WRITE setFavoriteIcon) |
|
62 |
Q_PROPERTY(HbIcon nonFavoriteIcon READ nonFavoriteIcon WRITE setNonFavoriteIcon) |
|
63 |
Q_PROPERTY( int autoScrollTime READ autoScrollTime WRITE setAutoScrollTime ) |
|
64 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
65 |
friend class RadioCarouselAnimator; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
66 |
friend class RadioCarouselItem; |
24 | 67 |
|
68 |
public: |
|
69 |
||
70 |
enum ScrollFlag |
|
71 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
72 |
Default = 0, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
73 |
NoAnim = 1 << 0, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
NoSignal = 1 << 1, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
IgnoreCenter = 1 << 2, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
76 |
UpdateItem = 1 << 3, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
77 |
FromPanGesture = 1 << 4, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
78 |
FromSwipeGesture = 1 << 5 |
24 | 79 |
}; |
80 |
Q_DECLARE_FLAGS( ScrollMode, ScrollFlag ) |
|
81 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
82 |
RadioStationCarousel( QGraphicsItem* parent = 0 ); |
24 | 83 |
|
84 |
void setFavoriteIcon( const HbIcon& favoriteIcon ); |
|
85 |
HbIcon favoriteIcon() const; |
|
86 |
||
87 |
void setNonFavoriteIcon( const HbIcon& nonFavoriteIcon ); |
|
88 |
HbIcon nonFavoriteIcon() const; |
|
89 |
||
90 |
void setAutoScrollTime( const int time ); |
|
91 |
int autoScrollTime() const; |
|
92 |
||
93 |
void init( RadioUiLoader& uiLoader, RadioUiEngine* uiEngine ); |
|
94 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
95 |
void setFrequency( uint frequency, int reason, Scroll::Direction direction = Scroll::Shortest ); |
24 | 96 |
|
97 |
RadioUiEngine* uiEngine(); |
|
98 |
||
99 |
bool isAntennaAttached() const; |
|
100 |
||
101 |
void setScanningMode( bool scanning ); |
|
102 |
bool isInScanningMode() const; |
|
103 |
||
104 |
void cleanRdsData(); |
|
105 |
||
106 |
void animateNewStation( const RadioStation& station ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
107 |
void cancelAnimation(); |
24 | 108 |
|
109 |
void setInfoText( CarouselInfoText::Type type ); |
|
110 |
void clearInfoText(); |
|
111 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
112 |
void setManualSeekMode( bool manualSeekActive ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
113 |
|
34 | 114 |
void drawOffScreen( QPainter& painter ); |
115 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
116 |
void setAlternateSkippingMode( bool alternateSkipping ); //TODO: Remove this! This is test code |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
117 |
|
24 | 118 |
signals: |
119 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
120 |
void frequencyChanged( uint frequency, int reason, int direction ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
121 |
void skipRequested( int skipMode ); |
24 | 122 |
void scanAnimationFinished(); |
123 |
||
124 |
public slots: |
|
125 |
||
126 |
void updateAntennaStatus( bool connected ); |
|
127 |
||
128 |
private slots: |
|
129 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
130 |
void scrollPosChanged( const QPointF& newPosition ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
131 |
void adjustAfterScroll(); |
24 | 132 |
void update( const RadioStation& station ); |
133 |
void updateRadioText( const RadioStation& station ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
134 |
void updateStations(); |
24 | 135 |
void timerFired(); |
136 |
||
137 |
#ifdef USE_DEBUGGING_CONTROLS |
|
138 |
void setRdsAvailable( bool available ); |
|
139 |
#endif // USE_DEBUGGING_CONTROLS |
|
140 |
||
141 |
private: |
|
142 |
||
143 |
// from base class QGraphicsItem |
|
144 |
||
145 |
void mousePressEvent( QGraphicsSceneMouseEvent* event ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
146 |
void resizeEvent( QGraphicsSceneResizeEvent* event ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
147 |
void showEvent( QShowEvent* event ); |
24 | 148 |
void gestureEvent( QGestureEvent* event ); |
149 |
||
34 | 150 |
// from base class RadioCarouselItemObserver |
151 |
||
152 |
void handleIconClicked( const RadioStation& station ); |
|
153 |
void handleRadiotextClicked( const RadioStation& station ); |
|
154 |
void handleUrlClicked( const RadioStation& station ); |
|
155 |
QString localizeGenre( int genre ); |
|
156 |
bool isInManualSeek() const; |
|
157 |
RadioStation findStation( uint frequency ); |
|
158 |
||
24 | 159 |
// New functions |
160 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
161 |
bool isInitialized() const; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
162 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
163 |
void setCenterIndex( int index, ScrollMode mode = Default ); |
24 | 164 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
165 |
void scrollToIndex( int index, Scroll::Direction direction = Scroll::Shortest, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
166 |
ScrollMode mode = Default ); |
24 | 167 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
168 |
int calculateDifference( int targetIndex, Scroll::Direction& direction ); |
24 | 169 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
170 |
bool isScrollingAllowed() const; |
24 | 171 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
172 |
void adjustPos( int offset ); |
24 | 173 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
174 |
int trimIndex( int index ); |
24 | 175 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
176 |
int prevIndex( int index ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
177 |
int nextIndex( int index ); |
24 | 178 |
|
179 |
void skip( StationSkip::Mode mode ); |
|
180 |
||
181 |
private: // data |
|
182 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
183 |
enum TimerMode { NoTimer, SetFrequency, RtPlusCheck, InfoText, FavoriteHintShow, FavoriteHintHide }; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
184 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
185 |
RadioUiEngine* mUiEngine; |
24 | 186 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
187 |
int mAutoScrollTime; |
24 | 188 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
189 |
HbIcon mFavoriteIcon; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
190 |
HbIcon mNonFavoriteIcon; |
24 | 191 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
192 |
QTimer* mGenericTimer; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
193 |
TimerMode mTimerMode; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
194 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
195 |
QString mRadioTextHolder; |
24 | 196 |
|
34 | 197 |
QWeakPointer<RadioCarouselAnimator> mAnimator; |
24 | 198 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
199 |
HbLabel* mInfoText; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
200 |
|
34 | 201 |
HbMenu* mRadiotextPopup; |
202 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
203 |
HbWidget* mContainer; |
24 | 204 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
205 |
enum CarouselItem { LeftItem, CenterItem, RightItem }; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
206 |
RadioCarouselItem* mItems[3]; |
24 | 207 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
208 |
int mMidScrollPos; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
209 |
int mMaxScrollPos; |
24 | 210 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
211 |
int mCurrentIndex; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
212 |
int mTargetIndex; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
213 |
bool mIsCustomFreq; |
24 | 214 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
CarouselInfoText::Type mInfoTextType; |
24 | 216 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
217 |
RadioStationModel* mModel; |
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 |
bool mPosAdjustmentDisabled; |
24 | 220 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
221 |
Scroll::Direction mScrollDirection; |
24 | 222 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
223 |
bool mManualSeekMode; |
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 |
bool mAlternateSkipping; |
34 | 226 |
|
24 | 227 |
#ifdef USE_DEBUGGING_CONTROLS |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
228 |
RadioFadingLabel* mRdsLabel; |
24 | 229 |
#endif |
230 |
||
231 |
}; |
|
232 |
||
233 |
Q_DECLARE_OPERATORS_FOR_FLAGS( RadioStationCarousel::ScrollMode ) |
|
234 |
||
235 |
#endif // RADIOSTATIONCAROUSEL_H |