radioapp/radiowidgets/src/radiocarouselitem.cpp
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 33 11b6825f0862
equal deleted inserted replaced
28:075425b8d9a4 32:189d20c34778
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <HbStyleLoader>
    19 #include <HbStyleLoader>
    20 #include <HbPushButton>
    20 #include <HbTextItem>
    21 #include <HbAnchorLayout>
    21 #include <HbRichTextItem>
    22 #include <HbMessageBox>
    22 #include <HbIconItem>
       
    23 #include <HbTouchArea>
       
    24 #include <HbTapGesture>
    23 
    25 
    24 // User includes
    26 // User includes
    25 #include "radiocarouselitem.h"
    27 #include "radiocarouselitem.h"
       
    28 #include "radiocarouselitemobserver.h"
    26 #include "radiostation.h"
    29 #include "radiostation.h"
    27 #include "radiostationcarousel.h"
       
    28 #include "radiouiengine.h"
       
    29 #include "radiofadinglabel.h"
       
    30 #include "radiostationmodel.h"
       
    31 #include "radiologger.h"
    30 #include "radiologger.h"
    32 
    31 
    33 //static const char* FILE_PATH_WIDGETML   = ":/layout/radiostationitem.widgetml";
    32 const QLatin1String FILE_PATH_WIDGETML   ( ":/layout/radiocarouselitem.widgetml" );
    34 //static const char* FILE_PATH_CSS        = ":/layout/radiostationitem.css";
    33 const QLatin1String FILE_PATH_CSS        ( ":/layout/radiocarouselitem.css" );
    35 static const char* GENRE_LABEL            = "tv:genre_label";
    34 const QLatin1String ICON_BUTTON          ( "star_button" );
    36 static const char* NAME_LABEL             = "tv:name_label";
    35 const QLatin1String GENRE_LABEL          ( "genre_label" );
    37 static const char* RADIOTEXT_LABEL        = "tv:radiotext_label";
    36 const QLatin1String FAVORITE_TOUCH_AREA  ( "favorite_touch_area" );
    38 static const char* URL_LABEL              = "tv:url_label";
    37 const QLatin1String NAME_LABEL           ( "name_label" );
    39 //static const char* FAVORITE_BUTTON      = "favorite_button";
    38 const QLatin1String RT_LABEL             ( "rt_label" );
    40 
    39 const QLatin1String URL_LABEL            ( "url_label" );
    41 const char* SEEKING_TEXT = "txt_rad_list_tuning";
    40 
    42 const char* CONNECT_HEADSET_TEXT = "txt_rad_list_connect_wireless_antenna_headset_with";
    41 const QLatin1String SEEKING_TEXT        ( "txt_rad_list_tuning" );
    43 
    42 const QLatin1String CONNECT_HEADSET_TEXT( "txt_rad_list_connect_wireless_antenna_headset_with" );
    44 /*!
    43 
    45  *
    44 /*!
    46  */
    45  *
    47 RadioCarouselItem::RadioCarouselItem( RadioStationCarousel& carousel ) :
    46  */
    48     HbWidget( &carousel ),
    47 static void registerAndCheck( const QString& file ) {
    49     mCarousel( carousel ),
    48     bool registered = HbStyleLoader::registerFilePath( file );
    50     mData( new Data() )
    49     Q_ASSERT_X( registered, "RadioCarouselItem", "Failed to register CSS or WIDGETML!" );
    51 {
    50 }
    52     mData->mStation.reset( new RadioStation() );
    51 
    53 
    52 /*!
    54     mData->mIconButton.reset( new HbPushButton( this ) );
    53  *
    55     QPixmap background( QSize( 70, 70 ) );
    54  */
    56     background.fill( Qt::transparent );
    55 RadioCarouselItem::RadioCarouselItem( RadioCarouselItemObserver& observer, QGraphicsItem* parent, bool registerCss ) :
    57     mData->mIconButton->setBackground( HbIcon( background ) );
    56     HbWidget( parent ),
    58     mData->mIconButton->setIcon( mCarousel.nonFavoriteIcon() );
    57     mObserver( observer ),
    59 
    58     mFavoriteItem( NULL ),
    60     Radio::connect( mData->mIconButton.data(),  SIGNAL(clicked()),
    59     mGenreItem( NULL ),
    61                     &mCarousel,                 SLOT(toggleFavorite()));
    60     mFavoriteTouchArea( NULL ),
    62 
    61     mNameItem( NULL ),
    63     mData->mNameLabel.reset( new RadioFadingLabel( this ) );
    62     mRadiotextItem( NULL ),
    64     mData->mNameLabel->setAlignment( Qt::AlignCenter );
    63     mUrlItem( NULL ),
    65     mData->mNameLabel->setObjectName( NAME_LABEL );
    64     mAppearance( Default ),
    66     HbFontSpec spec = mData->mNameLabel->fontSpec();
    65     mOwnsCss( registerCss ),
    67     spec.setRole( HbFontSpec::Primary );
    66     mFlags( DefaultFlags )
    68     spec.setTextHeight( 40 );
    67 {
    69     mData->mNameLabel->setFontSpec( spec );
    68     mStation.reset( new RadioStation() );
    70 
    69 
    71     spec.setRole( HbFontSpec::Secondary );
    70     if ( mOwnsCss ) {
    72 
    71         registerAndCheck( FILE_PATH_CSS );
    73     mData->mGenreLabel.reset( new RadioFadingLabel( this ) );
    72         registerAndCheck( FILE_PATH_WIDGETML );
    74     mData->mGenreLabel->setAlignment( Qt::AlignCenter );
    73     }
    75     mData->mGenreLabel->setObjectName( GENRE_LABEL );
    74 
    76     mData->mGenreLabel->setTextColor( Qt::white );
    75     createPrimitives();
    77 
    76     updatePrimitives();
    78     mData->mRadiotextLabel.reset( new RadioFadingLabel( this ) );
    77 
    79     mData->mRadiotextLabel->setAlignment( Qt::AlignCenter );
    78     updateFavoriteIcon( false );
    80     mData->mRadiotextLabel->setObjectName( RADIOTEXT_LABEL );
    79 
    81     mData->mRadiotextLabel->setTextWrapping( Hb::TextWordWrap );
    80     updateVisibilities();
    82 //        mRadiotextLabel->setFadingEnabled( true );    TODO
    81 
    83 //        mRadiotextLabel->setFontSpec( spec );
    82     grabGesture( Qt::TapGesture );
    84     mData->mRadiotextLabel->setTextColor( Qt::white );
       
    85 
       
    86     mData->mUrlLabel.reset( new RadioFadingLabel( this ) );
       
    87     mData->mUrlLabel->setAlignment( Qt::AlignCenter );
       
    88     mData->mUrlLabel->setObjectName( URL_LABEL );
       
    89     mData->mUrlLabel->setTextColor( Qt::white );
       
    90 
       
    91     mData->mLayout = new HbAnchorLayout();
       
    92     HbAnchorLayout* layout = mData->mLayout;
       
    93 
       
    94     HbPushButton* iconButton = mData->mIconButton.data();
       
    95     RadioFadingLabel* nameLabel = mData->mNameLabel.data();
       
    96     RadioFadingLabel* genreLabel = mData->mGenreLabel.data();
       
    97     RadioFadingLabel* urlLabel = mData->mUrlLabel.data();
       
    98     RadioFadingLabel* radiotextLabel = mData->mRadiotextLabel.data();
       
    99 
       
   100     layout->setAnchor( layout, Hb::TopEdge, iconButton, Hb::TopEdge, 20.0 );
       
   101     layout->setAnchor( layout, Hb::LeftEdge, iconButton, Hb::LeftEdge, 20.0 );
       
   102 
       
   103     layout->setAnchor( iconButton, Hb::CenterVEdge, genreLabel, Hb::CenterVEdge, 0.0 );
       
   104     layout->setAnchor( iconButton, Hb::RightEdge, genreLabel, Hb::LeftEdge, 20.0 );
       
   105     layout->setAnchor( layout, Hb::RightEdge, genreLabel, Hb::RightEdge, -70.0 );
       
   106 
       
   107     layout->setAnchor( genreLabel, Hb::BottomEdge, nameLabel, Hb::TopEdge, 0.0 );
       
   108     layout->setAnchor( layout, Hb::LeftEdge, nameLabel, Hb::LeftEdge, 10.0 );
       
   109     layout->setAnchor( layout, Hb::RightEdge, nameLabel, Hb::RightEdge, -10.0 );
       
   110 
       
   111     layout->setAnchor( nameLabel, Hb::BottomEdge, radiotextLabel, Hb::TopEdge, 10.0 );
       
   112     layout->setAnchor( layout, Hb::LeftEdge, radiotextLabel, Hb::LeftEdge, 10.0 );
       
   113     layout->setAnchor( layout, Hb::RightEdge, radiotextLabel, Hb::RightEdge, -10.0 );
       
   114 
       
   115     layout->setAnchor( radiotextLabel, Hb::BottomEdge, urlLabel, Hb::TopEdge, 10.0 );
       
   116     layout->setAnchor( layout, Hb::LeftEdge, urlLabel, Hb::LeftEdge, 10.0 );
       
   117     layout->setAnchor( layout, Hb::RightEdge, urlLabel, Hb::RightEdge, -10.0 );
       
   118     layout->setAnchor( layout, Hb::BottomEdge, urlLabel, Hb::BottomEdge, -10.0 );
       
   119 
       
   120     setLayout( layout );
       
   121 }
    83 }
   122 
    84 
   123 /*!
    85 /*!
   124  *
    86  *
   125  */
    87  */
   126 RadioCarouselItem::~RadioCarouselItem()
    88 RadioCarouselItem::~RadioCarouselItem()
   127 {
    89 {
       
    90     if ( mOwnsCss ) {
       
    91         HbStyleLoader::unregisterFilePath( FILE_PATH_CSS );
       
    92         HbStyleLoader::unregisterFilePath( FILE_PATH_WIDGETML );
       
    93     }
       
    94 }
       
    95 
       
    96 /*!
       
    97  *
       
    98  */
       
    99 void RadioCarouselItem::createPrimitives()
       
   100 {
       
   101     mFavoriteItem = new HbIconItem( this );
       
   102     HbStyle::setItemName( mFavoriteItem, ICON_BUTTON );
       
   103 
       
   104     mGenreItem = new HbTextItem( this );
       
   105     HbStyle::setItemName( mGenreItem, GENRE_LABEL );
       
   106 
       
   107     mNameItem = new HbTextItem( this );
       
   108     HbStyle::setItemName( mNameItem, NAME_LABEL );
       
   109 
       
   110     mRadiotextItem = new HbRichTextItem( this );
       
   111     HbStyle::setItemName( mRadiotextItem, RT_LABEL );
       
   112 
       
   113     mUrlItem = new HbRichTextItem( this );
       
   114     HbStyle::setItemName( mUrlItem, URL_LABEL );
       
   115 
       
   116     mFavoriteTouchArea = new HbTouchArea( this );
       
   117     HbStyle::setItemName( mFavoriteTouchArea, FAVORITE_TOUCH_AREA );
       
   118 }
       
   119 
       
   120 /*!
       
   121  *
       
   122  */
       
   123 void RadioCarouselItem::updatePrimitives()
       
   124 {
       
   125     update();
       
   126 }
       
   127 
       
   128 /*!
       
   129  * \reimp
       
   130  */
       
   131 void RadioCarouselItem::gestureEvent( QGestureEvent* event )
       
   132 {
       
   133     if ( HbTapGesture* gesture = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) {
       
   134         if ( gesture->state() == Qt::GestureFinished ) {
       
   135             const QPointF mappedHotSpot = event->mapToGraphicsScene( gesture->hotSpot() );
       
   136 
       
   137             if ( mFlags.testFlag( FavoriteTouchable ) &&
       
   138                     mFavoriteTouchArea->sceneBoundingRect().contains( mappedHotSpot ) ) {
       
   139 
       
   140                 mObserver.handleIconClicked( *mStation );
       
   141 
       
   142             } else if ( mFlags.testFlag( RadiotextTouchable ) &&
       
   143                     mRadiotextItem->sceneBoundingRect().contains( mappedHotSpot ) ) {
       
   144 
       
   145                 mObserver.handleRadiotextClicked( *mStation );
       
   146 
       
   147             } else if ( mFlags.testFlag( UrlTouchable ) &&
       
   148                     mUrlItem->sceneBoundingRect().contains( mappedHotSpot ) ) {
       
   149 
       
   150                 mObserver.handleUrlClicked( *mStation );
       
   151 
       
   152             }
       
   153         }
       
   154     }
       
   155 }
       
   156 
       
   157 /*!
       
   158  *
       
   159  */
       
   160 void RadioCarouselItem::setFlags( CarouselItemFlags flags )
       
   161 {
       
   162     mFlags |= flags;
       
   163     updateVisibilities();
       
   164 }
       
   165 
       
   166 /*!
       
   167  *
       
   168  */
       
   169 void RadioCarouselItem::clearFlags( CarouselItemFlags flags )
       
   170 {
       
   171     for ( int i = 1; i < LastFlagMarker; i = i << 1 ) {
       
   172         if ( flags.testFlag( static_cast<ItemFlag>( i ) ) ) {
       
   173             mFlags &= ~i;
       
   174         }
       
   175     }
       
   176     updateVisibilities();
       
   177 }
       
   178 
       
   179 /*!
       
   180  *
       
   181  */
       
   182 void RadioCarouselItem::updateVisibilities()
       
   183 {
       
   184     mFavoriteItem->setVisible( mFlags.testFlag( FavoriteVisible ) );
       
   185     mGenreItem->setVisible( mFlags.testFlag( GenreVisible ) );
       
   186     mRadiotextItem->setVisible( mFlags.testFlag( RadiotextVisible ) );
       
   187     mUrlItem->setVisible( mFlags.testFlag( UrlVisible ) );
       
   188 }
       
   189 
       
   190 /*!
       
   191  *
       
   192  */
       
   193 void RadioCarouselItem::setAppearance( Appearance appearance )
       
   194 {
       
   195     mAppearance = appearance;
       
   196 
       
   197     if ( mAppearance == ManualSeek ) {
       
   198         mFlags = ManualSeekFlags;
       
   199         mGenreItem->setText( "" );
       
   200         mRadiotextItem->setText( "" );
       
   201         mUrlItem->setText( "" );
       
   202         mNameItem->setText( mStation->frequencyString() );
       
   203         updateFavoriteIcon( false );
       
   204     } else {
       
   205         mFlags = DefaultFlags;
       
   206     }
       
   207 
       
   208     updateVisibilities();
       
   209 
       
   210     repolish();
       
   211 }
       
   212 
       
   213 /*!
       
   214  *
       
   215  */
       
   216 RadioCarouselItem::Appearance RadioCarouselItem::appearance() const
       
   217 {
       
   218     return mAppearance;
       
   219 }
       
   220 
       
   221 /*!
       
   222  *
       
   223  */
       
   224 void RadioCarouselItem::setSeekLayout( bool seekLayout )
       
   225 {
       
   226     if ( seekLayout ) {
       
   227         setAppearance( ManualSeek );
       
   228     } else {
       
   229         setAppearance( mStation->radioText().isEmpty() ? Default : Full );
       
   230     }
   128 }
   231 }
   129 
   232 
   130 /*!
   233 /*!
   131  *
   234  *
   132  */
   235  */
   133 void RadioCarouselItem::setStation( const RadioStation& station )
   236 void RadioCarouselItem::setStation( const RadioStation& station )
   134 {
   237 {
   135     *mData->mStation = station;
   238     *mStation = station;
   136     update();
   239     update();
   137 }
   240 }
   138 
   241 
   139 /*!
   242 /*!
   140  *
   243  *
   141  */
   244  */
   142 void RadioCarouselItem::swapData( RadioCarouselItem& other )
       
   143 {
       
   144     RadioCarouselItem::Data* tempData = mData.take();
       
   145     mData.reset( other.mData.data() );
       
   146     other.mData.reset( tempData );
       
   147 
       
   148     other.setLayout( other.mData->mLayout );
       
   149     setLayout( mData->mLayout );
       
   150 }
       
   151 
       
   152 /*!
       
   153  *
       
   154  */
       
   155 uint RadioCarouselItem::frequency() const
   245 uint RadioCarouselItem::frequency() const
   156 {
   246 {
   157     return mData->mStation->frequency();
   247     return mStation->frequency();
   158 }
   248 }
   159 
   249 
   160 /*!
   250 /*!
   161  *
   251  *
   162  */
   252  */
   163 void RadioCarouselItem::update( const RadioStation* station )
   253 void RadioCarouselItem::update( const RadioStation* station )
   164 {
   254 {
   165     if ( station ) {
   255     if ( station ) {
   166         *mData->mStation = *station;
   256         *mStation = *station;
   167     }
   257     }
   168 
   258 
   169     if ( mData->mStation->isValid() ) {
   259     if ( mStation->isValid() ) {
   170         mData->mNameLabel->setTextWithoutFading( mData->mStation->nameOrFrequencyMhz() );
   260         mGenreItem->setText( mObserver.localizeGenre( mStation->genre() ) );
   171 
   261 
   172 //        mData->mGenreLabel->setText( "Rock Music" );
   262         const bool stationHasName = !mStation->name().isEmpty();
   173 //        mData->mRadiotextLabel->setText( "This is a bit of radio text that should span many lines" );
   263         const bool stationHasRadiotext = !mStation->radioText().isEmpty();
   174 //        mData->mUrlLabel->setText( "www.radiorock.fi" );
   264         const bool stationHasUrl = !mStation->url().isEmpty();
   175 
   265         setAppearance( stationHasName || stationHasRadiotext || stationHasUrl ? Full : Default );
   176         mData->mGenreLabel->setText( mCarousel.uiEngine()->genreToString( mData->mStation->genre(), GenreTarget::Carousel ) );
   266 
   177 
   267         if ( stationHasName ) {
   178         if ( !mData->mStation->radioText().isEmpty() ) {
   268             mNameItem->setText( mStation->name() );
   179             mData->mRadiotextLabel->setText( mData->mStation->radioText() );
       
   180         } else if ( !mData->mStation->dynamicPsText().isEmpty() ) {
       
   181             mData->mRadiotextLabel->setText( mData->mStation->dynamicPsText() );
       
   182         } else {
   269         } else {
   183             mData->mRadiotextLabel->setText( "" );
   270             mNameItem->setText( mStation->frequencyString() );
   184         }
   271         }
   185 
   272 
   186         mData->mUrlLabel->setText( mData->mStation->url() );
   273         if ( stationHasRadiotext ) {
   187 
   274             mRadiotextItem->setText( mStation->radioText() );
   188         updateFavoriteIcon( mData->mStation->isFavorite() );
   275         } else {
       
   276             if ( !mStation->dynamicPsText().isEmpty() ) {
       
   277                 mRadiotextItem->setText( mStation->dynamicPsText() );
       
   278             } else if ( stationHasName ) {
       
   279                 mRadiotextItem->setText( mStation->frequencyString() );
       
   280             } else {
       
   281                 mRadiotextItem->setText( "" );
       
   282             }
       
   283         }
       
   284 
       
   285         mUrlItem->setText( mStation->url() );
       
   286         if ( stationHasUrl ) {
       
   287             HbStyle::setItemName( mUrlItem, URL_LABEL );
       
   288             setFlags( UrlVisible | UrlTouchable );
       
   289         } else {
       
   290             HbStyle::setItemName( mUrlItem, "" ); // Clear the name so the item disappears from layout
       
   291             clearFlags( UrlVisible | UrlTouchable );
       
   292         }
       
   293 
       
   294         updateFavoriteIcon( mStation->isFavorite() );
   189     } else {
   295     } else {
   190         cleanRdsData();
   296         cleanRdsData();
   191     }
   297     }
   192 }
   298 }
   193 
   299 
   194 /*!
   300 /*!
   195  *
   301  *
   196  */
   302  */
   197 void RadioCarouselItem::setFrequency( uint frequency )
   303 void RadioCarouselItem::setFrequency( uint frequency )
   198 {
   304 {
   199 //    LOG_FORMAT( "RadioCarouselItem::setFrequency: %d", frequency );
   305     LOG_FORMAT( "RadioCarouselItem::setFrequency: %d", frequency );
   200 
   306 
   201     if ( !mCarousel.mManualSeekMode ) {
   307     mNameItem->setText( RadioStation::parseFrequency( frequency ) );
   202         mData->mStation->setFrequency( frequency );
   308 
   203         mData->mNameLabel->setTextWithoutFading( parseFrequency( frequency ) );
   309     if ( !mObserver.isInManualSeek() ) {
   204         mData->mGenreLabel->setTextWithoutFading( "" );
   310         *mStation = mObserver.findStation( frequency );
   205         mData->mRadiotextLabel->setTextWithoutFading( "" );
   311     }
   206         mData->mUrlLabel->setTextWithoutFading( "" );
   312 }
   207         updateFavoriteIcon( false );
   313 
       
   314 /*!
       
   315  *
       
   316  */
       
   317 void RadioCarouselItem::cleanRdsData()
       
   318 {
       
   319     mGenreItem->setText( "" );
       
   320     mRadiotextItem->setText( "" );
       
   321     mUrlItem->setText( "" );
       
   322 }
       
   323 
       
   324 /*!
       
   325  *
       
   326  */
       
   327 void RadioCarouselItem::setRadioText( const QString& text )
       
   328 {
       
   329     mRadiotextItem->setText( text );
       
   330 }
       
   331 
       
   332 /*!
       
   333  *
       
   334  */
       
   335 void RadioCarouselItem::setItemVisibility( ItemVisibility visibility )
       
   336 {
       
   337     CarouselItemFlags flags = 0;
       
   338     if ( visibility == AllVisible ) {
       
   339         flags = DefaultFlags;
       
   340     } else if ( visibility == AllHidden ) {
       
   341 
       
   342     } else if ( visibility == IconVisible ) {
       
   343         flags = FavoriteVisible;
       
   344     }
       
   345 
       
   346     setFlags( flags );
       
   347 }
       
   348 
       
   349 /*!
       
   350  *
       
   351  */
       
   352 void RadioCarouselItem::setIconOpacity( qreal opacity )
       
   353 {
       
   354     mFavoriteItem->setOpacity( opacity );
       
   355 }
       
   356 
       
   357 /*!
       
   358  *
       
   359  */
       
   360 void RadioCarouselItem::updateFavoriteIcon( bool isFavorite )
       
   361 {
       
   362     if ( isFavorite ) {
       
   363         mFavoriteItem->setIcon( mObserver.favoriteIcon() );
   208     } else {
   364     } else {
   209         mData->mNameLabel->setTextWithoutFading( parseFrequency( frequency ) );
   365         mFavoriteItem->setIcon( mObserver.nonFavoriteIcon() );
   210     }
   366     }
   211 }
   367 }
   212 
       
   213 /*!
       
   214  *
       
   215  */
       
   216 void RadioCarouselItem::cleanRdsData()
       
   217 {
       
   218     if ( !mCarousel.mManualSeekMode ) {
       
   219         mData->mNameLabel->setTextWithoutFading( "" );
       
   220     }
       
   221     mData->mGenreLabel->setTextWithoutFading( "" );
       
   222     mData->mRadiotextLabel->setTextWithoutFading( "" );
       
   223     mData->mUrlLabel->setTextWithoutFading( "" );
       
   224     mData->mIconButton->setIcon( HbIcon( "" ) );
       
   225 }
       
   226 
       
   227 /*!
       
   228  *
       
   229  */
       
   230 void RadioCarouselItem::handleLongPress( const QPointF& /*coords*/ )
       
   231 {
       
   232 //    QString text = QString( "Selected frequency: %1" ).arg( mFrequency );
       
   233 //    HbMessageBox::information( text );
       
   234 }
       
   235 
       
   236 /*!
       
   237  *
       
   238  */
       
   239 void RadioCarouselItem::setRadioText( const QString& text )
       
   240 {
       
   241     mData->mRadiotextLabel->setHtml( text );
       
   242 }
       
   243 
       
   244 /*!
       
   245  *
       
   246  */
       
   247 void RadioCarouselItem::setSeekLayout( bool seekLayout )
       
   248 {
       
   249     HbFontSpec spec = mData->mNameLabel->fontSpec();
       
   250     mData->mSeekLayout = seekLayout;
       
   251     if ( seekLayout ) {
       
   252         cleanRdsData();
       
   253         spec.setTextHeight( 60 );
       
   254     } else {
       
   255         spec.setTextHeight( 40 );
       
   256     }
       
   257     mData->mNameLabel->setFontSpec( spec );
       
   258 }
       
   259 
       
   260 /*!
       
   261  *
       
   262  */
       
   263 void RadioCarouselItem::setItemVisibility( ItemVisibility visibility )
       
   264 {
       
   265     mData->mIconButton->setEnabled( true );
       
   266     if ( visibility == AllVisible ) {
       
   267         mData->mNameLabel->setVisible( true );
       
   268         mData->mGenreLabel->setVisible( true );
       
   269         mData->mRadiotextLabel->setVisible( true );
       
   270         mData->mUrlLabel->setVisible( true );
       
   271         mData->mIconButton->setVisible( true );
       
   272     } else if ( visibility == AllHidden ) {
       
   273         mData->mNameLabel->setVisible( false );
       
   274         mData->mGenreLabel->setVisible( false );
       
   275         mData->mRadiotextLabel->setVisible( false );
       
   276         mData->mUrlLabel->setVisible( false );
       
   277         mData->mIconButton->setVisible( false );
       
   278     } else if ( visibility == IconVisible ) {
       
   279         mData->mNameLabel->setVisible( false );
       
   280         mData->mGenreLabel->setVisible( false );
       
   281         mData->mRadiotextLabel->setVisible( false );
       
   282         mData->mUrlLabel->setVisible( false );
       
   283         mData->mIconButton->setVisible( true );
       
   284         mData->mIconButton->setEnabled( false );
       
   285     }
       
   286 }
       
   287 
       
   288 /*!
       
   289  *
       
   290  */
       
   291 void RadioCarouselItem::setIconOpacity( qreal opacity )
       
   292 {
       
   293     mData->mIconButton->setOpacity( opacity );
       
   294 }
       
   295 
       
   296 /*!
       
   297  *
       
   298  */
       
   299 void RadioCarouselItem::updateFavoriteIcon( bool isFavorite )
       
   300 {
       
   301     if ( !mData->mSeekLayout ) {
       
   302         if ( isFavorite ) {
       
   303             mData->mIconButton->setIcon( mCarousel.favoriteIcon() );
       
   304         } else {
       
   305             mData->mIconButton->setIcon( mCarousel.nonFavoriteIcon() );
       
   306         }
       
   307     } else {
       
   308         mData->mIconButton->setIcon( HbIcon( "" ) );
       
   309     }
       
   310 }
       
   311 
       
   312 /*!
       
   313  *
       
   314  */
       
   315 QString RadioCarouselItem::parseFrequency( const uint frequency )
       
   316 {
       
   317     QString loc = "%L1 MHz";// hbTrId( "txt_rad_list_l1_mhz_big" );
       
   318     return loc.arg( RadioStation::parseFrequency( frequency ) );
       
   319 }
       
   320 
       
   321 /*!
       
   322  *
       
   323  */
       
   324 QString RadioCarouselItem::nameOrFrequency( const RadioStation& station, uint frequency )
       
   325 {
       
   326     if ( frequency == 0 ) {
       
   327         frequency = station.frequency();
       
   328     }
       
   329 
       
   330     QString text = "";
       
   331     if ( station.isValid() && !station.name().isEmpty() ) {
       
   332         text = station.name();
       
   333     } else {
       
   334         text = parseFrequency( frequency );
       
   335     }
       
   336 
       
   337     return text;
       
   338 }
       
   339 
       
   340 /*!
       
   341  *
       
   342  */
       
   343 RadioCarouselItem::Data::Data() :
       
   344     mLayout( NULL ),
       
   345     mSeekLayout( false )
       
   346 {
       
   347 }
       
   348 
       
   349 /*!
       
   350  *
       
   351  */
       
   352 RadioCarouselItem::Data::~Data()
       
   353 {
       
   354 }