73 : QAbstractListModel( parent ), |
73 : QAbstractListModel( parent ), |
74 mCollectionData( collectionData ), |
74 mCollectionData( collectionData ), |
75 mPlaybackData( playbackData ), |
75 mPlaybackData( playbackData ), |
76 mRowCount( 0 ), |
76 mRowCount( 0 ), |
77 mCurrentSongId( 0 ), |
77 mCurrentSongId( 0 ), |
78 mPlaybackActive( false ) |
78 mPlaybackActive( false ), |
|
79 mPlaybackIndicatorEnabled( false ) |
79 { |
80 { |
80 TX_ENTRY |
81 TX_ENTRY |
81 connect( mCollectionData, SIGNAL(refreshAlbumSongs()), |
82 connect( mCollectionData, SIGNAL(refreshAlbumSongs()), |
82 this, SLOT(refreshModel()) ); |
83 this, SLOT(refreshModel()) ); |
83 connect( mCollectionData, SIGNAL(albumDataChanged()), |
84 connect( mCollectionData, SIGNAL(albumDataChanged()), |
84 this, SIGNAL(albumDataChanged()) ); |
85 this, SIGNAL(albumDataChanged()) ); |
85 |
86 |
86 if ( mPlaybackData ) { |
87 if ( mPlaybackData ) { |
87 connect( mPlaybackData, SIGNAL(playbackInfoChanged()), |
88 connect( mPlaybackData, SIGNAL(fileCorrupted( int )), |
88 this, SLOT(updateSong())); |
89 this, SLOT(fileCorrupted( int ))); |
89 |
|
90 connect( mPlaybackData, SIGNAL(playbackStateChanged()), |
|
91 this, SLOT(updatePlaybackState())); |
|
92 mPlaybackActive = mPlaybackData->playbackState() != MpPlaybackData::NotPlaying; |
|
93 } |
90 } |
94 |
91 |
95 TX_EXIT |
92 TX_EXIT |
96 } |
93 } |
97 |
94 |
139 else { |
136 else { |
140 returnValue = hbTrId("txt_mus_other_unknown4"); |
137 returnValue = hbTrId("txt_mus_other_unknown4"); |
141 } |
138 } |
142 } |
139 } |
143 else if ( role == Qt::DecorationRole ) { |
140 else if ( role == Qt::DecorationRole ) { |
144 if ( mPlaybackActive |
141 if ( mCollectionData->hasAlbumSongProperty(row, MpMpxCollectionData::Corrupted) ) { |
|
142 QList<QVariant> iconList; |
|
143 iconList << QVariant(); |
|
144 iconList << HbIcon("qtg_mono_corrupted"); |
|
145 returnValue = iconList; |
|
146 } |
|
147 else if ( mCollectionData->hasAlbumSongProperty(row, MpMpxCollectionData::DrmExpired) ) { |
|
148 QList<QVariant> iconList; |
|
149 iconList << QVariant(); |
|
150 iconList << HbIcon("qtg_small_drm_rights_expired"); |
|
151 returnValue = iconList; |
|
152 } |
|
153 else if ( mPlaybackActive && mPlaybackIndicatorEnabled |
145 && mPlaybackData->id() == mCollectionData->albumSongId( row ) ) { |
154 && mPlaybackData->id() == mCollectionData->albumSongId( row ) ) { |
146 QList<QVariant> iconList; |
155 QList<QVariant> iconList; |
147 iconList << QVariant(); //primary icon is not used. |
156 iconList << QVariant(); //primary icon is not used. |
148 |
157 |
149 iconList << HbIcon("qtg_small_speaker"); |
158 iconList << HbIcon("qtg_small_speaker"); |
150 returnValue = iconList; |
159 returnValue = iconList; |
151 } |
160 } |
152 } |
161 } |
153 TX_EXIT |
162 TX_EXIT |
154 return returnValue; |
163 return returnValue; |
|
164 } |
|
165 |
|
166 /*! |
|
167 Set Playback Indicator in TBone List Model |
|
168 */ |
|
169 void MpCollectionTBoneListDataModel::enablePlaybackIndicatorEnable(bool enable) |
|
170 { |
|
171 TX_ENTRY |
|
172 if ( !mPlaybackData ) { |
|
173 return; |
|
174 } |
|
175 if ( enable ){ |
|
176 connect( mPlaybackData, SIGNAL(playbackInfoChanged()), |
|
177 this, SLOT(updateSong())); |
|
178 |
|
179 connect( mPlaybackData, SIGNAL(playbackStateChanged()), |
|
180 this, SLOT(updatePlaybackState())); |
|
181 mPlaybackActive = mPlaybackData->playbackState() != MpPlaybackData::NotPlaying; |
|
182 mPlaybackIndicatorEnabled = true; |
|
183 } |
|
184 else{ |
|
185 disconnect( mPlaybackData, SIGNAL(playbackInfoChanged()), |
|
186 this, SLOT(updateSong())); |
|
187 |
|
188 disconnect( mPlaybackData, SIGNAL(playbackStateChanged()), |
|
189 this, SLOT(updatePlaybackState())); |
|
190 mPlaybackActive = false; |
|
191 mPlaybackIndicatorEnabled = false; |
|
192 } |
|
193 TX_EXIT |
155 } |
194 } |
156 |
195 |
157 /*! |
196 /*! |
158 Slot to be called when data has changed and model needs to be refreshed |
197 Slot to be called when data has changed and model needs to be refreshed |
159 to reflect the new data. |
198 to reflect the new data. |
207 mPlaybackActive = mPlaybackData->playbackState() != MpPlaybackData::NotPlaying; |
246 mPlaybackActive = mPlaybackData->playbackState() != MpPlaybackData::NotPlaying; |
208 if ( mPlaybackActive && !playbackWasActive ) { |
247 if ( mPlaybackActive && !playbackWasActive ) { |
209 updateSong(); |
248 updateSong(); |
210 } |
249 } |
211 } |
250 } |
|
251 |
|
252 /*! |
|
253 Slot to be called when a song is marked as corrupted |
|
254 */ |
|
255 void MpCollectionTBoneListDataModel::fileCorrupted(int songId) |
|
256 { |
|
257 TX_ENTRY |
|
258 QModelIndex corruptedSongIndex; |
|
259 corruptedSongIndex = index( mCollectionData->albumSongIndex( songId ) ); |
|
260 if ( !(corruptedSongIndex.isValid()) ){ |
|
261 mCollectionData->setReloadAlbumContent( true ); |
|
262 } |
|
263 else if (!(mCollectionData->hasAlbumSongProperty(corruptedSongIndex.row(), |
|
264 MpMpxCollectionData::Corrupted))) { |
|
265 mCollectionData->setCorruptValue(corruptedSongIndex, true); |
|
266 emit dataChanged( corruptedSongIndex, corruptedSongIndex ); |
|
267 } |
|
268 TX_EXIT |
|
269 } |
212 |
270 |
213 |
271 |
214 //EOF |
272 //EOF |
215 |
273 |
216 |
274 |