Summary: | Negative duration for Last.fm track | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Bram Schoenmakers <me> |
Component: | general | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.4.3 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Update playlist lenghs when playlistitem changes |
Description
Bram Schoenmakers
2006-09-19 15:33:19 UTC
Created attachment 18695 [details]
Update playlist lenghs when playlistitem changes
Properly compute total playlist length if there are tracks with dynamic lengths
(e.g. last.fm streams) in the playlist.
The patch is against amarok 1.4.4
SVN commit 608931 by aumuell: correctly update total playlist play time when removing last.fm streams - thanks to Modestas Vainius <geromanas@mailas.com> for the patch! BUG: 134333 M +2 -0 ChangeLog M +68 -28 src/playlistitem.cpp M +5 -0 src/playlistitem.h --- trunk/extragear/multimedia/amarok/ChangeLog #608930:608931 @@ -39,6 +39,8 @@ * Amarok now saves playlists with relative paths by default. BUGFIXES: + * Correctly update total playlist play time when removing last.fm + streams. Patch by Modestas Vainius <geromanas@mailas.com>. (BR 134333) * File organization jobs could not be canceled. Patch by Wenli Liu <wenlil@xandros.com>. (BR 136527) * Sending filenames to MTP media devices as UTF-8 caused problems, use --- trunk/extragear/multimedia/amarok/src/playlistitem.cpp #608930:608931 @@ -71,19 +71,8 @@ refAlbum(); - listView()->m_totalCount++; - listView()->m_totalLength += length(); - if( isSelected() ) - { - listView()->m_selCount++; - listView()->m_selLength += length(); - } - if( isVisible() ) - { - listView()->m_visCount++; - listView()->m_visLength += length(); - incrementTotals(); - } + incrementCounts(); + incrementLengths(); filter( listView()->m_filter ); @@ -96,19 +85,8 @@ if( isEmpty() ) //constructed with the generic constructor, for PlaylistLoader's marker item return; - listView()->m_totalCount--; - listView()->m_totalLength -= length(); - if( isSelected() ) - { - listView()->m_selCount--; - listView()->m_selLength -= length(); - } - if( isVisible() ) - { - listView()->m_visCount--; - listView()->m_visLength -= length(); - decrementTotals(); - } + decrementCounts(); + decrementLengths(); derefAlbum(); @@ -160,13 +138,16 @@ void PlaylistItem::aboutToChange( const QValueList<int> &columns ) { - bool totals = false, ref = false; + bool totals = false, ref = false, length = false; for( int i = 0, n = columns.count(); i < n; ++i ) switch( columns[i] ) { + case Length: length = true; break; case Artist: case Album: ref = true; //note, no breaks case Track: case Rating: case Score: case LastPlayed: totals = true; } + if ( length ) + decrementLengths(); if( totals ) decrementTotals(); if( ref ) @@ -176,11 +157,16 @@ void PlaylistItem::reactToChanges( const QValueList<int> &columns ) { MetaBundle::reactToChanges(columns); - bool totals = false, ref = false; + bool totals = false, ref = false, length = false; for( int i = 0, n = columns.count(); i < n; ++i ) { if( columns[i] == Mood ) moodbar().reset(); + if ( !length && columns[i] == Length ) { + length = true; + incrementLengths(); + listView()->countChanged(); + } switch( columns[i] ) { case Artist: case Album: ref = true; //note, no breaks @@ -1069,6 +1055,60 @@ } } +void PlaylistItem::incrementCounts() +{ + listView()->m_totalCount++; + if( isSelected() ) + { + listView()->m_selCount++; + } + if( isVisible() ) + { + listView()->m_visCount++; + incrementTotals(); + } +} + +void PlaylistItem::decrementCounts() +{ + listView()->m_totalCount--; + if( isSelected() ) + { + listView()->m_selCount--; + } + if( isVisible() ) + { + listView()->m_visCount--; + decrementTotals(); + } +} + +void PlaylistItem::incrementLengths() +{ + listView()->m_totalLength += length(); + if( isSelected() ) + { + listView()->m_selLength += length(); + } + if( isVisible() ) + { + listView()->m_visLength += length(); + } +} + +void PlaylistItem::decrementLengths() +{ + listView()->m_totalLength -= length(); + if( isSelected() ) + { + listView()->m_selLength -= length(); + } + if( isVisible() ) + { + listView()->m_visLength -= length(); + } +} + QPixmap *PlaylistItem::s_star = 0; QPixmap *PlaylistItem::s_grayedStar = 0; QPixmap *PlaylistItem::s_smallStar = 0; --- trunk/extragear/multimedia/amarok/src/playlistitem.h #608930:608931 @@ -149,6 +149,11 @@ void decrementTotals(); void incrementTotals(); + void incrementCounts(); + void decrementCounts(); + void incrementLengths(); + void decrementLengths(); + int totalIncrementAmount() const; PlaylistAlbum *m_album; |