radioapp/radiouiengine/src/radiohistoryitem.cpp
author William Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:33:45 +0100
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 32 189d20c34778
permissions -rw-r--r--
Catchup to latest Symbian^4

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

// User includes
#include "radiohistoryitem.h"
#include "radiohistoryitem_p.h"

/**
 * Static shared data instance that is used by all default-constructed RadioStation instances
 */
Q_GLOBAL_STATIC( RadioHistoryItemPrivate, shared_null )


/*!
 *
 */
RadioHistoryItem::RadioHistoryItem() :
    mData( shared_null() )
{
    mData->ref.ref();
}

/*!
 *
 */
RadioHistoryItem::RadioHistoryItem( const QString& artist, const QString& title ) :
    mData( new RadioHistoryItemPrivate( artist, title ) )
{
}

/*!
 *
 */
RadioHistoryItem::RadioHistoryItem( const RadioHistoryItem& other ) :
    mData( other.mData )
{
}

/*!
 *
 */
RadioHistoryItem::~RadioHistoryItem()
{
}

/*!
 *
 */
RadioHistoryItem& RadioHistoryItem::operator=( const RadioHistoryItem& other )
{
    mData = other.mData;
    return *this;
}

/*!
 *
 */
bool RadioHistoryItem::isValid() const
{
    return id() != 0 && !title().isEmpty();
}

/*!
 *
 */
void RadioHistoryItem::reset()
{
    mData = shared_null();
}

/*!
 *
 */
int RadioHistoryItem::id() const
{
    return mData->mId;
}

/*!
 *
 */
QString RadioHistoryItem::artist() const
{
    return mData->mArtist;
}

/*!
 *
 */
void RadioHistoryItem::setArtist( const QString& artist )
{
    if ( artist.compare( mData->mArtist ) != 0 ) {
        mData->mArtist = artist;
    }
}

/*!
 *
 */
QString RadioHistoryItem::title() const
{
    return mData->mTitle;
}

/*!
 *
 */
void RadioHistoryItem::setTitle( const QString& title )
{
    if ( title.compare( mData->mTitle ) != 0 ) {
        mData->mTitle = title;
    }
}

/*!
 *
 */
QString RadioHistoryItem::station() const
{
    return mData->mStation;
}

/*!
 *
 */
void RadioHistoryItem::setStation( const QString& station )
{
    if ( station.compare( mData->mStation ) != 0 ) {
        mData->mStation = station;
    }
}

/*!
 *
 */
uint RadioHistoryItem::frequency() const
{
    return mData->mFrequency;
}

/*!
 *
 */
void RadioHistoryItem::setFrequency( uint frequency )
{
    if ( frequency != mData->mFrequency ) {
        mData->mFrequency = frequency;
    }
}

/*!
 *
 */
QString RadioHistoryItem::time() const
{
    return mData->mTime.toString();
}

/*!
 *
 */
void RadioHistoryItem::setCurrentTime()
{
    mData->mTime = QDateTime::currentDateTime();
}

/*!
 *
 */
bool RadioHistoryItem::isTagged() const
{
    return mData->mTagged;
}

/*!
 *
 */
bool RadioHistoryItem::isRecognizedByRds() const
{
    return mData->mFromRds;
}

/*!
 *
 */
bool RadioHistoryItem::isDetached() const
{
    return mData->ref == 1;
}