itunesdb::Playlist Class Reference

#include <playlist.h>

Inheritance diagram for itunesdb::Playlist:

itunesdb::ListItem itunesdb::MasterPlaylist ITunesDBPlaylist List of all members.

Public Types

enum  Sortorder {
  SORTORDER_MANUAL = 1, SORTORDER_TITLE = 3, SORTORDER_ALBUM = 4, SORTORDER_ARTIST = 5,
  SORTORDER_BITRATE = 6, SORTORDER_GENRE = 7, SORTORDER_FILETYPE = 8, SORTORDER_TIME_MODIFIED = 9,
  SORTORDER_TRACK_NR = 10, SORTORDER_SIZE = 11, SORTORDER_TIME = 12, SORTORDER_YEAR = 13,
  SORTORDER_SAMPLERATE = 14, SORTORDER_COMMENT = 15, SORTORDER_TIME_ADDED = 16, SORTORDER_EQUALIZER = 17,
  SORTORDER_COMPOSER = 18, SORTORDER_PLAYCOUNT = 20, SORTORDER_TIME_PLAYED = 21, SORTORDER_CD_NR = 22,
  SORTORDER_RATING = 23, SORTORDER_RELEASE_DATE = 24, SORTORDER_BPM = 25, SORTORDER_GROUPING = 26,
  SORTORDER_CATEGORY = 27, SORTORDER_DESCRIPTION = 28
}

Public Member Functions

const QString & getTitle () const
void setTitle (const QString &newtitle)
Sortorder getSortOrder () const
bool contains (Q_UINT32 trackID) const
int addPlaylistItem (Q_UINT32 trackid, int position=-1)
Q_UINT32 removeTrackAt (Iterator &pos)
Q_UINT32 removeTrackAt (uint pos)
bool removeAll (Q_UINT32 trackid)
virtual Q_UINT32 getTrackIDAt (uint pos)
virtual Iterator getTrackIDs ()
virtual ConstIterator getTrackIDs () const
virtual uint getNumTracks () const
Q_UINT64 getID () const
void setID (Q_UINT64 id)
void sort ()
void clear ()
virtual bool isHidden () const
SmartPlaylistRuleSetenableSmartPlaylist ()
bool isSmartPlaylist () const
void discardSmartPlaylistData ()
SmartPlaylistRuleSetgetSmartPlaylistRules () const
bool isPodcastList () const
template<class JavaLikeTrackIterator>
void addAll (JavaLikeTrackIterator trackIter)
template<class CPPStyleTrackIterator>
void addAll (CPPStyleTrackIterator trackIter, CPPStyleTrackIterator end)

Public Attributes

enum itunesdb::Playlist::Sortorder ItdbPlaylistSortOrder

Protected Member Functions

 Playlist (const Playlist &)
virtual PlaylistItemcreateNewItem (Q_UINT32 trackid)
virtual QDataStream & readFromStream (QDataStream &instream, bool *ok=NULL)
virtual QDataStream & writeToStream (QDataStream &outstream, bool isMainlist)
virtual void doneAddingData ()
virtual int addPlaylistItem (PlaylistItem *item)
virtual SmartPlaylistRuleSetcreateNewSplRuleSet ()
void fillSplHeaderBuffer (QByteArray &buffer) const
void fillSplRulesBuffer (QByteArray &buffer) const
virtual void readNonStringMHOD (QDataStream &stream, Q_UINT32 type, Q_UINT32 blocklen)
virtual uint writeNonStringMHODs (QDataStream &outstream) const
void writeData (QByteArray &data, bool isMainlist) const
void writeTitle (QDataStream &stream) const
void writeLongPlaylist (QDataStream &stream) const
void writeTracks (QDataStream &stream) const

Protected Attributes

TrackList_T m_tracklist
Q_UINT32 hidden
Q_UINT32 timeStamp
Q_UINT64 m_id
Q_UINT32 unk3
Q_UINT16 mIsPodcast
Sortorder m_order
SmartPlaylistRuleSetmSplRuleSet

Friends

class ItunesDBParser
class ItunesDBWriter

Classes

class  ConstIterator
class  Iterator
class  TrackList_T

Detailed Description

This class represents a playlist in the database.
It allows to read, create, manipulate and write back all kinds of playlists. It's part of the itunesdb namespace which is intended to be used for plain reading/writing the database. More enhanced features like sorting or updating smart playlists is implemented in the ITunesDB related implementation ITunesDBPlaylist
For normal playlists the addPlaylistItem( Q_UINT32, int ) method can be used to add tracks to the playlist, removeAll( Q_UINT32 ) and removeTrackAt( uint ) will remove them. For editing the rules of smart playlists use the getSmartPlaylistRules() method to retrieve the SmartPlaylistRuleSet and use its methods for manipulating the rules. To create a new smart playlist create a new playlist and use enableSmartPlaylist() method to enable smart playlist behaviour. This method also returns the still empty SmartPlaylistRuleSet ready for adding new rules.

See also:
ITunesDBPlaylist

SmartPlaylistRuleSet

Author:
Michael Schulze


Member Function Documentation

template<class CPPStyleTrackIterator>
void itunesdb::Playlist::addAll CPPStyleTrackIterator  trackIter,
CPPStyleTrackIterator  end
[inline]
 

Adds all tracks delivered by the given Iterator.

template<class JavaLikeTrackIterator>
void itunesdb::Playlist::addAll JavaLikeTrackIterator  trackIter  )  [inline]
 

Adds all tracks delivered by the given Iterator.

int itunesdb::Playlist::addPlaylistItem PlaylistItem item  )  [protected, virtual]
 

Adds a new playlist item to the internal list.

int itunesdb::Playlist::addPlaylistItem Q_UINT32  trackid,
int  position = -1
 

Adds a new PlaylistItem at the specified position to the list and sets the dirty flag to true. The position field only works if the playlists sort order is set to "manual" which is the only sort order implemented by this class, but may be ignored if you use the ITunesDBPlaylist implementation and set the sort order to something other than manual.

Parameters:
trackid the id of the track to add. Doesn't check if the track actually exists
position the position field as found in the itunesdb mhip playlist item, or -1 if the item should just be appended to the list
Returns:
the index of the item in the list or -1 if the item could not be added or the item was NULL
See also:
ITunesDBPlaylist for a full implementation of itunesDBs playlists

void itunesdb::Playlist::clear  ) 
 

Empties the playlist. After a call to this method the getNumTracks() method returns 0.

bool itunesdb::Playlist::contains Q_UINT32  trackID  )  const
 

Returns true if the playlist contains the specified trackid.

PlaylistItem * itunesdb::Playlist::createNewItem Q_UINT32  trackid  )  [protected, virtual]
 

Creates a new PlaylistItem. Override this method if you need your own PlaylistItem implementation.

Reimplemented in ITunesDBPlaylist.

void itunesdb::Playlist::discardSmartPlaylistData  ) 
 

Discards smart playlist data thus making it a normal playlist. The items in this playlist will be kept.

void itunesdb::Playlist::doneAddingData  )  [protected, virtual]
 

override from ListItem::doneAddingData()

Reimplemented from itunesdb::ListItem.

SmartPlaylistRuleSet & itunesdb::Playlist::enableSmartPlaylist  ) 
 

Enables Smart Playlist Behaviour by creating a SmartPlaylistRuleSet.

Q_UINT64 itunesdb::Playlist::getID  )  const [inline]
 

Returns the unique DB id for this playlist

Returns:
the unique DB id for this playlist

uint itunesdb::Playlist::getNumTracks  )  const [virtual]
 

Returns the number of tracks in this playlist

Returns:
the number of tracks in this playlist

SmartPlaylistRuleSet * itunesdb::Playlist::getSmartPlaylistRules  )  const
 

Returns the SmartPlaylistRuleSet making up this smart playlist, or NULL IF this playlist isn't a SmartPlaylist. All smart playlist behaviour can be / is controlled by the returned object.

Playlist::Sortorder itunesdb::Playlist::getSortOrder  )  const
 

Returns the sort order field of the playlist

Returns:
the sort order field of the playlist

const QString & itunesdb::Playlist::getTitle  )  const
 

Returns the title of the playlist

Returns:
the title of the playlist

Q_UINT32 itunesdb::Playlist::getTrackIDAt uint  pos  )  [virtual]
 

Returns the trackID at the given position or PLAYLISTITEM_INVALID (as defined in playlistitem.h) if the given position is either negative or above the last element in the list.

Playlist::ConstIterator itunesdb::Playlist::getTrackIDs  )  const [virtual]
 

The const version of the above method. Returns an iterator over all tracks in this playlist.

Playlist::Iterator itunesdb::Playlist::getTrackIDs  )  [virtual]
 

Returns an iterator over all tracks in this playlist. The iterator works like a java iterator - you can check if there are any elements left with the Iterator::hasNext() method and get the next element with the Iterator::next() method.

virtual bool itunesdb::Playlist::isHidden  )  const [inline, virtual]
 

Returns true if this playlist is hidden.

bool itunesdb::Playlist::isPodcastList  )  const [inline]
 

Returns true if this playlist is a podcast list

bool itunesdb::Playlist::isSmartPlaylist  )  const
 

Returns true if this playlist is a smart playlist.

bool itunesdb::Playlist::removeAll Q_UINT32  trackid  ) 
 

Removes all occurences of the track with the given ID. Returns true if an element with the given trackid existed and was removed, false otherwise.

Q_UINT32 itunesdb::Playlist::removeTrackAt uint  pos  ) 
 

Removes the track at the given position and returns the former trackid at that position. If the given position is out of range PLAYLISTITEM_INVALID (as defined in playlistitem.h) is returned.

Q_UINT32 itunesdb::Playlist::removeTrackAt Iterator &  pos  ) 
 

Removes the track at the position the given Iterator points to and returns the former trackid at that position. If the Iterator doesn't point to an element in this list PLAYLISTITEM_INVALID (as defined in playlistitem.h) is returned. After the operation the given Iterator will point to the next element.

void itunesdb::Playlist::setID Q_UINT64  id  ) 
 

Sets the unique DB id for this playlist

Parameters:
id the unique DB id for this playlist

void itunesdb::Playlist::setTitle const QString &  newtitle  ) 
 

Sets the title of the playlist

Parameters:
newtitle the new title

void itunesdb::Playlist::sort  ) 
 

Sorts the playlistItems by position.

void itunesdb::Playlist::writeLongPlaylist QDataStream &  stream  )  const [protected]
 

writes the stuff uiTunes would write as the second mhod for playlists. We don't use it - it's just here for completeness

void itunesdb::Playlist::writeTracks QDataStream &  stream  )  const [protected]
 

Writes the track list


The documentation for this class was generated from the following files:
Generated on Sun Oct 1 20:34:31 2006 for libqtpod.kdevelop by  doxygen 1.4.6