radioapp/radiouiengine/src/radiohistoryitem.cpp
branchRCL_3
changeset 19 cce62ebc198e
equal deleted inserted replaced
18:1a6714c53019 19:cce62ebc198e
       
     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 // User includes
       
    19 #include "radiohistoryitem.h"
       
    20 #include "radiohistoryitem_p.h"
       
    21 
       
    22 /**
       
    23  * Static shared data instance that is used by all default-constructed RadioStation instances
       
    24  */
       
    25 Q_GLOBAL_STATIC( RadioHistoryItemPrivate, shared_null )
       
    26 
       
    27 
       
    28 /*!
       
    29  *
       
    30  */
       
    31 RadioHistoryItem::RadioHistoryItem() :
       
    32     mData( shared_null() )
       
    33 {
       
    34     mData->ref.ref();
       
    35 }
       
    36 
       
    37 /*!
       
    38  *
       
    39  */
       
    40 RadioHistoryItem::RadioHistoryItem( const QString& artist, const QString& title ) :
       
    41     mData( new RadioHistoryItemPrivate( artist, title ) )
       
    42 {
       
    43 }
       
    44 
       
    45 /*!
       
    46  *
       
    47  */
       
    48 RadioHistoryItem::RadioHistoryItem( const RadioHistoryItem& other ) :
       
    49     mData( other.mData )
       
    50 {
       
    51 }
       
    52 
       
    53 /*!
       
    54  *
       
    55  */
       
    56 RadioHistoryItem::~RadioHistoryItem()
       
    57 {
       
    58 }
       
    59 
       
    60 /*!
       
    61  *
       
    62  */
       
    63 RadioHistoryItem& RadioHistoryItem::operator=( const RadioHistoryItem& other )
       
    64 {
       
    65     mData = other.mData;
       
    66     return *this;
       
    67 }
       
    68 
       
    69 /*!
       
    70  *
       
    71  */
       
    72 bool RadioHistoryItem::isValid() const
       
    73 {
       
    74     return id() != 0 && !title().isEmpty();
       
    75 }
       
    76 
       
    77 /*!
       
    78  *
       
    79  */
       
    80 void RadioHistoryItem::reset()
       
    81 {
       
    82     mData = shared_null();
       
    83 }
       
    84 
       
    85 /*!
       
    86  *
       
    87  */
       
    88 int RadioHistoryItem::id() const
       
    89 {
       
    90     return mData->mId;
       
    91 }
       
    92 
       
    93 /*!
       
    94  *
       
    95  */
       
    96 QString RadioHistoryItem::artist() const
       
    97 {
       
    98     return mData->mArtist;
       
    99 }
       
   100 
       
   101 /*!
       
   102  *
       
   103  */
       
   104 void RadioHistoryItem::setArtist( const QString& artist )
       
   105 {
       
   106     if ( artist.compare( mData->mArtist ) != 0 ) {
       
   107         mData->mArtist = artist;
       
   108     }
       
   109 }
       
   110 
       
   111 /*!
       
   112  *
       
   113  */
       
   114 QString RadioHistoryItem::title() const
       
   115 {
       
   116     return mData->mTitle;
       
   117 }
       
   118 
       
   119 /*!
       
   120  *
       
   121  */
       
   122 void RadioHistoryItem::setTitle( const QString& title )
       
   123 {
       
   124     if ( title.compare( mData->mTitle ) != 0 ) {
       
   125         mData->mTitle = title;
       
   126     }
       
   127 }
       
   128 
       
   129 /*!
       
   130  *
       
   131  */
       
   132 QString RadioHistoryItem::station() const
       
   133 {
       
   134     return mData->mStation;
       
   135 }
       
   136 
       
   137 /*!
       
   138  *
       
   139  */
       
   140 void RadioHistoryItem::setStation( const QString& station )
       
   141 {
       
   142     if ( station.compare( mData->mStation ) != 0 ) {
       
   143         mData->mStation = station;
       
   144     }
       
   145 }
       
   146 
       
   147 /*!
       
   148  *
       
   149  */
       
   150 uint RadioHistoryItem::frequency() const
       
   151 {
       
   152     return mData->mFrequency;
       
   153 }
       
   154 
       
   155 /*!
       
   156  *
       
   157  */
       
   158 void RadioHistoryItem::setFrequency( uint frequency )
       
   159 {
       
   160     if ( frequency != mData->mFrequency ) {
       
   161         mData->mFrequency = frequency;
       
   162     }
       
   163 }
       
   164 
       
   165 /*!
       
   166  *
       
   167  */
       
   168 QString RadioHistoryItem::time() const
       
   169 {
       
   170     return mData->mTime.toString();
       
   171 }
       
   172 
       
   173 /*!
       
   174  *
       
   175  */
       
   176 void RadioHistoryItem::setCurrentTime()
       
   177 {
       
   178     mData->mTime = QDateTime::currentDateTime();
       
   179 }
       
   180 
       
   181 /*!
       
   182  *
       
   183  */
       
   184 bool RadioHistoryItem::isTagged() const
       
   185 {
       
   186     return mData->mTagged;
       
   187 }
       
   188 
       
   189 /*!
       
   190  *
       
   191  */
       
   192 bool RadioHistoryItem::isRecognizedByRds() const
       
   193 {
       
   194     return mData->mFromRds;
       
   195 }
       
   196 
       
   197 /*!
       
   198  *
       
   199  */
       
   200 bool RadioHistoryItem::isDetached() const
       
   201 {
       
   202     return mData->ref == 1;
       
   203 }