radioapp/radiowidgets/src/radiostationcarousel.cpp
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 33 11b6825f0862
--- a/radioapp/radiowidgets/src/radiostationcarousel.cpp	Fri Jun 11 13:38:32 2010 +0300
+++ b/radioapp/radiowidgets/src/radiostationcarousel.cpp	Wed Jun 23 18:12:57 2010 +0300
@@ -22,6 +22,7 @@
 #include <HbPanGesture>
 #include <HbSwipeGesture>
 #include <HbFontSpec>
+#include <HbMenu>
 
 // User includes
 #include "radiostationcarousel.h"
@@ -63,8 +64,8 @@
     mAutoScrollTime( 300 ),
     mGenericTimer( new QTimer( this ) ),
     mTimerMode( NoTimer ),
-    mAnimator( NULL ),
     mInfoText( NULL ),
+    mRadiotextPopup( NULL ),
     mContainer( new HbWidget( this ) ),
     mMidScrollPos( 0 ),
     mMaxScrollPos( 0 ),
@@ -143,9 +144,9 @@
     mUiEngine = uiEngine;
     RadioUtil::setCarousel( this );
 
-    mItems[LeftItem] = new RadioCarouselItem( *this );
-    mItems[CenterItem] = new RadioCarouselItem( *this );
-    mItems[RightItem] = new RadioCarouselItem( *this );
+    mItems[CenterItem] = new RadioCarouselItem( *this, this, true );
+    mItems[LeftItem] = new RadioCarouselItem( *this, this );
+    mItems[RightItem] = new RadioCarouselItem( *this, this );
 
     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout( Qt::Horizontal );
     layout->setContentsMargins( 0, 0, 0, 0 );
@@ -166,6 +167,8 @@
     mInfoText = uiLoader.findWidget<HbLabel>( DOCML::MV_NAME_INFO_TEXT );
     mInfoText->setTextWrapping( Hb::TextWordWrap );
 
+    mRadiotextPopup = uiLoader.findObject<HbMenu>( DOCML::MV_NAME_CAROUSEL_RT_MENU );
+
 #ifdef BUILD_WIN32
     HbFontSpec spec = mInfoText->fontSpec();
     spec.setRole( HbFontSpec::Secondary );
@@ -173,10 +176,7 @@
 #endif
 
     setScrollDirections( Qt::Horizontal );
-//    grabGesture( Qt::SwipeGesture );
 
-//    Radio::connect( this,           SIGNAL(scrollPositionChanged(QPointF)),
-//                    this,           SLOT(scrollPosChanged(QPointF)) );
     Radio::connect( this,           SIGNAL(scrollingEnded()),
                     this,           SLOT(adjustAfterScroll()) );
 
@@ -290,10 +290,10 @@
         if ( !mAnimator ) {
             mAnimator = new RadioCarouselAnimator( *this );
         }
-        mAnimator->startFlashingText();
+        mAnimator.data()->startFlashingText();
     } else {
         if ( mAnimator ) {
-            mAnimator->stopFlashingText();
+            mAnimator.data()->stopFlashingText();
         }
         clearInfoText();
         setCenterIndex( 0 );
@@ -331,7 +331,7 @@
         mItems[RightItem]->setFrequency( previousFrequency );
         mCurrentIndex = mModel->indexFromFrequency( station.frequency() );
 
-        mAnimator->startNumberScroll( previousFrequency, station.frequency() );
+        mAnimator.data()->startNumberScroll( previousFrequency, station.frequency() );
     }
 }
 
@@ -341,7 +341,7 @@
 void RadioStationCarousel::cancelAnimation()
 {
     if ( mAnimator ) {
-        mAnimator->stopAll();
+        mAnimator.data()->stopAll();
     }
 }
 
@@ -364,7 +364,7 @@
         if ( !mAnimator ) {
             mAnimator = new RadioCarouselAnimator( *this );
         }
-        mAnimator->startFlashingIcon();
+        mAnimator.data()->startFlashingIcon();
 
     } else if ( type == CarouselInfoText::ConnectAntenna ) {
         cleanRdsData();
@@ -393,7 +393,7 @@
 {
     if ( mInfoTextType != CarouselInfoText::None ) {
         if ( mAnimator ) {
-            mAnimator->stopFlashingIcon();
+            mAnimator.data()->stopFlashingIcon();
         }
 
         mGenericTimer->stop();
@@ -525,26 +525,6 @@
     }
 }
 
-/*!
- * Private slot
- */
-void RadioStationCarousel::toggleFavorite()
-{
-    if ( mModel ) {
-        mModel->setData( QModelIndex(), mItems[CenterItem]->frequency(), RadioRole::ToggleFavoriteRole );
-    }
-}
-
-/*!
- * Private slot
- */
-//void RadioStationCarousel::openContextMenu( HbAbstractViewItem* item, const QPointF& coords )
-//{
-//    if ( item ) {
-//        static_cast<RadioStationItem*>( item )->handleLongPress( coords );
-//    }
-//}
-
 #ifdef USE_DEBUGGING_CONTROLS
 /*!
  * Public slot
@@ -644,6 +624,57 @@
 }
 
 /*!
+ * \reimp
+ */
+void RadioStationCarousel::handleIconClicked( const RadioStation& station )
+{
+    if ( mModel ) {
+        mModel->setData( QModelIndex(), station.frequency(), RadioRole::ToggleFavoriteRole );
+    }
+}
+
+/*!
+ * \reimp
+ */
+void RadioStationCarousel::handleRadiotextClicked( const RadioStation& station )
+{
+    Q_UNUSED( station );
+    mRadiotextPopup->show();
+}
+
+/*!
+ * \reimp
+ */
+void RadioStationCarousel::handleUrlClicked( const RadioStation& station )
+{
+    mUiEngine->launchBrowser( station.url() );
+}
+
+/*!
+ * \reimp
+ */
+QString RadioStationCarousel::localizeGenre( int genre )
+{
+    return mUiEngine->genreToString( genre, GenreTarget::Carousel );
+}
+
+/*!
+ * \reimp
+ */
+bool RadioStationCarousel::isInManualSeek() const
+{
+    return mManualSeekMode;
+}
+
+/*!
+ *
+ */
+RadioStation RadioStationCarousel::findStation( uint frequency )
+{
+    return mModel->findStation( frequency, FindCriteria::IncludeManualStation );
+}
+
+/*!
  *
  */
 bool RadioStationCarousel::isInitialized() const