#include <itunesdb.h>
Inheritance diagram for ITunesDB:
Public Types | |
typedef itunesdb::utils::SortablePtrVector< ITunesDBTrack > | TrackList |
typedef FilteredTrackConstIterator | TrackConstIterator |
typedef FilteredTrackConstIterator< itunesdb::TrackPredicates::ByAlbum > | AlbumIterator |
typedef FilteredTrackConstIterator< itunesdb::TrackPredicates::ByArtist > | ArtistIterator |
typedef FilteredTrackConstIterator< itunesdb::TrackPredicates::Contains > | ContainsIterator |
Public Member Functions | |
ITunesDB (IPodSysInfo &ipodSysInfo) | |
bool | open () |
Opens the itunesdb file at the given ipod mountpoint. | |
bool | isOpen () |
Returns true if open() has already been successfully called. | |
bool | writeDatabase (const QString &filename=QString()) |
Writes the (changed) database back to the ipod. | |
bool | dbFileChanged () const |
Returns true if the itunesdb file has been changed thus needs to be reloaded or does not exist anymore. | |
QString | getFilename () const |
Returns the name of the filename given with the open() call. | |
ITunesDBPlaylist * | createNewPlaylist (const QString &title) |
Creates a new empty playlist. | |
ITunesDBTrack * | createEmptyTrack (Q_UINT32 trackid) |
Creates a new empty track. | |
ITunesDBTrack * | createNewTrack (const QString &fileExtension=QString::null) |
Returns a new itunesdb::Track instance for adding a new track to the database. | |
bool | addTrack (ITunesDBTrack *track) |
Adds a new track to the database. | |
ITunesDBTrack * | getTrackByID (const Q_UINT32 id) const |
Returns the Track corresponding to the given ID. | |
ITunesDBTrack * | findTrackByDBID (const Q_UINT64 dbid) const |
Returns the first track found with the given dbid. | |
int | getMHITTrackPosFor (Q_UINT32 id) const |
Returns the MHIT position of the track with the given ID. | |
ITunesDBTrack * | getTrackAt (uint mhitTrackPos) const |
Returns the Track at the specified position in the itunesdb. | |
ITunesDBTrack * | findFirstTrackBy (const itunesdb::TrackPredicate &predicate) const |
Returns the first Track where the given predicate returned true. | |
itunesdb::TrackPtrList * | getTracksBy (const itunesdb::TrackPredicate &predicate, itunesdb::TrackPtrList &buffer) const |
Returns all the Tracks where the given itunesdb::TrackPredicate returned true. | |
template<typename TrackPredicate_T> | |
FilteredTrackConstIterator< TrackPredicate_T > | getTracksBy (const TrackPredicate_T &predicate) const |
Returns all the Tracks where the given itunesdb::TrackPredicate returns true. | |
ITunesDBTrack * | 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. | |
QStringList * | getArtists (QStringList &buffer) const |
Fills the given QStringList with the names of all artists in the database. | |
QStringList * | getAllAlbums (QStringList &buffer) const |
Fills the given QStringList with the names of all albums in the database. | |
QStringList * | getAlbumsByArtist (const QString &artistname, QStringList &buffer) const |
Fills the given QStringList with the names of the albums by the given artist. | |
bool | containsArtist (const QString &artistname) const |
Returns true if the given artist exists. | |
bool | containsAlbum (const QString &artistname, const QString &albumname) const |
Returns true if the given album exists. | |
itunesdb::TrackPtrList * | getAllTracks (itunesdb::TrackPtrList &buffer) const |
Fills the given TrackPtrList with all itunesdb::Track instances in the database. | |
TrackConstIterator | getAllTracks () const |
Returns an Iterator over all the tracks in the database. | |
itunesdb::TrackPtrList * | getAlbum (const QString &artistname, const QString &albumname, itunesdb::TrackPtrList &buffer) const |
Returns an album by the given artistname and title. | |
AlbumIterator | getAlbum (const QString &artistname, const QString &albumname) const |
Returns all the tracks matching the given artist and album. | |
itunesdb::TrackPtrList * | getTracksByArtist (const QString &artistname, itunesdb::TrackPtrList &buffer) const |
Returns all the Tracks by the given artist. | |
ArtistIterator | getTracksByArtist (const QString &artistname) const |
Returns all the tracks matching the given artistname. | |
itunesdb::TrackPtrList * | getTracksContaining (const QString &someString, itunesdb::TrackPtrList &buffer, bool caseSensitive=true) const |
Returns all tracks with the given string in its metadata. | |
ContainsIterator | getTracksContaining (const QString &someString, bool caseSensitive=true) const |
Returns all tracks with the given string in its metadata (artist, album, title or composer). | |
QStringList * | getPlaylistTitles (QStringList &buffer) const |
Returns a list with all playlist names. | |
ITunesDBPlaylist * | getPlaylistByTitle (const QString &playlisttitle) const |
Returns a playlist by the given playlist title. | |
ITunesDBPlaylist * | getPlaylistByID (Q_UINT64 playlistID) const |
Returns the playlist by the given playlistID. | |
bool | removeArtist (const QString &artistname) |
Removes all the tracks of the given artist (an thus the artist itself) from the database. | |
bool | renameAlbum (const QString &artist, const QString &title, const QString &newartist, const QString &newtitle) |
Renames an album with the given title and artist. | |
bool | addPlaylist (ITunesDBPlaylist *playlist) |
Adds a new playlist to the database. | |
bool | removePlaylist (const QString &title, bool delete_instance) |
Removes the playlist with the given title. | |
void | updateSmartPlaylists () |
Updates all Smart Playlists in this itunesdb instance. | |
Q_UINT32 | removeTrack (Q_UINT32 trackid, bool delete_instance=true) |
Removes the Track with the given trackid from the database. | |
void | clear () |
Wipes all data from the container. | |
bool | isDirty () const |
Returns true if something in the container's control has been changed. | |
Q_UINT32 | getNumTracks () const |
Returns the number of tracks. | |
Q_UINT32 | getNumPlaylists () const |
Returns the number of playlists. | |
void | lock (bool write_lock) |
Lock control functions to prevent concurrent access to the Database from different instances. | |
void | unlock () |
bool | isLocked () const |
uint | lastModified () |
Returns the timestamp the database file was modified. | |
void | setTitle (const QString &title) |
sets the title of the database | |
const QString & | getTitle () const |
Returns the title of the database. | |
bool | hasPodcasts () const |
Returns true if the database contains podcasts. | |
Q_UINT32 | getNextFreeTrackID () const |
Returns the next free trackID for a new track. | |
Q_UINT64 | getNextFreeDBID () const |
Returns the next available DBID. | |
QString | getFileForPathInfo (QString pathinfo) const |
Returns the fully qualified path for the given ipod path information. | |
const QString & | getIPodBase () const |
Returns the ipod's base directory. | |
Public Attributes | |
QString | error |
Protected Member Functions | |
void | setDirty (bool dirtyFlag=true) |
ITunesDBTrack * | insertTrackToDataBase (ITunesDBTrack *track) |
Protected Attributes | |
TrackIDMap | m_TrackIdMap |
TrackList | m_TrackList |
QString | m_Title |
ITunesDB::PlaylistContainer * | m_playlists |
bool | m_dirty |
Q_UINT32 | maxtrackid |
Q_UINT64 | mMaxDBID |
Friends | |
class | ITunesDBPlaylist |
class | ITunesDBSPLRuleSet |
class | ITunesDBTrack |
Classes | |
struct | FilteredTrackConstIterator |
An Iterator over a sequence of ITunesDBTrack instances. More... | |
class | ItunesDBReaderAdapter |
class | ItunesDBWriterAdapter |
class | PlaylistContainer |
bool ITunesDB::open | ( | ) |
Opens the itunesdb file at the given ipod mountpoint.
bool ITunesDB::isOpen | ( | ) |
Returns true if open() has already been successfully called.
bool ITunesDB::writeDatabase | ( | const QString & | filename = QString() |
) |
Writes the (changed) database back to the ipod.
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() |
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 | ) |
ITunesDBTrack * ITunesDB::createEmptyTrack | ( | Q_UINT32 | trackid | ) |
Creates a new empty track.
Only use this function if you know what you're doing.
trackid | the id of the new track in the database. |
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.
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 database.
This only adds the control information to the database, the track itself (the file) has to by copied by the calling application.
track | the track to add to the database |
ITunesDBTrack * ITunesDB::getTrackByID | ( | const Q_UINT32 | id | ) | const |
Returns the Track corresponding to the given ID.
id | ID of the track |
ITunesDBTrack * ITunesDB::findTrackByDBID | ( | const Q_UINT64 | dbid | ) | const |
Returns the first track found with the given dbid.
dbid | the 64bit DBID being unique for all objects in the database |
int ITunesDB::getMHITTrackPosFor | ( | Q_UINT32 | id | ) | const |
Returns the MHIT position of the track with the given ID.
id | ID of the track |
ITunesDBTrack * ITunesDB::getTrackAt | ( | uint | mhitTrackPos | ) | const |
Returns the Track at the specified position in the itunesdb.
mhitTrackPos | the position of the desired track |
ITunesDBTrack * ITunesDB::findFirstTrackBy | ( | const 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
TrackPtrList * ITunesDB::getTracksBy | ( | const itunesdb::TrackPredicate & | predicate, | |
itunesdb::TrackPtrList & | buffer | |||
) | const |
Returns all the Tracks where the given itunesdb::TrackPredicate
returned true.
More formally the method fills in the Tracks where the given itunesdb::TrackPredicate
returned true into the given TrackPtrList and returns a pointer to the list if at least one track got added.
itunesdb::TrackPredicates for a list of predefined predicates
FilteredTrackConstIterator<TrackPredicate_T> ITunesDB::getTracksBy | ( | const TrackPredicate_T & | predicate | ) | const [inline] |
Returns all the Tracks where the given itunesdb::TrackPredicate
returns true.
The next() method of the returned Iterator delivers pointers to ITunesDBTrack instances
itunesdb::TrackPredicate
returns true 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.
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 |
QStringList * ITunesDB::getArtists | ( | QStringList & | buffer | ) | const |
Fills the given QStringList with the names of all artists in the database.
buffer | a QStringList to fill in the artist names |
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.
artistname | the name of the artist to look for | |
buffer | the list to put the names of the albums found |
bool ITunesDB::containsArtist | ( | const QString & | artistname | ) | const |
Returns true if the given artist exists.
artistname | the artists name to check for. |
bool ITunesDB::containsAlbum | ( | const QString & | artistname, | |
const QString & | albumname | |||
) | const |
Returns true if the given album exists.
artistname | the artists name to check for | |
albumname | the name of the album |
TrackPtrList * ITunesDB::getAllTracks | ( | itunesdb::TrackPtrList & | buffer | ) | const |
Fills the given TrackPtrList with all itunesdb::Track instances in the database.
Fills the given TrackPtrList with all itunesdb::Track instances in the database and returns a pointer to the given list.
buffer | the list to put the tracks into. |
TrackConstIterator ITunesDB::getAllTracks | ( | ) | const [inline] |
Returns an Iterator over 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.
This method fills in all tracks matching the given artist/album information to the given TrackPtrList
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 |
AlbumIterator ITunesDB::getAlbum | ( | const QString & | artistname, | |
const QString & | albumname | |||
) | const [inline] |
Returns all the tracks matching the given artist and album.
artistname | name of the artist of the album in question | |
albumname | name of the album |
TrackPtrList * ITunesDB::getTracksByArtist | ( | const QString & | artistname, | |
itunesdb::TrackPtrList & | buffer | |||
) | const |
Returns all the Tracks by the given artist.
This method fills in all tracks matching the artist to the given TrackPtrList
artistname | the name of the artist to look for. | |
buffer | the list to put the found tracks into. |
ArtistIterator ITunesDB::getTracksByArtist | ( | const QString & | artistname | ) | const [inline] |
Returns all the tracks matching the given artistname.
artistname | the name of the artist to look for. |
TrackPtrList * ITunesDB::getTracksContaining | ( | const QString & | someString, | |
itunesdb::TrackPtrList & | buffer, | |||
bool | caseSensitive = true | |||
) | const |
Returns all tracks with the given string in its metadata.
This method fills in all tracks matching the given String in its metadata (artist, album, title or composer) to the TrackPtrList.
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 |
ContainsIterator ITunesDB::getTracksContaining | ( | const QString & | someString, | |
bool | caseSensitive = true | |||
) | const [inline] |
Returns all tracks with the given string in its metadata (artist, album, title or composer).
someString | the string to look for | |
caseSensitive | set to false if uppercase/lowercase should be ignored |
QStringList * ITunesDB::getPlaylistTitles | ( | QStringList & | buffer | ) | const |
Returns a list with all playlist names.
buffer | the list to put the playlisttitles into |
ITunesDBPlaylist * ITunesDB::getPlaylistByTitle | ( | const QString & | playlisttitle | ) | const |
Returns a playlist by the given playlist title.
playlisttitle | title of the playlist in question |
ITunesDBPlaylist * ITunesDB::getPlaylistByID | ( | Q_UINT64 | playlistID | ) | const |
Returns the playlist by the given playlistID.
playlistID | the DB ID of the desired playlist |
bool ITunesDB::removeArtist | ( | const QString & | artistname | ) |
Removes all the tracks of the given artist (an thus the artist itself) from the database.
artistname | the name of the artist |
bool ITunesDB::renameAlbum | ( | const QString & | artist, | |
const QString & | title, | |||
const QString & | newartist, | |||
const QString & | newtitle | |||
) |
Renames an album with the given title and artist.
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.
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. |
bool ITunesDB::addPlaylist | ( | ITunesDBPlaylist * | playlist | ) |
Adds a new playlist to the database.
playlist | The playlist to be added to the database. |
bool ITunesDB::removePlaylist | ( | const QString & | title, | |
bool | delete_instance | |||
) |
Removes the playlist with the given title.
title | the title of the playlist to be removed | |
delete_instance | if set to true the element gets deleted during removal |
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
trackid | ID of the track to be deleted | |
delete_instance | if set to true (default) the Track gets deleted during removal |
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 |
void ITunesDB::lock | ( | bool | write_lock | ) |
Lock control functions to prevent concurrent access to the Database from different instances.
uint ITunesDB::lastModified | ( | ) | [inline] |
Returns the timestamp the database file was modified.
void ITunesDB::setTitle | ( | const QString & | title | ) |
sets the title of the database
The title will be stored as the title of the main track list
title | the new title for the database |
const QString& ITunesDB::getTitle | ( | ) | const [inline] |
Returns the title of the database.
bool ITunesDB::hasPodcasts | ( | ) | const [inline] |
Returns true if the database contains podcasts.
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 |
Returns the fully qualified path for the given ipod path information.
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.
pathinfo | the path property in database items |
const QString& ITunesDB::getIPodBase | ( | ) | const [inline] |
Returns the ipod's base directory.
ITunesDB::PlaylistContainer * ITunesDB::m_playlists [protected] |
The container that holds all the playlist for this iTunesDB instance.