27 |
27 |
28 /*! |
28 /*! |
29 * |
29 * |
30 */ |
30 */ |
31 RadioHistoryItem::RadioHistoryItem() : |
31 RadioHistoryItem::RadioHistoryItem() : |
32 QObject( 0 ) |
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() |
33 { |
81 { |
34 mData = shared_null(); |
82 mData = shared_null(); |
35 mData->ref.ref(); |
|
36 } |
|
37 |
|
38 /*! |
|
39 * |
|
40 */ |
|
41 RadioHistoryItem::RadioHistoryItem( const QString& artist, const QString& title ) : |
|
42 QObject( 0 ) |
|
43 { |
|
44 mData = new RadioHistoryItemPrivate( artist, title ); |
|
45 } |
|
46 |
|
47 /*! |
|
48 * |
|
49 */ |
|
50 RadioHistoryItem::RadioHistoryItem( const RadioHistoryItem& other ) : |
|
51 QObject( 0 ) |
|
52 { |
|
53 mData = other.mData; |
|
54 mData->ref.ref(); |
|
55 } |
|
56 |
|
57 /*! |
|
58 * |
|
59 */ |
|
60 RadioHistoryItem::~RadioHistoryItem() |
|
61 { |
|
62 decrementReferenceCount(); |
|
63 } |
|
64 |
|
65 /*! |
|
66 * |
|
67 */ |
|
68 RadioHistoryItem& RadioHistoryItem::operator=( const RadioHistoryItem& other ) |
|
69 { |
|
70 qAtomicAssign( mData, other.mData ); |
|
71 return *this; |
|
72 } |
|
73 |
|
74 /*! |
|
75 * |
|
76 */ |
|
77 bool RadioHistoryItem::isValid() const |
|
78 { |
|
79 return id() != 0 && !title().isEmpty(); |
|
80 } |
|
81 |
|
82 /*! |
|
83 * |
|
84 */ |
|
85 void RadioHistoryItem::reset() |
|
86 { |
|
87 decrementReferenceCount(); |
|
88 mData = shared_null(); |
|
89 mData->ref.ref(); |
|
90 } |
83 } |
91 |
84 |
92 /*! |
85 /*! |
93 * |
86 * |
94 */ |
87 */ |
205 bool RadioHistoryItem::isRecognizedByRds() const |
192 bool RadioHistoryItem::isRecognizedByRds() const |
206 { |
193 { |
207 return mData->mFromRds; |
194 return mData->mFromRds; |
208 } |
195 } |
209 |
196 |
210 /** |
197 /*! |
211 * Decrements the reference count of the implicitly shared data. |
198 * |
212 */ |
|
213 void RadioHistoryItem::decrementReferenceCount() |
|
214 { |
|
215 if ( !mData->ref.deref() ) { |
|
216 delete mData; |
|
217 mData = 0; |
|
218 } |
|
219 } |
|
220 |
|
221 /** |
|
222 * Detach from the implicitly shared data |
|
223 */ |
|
224 void RadioHistoryItem::detach() |
|
225 { |
|
226 if ( !isDetached() ) { |
|
227 RadioHistoryItemPrivate* newData = new RadioHistoryItemPrivate( *mData ); |
|
228 |
|
229 decrementReferenceCount(); |
|
230 |
|
231 newData->ref = 1; |
|
232 mData = newData; |
|
233 } |
|
234 } |
|
235 |
|
236 /** |
|
237 * Checks if the class is detached from implicitly shared data |
|
238 */ |
199 */ |
239 bool RadioHistoryItem::isDetached() const |
200 bool RadioHistoryItem::isDetached() const |
240 { |
201 { |
241 return mData->ref == 1; |
202 return mData->ref == 1; |
242 } |
203 } |