35 class RadioFrequencyItem; |
34 class RadioFrequencyItem; |
36 class RadioStation; |
35 class RadioStation; |
37 class HbPushButton; |
36 class HbPushButton; |
38 class QTimer; |
37 class QTimer; |
39 class QModelIndex; |
38 class QModelIndex; |
|
39 class RadioUiLoader; |
|
40 |
|
41 typedef QList<RadioStation> StationList; |
40 |
42 |
41 // Class declaration |
43 // Class declaration |
42 class WIDGETS_DLL_EXPORT RadioFrequencyStrip : public RadioStripBase |
44 class WIDGETS_DLL_EXPORT RadioFrequencyStrip : public RadioStripBase |
43 { |
45 { |
44 Q_OBJECT |
46 Q_OBJECT |
45 Q_PROPERTY( HbIcon leftButtonIcon READ leftButtonIcon WRITE setLeftButtonIcon ) |
47 Q_PROPERTY(int itemHeight READ itemHeight WRITE setItemHeight) |
46 Q_PROPERTY( HbIcon rightButtonIcon READ rightButtonIcon WRITE setRightButtonIcon ) |
48 Q_PROPERTY(uint frequency READ frequency) |
47 |
49 |
48 friend class RadioFrequencyItem; |
50 friend class RadioFrequencyItem; |
49 |
51 |
50 public: |
52 public: |
51 |
53 |
52 RadioFrequencyStrip(); |
54 RadioFrequencyStrip(); |
53 |
55 |
54 void setLeftButtonIcon( const HbIcon& leftButtonIcon ); |
56 void setItemHeight( int itemHeight ); |
55 HbIcon leftButtonIcon() const; |
57 int itemHeight() const; |
56 |
58 |
57 void setRightButtonIcon( const HbIcon& rightButtonIcon ); |
59 void init( RadioUiEngine* engine, RadioUiLoader& uiLoader ); |
58 HbIcon rightButtonIcon() const; |
60 |
59 |
61 void setFrequency( const uint frequency, int reason, Scroll::Direction direction = Scroll::Shortest ); |
60 void init( RadioUiEngine* engine ); |
|
61 |
|
62 void setFrequency( const uint frequency, int reason = 0 ); |
|
63 uint frequency() const; |
62 uint frequency() const; |
64 |
63 |
|
64 bool isInManualSeekMode() const; |
|
65 void cancelManualSeek(); |
|
66 |
|
67 void addScannedStation( const RadioStation& station ); |
|
68 |
|
69 void updateFavorite( const RadioStation& station ); |
|
70 |
65 public slots: |
71 public slots: |
66 |
72 |
67 void updateFavorite( const RadioStation& station ); |
|
68 void setScanningMode( bool isScanning ); |
73 void setScanningMode( bool isScanning ); |
69 |
74 |
70 signals: |
75 signals: |
71 |
76 |
72 void frequencyChanged( uint frequency, int reason ); // reason is always CommandSender::RadioFrequencyStrip |
77 void frequencyChanged( uint frequency, int reason, int direction ); |
73 void skipRequested( int skipMode ); |
78 void skipRequested( int skipMode ); |
74 void seekRequested( int seekDirection ); |
79 void seekRequested( int seekDirection ); |
|
80 void manualSeekChanged( bool manualSeek ); |
75 |
81 |
76 private slots: |
82 private slots: |
77 |
83 |
|
84 void removeStation( const QModelIndex& parent, int first, int last ); |
78 void updateStation( const QModelIndex& parent, int first, int last ); |
85 void updateStation( const QModelIndex& parent, int first, int last ); |
79 void initEmptyItems(); |
86 void initEmptyItems(); |
80 void handleLeftButton(); |
87 void handleLeftButton(); |
81 void handleLongLeftButton(); |
88 void handleLongLeftButton(); |
82 void handleRightButton(); |
89 void handleRightButton(); |
83 void handleLongRightButton(); |
90 void handleLongRightButton(); |
84 void toggleButtons(); |
91 void toggleManualSeek(); |
85 void checkIllegalPos(); |
92 void handleScrollingEnd(); |
86 |
93 |
87 private: |
94 private: |
88 |
95 |
89 // from base class RadioStripBase |
96 // from base class RadioStripBase |
90 |
97 |
91 void updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex ); |
98 void updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex ); |
92 QGraphicsItem* createItemPrimitive( QGraphicsItem *parent ); |
99 QGraphicsItem* createItemPrimitive( QGraphicsItem *parent ); |
93 void scrollPosChanged( QPointF newPosition ); |
100 void scrollPosChanged(); |
94 |
101 |
95 // from base class QGraphicsWidget |
102 // from base class QGraphicsWidget |
96 |
103 |
97 void resizeEvent ( QGraphicsSceneResizeEvent* event ); |
104 void resizeEvent ( QGraphicsSceneResizeEvent* event ); |
98 void showEvent( QShowEvent* event ); |
105 // void showEvent( QShowEvent* event ); |
99 void changeEvent( QEvent* event ); |
106 void changeEvent( QEvent* event ); |
100 |
107 |
101 // from base class HbScrollArea |
108 // from base class HbScrollArea |
102 |
109 |
103 void mousePressEvent( QGraphicsSceneMouseEvent* event ); |
110 void mousePressEvent( QGraphicsSceneMouseEvent* event ); |
104 void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); |
111 void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); |
105 void gestureEvent( QGestureEvent* event ); |
112 void gestureEvent( QGestureEvent* event ); |
106 |
113 |
|
114 // from base class QObject |
|
115 |
|
116 void timerEvent( QTimerEvent* event ); |
|
117 |
107 // New functions |
118 // New functions |
108 |
119 |
109 void initModel(); |
120 void initModel(); |
110 |
121 |
111 void initSelector(); |
122 void initSelector(); |
114 |
125 |
115 void initButtons(); |
126 void initButtons(); |
116 |
127 |
117 void addFrequencyPos( int pos, uint frequency, RadioFrequencyItem* item ); |
128 void addFrequencyPos( int pos, uint frequency, RadioFrequencyItem* item ); |
118 |
129 |
119 void updateFavorites( RadioFrequencyItem* item ); |
130 void updateStationsInRange( int first, int last, bool stationRemoved = false ); |
120 |
131 |
121 void updateItems(); |
132 void updateItem( RadioFrequencyItem* item, uint upperRange = 0, uint ignoredFrequency = 0 ); |
|
133 |
|
134 void updateAllItems(); |
122 |
135 |
123 QPixmap drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item ); |
136 QPixmap drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item ); |
124 |
137 |
|
138 QLineF makeTab( qreal pos, int height ); |
|
139 |
125 void emitFrequencyChanged( uint frequency ); |
140 void emitFrequencyChanged( uint frequency ); |
126 |
141 |
127 int selectorPos() const; |
142 int selectorPos() const; |
128 |
143 |
129 void scrollToFrequency( uint frequency, int time = 0 ); |
144 void scrollToFrequency( uint frequency, |
|
145 Scroll::Direction direction = Scroll::Shortest, |
|
146 int time = 0, |
|
147 TuneReason::Reason reason = TuneReason::Unspecified ); |
130 |
148 |
131 void hideButtons(); |
149 void hideButtons(); |
132 void showButtons(); |
150 void showButtons(); |
133 |
151 |
134 private: // data |
152 private: // data |
182 * it offers the fastest lookup time of any other QT container. QHash stores the items in arbitrary |
202 * it offers the fastest lookup time of any other QT container. QHash stores the items in arbitrary |
183 * order so we must never try to loop through them and assume they are in any particular order. |
203 * order so we must never try to loop through them and assume they are in any particular order. |
184 */ |
204 */ |
185 QHash<int,uint> mPositions; |
205 QHash<int,uint> mPositions; |
186 |
206 |
187 HbIcon mLeftButtonIcon; |
|
188 |
|
189 HbIcon mRightButtonIcon; |
|
190 |
|
191 HbPushButton* mLeftButton; |
207 HbPushButton* mLeftButton; |
192 |
208 |
193 HbPushButton* mRightButton; |
209 HbPushButton* mRightButton; |
194 |
210 |
195 QTimer* mButtonTimer; |
211 QTimer* mManualSeekTimer; |
196 bool mButtonsVisible; |
212 |
197 |
213 bool mManualSeekMode; |
198 bool mUserIsScrolling; |
214 |
|
215 uint mLastReportedFrequency; |
|
216 |
|
217 int mManualSeekTimerId; |
199 |
218 |
200 QColor mForegroundColor; |
219 QColor mForegroundColor; |
201 |
220 |
202 }; |
221 }; |
203 |
222 |