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
|
|
22 |
#include <HbGridView>
|
|
23 |
#include <QMap>
|
|
24 |
#include <QAbstractItemModel>
|
|
25 |
#include <HbIcon>
|
|
26 |
|
|
27 |
// User includes
|
|
28 |
#include "radiowidgetsexport.h"
|
|
29 |
#include "radio_global.h"
|
|
30 |
|
|
31 |
// Forward declarations
|
|
32 |
class RadioUiEngine;
|
|
33 |
class RadioUiLoader;
|
|
34 |
class RadioStation;
|
|
35 |
class RadioStationItem;
|
|
36 |
class RadioStationCarousel;
|
|
37 |
class RadioCarouselModel;
|
|
38 |
class RadioFadingLabel;
|
|
39 |
class QTimeLine;
|
|
40 |
class HbLabel;
|
|
41 |
|
|
42 |
namespace CarouselInfoText
|
|
43 |
{
|
|
44 |
enum Type
|
|
45 |
{
|
|
46 |
None,
|
|
47 |
ConnectAntenna,
|
|
48 |
NoFavorites,
|
|
49 |
Seeking,
|
|
50 |
Scanning
|
|
51 |
};
|
|
52 |
}
|
|
53 |
|
|
54 |
// Class declaration
|
|
55 |
class ScanningHelper : public QObject
|
|
56 |
{
|
|
57 |
Q_OBJECT
|
|
58 |
|
|
59 |
public:
|
|
60 |
|
|
61 |
ScanningHelper( RadioStationCarousel& carousel );
|
|
62 |
|
|
63 |
void start();
|
|
64 |
|
|
65 |
private slots:
|
|
66 |
|
|
67 |
void startSlide();
|
|
68 |
void startNumberScroll();
|
|
69 |
void numberScrollUpdate( int value );
|
|
70 |
|
|
71 |
public:
|
|
72 |
|
|
73 |
RadioStationCarousel& mCarousel;
|
|
74 |
uint mCurrentFrequency;
|
|
75 |
uint mPreviousFrequency;
|
|
76 |
RadioStationItem* mStationItem;
|
|
77 |
QTimeLine* mNumberScrollingTimeLine;
|
|
78 |
QModelIndex mModelIndex;
|
|
79 |
|
|
80 |
};
|
|
81 |
|
|
82 |
// Class declaration
|
|
83 |
class WIDGETS_DLL_EXPORT RadioStationCarousel : public HbGridView
|
|
84 |
{
|
|
85 |
Q_OBJECT
|
|
86 |
Q_PROPERTY(HbIcon favoriteIcon READ favoriteIcon WRITE setFavoriteIcon)
|
|
87 |
Q_PROPERTY(HbIcon nonFavoriteIcon READ nonFavoriteIcon WRITE setNonFavoriteIcon)
|
|
88 |
Q_PROPERTY( int autoScrollTime READ autoScrollTime WRITE setAutoScrollTime )
|
|
89 |
|
|
90 |
friend class ScanningHelper;
|
|
91 |
|
|
92 |
public:
|
|
93 |
|
|
94 |
enum ScrollFlag
|
|
95 |
{
|
|
96 |
Default = 0,
|
|
97 |
NoAnim = 1 << 0,
|
|
98 |
NoSignal = 1 << 1,
|
|
99 |
UpdateItem = 1 << 2
|
|
100 |
};
|
|
101 |
Q_DECLARE_FLAGS( ScrollMode, ScrollFlag )
|
|
102 |
|
|
103 |
RadioStationCarousel( RadioUiEngine* uiEngine = 0 );
|
|
104 |
|
|
105 |
void setFavoriteIcon( const HbIcon& favoriteIcon );
|
|
106 |
HbIcon favoriteIcon() const;
|
|
107 |
|
|
108 |
void setNonFavoriteIcon( const HbIcon& nonFavoriteIcon );
|
|
109 |
HbIcon nonFavoriteIcon() const;
|
|
110 |
|
|
111 |
void setAutoScrollTime( const int time );
|
|
112 |
int autoScrollTime() const;
|
|
113 |
|
|
114 |
void init( RadioUiLoader& uiLoader, RadioUiEngine* uiEngine );
|
|
115 |
|
|
116 |
void setCarouselModel( RadioCarouselModel* carouselModel );
|
|
117 |
|
|
118 |
void setFrequency( uint frequency, int reason );
|
|
119 |
|
|
120 |
RadioUiEngine* uiEngine();
|
|
121 |
|
|
122 |
bool isAntennaAttached() const;
|
|
123 |
|
|
124 |
void setScanningMode( bool scanning );
|
|
125 |
bool isInScanningMode() const;
|
|
126 |
|
|
127 |
void cleanRdsData();
|
|
128 |
|
|
129 |
void updateCurrentItem();
|
|
130 |
|
|
131 |
void animateNewStation( const RadioStation& station );
|
|
132 |
|
|
133 |
void setItemVisible( bool visible );
|
|
134 |
|
|
135 |
void setInfoText( CarouselInfoText::Type type );
|
|
136 |
void clearInfoText();
|
|
137 |
|
|
138 |
signals:
|
|
139 |
|
|
140 |
void frequencyChanged( uint frequency, int reason );
|
|
141 |
void scanAnimationFinished();
|
|
142 |
|
|
143 |
public slots:
|
|
144 |
|
|
145 |
void updateAntennaStatus( bool connected );
|
|
146 |
|
|
147 |
private slots:
|
|
148 |
|
|
149 |
void update( const RadioStation& station );
|
|
150 |
void updateRadioText( const RadioStation& station );
|
|
151 |
void insertFrequency( const QModelIndex& parent, int first, int last );
|
|
152 |
void prepareToRemoveFrequency( const QModelIndex& parent, int first, int last );
|
|
153 |
void removeFrequency( const QModelIndex& parent, int first, int last );
|
|
154 |
void updateFrequencies();
|
|
155 |
void timerFired();
|
|
156 |
void openContextMenu( HbAbstractViewItem* item, const QPointF& coords );
|
|
157 |
|
|
158 |
#ifdef USE_DEBUGGING_CONTROLS
|
|
159 |
void setRdsAvailable( bool available );
|
|
160 |
#endif // USE_DEBUGGING_CONTROLS
|
|
161 |
|
|
162 |
private:
|
|
163 |
|
|
164 |
// from base class QGraphicsItem
|
|
165 |
|
|
166 |
void mousePressEvent( QGraphicsSceneMouseEvent* event );
|
|
167 |
|
|
168 |
void gestureEvent( QGestureEvent* event );
|
|
169 |
|
|
170 |
// New functions
|
|
171 |
|
|
172 |
void initToLastTunedFrequency();
|
|
173 |
|
|
174 |
void updateClampingStyle();
|
|
175 |
|
|
176 |
void initCurrentStationItem();
|
|
177 |
|
|
178 |
RadioStationItem* currentStationItem();
|
|
179 |
|
|
180 |
RadioCarouselModel* carouselModel() const;
|
|
181 |
|
|
182 |
void scrollToIndex( const QModelIndex& index, ScrollMode mode = Default );
|
|
183 |
|
|
184 |
void updatePos( int offset );
|
|
185 |
|
|
186 |
void skip( StationSkip::Mode mode );
|
|
187 |
|
|
188 |
private: // data
|
|
189 |
|
|
190 |
enum TimerMode { NoTimer, RtPlusCheck, InfoText };
|
|
191 |
|
|
192 |
RadioUiEngine* mUiEngine;
|
|
193 |
|
|
194 |
bool mAntennaAttached;
|
|
195 |
|
|
196 |
int mAutoScrollTime;
|
|
197 |
|
|
198 |
QMap<uint,QModelIndex> mModelIndexes;
|
|
199 |
|
|
200 |
HbIcon mFavoriteIcon;
|
|
201 |
HbIcon mNonFavoriteIcon;
|
|
202 |
|
|
203 |
QTimer* mGenericTimer;
|
|
204 |
TimerMode mTimerMode;
|
|
205 |
|
|
206 |
QString mRadioTextHolder;
|
|
207 |
|
|
208 |
ScanningHelper* mScanningHelper;
|
|
209 |
|
|
210 |
HbLabel* mInfoText;
|
|
211 |
|
|
212 |
RadioStationItem* mCurrentItem;
|
|
213 |
|
|
214 |
CarouselInfoText::Type mInfoTextType;
|
|
215 |
|
|
216 |
int mPanStartPos;
|
|
217 |
|
|
218 |
#ifdef USE_DEBUGGING_CONTROLS
|
|
219 |
RadioFadingLabel* mRdsLabel;
|
|
220 |
#endif
|
|
221 |
|
|
222 |
};
|
|
223 |
|
|
224 |
Q_DECLARE_OPERATORS_FOR_FLAGS( RadioStationCarousel::ScrollMode )
|
|
225 |
|
|
226 |
#endif // RADIOSTATIONCAROUSEL_H
|