Unbreak coverfetcher.

This commit is contained in:
Tobias Rundstrom 2006-03-07 19:36:02 -03:00
parent 2ed2234013
commit dec1b66342
2 changed files with 23 additions and 6 deletions

View file

@ -60,6 +60,8 @@ MedialibWindow::MedialibWindow (QWidget *parent) : QMainWindow (parent)
m_http = new QHttp (this); m_http = new QHttp (this);
connect (m_http, SIGNAL (requestFinished (int, bool)), this, connect (m_http, SIGNAL (requestFinished (int, bool)), this,
SLOT (httpDone (int, bool))); SLOT (httpDone (int, bool)));
connect (m_http, SIGNAL (requestStarted (int)), this,
SLOT (httpDone (int)));
/*** artist ***/ /*** artist ***/
m_artist = new MediaArtistList (this, "artist"); m_artist = new MediaArtistList (this, "artist");
@ -116,28 +118,42 @@ MedialibWindow::settingsSaved ()
void void
MedialibWindow::addRequest (QUrl url, MedialibListItem *item) MedialibWindow::addRequest (QUrl url, MedialibListItem *item)
{ {
m_http->setHost (url.host (), url.port () != 1 ? url.port () : 80); m_http->setHost (url.host (), url.port () != -1 ? url.port () : 80);
if (!url.userName().isEmpty()) { if (!url.userName().isEmpty()) {
m_http->setUser (url.userName(), url.password()); m_http->setUser (url.userName(), url.password());
} }
int id = m_http->get (url.path (), item->getFile ()); int id = m_http->get (url.path (), item->getFile ());
m_httpmap[id] = item; m_httpmap.insert (id, item);
qDebug ("add request %s (%d)", qPrintable (url.path ()), id); }
void
MedialibWindow::httpStarted (int id)
{
MedialibListItem *it = m_httpmap[id];
if (it) {
setStatusText ("Downloading art: " + it->text ());
}
} }
void void
MedialibWindow::httpDone (int id, bool error) MedialibWindow::httpDone (int id, bool error)
{ {
MedialibListItem *it = m_httpmap[id];
if (error) { if (error) {
qWarning ("error!"); if (it) {
setStatusText ("Error when downloading " + it->text ());
} else {
setStatusText ("Generic error in HTTP");
}
qDebug (qPrintable (m_http->errorString ()));
return; return;
} }
MedialibListItem *it = m_httpmap[id];
if (it) { if (it) {
QFile *f = it->getFile (); QFile *f = it->getFile ();
f->close (); f->close ();

View file

@ -120,6 +120,7 @@ class MedialibWindow : public QMainWindow
public slots: public slots:
void httpDone (int, bool); void httpDone (int, bool);
void httpStarted (int);
void settingsSaved (void); void settingsSaved (void);
private: private: