radioapp/radiouiengine/src/radiostation_p.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 // User includes
       
    21 #include "radiostation_p.h"
       
    22 
       
    23 /**
       
    24  * Convenience macro to set and unset flag values
       
    25  */
       
    26 #define SET_FLAG_VALUE(member,flag,value) \
       
    27     if ( value ) { \
       
    28         member |= flag; \
       
    29     } else { \
       
    30         member &= ~flag; \
       
    31     }
       
    32 
       
    33 /*!
       
    34  *
       
    35  */
       
    36 RadioStationPrivate::RadioStationPrivate( int presetIndex, uint frequency )
       
    37 {
       
    38     init( presetIndex, frequency );
       
    39 
       
    40     if ( presetIndex == RadioStation::SharedNull ) {
       
    41         ref = 2;
       
    42     }
       
    43 }
       
    44 
       
    45 /*!
       
    46  *
       
    47  */
       
    48 RadioStationPrivate::RadioStationPrivate( const RadioStationPrivate& other ) :
       
    49     QSharedData( other ),
       
    50     mPresetIndex( other.mPresetIndex ),
       
    51     mFrequency( other.mFrequency ),
       
    52     mName( other.mName ),
       
    53     mGenre( other.mGenre ),
       
    54     mUrl( other.mUrl ),
       
    55     mPiCode( other.mPiCode ),
       
    56     mType( other.mType ),
       
    57     mPsType( other.mPsType ),
       
    58     mRadioText( other.mRadioText ),
       
    59     mDynamicPsText( other.mDynamicPsText ),
       
    60     mChangeFlags( other.mChangeFlags ),
       
    61     mLastPsNameChangeTime( other.mLastPsNameChangeTime )
       
    62 {
       
    63     setRenamedByUser( other.isRenamedByUser() );
       
    64     setCallSignCheckDone( other.isCallSignCheckDone() );
       
    65     setStationHasSentRds( other.hasStationSentRds() );
       
    66 
       
    67     // Protect the shared null preset index to make debugging easier
       
    68     if ( mPresetIndex == RadioStation::SharedNull ) {
       
    69         mPresetIndex = RadioStation::Invalid;
       
    70     }
       
    71 }
       
    72 
       
    73 /*!
       
    74  *
       
    75  */
       
    76 RadioStationPrivate::~RadioStationPrivate()
       
    77 {
       
    78 }
       
    79 
       
    80 /*!
       
    81  *
       
    82  */
       
    83 void RadioStationPrivate::init( int presetIndex, uint frequency )
       
    84 {
       
    85     mPresetIndex    = presetIndex;
       
    86     mFrequency      = frequency;
       
    87     mGenre          = -1;
       
    88     mPiCode         = -1;
       
    89     mType           = 0;
       
    90     mPsType         = RadioStation::Unknown;
       
    91     mChangeFlags    = RadioStation::NoChange;
       
    92     mStationInfo    = 0;
       
    93 }
       
    94 
       
    95 /*!
       
    96  * \reimp
       
    97  */
       
    98 int RadioStationPrivate::presetIndex() const
       
    99 {
       
   100     return mPresetIndex;
       
   101 }
       
   102 
       
   103 /*!
       
   104  * \reimp
       
   105  */
       
   106 void RadioStationPrivate::setPresetIndex( int presetIndex )
       
   107 {
       
   108     mPresetIndex = presetIndex;
       
   109 }
       
   110 
       
   111 /*!
       
   112  * \reimp
       
   113  */
       
   114 uint RadioStationPrivate::frequency() const
       
   115 {
       
   116     return mFrequency;
       
   117 }
       
   118 
       
   119 /*!
       
   120  * \reimp
       
   121  */
       
   122 void RadioStationPrivate::setFrequency( uint frequency )
       
   123 {
       
   124     mFrequency = frequency;
       
   125 }
       
   126 
       
   127 /*!
       
   128  * \reimp
       
   129  */
       
   130 QString RadioStationPrivate::name() const
       
   131 {
       
   132     return mName;
       
   133 }
       
   134 
       
   135 /*!
       
   136  * \reimp
       
   137  */
       
   138 void RadioStationPrivate::setName( QString name )
       
   139 {
       
   140     mName = name;
       
   141 }
       
   142 
       
   143 /*!
       
   144  * \reimp
       
   145  */
       
   146 bool RadioStationPrivate::isRenamedByUser() const
       
   147 {
       
   148     return mStationInfo.testFlag( RenamedByUser );
       
   149 }
       
   150 
       
   151 /*!
       
   152  * \reimp
       
   153  */
       
   154 void RadioStationPrivate::setRenamedByUser( bool renamed )
       
   155 {
       
   156     SET_FLAG_VALUE( mStationInfo, RenamedByUser, renamed );
       
   157 }
       
   158 
       
   159 /*!
       
   160  * \reimp
       
   161  */
       
   162 int RadioStationPrivate::genre() const
       
   163 {
       
   164     return mGenre;
       
   165 }
       
   166 
       
   167 /*!
       
   168  * \reimp
       
   169  */
       
   170 void RadioStationPrivate::setGenre( int genre )
       
   171 {
       
   172     mGenre = genre;
       
   173 }
       
   174 
       
   175 /*!
       
   176  * \reimp
       
   177  */
       
   178 QString RadioStationPrivate::url() const
       
   179 {
       
   180     return mUrl;
       
   181 }
       
   182 
       
   183 /*!
       
   184  * \reimp
       
   185  */
       
   186 void RadioStationPrivate::setUrl( QString url )
       
   187 {
       
   188     mUrl = url;
       
   189 }
       
   190 
       
   191 /*!
       
   192  * \reimp
       
   193  */
       
   194 int RadioStationPrivate::piCode() const
       
   195 {
       
   196     return mPiCode;
       
   197 }
       
   198 
       
   199 /*!
       
   200  * \reimp
       
   201  */
       
   202 void RadioStationPrivate::setPiCode( int piCode )
       
   203 {
       
   204     mPiCode = piCode;
       
   205 }
       
   206 
       
   207 /*!
       
   208  * \reimp
       
   209  */
       
   210 bool RadioStationPrivate::isFavorite() const
       
   211 {
       
   212     return mType.testFlag( RadioStation::Favorite );
       
   213 }
       
   214 
       
   215 /*!
       
   216  * \reimp
       
   217  */
       
   218 void RadioStationPrivate::setFavorite( bool favorite )
       
   219 {
       
   220     SET_FLAG_VALUE( mType, RadioStation::Favorite, favorite );
       
   221 }
       
   222 
       
   223 /*!
       
   224  * \reimp
       
   225  */
       
   226 bool RadioStationPrivate::isLocalStation() const
       
   227 {
       
   228     return mType.testFlag( RadioStation::LocalStation );
       
   229 }
       
   230 
       
   231 /*!
       
   232  * \reimp
       
   233  */
       
   234 void RadioStationPrivate::setLocalStation( bool localStation )
       
   235 {
       
   236     SET_FLAG_VALUE( mType, RadioStation::LocalStation, localStation );
       
   237 }
       
   238 
       
   239 /*!
       
   240  * \reimp
       
   241  */
       
   242 bool RadioStationPrivate::hasStationSentRds() const
       
   243 {
       
   244     return mStationInfo.testFlag( StationSendsRds );
       
   245 }
       
   246 
       
   247 /*!
       
   248  * \reimp
       
   249  */
       
   250 void RadioStationPrivate::setStationHasSentRds( bool hasSentRds )
       
   251 {
       
   252     SET_FLAG_VALUE( mStationInfo, StationSendsRds, hasSentRds );
       
   253 }
       
   254 
       
   255 /*!
       
   256  *
       
   257  */
       
   258 bool RadioStationPrivate::isCallSignCheckDone() const
       
   259 {
       
   260     return mStationInfo.testFlag( CallSignCheckDone );
       
   261 }
       
   262 
       
   263 /*!
       
   264  *
       
   265  */
       
   266 void RadioStationPrivate::setCallSignCheckDone( bool checkDone )
       
   267 {
       
   268     SET_FLAG_VALUE( mStationInfo, CallSignCheckDone, checkDone );
       
   269 }