ITunesDB Class Reference

#include <itunesdb.h>

Inheritance diagram for ITunesDB:

itunesdb::utils::NonCopyAble List of all members.

Public Member Functions

 ITunesDB (IPodSysInfo &ipodSysInfo)
bool open ()
bool isOpen ()
bool writeDatabase (const QString &filename=QString())
bool dbFileChanged () const
QString getFilename () const
ITunesDBPlaylistcreateNewPlaylist (const QString &title)
ITunesDBTrackcreateEmptyTrack (Q_UINT32 trackid)
ITunesDBTrackcreateNewTrack (const QString &fileExtension=QString::null)
bool addTrack (ITunesDBTrack *track)
ITunesDBTrackgetTrackByID (const Q_UINT32 id) const
ITunesDBTrackfindTrackByDBID (const Q_UINT64 dbid) const
int getMHITTrackPosFor (Q_UINT32 id) const
ITunesDBTrackgetTrackAt (uint mhitTrackPos) const
ITunesDBTrackfindFirstTrackBy (itunesdb::TrackPredicate &predicate) const
TrackIterator getTracksBy (itunesdb::TrackPredicate *predicate) const
itunesdb::TrackPtrListgetTracksBy (itunesdb::TrackPredicate &predicate, itunesdb::TrackPtrList &buffer) const
ITunesDBTrackfindTrack (const QString &artistname, const QString &albumname, const QString &title, Q_UINT32 trackNum=0) const
QStringList * getArtists (QStringList &buffer) const
QStringList * getAllAlbums (QStringList &buffer) const
QStringList * getAlbumsByArtist (const QString &artistname, QStringList &buffer) const
bool containsArtist (const QString &artistname) const
bool containsAlbum (const QString &artistname, const QString &albumname) const
itunesdb::TrackPtrListgetAllTracks (itunesdb::TrackPtrList &buffer) const
TrackIterator getAllTracks () const
itunesdb::TrackPtrListgetAlbum (const QString &artistname, const QString &albumname, itunesdb::TrackPtrList &buffer) const
itunesdb::TrackPtrListgetTracksByArtist (const QString &artistname, itunesdb::TrackPtrList &buffer) const
itunesdb::TrackPtrListgetTracksContaining (const QString &someString, itunesdb::TrackPtrList &buffer, bool caseSensitive=true) const
QStringList * getPlaylistTitles (QStringList &buffer) const
ITunesDBPlaylistgetPlaylistByTitle (const QString &playlisttitle) const
ITunesDBPlaylistgetPlaylistByID (Q_UINT64 playlistID) const
bool removeArtist (const QString &artistname)
bool renameAlbum (const QString &artist, const QString &title, const QString &newartist, const QString &newtitle)
bool addPlaylist (ITunesDBPlaylist *playlist)
bool removePlaylist (const QString &title, bool delete_instance)
void updateSmartPlaylists ()
Q_UINT32 removeTrack (Q_UINT32 trackid, bool delete_instance=true)
void clear ()
bool isDirty () const
Q_UINT32 getNumTracks () const
Q_UINT32 getNumPlaylists () const
void lock (bool write_lock)
void unlock ()
bool isLocked () const
uint lastModified ()
void setTitle (const QString &title)
const QString & getTitle () const
bool hasPodcasts () const
Q_UINT32 getNextFreeTrackID () const
Q_UINT64 getNextFreeDBID () const
QString getFileForPathInfo (QString pathinfo) const
const QString & getIPodBase () const

Public Attributes

QString error

Protected Member Functions

void setDirty (bool dirtyFlag=true)
ITunesDBTrackinsertTrackToDataBase (ITunesDBTrack *track)

Protected Attributes

TrackIDMap m_TrackIdMap
TrackList m_TrackList
QString m_Title
ITunesDB::PlaylistContainerplaylists
bool m_dirty
Q_UINT32 maxtrackid
Q_UINT64 mMaxDBID

Friends

class ITunesDBPlaylist
class ITunesDBSPLRuleSet
class ITunesDBTrack

Classes

class  ItunesDBReaderAdapter
class  ItunesDBWriterAdapter
class  PlaylistContainer
class  TrackIterator

Detailed Description

Class representing the contents of your iPods ITunesDB file


Member Function Documentation

bool ITunesDB::open (  ) 

Opens the itunesdb file at the given ipod mountpoint

Returns:
true if the itunesdb does exist and could be opened. For parse errors check the error member afterwards

bool ITunesDB::isOpen (  ) 

Returns true if open() has already been successfully called.

Returns:
true if open has already been successfully called, false otherwise

bool ITunesDB::writeDatabase ( const QString &  filename = QString()  ) 

Writes the (changed) database back to the ipod

Parameters:
filename the name of the file to be written. If no filename is given the database will be written to the file read whith open()
Returns:
true if writing the database was successful

bool ITunesDB::dbFileChanged (  )  const

Returns true if the itunesdb file has been changed thus needs to be reloaded or does not exist anymore

QString ITunesDB::getFilename (  )  const [inline]

Returns the name of the filename given with the open() call

ITunesDBPlaylist * ITunesDB::createNewPlaylist ( const QString &  title  ) 

Creates a new empty playlist

ITunesDBTrack * ITunesDB::createEmptyTrack ( Q_UINT32  trackid  ) 

Creates a new empty track

ITunesDBTrack * ITunesDB::createNewTrack ( const QString &  fileExtension = QString::null  ) 

Returns a new itunesdb::Track instance for adding a new track to the database. The new instance gets initialized with an unused trackid and trackpath. Subsequent calls will get itunesdb::Track with the same trackid until the returned track is as added via addTrack() thus a call to addTrack() has to be done afterwards.

Parameters:
fileExtension file extension of the file representing the track. If you don't know the file extension yet leave empty and set it with Track::setFileExtension() later

bool ITunesDB::addTrack ( ITunesDBTrack track  ) 

Adds a new track to the collection. This only adds the control information to the database, the track itself (the file) has to by copied by the user.

Parameters:
track the track to add to the database
Returns:
true if the track was successfully added

ITunesDBTrack * ITunesDB::getTrackByID ( const Q_UINT32  id  )  const

returns the Track corresponding to the given ID

Parameters:
id ID of the track
Returns:
the Track corresponding to the given ID

ITunesDBTrack * ITunesDB::findTrackByDBID ( const Q_UINT64  dbid  )  const

Returns the first track found with the given dbid

int ITunesDB::getMHITTrackPosFor ( Q_UINT32  id  )  const

Returns the MHIT position of the track with the given ID or -1 if there's no such track.

Parameters:
id ID of the track
Returns:
the position of the track in the MHIT section

ITunesDBTrack * ITunesDB::getTrackAt ( uint  mhitTrackPos  )  const

returns the Track at the specified position in the itunesdb

Parameters:
mhitTrackPos the position of the desired track
Returns:
the track at the specified position or NULL if the given position is out of range

ITunesDBTrack * ITunesDB::findFirstTrackBy ( itunesdb::TrackPredicate predicate  )  const

Returns the first Track where the given predicate returned true The given trackpredicate needs to contain a method that gets a track, and returns a bool if it's the desired track

Returns:
the first Track where the given predicate returned true
See also:
class TrackPredicate

ITunesDB::TrackIterator ITunesDB::getTracksBy ( itunesdb::TrackPredicate predicate  )  const

Returns all the Tracks where the given itunesdb::TrackPredicate returned true Be aware that the returned TrackIterator depends on the given predicate, so do not delete it as long as you need access to the Iterator

See also:
itunesdb::TrackPredicates for a list of predefined predicates

TrackPtrList * ITunesDB::getTracksBy ( itunesdb::TrackPredicate predicate,
itunesdb::TrackPtrList buffer 
) const

Returns all the Tracks where the given itunesdb::TrackPredicate returned true

See also:
itunesdb::TrackPredicates for a list of predefined predicates

ITunesDBTrack * ITunesDB::findTrack ( const QString &  artistname,
const QString &  albumname,
const QString &  title,
Q_UINT32  trackNum = 0 
) const

returns the Track found by the given information or NULL if no such Track could be found

Parameters:
artistname the name of the artist
albumname the name of the album
title the title of the track
trackNum the position of the track in its album
Returns:
the Track found or NULL if no track matched the given criteria.

QStringList * ITunesDB::getArtists ( QStringList &  buffer  )  const

Fills the given QStringList with the names of all artists in the database

Returns:
a pointer to the StringList

QStringList * ITunesDB::getAllAlbums ( QStringList &  buffer  )  const

Fills the given QStringList with the names of all albums in the database

QStringList * ITunesDB::getAlbumsByArtist ( const QString &  artistname,
QStringList &  buffer 
) const

Fills the given QStringList with the names of the albums by the given artist

Parameters:
artistname the name of the artist to look for
buffer the list to put the names of the albums found
Returns:
a pointer to the given QStringList or NULL if no such artist exists

bool ITunesDB::containsArtist ( const QString &  artistname  )  const

Returns true if the given artist exists.

Parameters:
artistname the artists name to check for.
Returns:
true if the artist exists, false otherwise.

bool ITunesDB::containsAlbum ( const QString &  artistname,
const QString &  albumname 
) const

Returns true if the given album exists.

Parameters:
artistname the artists name to check for
albumname the name of the album
Returns:
true if such an album exists for the given artist, false otherwise.

TrackPtrList * ITunesDB::getAllTracks ( itunesdb::TrackPtrList buffer  )  const

Returns a list with all the tracks in the database.

Parameters:
buffer the list to put the tracks into.
Returns:
the pointer to the given filled list

ITunesDB::TrackIterator ITunesDB::getAllTracks (  )  const

Returns a list with all the tracks in the database

TrackPtrList * ITunesDB::getAlbum ( const QString &  artistname,
const QString &  albumname,
itunesdb::TrackPtrList buffer 
) const

Returns an album by the given artistname and title.

Parameters:
artistname name of the artist of the album in question
albumname name of the album
buffer the list the tracks of the album will be put to
Returns:
a pointer to the given buffer or NULL if no such album could by found

TrackPtrList * ITunesDB::getTracksByArtist ( const QString &  artistname,
itunesdb::TrackPtrList buffer 
) const

Returns all the Tracks by the given artist.

Parameters:
artistname the name of the artist to look for.
buffer the list to put the found tracks into.
Returns:
the pointer to the given buffer or NULL if no such artist exists.

TrackPtrList * ITunesDB::getTracksContaining ( const QString &  someString,
itunesdb::TrackPtrList buffer,
bool  caseSensitive = true 
) const

Returns all tracks with the given string in its metadata (artist, album, title or composer)

Parameters:
someString the string to look for
buffer the list to put the found tracks into
caseSensitive set to false if uppercase/lowercase should be ignored
Returns:
the pointer to the given list or NULL if no such tracks exist.

QStringList * ITunesDB::getPlaylistTitles ( QStringList &  buffer  )  const

Returns a list with all playlist names

Parameters:
buffer the list to put the playlisttitles into
Returns:
the pointer to the given buffer

ITunesDBPlaylist * ITunesDB::getPlaylistByTitle ( const QString &  playlisttitle  )  const

Returns a playlist by the given playlist title.

Parameters:
playlisttitle title of the playlist in question
Returns:
a pointer to the playlist found or NULL if no such playlist exists

ITunesDBPlaylist * ITunesDB::getPlaylistByID ( Q_UINT64  playlistID  )  const

Returns the playlist by the given playlistID.

Parameters:
playlistID the DB ID of the desired playlist
Returns:
the playlist found or NULL if no such playlist could be found.

bool ITunesDB::removeArtist ( const QString &  artistname  ) 

Removes all the tracks of the given artist (an thus the artist itself) from the database.

Parameters:
artistname the name of the artist
Returns:
true if tracks were found and removed, false otherwise.

bool ITunesDB::renameAlbum ( const QString &  artist,
const QString &  title,
const QString &  newartist,
const QString &  newtitle 
)

Renames an album with the given title and artist to newtitle, newartist by changing the artist and album properties of all the tracks found by the given artist/album combination to newartist/newalbum.

Parameters:
artist the artist to look for
title the album to look for
newartist the new artist name to set. Give an empty or QString::null string if the artist property should remain unchanged.
newtitle the new album title to set. Give an empty or QString::null string if the album property should remain unchanged.
Returns:
true if tracks were found and changed, false otherwise

bool ITunesDB::addPlaylist ( ITunesDBPlaylist playlist  ) 

adds a new playlist to the database

bool ITunesDB::removePlaylist ( const QString &  title,
bool  delete_instance 
)

Removes the playlist with the given title

Parameters:
title the title of the playlist to be removed
delete_instance if set to true the element gets deleted during removal
Returns:
true if successful, otherwise false

void ITunesDB::updateSmartPlaylists (  ) 

Updates all Smart Playlists in this itunesdb instance.

Q_UINT32 ITunesDB::removeTrack ( Q_UINT32  trackid,
bool  delete_instance = true 
)

Removes the Track with the given trackid from the database. This also removes all playlist references to this track

Parameters:
trackid ID of the track to be deleted
delete_instance if set to true (default) the Track gets deleted during removal
Returns:
the trackid of the Track or 0 if no such Track exists

void ITunesDB::clear (  ) 

Wipes all data from the container.

bool ITunesDB::isDirty (  )  const

returns true if something in the container's control has been changed. a change to a Playlist or a Track for example will not set the change flag yet.

Q_UINT32 ITunesDB::getNumTracks (  )  const

Returns the number of tracks

Q_UINT32 ITunesDB::getNumPlaylists (  )  const

returns the number of playlists

void ITunesDB::lock ( bool  write_lock  ) 

Lock control functions to prevent concurrent access to the Database from different slaves

void ITunesDB::setTitle ( const QString &  title  ) 

sets the title of the mainlist

const QString& ITunesDB::getTitle (  )  const [inline]

Returns the title of the mainlist

Q_UINT32 ITunesDB::getNextFreeTrackID (  )  const

Returns the next free trackID for a new track

Q_UINT64 ITunesDB::getNextFreeDBID (  )  const

Returns the next available DBID.

QString ITunesDB::getFileForPathInfo ( QString  pathinfo  )  const

translates the pathinfo stored on the ipod to a real path info and adds the ipodBase path so we can access the real file. The caller needs to check if the file actually exists.

Returns:
the path pointing to the file.

const QString& ITunesDB::getIPodBase (  )  const [inline]

Returns the ipods base directory.


Member Data Documentation

ITunesDB::PlaylistContainer * ITunesDB::playlists [protected]

The container that holds all the playlist for this iTunesDB instance.


The documentation for this class was generated from the following files:
Generated on Tue Dec 12 16:39:27 2006 for libqtpod.kdevelop by  doxygen 1.5.1