#include <KDebug>
#include "kdenlivesettings.h"
#include <kio/job.h>
-#include <KLocale>
+#include <KLocalizedString>
#ifdef USE_QJSON
#include <qjson/parser.h>
FreeSound::~FreeSound()
{
- if (m_previewProcess) delete m_previewProcess;
+ delete m_previewProcess;
}
-void FreeSound::slotStartSearch(const QString searchText, int page)
+void FreeSound::slotStartSearch(const QString &searchText, int page)
{
m_listWidget->clear();
QString uri = "http://www.freesound.org/api/sounds/search/?q=";
uri.append(searchText);
- if (page > 1) uri.append("&p=" + QString::number(page));
+ if (page > 1)
+ uri.append("&p=" + QString::number(page));
uri.append("&api_key=a1772c8236e945a4bee30a64058dabf8");
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*)) );
}
QString extraInfoUrl = item->data(infoData).toString();
if (!extraInfoUrl.isEmpty()) {
KJob* resolveJob = KIO::storedGet( KUrl(extraInfoUrl), KIO::NoReload, KIO::HideProgressInfo );
- connect( resolveJob, SIGNAL( result( KJob* ) ), this, SLOT( slotParseResults( KJob* ) ) );
+ connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(slotParseResults(KJob*)) );
}
emit gotThumb(item->data(imageRole).toString());
return info;
KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
QJson::Parser parser;
bool ok;
- int ct = 0;
QString html = QString("<style type=\"text/css\">tr.cellone {background-color: %1;}</style>").arg(qApp->palette().alternateBase().color().name());
QVariant data = parser.parse(storedQueryJob->data(), &ok);
html += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
if (m_metaInfo.contains(i18n("Duration"))) {
- ct++;
- if (ct %2 == 0) {
- html += "<tr class=\"cellone\">";
- }
- else html += "<tr>";
+ html += "<tr>";
html += "<td>" + i18n("Duration") + "</td><td>" + m_metaInfo.value(i18n("Duration")) + "</td></tr>";
m_metaInfo.remove(i18n("Duration"));
}
if (infos.contains("samplerate")) {
- ct++;
- if (ct %2 == 0) {
- html += "<tr class=\"cellone\">";
- }
- else html += "<tr>";
+ html += "<tr class=\"cellone\">";
html += "<td>" + i18n("Samplerate") + "</td><td>" + QString::number(infos.value("samplerate").toDouble()) + "</td></tr>";
}
if (infos.contains("channels")) {
- ct++;
- if (ct %2 == 0) {
- html += "<tr class=\"cellone\">";
- }
- else html += "<tr>";
+ html += "<tr>";
html += "<td>" + i18n("Channels") + "</td><td>" + QString::number(infos.value("channels").toInt()) + "</td></tr>";
}
if (infos.contains("filesize")) {
- ct++;
- if (ct %2 == 0) {
- html += "<tr class=\"cellone\">";
- }
- else html += "<tr>";
+ html += "<tr class=\"cellone\">";
KIO::filesize_t fSize = infos.value("filesize").toDouble();
html += "<td>" + i18n("File size") + "</td><td>" + KIO::convertSize(fSize) + "</td></tr>";
}
bool FreeSound::startItemPreview(QListWidgetItem *item)
{
- if (!item) return false;
- QString url = item->data(previewRole).toString();
- if (url.isEmpty()) return false;
+ if (!item)
+ return false;
+ const QString url = item->data(previewRole).toString();
+ if (url.isEmpty())
+ return false;
if (m_previewProcess && m_previewProcess->state() != QProcess::NotRunning) {
m_previewProcess->close();
}
QString FreeSound::getExtension(QListWidgetItem *item)
{
- if (!item) return QString();
+ if (!item)
+ return QString();
return QString("*.") + item->text().section('.', -1);
}
QString FreeSound::getDefaultDownloadName(QListWidgetItem *item)
{
- if (!item) return QString();
+ if (!item)
+ return QString();
return item->text();
}
+
+#include "freesound.moc"