radioapp/radiouiengine/inc/radioplaylogitem.h
changeset 16 f54ebcfc1b80
parent 14 63aabac4416d
child 17 2cf3bab7c5c6
child 19 afea38384506
equal deleted inserted replaced
14:63aabac4416d 16:f54ebcfc1b80
     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 #ifndef RADIOPLAYLOGITEM_H
       
    19 #define RADIOPLAYLOGITEM_H
       
    20 
       
    21 // System includes
       
    22 #include <QMetaType>
       
    23 #include <QObject>
       
    24 
       
    25 // User includes
       
    26 #include "radiouiengineexport.h"
       
    27 
       
    28 // Forward declarations
       
    29 class RadioPlayLogItemPrivate;
       
    30 
       
    31 /*!
       
    32  * Radio play log item implements a song recognized from the radio broadcast
       
    33  *
       
    34  * Note! It is derived from QObject even though architecturally it shouldn't be.
       
    35  * It is done only to satisfy the WINSCW build which doesn't export the destructor in UREL
       
    36  * build. This causes mismatching def files and annoying warnings. Deriving from QObject fixes this
       
    37  */
       
    38 class UI_ENGINE_DLL_EXPORT RadioPlayLogItem : public QObject
       
    39 {
       
    40 public:
       
    41 
       
    42     RadioPlayLogItem();
       
    43     RadioPlayLogItem( const QString& artist, const QString& title );
       
    44     RadioPlayLogItem( const RadioPlayLogItem& other );
       
    45 
       
    46     ~RadioPlayLogItem();
       
    47 
       
    48     RadioPlayLogItem& operator=( const RadioPlayLogItem& other );
       
    49 
       
    50     QString artist() const;
       
    51     void setArtist( const QString& artist );
       
    52 
       
    53     QString title() const;
       
    54     void setTitle( const QString& title );
       
    55 
       
    56     QString station() const;
       
    57     void setStation( const QString& station );
       
    58 
       
    59     uint frequency() const;
       
    60     void setFrequency( uint frequency );
       
    61 
       
    62     QString time() const;
       
    63     void setCurrentTime();
       
    64 
       
    65     bool isFavorite() const;
       
    66     void setFavorite();
       
    67 
       
    68     void increasePlayCount();
       
    69     int playCount() const;
       
    70 
       
    71 private:
       
    72 
       
    73     /**
       
    74      * Decrements the reference count of the implicitly shared data.
       
    75      * Data is deleted if no instance uses it anymore.
       
    76      */
       
    77     void decrementReferenceCount();
       
    78 
       
    79 private: // data
       
    80 
       
    81     /**
       
    82      * Pointer to the implicitly shared private implementation
       
    83      * Own.
       
    84      */
       
    85     class RadioPlayLogItemPrivate* mData;
       
    86 
       
    87 public:
       
    88 
       
    89     /**
       
    90      * Detach from the implicitly shared data
       
    91      */
       
    92     void detach();
       
    93 
       
    94     /**
       
    95      * Checks if the class is detached from implicitly shared data
       
    96      * Required by many QT convenience functions for implicitly shared classes
       
    97      */
       
    98     bool isDetached() const;
       
    99 
       
   100     typedef RadioPlayLogItemPrivate* DataPtr;
       
   101     inline DataPtr &data_ptr() { return mData; }
       
   102 
       
   103 };
       
   104 
       
   105 Q_DECLARE_TYPEINFO( RadioPlayLogItem, Q_MOVABLE_TYPE );  // Can be moved around in memory by containers if necessary
       
   106 Q_DECLARE_SHARED( RadioPlayLogItem )                     // Uses implicit sharing
       
   107 Q_DECLARE_METATYPE( RadioPlayLogItem )                   // To be usable in a QVariant
       
   108 
       
   109 #endif // RADIOPLAYLOGITEM_H