#include <mediaartrequester.h>
Signals | |
void | started () |
Signals the processing hte request has started. | |
void | finished () |
Signals that request is finished. | |
void | mediaArt (const MediaArt::Info &mai, const QUrl &path, const QPixmap &pixmap) |
Signals that media art content is available. | |
void | defaultMediaArt (const MediaArt::Info &mai, const QUrl &path, const QPixmap &pixmap) |
Signal with default content for media art. | |
void | error (const QString &message, const MediaArt::Info &mai) |
Signals that there was some problem with media art. | |
void | unqueued (const MediaArt::Info &mai) |
Signals that some media art request was unqueued. | |
Public Member Functions | |
Requester (QUrl defaultPath=QUrl(), QPixmap defaultPixmap=QPixmap()) | |
Create a new Requester object. | |
~Requester () | |
Default destructor for requester. | |
void | setDefaultPath (const QUrl &path) |
Sets current default URL. | |
void | setDefaultPixmap (const QPixmap &pixmap) |
Sets current default pixmap. | |
const QUrl | defaultPath () const |
Returns current default URL. | |
const QPixmap | defaultPixmap () const |
Gives current default pixmap. | |
void | cancel (bool sendRemainingSignals=false) |
Cancel all currently running requests. | |
bool | request (QList< Info > &list, bool sendPixmap=false) |
Make a request for media arts. | |
Friends | |
class | MediaArtRequesterPrivate |
Thumbnails::Thumbnailer class documentation to get know how requesting for thumbnails is working - requesting for media arts is very similar.
Simplest example how to use MediaArt::Requester:
// we have some list of MediaArt::Info objects: MediaArt::Info album = MediaArt::Album("Artist A", "Album A"); MediaArt::Info track = MediaArt::Track("Artist A", "Album A", "Track 01"); MediaArt::Info podcast = MediaArt::Podcast("Funky Londonstyle"); QList<MediaArt::Info> listOfMedia; listOfMedia << album << track << podcast // now we are creating requester object (and we do not care about default values): MediaArt::Requester* requester = new MediaArt::Requester(); // connecting requester's signal to our slot: QObject::connect ( requester, SIGNAL(mediaArt(MediaArt::Info,QUrl,QPixmap)), this, SLOT(mediaArt(MediaArt::Info,QUrl,QPixmap)) ); // and makes a request: requester->request(listOfMedia); // You should have a mediaArt slot in You class which could look like this: void mediaArt(const MediaArt::Info& mai, const QUrl& url, const QPixmap& pixmap) { // it means there is a new media art's content - url for that content // is in url parameter. If You requested also for loading pixmaps // the pixmap with the content is in pixmap parameter. qDebug() << "There is a new media art's content in path:" << url.path(); // if You requested also for pixmap (requester->request(list, true)): someLabel->setPixmap(pixmap); }
MediaArt::Requester::Requester | ( | QUrl | defaultPath = QUrl() , |
|
QPixmap | defaultPixmap = QPixmap() | |||
) |
Create a new Requester object.
Builds a new Requester object. After object is built developer can start making requests stright away.
defaultPath | url which should be used as a default url returned in defaultMediaArt signal | |
defaultPixmap | pixmap which should be used as a default pixmap returned in defaultMediaArt signals |
void MediaArt::Requester::setDefaultPath | ( | const QUrl & | path | ) |
Sets current default URL.
When there is no real media art content for particular media art, Requester will send defaultMediaArt signal with default values: url and pixmap.
path | url to be used as a default one |
void MediaArt::Requester::setDefaultPixmap | ( | const QPixmap & | pixmap | ) |
Sets current default pixmap.
When there is no real media art content for particular media art, Requester will send defaultMediaArt signal with default values: url and pixmap.
pixmap | image to be used as a default one |
const QUrl MediaArt::Requester::defaultPath | ( | ) | const |
Returns current default URL.
const QPixmap MediaArt::Requester::defaultPixmap | ( | ) | const |
Gives current default pixmap.
void MediaArt::Requester::cancel | ( | bool | sendRemainingSignals = false |
) |
Cancel all currently running requests.
When there are some requests running and You are not interested anymore in the results You should call this method to reduce CPU usage. It will stop processing all requests.
sendRemainingSignals | if true Requester will send dequeueud signal for every not processed media art; otherwise You will receive only finished signal. |
bool MediaArt::Requester::request | ( | QList< Info > & | list, | |
bool | sendPixmap = false | |||
) |
Make a request for media arts.
Starts a request for content of list of media arts. In one request there could be mixed all kind of media arts (so it does not need to be a list with only albyum arts or artist arts).
Please note, that Requester returns You a media art itself, not a thumbnail of it. For thumbnails please use Thumbnails::Thumbnailer class.
list | a list of media art we want to request for | |
sendPixmap | set to true if You want Requester to load every image and send it in mediaArt signal. Setting this to true makes Requester to work much longer. When setting this to true You need to remember that You do not have any influence how images are loaded. |
void MediaArt::Requester::started | ( | ) | [signal] |
void MediaArt::Requester::finished | ( | ) | [signal] |
Signals that request is finished.
Signals that some request is finished and there will not be any other signal connected to that media art request.
void MediaArt::Requester::mediaArt | ( | const MediaArt::Info & | mai, | |
const QUrl & | path, | |||
const QPixmap & | pixmap | |||
) | [signal] |
Signals that media art content is available.
This signal is emitted when some media art's content is available.
mai | media art for which content was found | |
path | url to the media art content (image) | |
pixmap | pixmap with the image (it is filled only when you called request() with sendPixmap set to true) |
void MediaArt::Requester::defaultMediaArt | ( | const MediaArt::Info & | mai, | |
const QUrl & | path, | |||
const QPixmap & | pixmap | |||
) | [signal] |
Signal with default content for media art.
This signal is emitted when media art's content was not available at the call time and we need to spend some time trying to find this media art. It means that after some time You will receive for the same MediaArt::Info object one of:
mediaArt() if content will be found
error() if Requester will not able to find any content for media art.
mai | media art for which default content is signaled | |
path | default url for the media art | |
pixmap | default pixmap with the image for media art (it is filled only when you called request() with sendPixmap set to true) |
void MediaArt::Requester::error | ( | const QString & | message, | |
const MediaArt::Info & | mai | |||
) | [signal] |
Signals that there was some problem with media art.
This signals that the content for particular media art is not possible to be retrieved.
message | information with the reason why media art's content is not possible to be returned | |
mai | media art with wich that error is connected |
void MediaArt::Requester::unqueued | ( | const MediaArt::Info & | mai | ) | [signal] |
Signals that some media art request was unqueued.
Signals that particular media art was uqueued from the request. It means that there will not be any other signals for that media art.
mai | media art which is abandoned in the request |