radioapp/radiouiengine/src/radiostation_p.cpp
changeset 36 ba22309243a1
parent 34 bc10a61bd7d3
equal deleted inserted replaced
35:de7c4a48dcb4 36:ba22309243a1
    18 // System includes
    18 // System includes
    19 
    19 
    20 // User includes
    20 // User includes
    21 #include "radiostation_p.h"
    21 #include "radiostation_p.h"
    22 
    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 
    23 /*!
    33 /*!
    24  *
    34  *
    25  */
    35  */
    26 RadioStationPrivate::RadioStationPrivate( int presetIndex, uint frequency )
    36 RadioStationPrivate::RadioStationPrivate( int presetIndex, uint frequency )
    27 {
    37 {
    38 RadioStationPrivate::RadioStationPrivate( const RadioStationPrivate& other ) :
    48 RadioStationPrivate::RadioStationPrivate( const RadioStationPrivate& other ) :
    39     QSharedData( other ),
    49     QSharedData( other ),
    40     mPresetIndex( other.mPresetIndex ),
    50     mPresetIndex( other.mPresetIndex ),
    41     mFrequency( other.mFrequency ),
    51     mFrequency( other.mFrequency ),
    42     mName( other.mName ),
    52     mName( other.mName ),
    43     mRenamedByUser( other.mRenamedByUser ),
       
    44     mGenre( other.mGenre ),
    53     mGenre( other.mGenre ),
    45     mUrl( other.mUrl ),
    54     mUrl( other.mUrl ),
    46     mPiCode( other.mPiCode ),
    55     mPiCode( other.mPiCode ),
    47     mType( other.mType ),
    56     mType( other.mType ),
    48     mPsType( other.mPsType ),
    57     mPsType( other.mPsType ),
    49     mRadioText( other.mRadioText ),
    58     mRadioText( other.mRadioText ),
    50     mDynamicPsText( other.mDynamicPsText ),
    59     mDynamicPsText( other.mDynamicPsText ),
    51     mChangeFlags( other.mChangeFlags ),
    60     mChangeFlags( other.mChangeFlags ),
    52     mCallSignCheckDone( other.mCallSignCheckDone ),
       
    53     mLastPsNameChangeTime( other.mLastPsNameChangeTime )
    61     mLastPsNameChangeTime( other.mLastPsNameChangeTime )
    54 {
    62 {
       
    63     setRenamedByUser( other.isRenamedByUser() );
       
    64     setCallSignCheckDone( other.isCallSignCheckDone() );
       
    65     setStationHasSentRds( other.hasStationSentRds() );
       
    66 
    55     // Protect the shared null preset index to make debugging easier
    67     // Protect the shared null preset index to make debugging easier
    56     if ( mPresetIndex == RadioStation::SharedNull ) {
    68     if ( mPresetIndex == RadioStation::SharedNull ) {
    57         mPresetIndex = RadioStation::Invalid;
    69         mPresetIndex = RadioStation::Invalid;
    58     }
    70     }
    59 }
    71 }
    68 /*!
    80 /*!
    69  *
    81  *
    70  */
    82  */
    71 void RadioStationPrivate::init( int presetIndex, uint frequency )
    83 void RadioStationPrivate::init( int presetIndex, uint frequency )
    72 {
    84 {
    73     mPresetIndex       = presetIndex;
    85     mPresetIndex    = presetIndex;
    74     mFrequency         = frequency;
    86     mFrequency      = frequency;
    75     mRenamedByUser     = false;
    87     mGenre          = -1;
    76     mGenre             = -1;
    88     mPiCode         = -1;
    77     mPiCode            = -1;
    89     mType           = 0;
    78     mType              = 0;
    90     mPsType         = RadioStation::Unknown;
    79     mPsType            = RadioStation::Unknown;
    91     mChangeFlags    = RadioStation::NoChange;
    80     mChangeFlags       = RadioStation::NoChange;
    92     mStationInfo    = 0;
    81     mCallSignCheckDone = false;
       
    82 }
    93 }
    83 
    94 
    84 /*!
    95 /*!
    85  * \reimp
    96  * \reimp
    86  */
    97  */
   132 /*!
   143 /*!
   133  * \reimp
   144  * \reimp
   134  */
   145  */
   135 bool RadioStationPrivate::isRenamedByUser() const
   146 bool RadioStationPrivate::isRenamedByUser() const
   136 {
   147 {
   137     return mRenamedByUser;
   148     return mStationInfo.testFlag( RenamedByUser );
   138 }
   149 }
   139 
   150 
   140 /*!
   151 /*!
   141  * \reimp
   152  * \reimp
   142  */
   153  */
   143 void RadioStationPrivate::setRenamedByUser( bool renamed )
   154 void RadioStationPrivate::setRenamedByUser( bool renamed )
   144 {
   155 {
   145     mRenamedByUser = renamed;
   156     SET_FLAG_VALUE( mStationInfo, RenamedByUser, renamed );
   146 }
   157 }
   147 
   158 
   148 /*!
   159 /*!
   149  * \reimp
   160  * \reimp
   150  */
   161  */
   204 /*!
   215 /*!
   205  * \reimp
   216  * \reimp
   206  */
   217  */
   207 void RadioStationPrivate::setFavorite( bool favorite )
   218 void RadioStationPrivate::setFavorite( bool favorite )
   208 {
   219 {
   209     if ( favorite ) {
   220     SET_FLAG_VALUE( mType, RadioStation::Favorite, favorite );
   210         mType |= RadioStation::Favorite;
       
   211     } else {
       
   212         mType &= ~RadioStation::Favorite;
       
   213     }
       
   214 }
   221 }
   215 
   222 
   216 /*!
   223 /*!
   217  * \reimp
   224  * \reimp
   218  */
   225  */
   224 /*!
   231 /*!
   225  * \reimp
   232  * \reimp
   226  */
   233  */
   227 void RadioStationPrivate::setLocalStation( bool localStation )
   234 void RadioStationPrivate::setLocalStation( bool localStation )
   228 {
   235 {
   229     if ( localStation ) {
   236     SET_FLAG_VALUE( mType, RadioStation::LocalStation, localStation );
   230         mType |= RadioStation::LocalStation;
   237 }
   231     } else {
   238 
   232         mType &= ~RadioStation::LocalStation;
   239 /*!
   233     }
   240  * \reimp
   234 }
   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 }