ITunesDBPlaylist Class Reference

#include <itunesdb.h>

Inheritance diagram for ITunesDBPlaylist:

itunesdb::Playlist itunesdb::ListItem List of all members.

Public Types

enum  Sortorder {
  SORTORDER_MANUAL = 1, SORTORDER_RANDOM = 2, 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, SORTORDER_SHOW = 29,
  SORTORDER_SEASON = 30, SORTORDER_EPISODE_NUMBER = 31
}
typedef itunesdb::utils::SortablePtrVector<
PlaylistItem > 
TrackList_T
typedef TrackList_T::ConstIterator ConstIterator
typedef TrackList_T::Iterator Iterator

Public Member Functions

virtual itunesdb::PlaylistItemcreateNewItem (Q_UINT32 itemid)
void updateSmartPlaylist (bool force=false)
void setSortOrder (Sortorder sortOrder)
ITunesDBTrackgetTrackAt (uint position) const
ITunesDBTrackgetTrack (const itunesdb::PlaylistItem &plItem) const
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 getElements ()
virtual ConstIterator getElements () const
Iterator getTrackIDs () __attribute__((deprecated))
ConstIterator getTrackIDs () const __attribute__((deprecated))
virtual uint getNumTracks () const
Q_UINT64 getID () const
void setID (Q_UINT64 id)
void sort ()
void clear ()
bool isMasterPL () const
SmartPlaylistRuleSet & enableSmartPlaylist ()
bool isSmartPlaylist () const
void discardSmartPlaylistData ()
SmartPlaylistRuleSet * getSmartPlaylistRules () const
bool isPodcastList () const
template<class JavaLikeTrackIterator>
void addAll (JavaLikeTrackIterator trackIter)
template<class CPPStyleTrackIterator>
void addAll (CPPStyleTrackIterator trackIter, CPPStyleTrackIterator end)
int getType () const
void setItemProperty (const QString &data, ItemProperty field)
bool containsItemProperty (ItemProperty field) const
const QString & getItemProperty (ItemProperty field) const
uint getNumComponents () const
uint getNumStringComponents () const
virtual bool isDirty () const

Public Attributes

enum itunesdb::Playlist::Sortorder ItdbPlaylistSortOrder

Protected Types

typedef std::map< Q_UINT32,
QString > 
PropertyMap
typedef std::vector< MHODPair > DumpedMHODs

Protected Member Functions

virtual void readNonStringMHOD (QDataStream &stream, Q_UINT32 type, Q_UINT32 blocklen)
virtual void setDirty (bool dirtyFlag=true)
virtual itunesdb::SmartPlaylistRuleSetcreateNewSplRuleSet ()
virtual int addPlaylistItem (PlaylistItem *item)
void updatePositions ()
virtual QDataStream & readFromStream (QDataStream &instream, bool *ok=NULL)
virtual QDataStream & writeToStream (QDataStream &outstream, bool isMainlist)
virtual void doneAddingData ()
void fillSplHeaderBuffer (QByteArray &buffer) const
void fillSplRulesBuffer (QByteArray &buffer) const
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
const QByteArray * getDumpedMHOD (Q_UINT32 type) const
virtual void readMHOD (QDataStream &stream, Q_UINT32 type, Q_UINT32 blocklen)
Q_UINT32 writeMHODsToStream (QDataStream &outstream) const

Protected Attributes

TrackList_T m_tracklist
Q_UINT8 m_isMaster
Q_UINT8 m_flag2
Q_UINT8 m_flag3
Q_UINT8 m_flag4
Q_UINT32 timeStamp
Q_UINT64 m_id
Q_UINT32 unk3
Q_UINT16 mIsPodcast
Sortorder m_order
SmartPlaylistRuleSet * mSplRuleSet
PropertyMap m_properties
DumpedMHODs m_dumpedMHODs
int m_itemType

Friends

class ITunesDB

Classes

class  Entry

Detailed Description

Special playlist implementation to use with the ITunesDB class. This adds important functionalities like setting the sort order and updating the contents of smart playlists.
To create a new ITunesDBPlaylist instance use the ITunesDB::createNewPlaylist( const QString& ) factory method and use the ITunesDB::addPlaylist( ITunesDBPlaylist* ) to add it to the database.
Here is an example on how to create a "recently played" Smart Playlist:

  // create a new playlist
  ITunesDBPlaylist * recentlyPlayed = itunesdb.createNewPlaylist( "recently played" );
  recentlyPlayed->setSortOrder( Playlist::SORTORDER_TIME_PLAYED );

  // make it a smart playlist and get the ruleset
  SmartPlaylistRuleSet& ruleSet = recentlyPlayed->enableSmartPlaylist();

  // add the rule "last played in the last 2 weeks"
  ruleSet.addInTheLastRule( FIELD_LASTPLAYED, false, -2, IN_THE_LAST_WEEKS );

  // limit to the first 30 songs, sorted by last played date
  ruleSet.setLimits( LIMIT_SORT_LASTPLAYED, LIMIT_TYPE_SONGS, 30 );

  // match ANY rule (doesn't really matter since we only have one rule)
  ruleSet.setMatchAnyFlag( true );

  // enable live update (updates the playlist on the go)
  ruleSet.setLiveUpdateFlag( true );

  // finally add the playlist to the database
  itunesdb.addPlaylist( recentlyPlayed );
 
Examples:

listtests.cpp.


Member Function Documentation

PlaylistItem * ITunesDBPlaylist::createNewItem ( Q_UINT32  itemid  )  [virtual]

Creates a new instance of the Entry class.

Reimplemented from itunesdb::Playlist.

void ITunesDBPlaylist::updateSmartPlaylist ( bool  force = false  ) 

Updates the content of this smart playlist against the database Nothing happens if this playlist is not a smart playlist.

See also:
itunesdb::Playlist::enableSmartPlaylist()

itunesdb::Playlist::getSmartPlaylistRules()

Examples:
listtests.cpp.

void ITunesDBPlaylist::setSortOrder ( Sortorder  sortOrder  ) 

Sets the sort order field.

See also:
itunesdb::Playlist::ItdbPlaylistSortOrder
Examples:
listtests.cpp.

ITunesDBTrack * ITunesDBPlaylist::getTrackAt ( uint  position  )  const

Returns the track the playlist entry at the given position is referring to

ITunesDBTrack * ITunesDBPlaylist::getTrack ( const itunesdb::PlaylistItem plItem  )  const

Returns the track for a given playlist item

Parameters:
plItem the PlaylistItem to get the referred track
Returns:
the track for the given playlist item

void ITunesDBPlaylist::readNonStringMHOD ( QDataStream &  stream,
Q_UINT32  type,
Q_UINT32  blocklen 
) [protected, virtual]

reads mhods with type above type 15 (mhods not containing strings)

Reimplemented from itunesdb::Playlist.

const QString & itunesdb::Playlist::getTitle (  )  const [inherited]

Returns the title of the playlist

Returns:
the title of the playlist

void itunesdb::Playlist::setTitle ( const QString &  newtitle  )  [inherited]

Sets the title of the playlist

Parameters:
newtitle the new title

Playlist::Sortorder itunesdb::Playlist::getSortOrder (  )  const [inherited]

Returns the sort order field of the playlist

Returns:
the sort order field of the playlist

bool itunesdb::Playlist::contains ( Q_UINT32  trackID  )  const [inherited]

Returns true if the playlist contains the specified trackid.

int itunesdb::Playlist::addPlaylistItem ( Q_UINT32  trackid,
int  position = -1 
) [inherited]

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

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

Adds a new playlist item to the internal list.

Q_UINT32 itunesdb::Playlist::removeTrackAt ( Iterator pos  )  [inherited]

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. The iterators position will be invalidated so the next() method has to be called before the next removal operation.

Q_UINT32 itunesdb::Playlist::removeTrackAt ( uint  pos  )  [inherited]

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.

bool itunesdb::Playlist::removeAll ( Q_UINT32  trackid  )  [inherited]

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::getTrackIDAt ( uint  pos  )  [virtual, inherited]

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::Iterator itunesdb::Playlist::getElements (  )  [virtual, inherited]

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.

Returns:
an iterator over the elements in the playlist

Playlist::ConstIterator itunesdb::Playlist::getElements (  )  const [virtual, inherited]

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

Returns:
an iterator over the playlists elements

Iterator itunesdb::Playlist::getTrackIDs (  )  [inline, inherited]

Deprecated:
as the Iterator iterates over elements of type PlaylistItem the name is somewhat misleading. Use the new Method getElements() instead.

ConstIterator itunesdb::Playlist::getTrackIDs (  )  const [inline, inherited]

Deprecated:
as the Iterator iterates over elements of type PlaylistItem the name is somewhat misleading. Use the new Method getElements() instead.

uint itunesdb::Playlist::getNumTracks (  )  const [virtual, inherited]

Returns the number of tracks in this playlist

Returns:
the number of tracks in this playlist

Q_UINT64 itunesdb::Playlist::getID (  )  const [inline, inherited]

Returns the unique DB id for this playlist

Returns:
the unique DB id for this playlist

void itunesdb::Playlist::setID ( Q_UINT64  id  )  [inherited]

Sets the unique DB id for this playlist

Parameters:
id the unique DB id for this playlist

void itunesdb::Playlist::sort (  )  [inherited]

Sorts the playlistItems by position.

void itunesdb::Playlist::clear (  )  [inherited]

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

bool itunesdb::Playlist::isMasterPL (  )  const [inline, inherited]

Returns true if this playlist is the master playlist.

SmartPlaylistRuleSet & itunesdb::Playlist::enableSmartPlaylist (  )  [inherited]

Enables Smart Playlist Behaviour by creating a SmartPlaylistRuleSet.

Examples:
listtests.cpp.

bool itunesdb::Playlist::isSmartPlaylist (  )  const [inherited]

Returns true if this playlist is a smart playlist.

void itunesdb::Playlist::discardSmartPlaylistData (  )  [inherited]

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

SmartPlaylistRuleSet * itunesdb::Playlist::getSmartPlaylistRules (  )  const [inherited]

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.

bool itunesdb::Playlist::isPodcastList (  )  const [inline, inherited]

Returns true if this playlist is a podcast list

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

Adds all tracks delivered by the given Iterator.

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

Adds all tracks delivered by the given Iterator.

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

override from ListItem::doneAddingData()

Reimplemented from itunesdb::ListItem.

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

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, inherited]

Writes the track list

int itunesdb::ListItem::getType (  )  const [inherited]

returns the type ofthis item possible values from the known implementors are ITEMTYPE_PLAYLIST, ITEMTYPE_PLAYLISTITEM and ITEMTYPE_TRACK

void itunesdb::ListItem::setItemProperty ( const QString &  data,
ItemProperty  field 
) [inherited]

sets a given itunesDB item property

Parameters:
data value for the property to be set
field propertyID of the property to be set

bool itunesdb::ListItem::containsItemProperty ( ItemProperty  field  )  const [inherited]

Returns true if the given field is set with a non empty value.

Parameters:
field PropertyID of the property to be checked.
Returns:
true if the given field is set with a non empty value.

const QString & itunesdb::ListItem::getItemProperty ( ItemProperty  field  )  const [inherited]

Returns the value for the given property.

Parameters:
field PropertyID of the property to be returned.
Returns:
the value for the given property.

uint itunesdb::ListItem::getNumComponents (  )  const [inherited]

Returns the number of properties.

uint itunesdb::ListItem::getNumStringComponents (  )  const [inherited]

Returns the number of String properties.

bool itunesdb::ListItem::isDirty (  )  const [virtual, inherited]

Returns true if this database item is out of sync with the database. This is true if/when the item got changed and did not get saved back to the database yet.


The documentation for this class was generated from the following files:
Generated on Wed Dec 19 00:15:19 2007 for libqtpod by  doxygen 1.5.0