radioapp/radiouiengine/inc/radiohistoryitem.h
changeset 32 189d20c34778
parent 24 6df133bd92e1
child 37 451b2e1545b2
equal deleted inserted replaced
28:075425b8d9a4 32:189d20c34778
    17 
    17 
    18 #ifndef RADIOHISTORYITEM_H
    18 #ifndef RADIOHISTORYITEM_H
    19 #define RADIOHISTORYITEM_H
    19 #define RADIOHISTORYITEM_H
    20 
    20 
    21 // System includes
    21 // System includes
       
    22 #include <QSharedDataPointer>
    22 #include <QMetaType>
    23 #include <QMetaType>
    23 #include <QObject>
       
    24 
    24 
    25 // User includes
    25 // User includes
    26 #include "radiouiengineexport.h"
    26 #include "radiouiengineexport.h"
    27 
    27 
    28 // Forward declarations
    28 // Forward declarations
    29 class RadioHistoryItemPrivate;
    29 class RadioHistoryItemPrivate;
    30 
    30 
    31 /*!
    31 /*!
    32  * Radio history item implements a song recognized from the radio broadcast
    32  * Radio history 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  */
    33  */
    38 class UI_ENGINE_DLL_EXPORT RadioHistoryItem : public QObject
    34 class UI_ENGINE_DLL_EXPORT RadioHistoryItem
    39 {
    35 {
    40 public:
    36 public:
    41 
    37 
    42     RadioHistoryItem();
    38     RadioHistoryItem();
    43     RadioHistoryItem( const QString& artist, const QString& title );
    39     RadioHistoryItem( const QString& artist, const QString& title );
    69 
    65 
    70     bool isTagged() const;
    66     bool isTagged() const;
    71 
    67 
    72     bool isRecognizedByRds() const;
    68     bool isRecognizedByRds() const;
    73 
    69 
    74 private:
       
    75 
       
    76     /**
       
    77      * Decrements the reference count of the implicitly shared data.
       
    78      * Data is deleted if no instance uses it anymore.
       
    79      */
       
    80     void decrementReferenceCount();
       
    81 
       
    82 private: // data
    70 private: // data
    83 
    71 
    84     /**
    72     /*!
    85      * Pointer to the implicitly shared private implementation
    73      * Pointer to the implicitly shared private implementation
    86      * Own.
    74      * Own.
    87      */
    75      */
    88     class RadioHistoryItemPrivate* mData;
    76     QSharedDataPointer<RadioHistoryItemPrivate> mData;
    89 
    77 
    90 public:
    78 public:
    91 
       
    92     /**
       
    93      * Detach from the implicitly shared data
       
    94      */
       
    95     void detach();
       
    96 
    79 
    97     /**
    80     /**
    98      * Checks if the class is detached from implicitly shared data
    81      * Checks if the class is detached from implicitly shared data
    99      * Required by many QT convenience functions for implicitly shared classes
    82      * Required by many QT convenience functions for implicitly shared classes
   100      */
    83      */
   101     bool isDetached() const;
    84     bool isDetached() const;
   102 
    85 
   103     typedef RadioHistoryItemPrivate* DataPtr;
    86     typedef QSharedDataPointer<RadioHistoryItemPrivate> DataPtr;
   104     inline DataPtr &data_ptr() { return mData; }
    87     inline DataPtr &data_ptr() { return mData; }
   105 
    88 
   106 };
    89 };
   107 
    90 
   108 Q_DECLARE_TYPEINFO( RadioHistoryItem, Q_MOVABLE_TYPE );  // Can be moved around in memory by containers if necessary
    91 Q_DECLARE_TYPEINFO( RadioHistoryItem, Q_MOVABLE_TYPE );  // Can be moved around in memory by containers if necessary