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 |
#ifndef FREQUENCYSTRIP_H |
|
19 |
#define FREQUENCYSTRIP_H |
|
20 |
||
21 |
// System includes |
|
22 |
#include <QMap> |
|
23 |
#include <QHash> |
|
24 |
#include <HbEffect> |
|
25 |
#include <QColor> |
|
26 |
||
27 |
// User includes |
|
28 |
#include "radiostripbase.h" |
|
29 |
#include "radio_global.h" |
|
30 |
#include "radiowidgetsexport.h" |
|
31 |
||
32 |
// Forward declarations |
|
33 |
class RadioUiEngine; |
|
34 |
class RadioFrequencyItem; |
|
35 |
class RadioStation; |
|
36 |
class HbPushButton; |
|
37 |
class QTimer; |
|
38 |
class QModelIndex; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
39 |
class RadioUiLoader; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
40 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
41 |
typedef QList<RadioStation> StationList; |
24 | 42 |
|
43 |
// Class declaration |
|
44 |
class WIDGETS_DLL_EXPORT RadioFrequencyStrip : public RadioStripBase |
|
45 |
{ |
|
46 |
Q_OBJECT |
|
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
47 |
Q_PROPERTY(int itemHeight READ itemHeight WRITE setItemHeight) |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
48 |
Q_PROPERTY(uint frequency READ frequency) |
24 | 49 |
|
50 |
friend class RadioFrequencyItem; |
|
51 |
||
52 |
public: |
|
53 |
||
54 |
RadioFrequencyStrip(); |
|
55 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
56 |
void setItemHeight( int itemHeight ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
57 |
int itemHeight() const; |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
58 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
59 |
void init( RadioUiEngine* engine, RadioUiLoader& uiLoader ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
60 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
61 |
void setFrequency( const uint frequency, int reason, Scroll::Direction direction = Scroll::Shortest ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
uint frequency() const; |
24 | 63 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
64 |
bool isInManualSeekMode() const; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
65 |
void cancelManualSeek(); |
24 | 66 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
67 |
void addScannedStation( const RadioStation& station ); |
24 | 68 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
69 |
void updateFavorite( const RadioStation& station ); |
24 | 70 |
|
71 |
public slots: |
|
72 |
||
73 |
void setScanningMode( bool isScanning ); |
|
74 |
||
75 |
signals: |
|
76 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
77 |
void frequencyChanged( uint frequency, int reason, int direction ); |
24 | 78 |
void skipRequested( int skipMode ); |
79 |
void seekRequested( int seekDirection ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
80 |
void manualSeekChanged( bool manualSeek ); |
24 | 81 |
|
82 |
private slots: |
|
83 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
84 |
void removeStation( const QModelIndex& parent, int first, int last ); |
24 | 85 |
void updateStation( const QModelIndex& parent, int first, int last ); |
86 |
void initEmptyItems(); |
|
87 |
void handleLeftButton(); |
|
88 |
void handleLongLeftButton(); |
|
89 |
void handleRightButton(); |
|
90 |
void handleLongRightButton(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
91 |
void toggleManualSeek(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
92 |
void handleScrollingEnd(); |
24 | 93 |
|
94 |
private: |
|
95 |
||
96 |
// from base class RadioStripBase |
|
97 |
||
98 |
void updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex ); |
|
99 |
QGraphicsItem* createItemPrimitive( QGraphicsItem *parent ); |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
100 |
void scrollPosChanged(); |
24 | 101 |
|
102 |
// from base class QGraphicsWidget |
|
103 |
||
104 |
void resizeEvent ( QGraphicsSceneResizeEvent* event ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
105 |
// void showEvent( QShowEvent* event ); |
24 | 106 |
void changeEvent( QEvent* event ); |
107 |
||
108 |
// from base class HbScrollArea |
|
109 |
||
110 |
void mousePressEvent( QGraphicsSceneMouseEvent* event ); |
|
111 |
void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); |
|
112 |
void gestureEvent( QGestureEvent* event ); |
|
113 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
114 |
// from base class QObject |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
115 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
116 |
void timerEvent( QTimerEvent* event ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
117 |
|
24 | 118 |
// New functions |
119 |
||
120 |
void initModel(); |
|
121 |
||
122 |
void initSelector(); |
|
123 |
||
124 |
void initPositions(); |
|
125 |
||
126 |
void initButtons(); |
|
127 |
||
128 |
void addFrequencyPos( int pos, uint frequency, RadioFrequencyItem* item ); |
|
129 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
130 |
void updateStationsInRange( int first, int last, bool stationRemoved = false ); |
24 | 131 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
132 |
void updateItem( RadioFrequencyItem* item, uint upperRange = 0, uint ignoredFrequency = 0 ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
133 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
134 |
void updateAllItems(); |
24 | 135 |
|
136 |
QPixmap drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item ); |
|
137 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
138 |
QLineF makeTab( qreal pos, int height ); |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
139 |
|
24 | 140 |
void emitFrequencyChanged( uint frequency ); |
141 |
||
142 |
int selectorPos() const; |
|
143 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
144 |
void scrollToFrequency( uint frequency, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
145 |
Scroll::Direction direction = Scroll::Shortest, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
146 |
int time = 0, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
147 |
TuneReason::Reason reason = TuneReason::Unspecified ); |
24 | 148 |
|
149 |
void hideButtons(); |
|
150 |
void showButtons(); |
|
151 |
||
152 |
private: // data |
|
153 |
||
154 |
class FrequencyPos |
|
155 |
{ |
|
156 |
public: |
|
157 |
explicit FrequencyPos( int pos, RadioFrequencyItem* item ) : |
|
158 |
mPosition( pos ), |
|
159 |
mItem( item ) {} |
|
160 |
||
161 |
FrequencyPos() : |
|
162 |
mPosition( 0 ), |
|
163 |
mItem( 0 ) {} |
|
164 |
||
165 |
int mPosition; |
|
166 |
RadioFrequencyItem* mItem; |
|
167 |
||
168 |
}; |
|
169 |
||
170 |
RadioUiEngine* mUiEngine; |
|
171 |
||
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
172 |
int mItemHeight; |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
32
diff
changeset
|
173 |
|
24 | 174 |
uint mMinFrequency; |
175 |
||
176 |
uint mMaxFrequency; |
|
177 |
||
178 |
uint mFrequencyStepSize; |
|
179 |
||
180 |
uint mFrequency; |
|
181 |
||
182 |
QGraphicsPixmapItem* mSelectorImage; |
|
183 |
||
184 |
qreal mSeparatorPos; |
|
185 |
||
186 |
short mMaxWidth; |
|
187 |
||
188 |
qreal mSelectorPos; |
|
189 |
||
190 |
QList<RadioFrequencyItem*> mFrequencyItems; |
|
191 |
||
192 |
/** |
|
193 |
* Container to help map a frequency to strip position and additional information about the frequency. |
|
194 |
* In the default region contains an item for every valid frequency from 87.50 Mhz to 108.00 Mhz with |
|
195 |
* stepsize 50 Khz which amounts to 410 items. |
|
196 |
*/ |
|
197 |
QMap<uint,FrequencyPos> mFrequencies; |
|
198 |
||
199 |
/** |
|
200 |
* Container to help map strip position to frequency. |
|
201 |
* It is queried every time the strip moves so the lookup time needs to be fast. QHash is used because |
|
202 |
* it offers the fastest lookup time of any other QT container. QHash stores the items in arbitrary |
|
203 |
* order so we must never try to loop through them and assume they are in any particular order. |
|
204 |
*/ |
|
205 |
QHash<int,uint> mPositions; |
|
206 |
||
207 |
HbPushButton* mLeftButton; |
|
208 |
||
209 |
HbPushButton* mRightButton; |
|
210 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
211 |
QTimer* mManualSeekTimer; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
212 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
213 |
bool mManualSeekMode; |
24 | 214 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
uint mLastReportedFrequency; |
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 |
int mManualSeekTimerId; |
24 | 218 |
|
219 |
QColor mForegroundColor; |
|
220 |
||
221 |
}; |
|
222 |
||
223 |
#endif // FREQUENCYSTRIP_H |