itunesdb::MasterPlaylist Class Reference

Inheritance diagram for itunesdb::MasterPlaylist:

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

 MasterPlaylist (itunesdb::TrackPtrList &allTracks)
void sortIndices (const TrackComparatorPtr &comparator) const
void writeMHOD52 (QDataStream &stream, uint sortIndex, const TrackComparatorPtr &comparator) const
virtual uint writeNonStringMHODs (QDataStream &outstream) 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
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)
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 int addPlaylistItem (PlaylistItem *item)
void updatePositions ()
virtual PlaylistItemcreateNewItem (Q_UINT32 trackid)
virtual QDataStream & readFromStream (QDataStream &instream, bool *ok=NULL)
virtual QDataStream & writeToStream (QDataStream &outstream, bool isMainlist)
virtual void doneAddingData ()
virtual SmartPlaylistRuleSetcreateNewSplRuleSet ()
void fillSplHeaderBuffer (QByteArray &buffer) const
void fillSplRulesBuffer (QByteArray &buffer) const
virtual void readNonStringMHOD (QDataStream &stream, Q_UINT32 type, Q_UINT32 blocklen)
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
virtual void setDirty (bool dirtyFlag=true)

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
SmartPlaylistRuleSetmSplRuleSet
PropertyMap m_properties
DumpedMHODs m_dumpedMHODs
int m_itemType

Classes

struct  IndexComparator

Detailed Description

void itunesdb::ItunesDBWriter::fillPodcastBuffer( QByteArray& buffer ) { QBuffer io_buffer( buffer); io_buffer.open(IO_WriteOnly); QDataStream stream( &io_buffer); stream.setByteOrder( QDataStream::LittleEndian);

stream << (Q_UINT32) 0x6473686D; // "mhsd" stream << (Q_UINT32) MHSD_HEADERLEN; // headerlen stream << (Q_UINT32) 0x0; // length - set when we're done stream << (Q_UINT32) 3; // type: podcastlist for( int i= 0; i< 20; i++) stream << (Q_UINT32) 0; // pad the rest (80 bytes)

stream << (Q_UINT32) 0x706C686D; // "mhlp" stream << (Q_UINT32) 0x5C; // headerlen stream << (Q_UINT32) 1; // one podlist for( int i= 0; i< 20; i++) stream << (Q_UINT32) 0; // pad the rest (80 bytes) ???

io_buffer.at( 8); stream << (Q_UINT32)io_buffer.size(); // write the length

io_buffer.close(); }


Member Function Documentation

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.

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

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

Reimplemented in ITunesDBPlaylist.

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 file:
Generated on Wed Nov 28 03:04:38 2007 for libqtpod by  doxygen 1.5.0