PlaylistItem enabled calculation change, dynamic playlists may be broken

Jeff Mitchell kde-dev at emailgoeshere.com
Fri Sep 29 01:49:01 UTC 2006


Folks--

Today I was coding up better fileAdded and fileDeleted behavior with AFT and 
the Playlist, when I realized that a problem has existed for quite some time: 
we have many ways of disabling or enabling playlist items, but only one 
variable to keep its state.  This is very limiting, because items can be 
disabled or enabled for completely different reasons -- if a file exists or 
doesn't exist, if a file's has or hasn't been played in Dynamic mode, and 
possible other uses in the future (such as a mode where the entire playlist 
is played in random order, tracks being disabled as they're played).  And it 
was causing other problems, such as files that were detected as being added 
back to collection folders causing tracks to be enabled that should be 
disabled because of dynamic playlists.  Hacks around this were very kludgy.

Anyways (I know how much Ian hates rambles), I came up with a solution that I 
think is pretty robust.  PlaylistItem::setEnabled no longer takes a bool, and 
should not be called directly.  Instead, you call 
PlaylistItem::setDynamicEnabled or PlaylistItem::setFilestatusEnabled.  These 
update the respective variables indicating whether the item should be 
disabled because of dynamic playlists, or because the file doesn't exist, and 
then in turn call setEnabled.  setEnabled now ANDs the various other bools 
together, only having the item enabled if they all indicate it should be.

You can probably see how this can easily be extended: simply create a setter 
and getter for the new bool that indicates if an item should be disabled or 
not; have the setter call setEnabled when done; add the bool to the 
setEnabled ANDing of the various bool values.  That's basically it.  There's 
one more function I added, setAllCriteriaEnabled, which sets all globally so 
should also be modified.

I tried to be careful in determining which value should be modified where, but 
I anticipate that there could be some issues in Dynamic Playlist mode, so 
I'll be testing it, and hopefully other people will be as well (read:  PLEASE 
TEST IT  :-)  ).  We have a ways to 1.4.4, we're in no rush, so should have 
plenty of time to iron out the kinks.

Anyways, sorry if this breaks dynamic playlists a bit, but it will end up 
making our life much easier anytime that we need to enable or disable the 
playlistitems for any reason, without having to hack around the other 
possibilities.

--Jeff



More information about the Amarok mailing list