author | hgs |
Fri, 23 Jul 2010 10:16:59 +0300 | |
changeset 38 | f8c3d4e6102c |
parent 36 | ba22309243a1 |
child 51 | bbebb0235466 |
permissions | -rw-r--r-- |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
// System includes |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <HbStyleLoader> |
34 | 20 |
#include <HbTextItem> |
21 |
#include <HbRichTextItem> |
|
22 |
#include <HbIconItem> |
|
23 |
#include <HbTouchArea> |
|
24 |
#include <HbTapGesture> |
|
25 |
#include <QPainter> |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
// User includes |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "radiocarouselitem.h" |
34 | 29 |
#include "radiocarouselitemobserver.h" |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "radiostation.h" |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "radiologger.h" |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
34 | 33 |
const QLatin1String FILE_PATH_WIDGETML ( ":/layout/radiocarouselitem.widgetml" ); |
34 |
const QLatin1String FILE_PATH_CSS ( ":/layout/radiocarouselitem.css" ); |
|
35 |
const QLatin1String ICON_BUTTON ( "star_button" ); |
|
36 |
const QLatin1String GENRE_LABEL ( "genre_label" ); |
|
37 |
const QLatin1String FAVORITE_TOUCH_AREA ( "favorite_touch_area" ); |
|
38 |
const QLatin1String NAME_LABEL ( "name_label" ); |
|
39 |
const QLatin1String RT_LABEL ( "rt_label" ); |
|
40 |
const QLatin1String URL_LABEL ( "url_label" ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
|
34 | 42 |
const QLatin1String SEEKING_TEXT ( "txt_rad_list_tuning" ); |
43 |
const QLatin1String CONNECT_HEADSET_TEXT( "txt_rad_list_connect_wireless_antenna_headset_with" ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
*/ |
34 | 48 |
static void registerAndCheck( const QString& file ) { |
49 |
bool registered = HbStyleLoader::registerFilePath( file ); |
|
50 |
Q_ASSERT_X( registered, "RadioCarouselItem", "Failed to register CSS or WIDGETML!" ); |
|
51 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
|
34 | 53 |
/*! |
54 |
* |
|
55 |
*/ |
|
56 |
RadioCarouselItem::RadioCarouselItem( RadioCarouselItemObserver& observer, QGraphicsItem* parent, bool registerCss ) : |
|
57 |
HbWidget( parent ), |
|
58 |
mObserver( observer ), |
|
59 |
mFavoriteItem( NULL ), |
|
60 |
mGenreItem( NULL ), |
|
61 |
mFavoriteTouchArea( NULL ), |
|
62 |
mNameItem( NULL ), |
|
63 |
mRadiotextItem( NULL ), |
|
64 |
mUrlItem( NULL ), |
|
65 |
mAppearance( Default ), |
|
66 |
mOwnsCss( registerCss ), |
|
38 | 67 |
mLandscapeMode( false ), |
34 | 68 |
mFlags( DefaultFlags ) |
69 |
{ |
|
70 |
mStation.reset( new RadioStation() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
|
34 | 72 |
if ( mOwnsCss ) { |
73 |
registerAndCheck( FILE_PATH_CSS ); |
|
74 |
registerAndCheck( FILE_PATH_WIDGETML ); |
|
75 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
|
34 | 77 |
createPrimitives(); |
78 |
updatePrimitives(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
|
34 | 80 |
updateFavoriteIcon( false ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
|
34 | 82 |
updateVisibilities(); |
83 |
||
84 |
grabGesture( Qt::TapGesture ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
RadioCarouselItem::~RadioCarouselItem() |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
{ |
34 | 92 |
if ( mOwnsCss ) { |
93 |
HbStyleLoader::unregisterFilePath( FILE_PATH_CSS ); |
|
94 |
HbStyleLoader::unregisterFilePath( FILE_PATH_WIDGETML ); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
/*! |
|
99 |
* |
|
100 |
*/ |
|
101 |
void RadioCarouselItem::createPrimitives() |
|
102 |
{ |
|
103 |
mFavoriteItem = new HbIconItem( this ); |
|
104 |
HbStyle::setItemName( mFavoriteItem, ICON_BUTTON ); |
|
105 |
||
106 |
mGenreItem = new HbTextItem( this ); |
|
107 |
HbStyle::setItemName( mGenreItem, GENRE_LABEL ); |
|
108 |
||
109 |
mNameItem = new HbTextItem( this ); |
|
110 |
HbStyle::setItemName( mNameItem, NAME_LABEL ); |
|
111 |
||
112 |
mRadiotextItem = new HbRichTextItem( this ); |
|
113 |
HbStyle::setItemName( mRadiotextItem, RT_LABEL ); |
|
114 |
||
115 |
mUrlItem = new HbTextItem( this ); |
|
116 |
HbStyle::setItemName( mUrlItem, URL_LABEL ); |
|
117 |
||
118 |
mFavoriteTouchArea = new HbTouchArea( this ); |
|
119 |
HbStyle::setItemName( mFavoriteTouchArea, FAVORITE_TOUCH_AREA ); |
|
120 |
||
121 |
// Matti testing needs these |
|
122 |
mFavoriteItem->setObjectName( ICON_BUTTON ); |
|
123 |
mGenreItem->setObjectName( GENRE_LABEL ); |
|
124 |
mNameItem->setObjectName( NAME_LABEL ); |
|
125 |
mRadiotextItem->setObjectName( RT_LABEL ); |
|
126 |
mUrlItem->setObjectName( URL_LABEL ); |
|
127 |
mFavoriteTouchArea->setObjectName( FAVORITE_TOUCH_AREA ); |
|
128 |
} |
|
129 |
||
130 |
/*! |
|
131 |
* |
|
132 |
*/ |
|
133 |
void RadioCarouselItem::drawOffScreen( QPainter& painter ) |
|
134 |
{ |
|
135 |
QStyleOptionGraphicsItem option; |
|
136 |
||
137 |
foreach ( QGraphicsItem* child, childItems() ) { |
|
138 |
QGraphicsWidget* childWidget = static_cast<QGraphicsWidget*>( child ); |
|
139 |
option.exposedRect = childWidget->rect(); |
|
140 |
painter.save(); |
|
141 |
painter.translate( childWidget->pos() ); |
|
142 |
childWidget->paint( &painter, &option, NULL ); |
|
143 |
painter.restore(); |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
/*! |
|
148 |
* |
|
149 |
*/ |
|
150 |
void RadioCarouselItem::updatePrimitives() |
|
151 |
{ |
|
152 |
update(); |
|
153 |
} |
|
154 |
||
155 |
/*! |
|
156 |
* \reimp |
|
157 |
*/ |
|
158 |
void RadioCarouselItem::gestureEvent( QGestureEvent* event ) |
|
159 |
{ |
|
160 |
if ( HbTapGesture* gesture = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) { |
|
161 |
if ( gesture->state() == Qt::GestureFinished ) { |
|
162 |
const QPointF mappedHotSpot = event->mapToGraphicsScene( gesture->hotSpot() ); |
|
163 |
||
164 |
if ( mFlags.testFlag( FavoriteTouchable ) && |
|
165 |
mFavoriteTouchArea->sceneBoundingRect().contains( mappedHotSpot ) ) { |
|
166 |
||
167 |
mObserver.handleIconClicked( *mStation ); |
|
168 |
||
169 |
} else if ( mFlags.testFlag( RadiotextTouchable ) && |
|
170 |
mRadiotextItem->sceneBoundingRect().contains( mappedHotSpot ) ) { |
|
171 |
||
172 |
mObserver.handleRadiotextClicked( *mStation ); |
|
173 |
||
174 |
} else if ( mFlags.testFlag( UrlTouchable ) && |
|
175 |
mUrlItem->sceneBoundingRect().contains( mappedHotSpot ) ) { |
|
176 |
||
177 |
mObserver.handleUrlClicked( *mStation ); |
|
178 |
||
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
} |
|
183 |
||
184 |
/*! |
|
185 |
* |
|
186 |
*/ |
|
187 |
void RadioCarouselItem::setFlags( CarouselItemFlags flags ) |
|
188 |
{ |
|
189 |
mFlags |= flags; |
|
190 |
updateVisibilities(); |
|
191 |
} |
|
192 |
||
193 |
/*! |
|
194 |
* |
|
195 |
*/ |
|
196 |
void RadioCarouselItem::clearFlags( CarouselItemFlags flags ) |
|
197 |
{ |
|
198 |
for ( int i = 1; i < LastFlagMarker; i = i << 1 ) { |
|
199 |
if ( flags.testFlag( static_cast<ItemFlag>( i ) ) ) { |
|
200 |
mFlags &= ~i; |
|
201 |
} |
|
202 |
} |
|
203 |
updateVisibilities(); |
|
204 |
} |
|
205 |
||
206 |
/*! |
|
207 |
* |
|
208 |
*/ |
|
209 |
void RadioCarouselItem::updateVisibilities() |
|
210 |
{ |
|
211 |
mFavoriteItem->setVisible( mFlags.testFlag( FavoriteVisible ) ); |
|
212 |
mGenreItem->setVisible( mFlags.testFlag( GenreVisible ) ); |
|
213 |
mRadiotextItem->setVisible( mFlags.testFlag( RadiotextVisible ) ); |
|
214 |
mUrlItem->setVisible( mFlags.testFlag( UrlVisible ) ); |
|
215 |
} |
|
216 |
||
217 |
/*! |
|
218 |
* |
|
219 |
*/ |
|
220 |
void RadioCarouselItem::setAppearance( Appearance appearance ) |
|
221 |
{ |
|
222 |
mAppearance = appearance; |
|
223 |
||
224 |
if ( mAppearance == ManualSeek ) { |
|
225 |
mFlags = ManualSeekFlags; |
|
226 |
mGenreItem->setText( "" ); |
|
227 |
mRadiotextItem->setText( "" ); |
|
228 |
mUrlItem->setText( "" ); |
|
229 |
mNameItem->setText( mStation->frequencyString() ); |
|
230 |
updateFavoriteIcon( false ); |
|
231 |
} else { |
|
232 |
mFlags = DefaultFlags; |
|
233 |
} |
|
234 |
||
235 |
updateVisibilities(); |
|
236 |
||
237 |
repolish(); |
|
238 |
} |
|
239 |
||
240 |
/*! |
|
241 |
* |
|
242 |
*/ |
|
243 |
RadioCarouselItem::Appearance RadioCarouselItem::appearance() const |
|
244 |
{ |
|
245 |
return mAppearance; |
|
246 |
} |
|
247 |
||
248 |
/*! |
|
249 |
* |
|
250 |
*/ |
|
38 | 251 |
void RadioCarouselItem::setLandscape( bool landscape ) |
252 |
{ |
|
253 |
mLandscapeMode = landscape; |
|
254 |
} |
|
255 |
||
256 |
/*! |
|
257 |
* |
|
258 |
*/ |
|
259 |
bool RadioCarouselItem::landscape() const |
|
260 |
{ |
|
261 |
return mLandscapeMode; |
|
262 |
} |
|
263 |
||
264 |
/*! |
|
265 |
* |
|
266 |
*/ |
|
34 | 267 |
void RadioCarouselItem::setSeekLayout( bool seekLayout ) |
268 |
{ |
|
269 |
if ( seekLayout ) { |
|
270 |
setAppearance( ManualSeek ); |
|
271 |
} else { |
|
272 |
setAppearance( mStation->radioText().isEmpty() ? Default : Full ); |
|
273 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
275 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
276 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
277 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
278 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
279 |
void RadioCarouselItem::setStation( const RadioStation& station ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
{ |
34 | 281 |
*mStation = station; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
|
34 | 283 |
updateLayout(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
284 |
|
34 | 285 |
update(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
286 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
287 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
288 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
289 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
290 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
291 |
uint RadioCarouselItem::frequency() const |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
292 |
{ |
34 | 293 |
return mStation->frequency(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
294 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
295 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
296 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
297 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
298 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
299 |
void RadioCarouselItem::update( const RadioStation* station ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
301 |
if ( station ) { |
34 | 302 |
*mStation = *station; |
303 |
updateLayout(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
305 |
|
34 | 306 |
if ( mStation->isValid() ) { |
307 |
mGenreItem->setText( mObserver.localizeGenre( mStation->genre() ) ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
308 |
|
34 | 309 |
const bool hasName = mStation->hasName(); |
310 |
if ( hasName ) { |
|
311 |
mNameItem->setText( mStation->name() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
} else { |
34 | 313 |
mNameItem->setText( mStation->frequencyString() ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
|
34 | 316 |
if ( mStation->hasRadiotext() ) { |
317 |
mRadiotextItem->setText( mStation->radioText() ); |
|
318 |
} else { |
|
319 |
if ( mStation->hasDynamicPs() ) { |
|
320 |
mRadiotextItem->setText( mStation->dynamicPsText() ); |
|
321 |
} else if ( hasName ) { |
|
322 |
const QString loc = "%L1 Mhz"; //hbTrId( "txt_rad_list_l1_mhz_small" ); |
|
323 |
mRadiotextItem->setText( loc.arg( mStation->frequencyString() ) ); |
|
324 |
} else { |
|
325 |
mRadiotextItem->setText( "" ); |
|
326 |
} |
|
327 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
|
34 | 329 |
mUrlItem->setText( mStation->url() ); |
330 |
if ( mStation->hasUrl() ) { |
|
331 |
HbStyle::setItemName( mUrlItem, URL_LABEL ); |
|
332 |
setFlags( UrlVisible | UrlTouchable ); |
|
333 |
} else { |
|
334 |
HbStyle::setItemName( mUrlItem, "" ); // Clear the name so the item disappears from layout |
|
335 |
clearFlags( UrlVisible | UrlTouchable ); |
|
336 |
} |
|
337 |
||
338 |
updateFavoriteIcon( mStation->isFavorite() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
340 |
cleanRdsData(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
342 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
343 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
344 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
345 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
346 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
void RadioCarouselItem::setFrequency( uint frequency ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
{ |
34 | 349 |
LOG_FORMAT( "RadioCarouselItem::setFrequency: %d", frequency ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
|
34 | 351 |
mNameItem->setText( RadioStation::parseFrequency( frequency ) ); |
352 |
||
353 |
if ( !mObserver.isInManualSeek() ) { |
|
354 |
*mStation = mObserver.findStation( frequency ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
355 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
356 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
357 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
358 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
361 |
void RadioCarouselItem::cleanRdsData() |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
362 |
{ |
34 | 363 |
mGenreItem->setText( "" ); |
364 |
mRadiotextItem->setText( "" ); |
|
365 |
mUrlItem->setText( "" ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
366 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
367 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
368 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
369 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
370 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
371 |
void RadioCarouselItem::setRadioText( const QString& text ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
372 |
{ |
34 | 373 |
mRadiotextItem->setText( text ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
374 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
375 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
376 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
377 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
378 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
379 |
void RadioCarouselItem::setItemVisibility( ItemVisibility visibility ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
380 |
{ |
34 | 381 |
CarouselItemFlags flags = 0; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
382 |
if ( visibility == AllVisible ) { |
34 | 383 |
flags = DefaultFlags; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
} else if ( visibility == AllHidden ) { |
34 | 385 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
386 |
} else if ( visibility == IconVisible ) { |
34 | 387 |
flags = FavoriteVisible; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
388 |
} |
34 | 389 |
|
390 |
setFlags( flags ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
392 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
394 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
395 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
396 |
void RadioCarouselItem::setIconOpacity( qreal opacity ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
{ |
34 | 398 |
mFavoriteItem->setOpacity( opacity ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
400 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
401 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
402 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
void RadioCarouselItem::updateFavoriteIcon( bool isFavorite ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
{ |
34 | 406 |
if ( isFavorite ) { |
407 |
mFavoriteItem->setIcon( mObserver.favoriteIcon() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
408 |
} else { |
34 | 409 |
mFavoriteItem->setIcon( mObserver.nonFavoriteIcon() ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
411 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
*/ |
34 | 416 |
void RadioCarouselItem::updateLayout() |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
417 |
{ |
36 | 418 |
setAppearance( mStation->hasSentRds() ? Full : Default ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
419 |
} |