radioapp/radiowidgets/src/radiostationcarousel.cpp
changeset 44 0a3ad94fc71c
parent 38 f8c3d4e6102c
child 47 74b7c6e79031
equal deleted inserted replaced
39:ac7857bd5fdb 44:0a3ad94fc71c
    80     mIsCustomFreq( false ),
    80     mIsCustomFreq( false ),
    81     mInfoTextType( CarouselInfoText::None ),
    81     mInfoTextType( CarouselInfoText::None ),
    82     mModel( NULL ),
    82     mModel( NULL ),
    83     mPosAdjustmentDisabled( false ),
    83     mPosAdjustmentDisabled( false ),
    84     mScrollDirection( Scroll::Shortest ),
    84     mScrollDirection( Scroll::Shortest ),
    85     mManualSeekMode( false ),
    85     mManualSeekMode( false )
    86     mAlternateSkipping( false )
       
    87 #ifdef USE_DEBUGGING_CONTROLS
    86 #ifdef USE_DEBUGGING_CONTROLS
    88     ,mRdsLabel( new RadioFadingLabel( this ) )
    87     ,mRdsLabel( new RadioFadingLabel( this ) )
    89 #endif // USE_DEBUGGING_CONTROLS
    88 #endif // USE_DEBUGGING_CONTROLS
    90 {
    89 {
    91 }
    90 }
   387         mInfoText->setPlainText( hbTrId( "txt_rad_list_seeking" ) );
   386         mInfoText->setPlainText( hbTrId( "txt_rad_list_seeking" ) );
   388     } else if ( type == CarouselInfoText::Scanning ) {
   387     } else if ( type == CarouselInfoText::Scanning ) {
   389         cleanRdsData();
   388         cleanRdsData();
   390         mInfoText->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
   389         mInfoText->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
   391         mInfoText->setPlainText( hbTrId( "txt_rad_list_searching_all_available_stations_ple" ) );
   390         mInfoText->setPlainText( hbTrId( "txt_rad_list_searching_all_available_stations_ple" ) );
   392     } else if ( type == CarouselInfoText::ManualSeek ) {
       
   393         mInfoText->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
       
   394         mInfoText->setPlainText( "Manual Seek Mode" );
       
   395     }
   391     }
   396 
   392 
   397     mInfoText->setVisible( true );
   393     mInfoText->setVisible( true );
   398 }
   394 }
   399 
   395 
   422 {
   418 {
   423     mManualSeekMode = manualSeekActive;
   419     mManualSeekMode = manualSeekActive;
   424     setEnabled( !manualSeekActive );
   420     setEnabled( !manualSeekActive );
   425 
   421 
   426     mItems[CenterItem]->setSeekLayout( manualSeekActive );
   422     mItems[CenterItem]->setSeekLayout( manualSeekActive );
   427     if ( manualSeekActive ) {
   423     if ( !manualSeekActive ) {
   428         setInfoText( CarouselInfoText::ManualSeek );
       
   429     } else {
       
   430         clearInfoText();
   424         clearInfoText();
   431         setFrequency( mUiEngine->currentFrequency(), TuneReason::Unspecified );
   425         setFrequency( mUiEngine->currentFrequency(), TuneReason::Unspecified );
   432     }
   426     }
   433 }
   427 }
   434 
   428 
   444  *
   438  *
   445  */
   439  */
   446 void RadioStationCarousel::setLandscape( bool landscape )
   440 void RadioStationCarousel::setLandscape( bool landscape )
   447 {
   441 {
   448     CALL_TO_ALL_ITEMS( setLandscape( landscape ) );
   442     CALL_TO_ALL_ITEMS( setLandscape( landscape ) );
   449 }
       
   450 
       
   451 /*!
       
   452  * TODO: Remove this! This is test code
       
   453  */
       
   454 void RadioStationCarousel::setAlternateSkippingMode( bool alternateSkipping )
       
   455 {
       
   456     mAlternateSkipping = alternateSkipping;
       
   457 }
   443 }
   458 
   444 
   459 /*!
   445 /*!
   460  * Private slot
   446  * Private slot
   461  *
   447  *
   805         }
   791         }
   806 
   792 
   807         if ( mode.testFlag( NoAnim ) ) {
   793         if ( mode.testFlag( NoAnim ) ) {
   808             scrollTime = 0;
   794             scrollTime = 0;
   809         } else if ( mode.testFlag( FromPanGesture ) ) {
   795         } else if ( mode.testFlag( FromPanGesture ) ) {
   810             if ( mAlternateSkipping ) { //TODO: Remove this! This is test code
   796             scrollTime = 500;
   811                 scrollTime = 500;
       
   812             } else {
       
   813                 scrollTime = 300;
       
   814             }
       
   815         } else if ( mode.testFlag( FromSwipeGesture ) ) {
   797         } else if ( mode.testFlag( FromSwipeGesture ) ) {
   816             scrollTime = 100;
   798             scrollTime = 100;
   817         }
   799         }
   818 
   800 
   819         scrollContentsTo( QPointF( posX, 0 ), scrollTime );
   801         scrollContentsTo( QPointF( posX, 0 ), scrollTime );
   882         needsToScroll = true;
   864         needsToScroll = true;
   883         if ( offset > 0 ) {
   865         if ( offset > 0 ) {
   884             newPos = 0;
   866             newPos = 0;
   885             mScrollDirection = Scroll::Right;
   867             mScrollDirection = Scroll::Right;
   886             if ( !mIsCustomFreq ) {
   868             if ( !mIsCustomFreq ) {
   887 
   869                 const uint newFreq = mModel->findClosest( mItems[CenterItem]->frequency(), StationSkip::PreviousFavorite ).frequency();
   888                 if ( mAlternateSkipping ) { //TODO: Remove this! This is test code
   870                 if ( newFreq > 0 ) {
   889                     const uint newFreq = mModel->findClosest( mItems[CenterItem]->frequency(), StationSkip::PreviousFavorite ).frequency();
   871                     newIndex = mModel->indexFromFrequency( newFreq );
   890                     if ( newFreq > 0 ) {
       
   891                         newIndex = mModel->indexFromFrequency( newFreq );
       
   892                     } else {
       
   893                         needsToScroll = false;
       
   894                         newPos = mMidScrollPos;
       
   895                     } // End test code
       
   896 
       
   897                 } else {
   872                 } else {
   898                     --newIndex;
   873                     needsToScroll = false;
       
   874                     newPos = mMidScrollPos;
   899                 }
   875                 }
   900             }
   876             }
   901         } else {
   877         } else {
   902             mScrollDirection = Scroll::Left;
   878             mScrollDirection = Scroll::Left;
   903             newPos = mMaxScrollPos;
   879             newPos = mMaxScrollPos;
   904 
   880 
   905             if ( mAlternateSkipping ) { //TODO: Remove this! This is test code
   881             const uint newFreq = mModel->findClosest( mItems[CenterItem]->frequency(), StationSkip::NextFavorite ).frequency();
   906                 const uint newFreq = mModel->findClosest( mItems[CenterItem]->frequency(), StationSkip::NextFavorite ).frequency();
   882             if ( newFreq > 0 ) {
   907                 if ( newFreq > 0 ) {
   883                 newIndex = mModel->indexFromFrequency( newFreq );
   908                     newIndex = mModel->indexFromFrequency( newFreq );
       
   909                 } else {
       
   910                     needsToScroll = false;
       
   911                     newPos = mMidScrollPos;
       
   912                 } // End test code
       
   913 
       
   914             } else {
   884             } else {
   915                 ++newIndex;
   885                 needsToScroll = false;
       
   886                 newPos = mMidScrollPos;
   916             }
   887             }
   917         }
   888         }
   918     }
   889     }
   919 
   890 
   920     newIndex = trimIndex( newIndex );
   891     newIndex = trimIndex( newIndex );