#include <itunesdb.h>
Inheritance diagram for ITunesDBPlaylist:
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::PlaylistItem * | createNewItem (Q_UINT32 itemid) |
void | updateSmartPlaylist (bool force=false) |
void | setSortOrder (Sortorder sortOrder) |
ITunesDBTrack * | getTrackAt (uint position) const |
ITunesDBTrack * | getTrack (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::SmartPlaylistRuleSet * | createNewSplRuleSet () |
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 |
ITunesDB::createNewPlaylist( const QString& )
factory method and use the ITunesDB::addPlaylist( ITunesDBPlaylist* )
to add it to the database.
// 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 );
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.
void ITunesDBPlaylist::setSortOrder | ( | Sortorder | sortOrder | ) |
Sets the sort order field.
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
plItem | the PlaylistItem to get the referred track |
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
void itunesdb::Playlist::setTitle | ( | const QString & | newtitle | ) | [inherited] |
Sets the title of the playlist
newtitle | the new title |
Playlist::Sortorder itunesdb::Playlist::getSortOrder | ( | ) | const [inherited] |
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.
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 |
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.
Playlist::ConstIterator itunesdb::Playlist::getElements | ( | ) | const [virtual, inherited] |
The const version of the above method. Returns an iterator over all tracks in this playlist.
Iterator itunesdb::Playlist::getTrackIDs | ( | ) | [inline, inherited] |
PlaylistItem
the name is somewhat misleading. Use the new Method getElements() instead. ConstIterator itunesdb::Playlist::getTrackIDs | ( | ) | const [inline, inherited] |
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
Q_UINT64 itunesdb::Playlist::getID | ( | ) | const [inline, inherited] |
Returns the unique DB id for this playlist
void itunesdb::Playlist::setID | ( | Q_UINT64 | id | ) | [inherited] |
Sets the unique DB id for this playlist
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.
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
void itunesdb::Playlist::addAll | ( | JavaLikeTrackIterator | trackIter | ) | [inline, inherited] |
Adds all tracks delivered by the given Iterator.
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
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.
field | PropertyID of the property to be checked. |
const QString & itunesdb::ListItem::getItemProperty | ( | ItemProperty | field | ) | const [inherited] |
Returns the value for the given property.
field | PropertyID of the property to be returned. |
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.