X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Futils%2Fopenclipart.cpp;h=2130cba39dadfbb5a89c475f0e839d450b945920;hb=56aee6aedeeed3efd10ada8fe3c229eddc01ef05;hp=f0cf579cbf86e3584d3c77de52328ead0deae05e;hpb=ed051c6ed3bf047538f279da0b6b7ad8bd380038;p=kdenlive diff --git a/src/utils/openclipart.cpp b/src/utils/openclipart.cpp index f0cf579c..2130cba3 100644 --- a/src/utils/openclipart.cpp +++ b/src/utils/openclipart.cpp @@ -39,51 +39,49 @@ OpenClipArt::~OpenClipArt() { } -void OpenClipArt::slotStartSearch(const QString searchText, int page) +void OpenClipArt::slotStartSearch(const QString &searchText, int page) { m_listWidget->clear(); QString uri = "http://openclipart.org/api/search/?query="; uri.append(searchText); - if (page > 1) uri.append("&page=" + QString::number(page)); + if (page > 1) + uri.append("&page=" + QString::number(page)); KJob* resolveJob = KIO::storedGet( KUrl(uri), KIO::NoReload, KIO::HideProgressInfo ); - connect( resolveJob, SIGNAL( result( KJob* ) ), this, SLOT( slotShowResults( KJob* ) ) ); + connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(slotShowResults(KJob*)) ); } void OpenClipArt::slotShowResults(KJob* job) { if (job->error() != 0 ) return; - m_listWidget->blockSignals(true); - - + m_listWidget->blockSignals(true); KIO::StoredTransferJob* storedQueryJob = static_cast( job ); QDomDocument doc; - doc.setContent(storedQueryJob->data()); - QDomNodeList items = doc.documentElement().elementsByTagName("item"); - for (int i = 0; i < items.count(); i++) { - QDomElement currentClip = items.at(i).toElement(); - QDomElement title = currentClip.firstChildElement("title"); - QListWidgetItem *item = new QListWidgetItem(title.firstChild().nodeValue(), m_listWidget); - QDomElement thumb = currentClip.firstChildElement("media:thumbnail"); - item->setData(imageRole, thumb.attribute("url")); - emit gotThumb(thumb.attribute("url")); - QDomElement enclosure = currentClip.firstChildElement("enclosure"); - item->setData(downloadRole, enclosure.attribute("url")); - QDomElement link = currentClip.firstChildElement("link"); - item->setData(infoUrl, link.firstChild().nodeValue()); - QDomElement license = currentClip.firstChildElement("cc:license"); - item->setData(licenseRole, license.firstChild().nodeValue()); - QDomElement desc = currentClip.firstChildElement("description"); - item->setData(descriptionRole, desc.firstChild().nodeValue()); - QDomElement author = currentClip.firstChildElement("dc:creator"); - item->setData(authorRole, author.firstChild().nodeValue()); - item->setData(authorUrl, QString("http://openclipart.org/user-detail/") + author.firstChild().nodeValue()); - } - + doc.setContent(QString::fromAscii(storedQueryJob->data())); + QDomNodeList items = doc.documentElement().elementsByTagName("item"); + for (int i = 0; i < items.count(); ++i) { + QDomElement currentClip = items.at(i).toElement(); + QDomElement title = currentClip.firstChildElement("title"); + QListWidgetItem *item = new QListWidgetItem(title.firstChild().nodeValue(), m_listWidget); + QDomElement thumb = currentClip.firstChildElement("media:thumbnail"); + item->setData(imageRole, thumb.attribute("url")); + QDomElement enclosure = currentClip.firstChildElement("enclosure"); + item->setData(downloadRole, enclosure.attribute("url")); + QDomElement link = currentClip.firstChildElement("link"); + item->setData(infoUrl, link.firstChild().nodeValue()); + QDomElement license = currentClip.firstChildElement("cc:license"); + item->setData(licenseRole, license.firstChild().nodeValue()); + QDomElement desc = currentClip.firstChildElement("description"); + item->setData(descriptionRole, desc.firstChild().nodeValue()); + QDomElement author = currentClip.firstChildElement("dc:creator"); + item->setData(authorRole, author.firstChild().nodeValue()); + item->setData(authorUrl, QString("http://openclipart.org/user-detail/") + author.firstChild().nodeValue()); + } m_listWidget->blockSignals(false); m_listWidget->setCurrentRow(0); + emit searchDone(); } @@ -118,7 +116,9 @@ QString OpenClipArt::getDefaultDownloadName(QListWidgetItem *item) if (!item) return QString(); QString url = item->data(downloadRole).toString(); QString path = item->text(); - path.append("." + url.section('.', -1)); + path.append('.' + url.section('.', -1)); return path; } + +#include "openclipart.moc"