MediaArt::Info Class Reference

Describes particular media art. More...

#include <mediaartinfo.h>

Inheritance diagram for MediaArt::Info:

MediaArt::Album MediaArt::Artist MediaArt::Podcast MediaArt::Radio MediaArt::Track

List of all members.

Public Member Functions

const QString & type () const
 Returns type of particular media art.
const QUrl & potentialPath () const
 Returns potential path of image with media art.
bool exists () const
 Checks if media art exists.
bool remove () const
 Remove the content of media art.
 Info (const QString &b=QString(), const QString &c=QString(), const QString &type=QString())
 Constructs basic media art object.
 Info (const MediaArt::Info &src)
 Creates new MediaArt::Info object which is a copy of src.
 ~Info ()
 Destructs media art object.
bool setMediaArtImage (const QUrl &source, bool overwrite=false) const
 Sets the content of media art image.
bool setMediaArtImage (const QPixmap &source, bool overwrite=false) const
 Sets the content of media art image.

Static Public Attributes

static const QString Type
 Type of undefined media arts.

Protected Member Functions

void updatePath ()
 Builds a proper potential path.

Static Protected Member Functions

static QString md5 (const QString &src)
 Function which calculates MD5 of the string.
static QString stripInvalidEntities (const QString &src)
 Cleans up the string from invalid entities.

Protected Attributes

QString _b
 Private field for media art description - 1st part.
QString _c
 Private field for media art description - 2nd part.
QString _d
 Private field for media art description - 3rd part.
QString _type
 Type of media art.
QUrl _path
 Potential path to image with media art content.

Friends

uint qHash (MediaArt::Info const &mai)
 Hashing function for MediaArt::Info objects.
QDebug operator<< (QDebug dbg, const MediaArt::Info &mai)
 Simple operator to prints out MediaArt::Info objects.


Detailed Description

Describes particular media art.

Every resource (file, web page, internet radio) can have some additional data attached. For example for album You can have an album cover or image of the CD. For video file You can have a DVD cover or producer's logo. All of those are called Media Arts. It some kind of art connected with particular media source.
There are lots of media arts types: album art, artist art, podcast art, radio art, track art etc. You can even create Your own type of media art. In Thumbnailer library we are supporting only those mentioned above. Supporting means we have some special version of MediaArt::Info class which make it easier to work with particular media art type. So You can use:
MediaArt::Album - for ablum arts
MediaArt::Artist - for artist arts
MediaArt::Track - for track arts
MediaArt::Radio - for radio arts
MediaArt::Podcast - for podcast arts
See specified subclass documentation to check how to use it. Supporting DOES NOT mean that You will always get something for that type of media art. The content of media art cache depends on much more components (mainly tracker, but also every other application which will put something into the cache - see setMediaArtImage()).
MediaArt::Info (base) class allows You to represent every kind of media art and to check if there is such a media art available:

 MediaArt::Info album = MediaArt::Album("Queen", "Greatest Hits vol.1");
 if(album.exists()) {
        // here we know that there is a media art of type album for artist Queen
        // and album "Greatest Hits vol.1". You can get the media art from Url:
        doSomethingWithMediaArtFromURL(album.potentialPath());
 }
You can also put into that media art Your own data. Later on when we will be asking for that album art we will get this content. ALSO someone else who will be asking for that will receive it. This could be usefull if You know some source for possible media art of particular media, e.g. for podcast which You have already downloaded:
 MediaArt::Info podcast = MediaArt::Podcast("Funky House Londondstyle");
 if(!podcast.exists()) {
        // here we know that there is NO media art of type album for that podcast.
        // Lets put there some own data, e.g. image downloaded with the podcast
        podcast.setMediaArtImage(qpixmapWithMediaArtGotFromTheServer);
 }

Media art path is defined by the type of media art and media itself. If You know that info You would be able to check Yourself if that media art exists but MediaArt::Info is doing that for You - You do not need to worry about how files with media art are named, where they are placed and what kind of prefix they have:
 MediaArt::Info podcast = MediaArt::Podcast("Funky House Londondstyle");
 // proper URL to the media art file is...
 QUrl mediaArtUrl = podcast.potentialPath();
 // .. so file should be placed here:
 QString pathToMediaArt = mediaArtUrl.path();
In that example You do not care if You have created album, artist or podcast art. As far as you have MediaArt::Info object You can get path to media art (which could or could not exists - you can check it by calling exists())
You can also clear cache with media art by calling remove() function:
 MediaArt::Info podcast = MediaArt::Podcast("Funky House Londondstyle");
 podcast.remove()
 // from now on there is no media art with type podcast for "Funky House Londonstyle".

Constructor & Destructor Documentation

MediaArt::Info::Info ( const QString &  b = QString(),
const QString &  c = QString(),
const QString &  type = QString() 
)

Constructs basic media art object.

You should NOT use that constructor in Your code. You should work with dedicated classes for particular types of media arts!

Parameters:
b 1st part of media art description
c 2st part of media art description
type type of media art


Member Function Documentation

static QString MediaArt::Info::md5 ( const QString &  src  )  [static, protected]

Function which calculates MD5 of the string.

Parameters:
src string for which we want to get the checksum
Returns:
new string with checksum formatted properly

static QString MediaArt::Info::stripInvalidEntities ( const QString &  src  )  [static, protected]

Cleans up the string from invalid entities.

Specification

See also:
http://live.gnome.org/MediaArtStorageSpec specifies what shopuld be removed from strings in order to be a proper description of media art.
Parameters:
src string to be cleanuped
Returns:
new string which is clean version of src

void MediaArt::Info::updatePath (  )  [protected]

Builds a proper potential path.

If you are building Your own type of media art it is possible that You need to overwritte that method in order to build proper potential path.

Reimplemented in MediaArt::Track.

const QString& MediaArt::Info::type (  )  const

Returns type of particular media art.

Returns:
string with type of media art

const QUrl& MediaArt::Info::potentialPath (  )  const

Returns potential path of image with media art.

Returns:
url of place where potential image with media art is placed

bool MediaArt::Info::exists (  )  const

Checks if media art exists.

Returns:
true if that media art exists and there is some image connected with it. False if there is no content for that media art.

bool MediaArt::Info::remove (  )  const

Remove the content of media art.

Returns:
true if the content was deleted properly, false otherwise.

bool MediaArt::Info::setMediaArtImage ( const QUrl &  source,
bool  overwrite = false 
) const

Sets the content of media art image.

At some cases You will have some image that You will know that it is a media art for some particular media. You should put then that image into the media arts cache, so other application (and even You later) can received it by MediaArt::Info API.

Parameters:
source url to the file which should become the content of that media art
overwrite false mean that if there is already some content it will not be overwritten. true will force to do that - old content will be deleted and replaced with the source.
Returns:
true if operation was successful, false otherwise

bool MediaArt::Info::setMediaArtImage ( const QPixmap &  source,
bool  overwrite = false 
) const

Sets the content of media art image.

At some cases You will have some image that You will know that it is a media art for some particular media. You should put then that image into the media arts cache, so other application (and even You later) can received it by MediaArt::Info API.

Parameters:
source pixmap with image which should become the content of that media art
overwrite false mean that if there is already some content it will not be overwritten. true will force to do that - old content will be deleted and replaced with the source.
Returns:
true if operation was successful, false otherwise


The documentation for this class was generated from the following file:

Generated on Wed Oct 3 19:26:08 2012 for thumbnailer by  doxygen 1.5.6