summaryrefslogtreecommitdiffstats
path: root/src/fetch/discogsfetcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fetch/discogsfetcher.cpp')
-rw-r--r--src/fetch/discogsfetcher.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/src/fetch/discogsfetcher.cpp b/src/fetch/discogsfetcher.cpp
index 31a8bab..a92219a 100644
--- a/src/fetch/discogsfetcher.cpp
+++ b/src/fetch/discogsfetcher.cpp
@@ -27,10 +27,10 @@
#include <kconfig.h>
#include <kio/job.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qfile.h>
-#include <qwhatsthis.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqfile.h>
+#include <tqwhatsthis.h>
//#define DISCOGS_TEST
@@ -42,10 +42,10 @@ namespace {
using Tellico::Fetch::DiscogsFetcher;
-DiscogsFetcher::DiscogsFetcher(QObject* parent_, const char* name_)
- : Fetcher(parent_, name_), m_xsltHandler(0),
+DiscogsFetcher::DiscogsFetcher(TQObject* tqparent_, const char* name_)
+ : Fetcher(tqparent_, name_), m_xsltHandler(0),
m_limit(DISCOGS_MAX_RETURNS_TOTAL), m_job(0), m_started(false),
- m_apiKey(QString::fromLatin1(DISCOGS_API_KEY)) {
+ m_apiKey(TQString::tqfromLatin1(DISCOGS_API_KEY)) {
}
DiscogsFetcher::~DiscogsFetcher() {
@@ -53,11 +53,11 @@ DiscogsFetcher::~DiscogsFetcher() {
m_xsltHandler = 0;
}
-QString DiscogsFetcher::defaultName() {
+TQString DiscogsFetcher::defaultName() {
return i18n("Discogs Audio Search");
}
-QString DiscogsFetcher::source() const {
+TQString DiscogsFetcher::source() const {
return m_name.isEmpty() ? defaultName() : m_name;
}
@@ -66,7 +66,7 @@ bool DiscogsFetcher::canFetch(int type) const {
}
void DiscogsFetcher::readConfigHook(const KConfigGroup& config_) {
- QString k = config_.readEntry("API Key");
+ TQString k = config_.readEntry("API Key");
if(!k.isEmpty()) {
m_apiKey = k;
}
@@ -74,7 +74,7 @@ void DiscogsFetcher::readConfigHook(const KConfigGroup& config_) {
m_fields = config_.readListEntry("Custom Fields");
}
-void DiscogsFetcher::search(FetchKey key_, const QString& value_) {
+void DiscogsFetcher::search(FetchKey key_, const TQString& value_) {
m_key = key_;
m_value = value_;
m_started = true;
@@ -89,31 +89,31 @@ void DiscogsFetcher::continueSearch() {
}
void DiscogsFetcher::doSearch() {
- KURL u(QString::fromLatin1(DISCOGS_API_URL));
- u.addQueryItem(QString::fromLatin1("f"), QString::fromLatin1("xml"));
- u.addQueryItem(QString::fromLatin1("api_key"), m_apiKey);
+ KURL u(TQString::tqfromLatin1(DISCOGS_API_URL));
+ u.addQueryItem(TQString::tqfromLatin1("f"), TQString::tqfromLatin1("xml"));
+ u.addQueryItem(TQString::tqfromLatin1("api_key"), m_apiKey);
if(!canFetch(Kernel::self()->collectionType())) {
- message(i18n("%1 does not allow searching for this collection type.").arg(source()), MessageHandler::Warning);
+ message(i18n("%1 does not allow searching for this collection type.").tqarg(source()), MessageHandler::Warning);
stop();
return;
}
switch(m_key) {
case Title:
- u.setPath(QString::fromLatin1("/search"));
- u.addQueryItem(QString::fromLatin1("q"), m_value);
- u.addQueryItem(QString::fromLatin1("type"), QString::fromLatin1("release"));
+ u.setPath(TQString::tqfromLatin1("/search"));
+ u.addQueryItem(TQString::tqfromLatin1("q"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("type"), TQString::tqfromLatin1("release"));
break;
case Person:
- u.setPath(QString::fromLatin1("/artist/%1").arg(m_value));
+ u.setPath(TQString::tqfromLatin1("/artist/%1").tqarg(m_value));
break;
case Keyword:
- u.setPath(QString::fromLatin1("/search"));
- u.addQueryItem(QString::fromLatin1("q"), m_value);
- u.addQueryItem(QString::fromLatin1("type"), QString::fromLatin1("all"));
+ u.setPath(TQString::tqfromLatin1("/search"));
+ u.addQueryItem(TQString::tqfromLatin1("q"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("type"), TQString::tqfromLatin1("all"));
break;
default:
@@ -123,15 +123,15 @@ void DiscogsFetcher::doSearch() {
}
#ifdef DISCOGS_TEST
- u = KURL(QString::fromLatin1("/home/robby/discogs-results.xml"));
+ u = KURL(TQString::tqfromLatin1("/home/robby/discogs-results.xml"));
#endif
// myDebug() << "DiscogsFetcher::search() - url: " << u.url() << endl;
m_job = KIO::get(u, false, false);
- connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
- SLOT(slotData(KIO::Job*, const QByteArray&)));
- connect(m_job, SIGNAL(result(KIO::Job*)),
- SLOT(slotComplete(KIO::Job*)));
+ connect(m_job, TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)),
+ TQT_SLOT(slotData(KIO::Job*, const TQByteArray&)));
+ connect(m_job, TQT_SIGNAL(result(KIO::Job*)),
+ TQT_SLOT(slotComplete(KIO::Job*)));
}
void DiscogsFetcher::stop() {
@@ -147,8 +147,8 @@ void DiscogsFetcher::stop() {
emit signalDone(this);
}
-void DiscogsFetcher::slotData(KIO::Job*, const QByteArray& data_) {
- QDataStream stream(m_data, IO_WriteOnly | IO_Append);
+void DiscogsFetcher::slotData(KIO::Job*, const TQByteArray& data_) {
+ TQDataStream stream(m_data, IO_WriteOnly | IO_Append);
stream.writeRawBytes(data_.data(), data_.size());
}
@@ -168,11 +168,11 @@ void DiscogsFetcher::slotComplete(KIO::Job* job_) {
#if 0
kdWarning() << "Remove debug from discogsfetcher.cpp" << endl;
- QFile f(QString::fromLatin1("/tmp/test.xml"));
+ TQFile f(TQString::tqfromLatin1("/tmp/test.xml"));
if(f.open(IO_WriteOnly)) {
- QTextStream t(&f);
- t.setEncoding(QTextStream::UnicodeUTF8);
- t << QCString(m_data, m_data.size()+1);
+ TQTextStream t(&f);
+ t.setEncoding(TQTextStream::UnicodeUTF8);
+ t << TQCString(m_data, m_data.size()+1);
}
f.close();
#endif
@@ -186,23 +186,23 @@ void DiscogsFetcher::slotComplete(KIO::Job* job_) {
}
if(m_total == -1) {
- QDomDocument dom;
+ TQDomDocument dom;
if(!dom.setContent(m_data, false)) {
kdWarning() << "DiscogsFetcher::slotComplete() - server did not return valid XML." << endl;
return;
}
// total is /resp/searchresults/@numResults
- QDomNode n = dom.documentElement().namedItem(QString::fromLatin1("resp"))
- .namedItem(QString::fromLatin1("searchresults"));
- QDomElement e = n.toElement();
+ TQDomNode n = dom.documentElement().namedItem(TQString::tqfromLatin1("resp"))
+ .namedItem(TQString::tqfromLatin1("searchresults"));
+ TQDomElement e = n.toElement();
if(!e.isNull()) {
- m_total = e.attribute(QString::fromLatin1("numResults")).toInt();
+ m_total = e.attribute(TQString::tqfromLatin1("numResults")).toInt();
myDebug() << "total = " << m_total;
}
}
// assume discogs is always utf-8
- QString str = m_xsltHandler->applyStylesheet(QString::fromUtf8(m_data, m_data.size()));
+ TQString str = m_xsltHandler->applyStylesheet(TQString::fromUtf8(m_data, m_data.size()));
Import::TellicoImporter imp(str);
Data::CollPtr coll = imp.collection();
if(!coll) {
@@ -218,11 +218,11 @@ void DiscogsFetcher::slotComplete(KIO::Job* job_) {
// might get aborted
break;
}
- QString desc = entry->field(QString::fromLatin1("artist"))
- + QChar('/')
- + entry->field(QString::fromLatin1("label"));
+ TQString desc = entry->field(TQString::tqfromLatin1("artist"))
+ + TQChar('/')
+ + entry->field(TQString::tqfromLatin1("label"));
- SearchResult* r = new SearchResult(this, entry->title(), desc, QString());
+ SearchResult* r = new SearchResult(this, entry->title(), desc, TQString());
m_entries.insert(r->uid, Data::EntryPtr(entry));
emit signalResultFound(r);
}
@@ -241,35 +241,35 @@ Tellico::Data::EntryPtr DiscogsFetcher::fetchEntry(uint uid_) {
}
// one way we tell if this entry has been fully initialized is to
// check for a cover image
- if(!entry->field(QString::fromLatin1("cover")).isEmpty()) {
+ if(!entry->field(TQString::tqfromLatin1("cover")).isEmpty()) {
myLog() << "DiscogsFetcher::fetchEntry() - already downloaded " << entry->title() << endl;
return entry;
}
- QString release = entry->field(QString::fromLatin1("discogs-id"));
+ TQString release = entry->field(TQString::tqfromLatin1("discogs-id"));
if(release.isEmpty()) {
myDebug() << "DiscogsFetcher::fetchEntry() - no discogs release found" << endl;
return entry;
}
#ifdef DISCOGS_TEST
- KURL u(QString::fromLatin1("/home/robby/discogs-release.xml"));
+ KURL u(TQString::tqfromLatin1("/home/robby/discogs-release.xml"));
#else
- KURL u(QString::fromLatin1(DISCOGS_API_URL));
- u.setPath(QString::fromLatin1("/release/%1").arg(release));
- u.addQueryItem(QString::fromLatin1("f"), QString::fromLatin1("xml"));
- u.addQueryItem(QString::fromLatin1("api_key"), m_apiKey);
+ KURL u(TQString::tqfromLatin1(DISCOGS_API_URL));
+ u.setPath(TQString::tqfromLatin1("/release/%1").tqarg(release));
+ u.addQueryItem(TQString::tqfromLatin1("f"), TQString::tqfromLatin1("xml"));
+ u.addQueryItem(TQString::tqfromLatin1("api_key"), m_apiKey);
#endif
// myDebug() << "DiscogsFetcher::fetchEntry() - url: " << u << endl;
// quiet, utf8, allowCompressed
- QString output = FileHandler::readTextFile(u, true, true, true);
+ TQString output = FileHandler::readTextFile(u, true, true, true);
#if 0
kdWarning() << "Remove output debug from discogsfetcher.cpp" << endl;
- QFile f(QString::fromLatin1("/tmp/test.xml"));
+ TQFile f(TQString::tqfromLatin1("/tmp/test.xml"));
if(f.open(IO_WriteOnly)) {
- QTextStream t(&f);
- t.setEncoding(QTextStream::UnicodeUTF8);
+ TQTextStream t(&f);
+ t.setEncoding(TQTextStream::UnicodeUTF8);
t << output;
}
f.close();
@@ -289,21 +289,21 @@ Tellico::Data::EntryPtr DiscogsFetcher::fetchEntry(uint uid_) {
const StringMap customFields = this->customFields();
for(StringMap::ConstIterator it = customFields.begin(); it != customFields.end(); ++it) {
- if(!m_fields.contains(it.key())) {
+ if(!m_fields.tqcontains(it.key())) {
coll->removeField(it.key());
}
}
// don't want to include id
- coll->removeField(QString::fromLatin1("discogs-id"));
+ coll->removeField(TQString::tqfromLatin1("discogs-id"));
entry = coll->entries().front();
- m_entries.replace(uid_, entry);
+ m_entries.tqreplace(uid_, entry);
return entry;
}
void DiscogsFetcher::initXSLTHandler() {
- QString xsltfile = locate("appdata", QString::fromLatin1("discogs2tellico.xsl"));
+ TQString xsltfile = locate("appdata", TQString::tqfromLatin1("discogs2tellico.xsl"));
if(xsltfile.isEmpty()) {
kdWarning() << "DiscogsFetcher::initXSLTHandler() - can not locate discogs2tellico.xsl." << endl;
return;
@@ -325,14 +325,14 @@ void DiscogsFetcher::initXSLTHandler() {
void DiscogsFetcher::updateEntry(Data::EntryPtr entry_) {
// myDebug() << "DiscogsFetcher::updateEntry()" << endl;
- QString value;
- QString title = entry_->field(QString::fromLatin1("title"));
+ TQString value;
+ TQString title = entry_->field(TQString::tqfromLatin1("title"));
if(!title.isEmpty()) {
search(Title, value);
return;
}
- QString artist = entry_->field(QString::fromLatin1("artist"));
+ TQString artist = entry_->field(TQString::tqfromLatin1("artist"));
if(!artist.isEmpty()) {
search(Person, artist);
return;
@@ -342,53 +342,53 @@ void DiscogsFetcher::updateEntry(Data::EntryPtr entry_) {
emit signalDone(this); // always need to emit this if not continuing with the search
}
-Tellico::Fetch::ConfigWidget* DiscogsFetcher::configWidget(QWidget* parent_) const {
- return new DiscogsFetcher::ConfigWidget(parent_, this);
+Tellico::Fetch::ConfigWidget* DiscogsFetcher::configWidget(TQWidget* tqparent_) const {
+ return new DiscogsFetcher::ConfigWidget(tqparent_, this);
}
-DiscogsFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const DiscogsFetcher* fetcher_)
- : Fetch::ConfigWidget(parent_) {
- QGridLayout* l = new QGridLayout(optionsWidget(), 2, 2);
+DiscogsFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const DiscogsFetcher* fetcher_)
+ : Fetch::ConfigWidget(tqparent_) {
+ TQGridLayout* l = new TQGridLayout(optionsWidget(), 2, 2);
l->setSpacing(4);
l->setColStretch(1, 10);
int row = -1;
- QLabel* label = new QLabel(i18n("API &key: "), optionsWidget());
+ TQLabel* label = new TQLabel(i18n("API &key: "), optionsWidget());
l->addWidget(label, ++row, 0);
m_apiKeyEdit = new KLineEdit(optionsWidget());
- connect(m_apiKeyEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified()));
+ connect(m_apiKeyEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified()));
l->addWidget(m_apiKeyEdit, row, 1);
- QString w = i18n("With your discogs.com account you receive an API key for the usage of their XML-based interface "
+ TQString w = i18n("With your discogs.com account you receive an API key for the usage of their XML-based interface "
"(See http://www.discogs.com/help/api).");
- QWhatsThis::add(label, w);
- QWhatsThis::add(m_apiKeyEdit, w);
+ TQWhatsThis::add(label, w);
+ TQWhatsThis::add(m_apiKeyEdit, w);
label->setBuddy(m_apiKeyEdit);
- m_fetchImageCheck = new QCheckBox(i18n("Download cover &image"), optionsWidget());
- connect(m_fetchImageCheck, SIGNAL(clicked()), SLOT(slotSetModified()));
+ m_fetchImageCheck = new TQCheckBox(i18n("Download cover &image"), optionsWidget());
+ connect(m_fetchImageCheck, TQT_SIGNAL(clicked()), TQT_SLOT(slotSetModified()));
++row;
l->addMultiCellWidget(m_fetchImageCheck, row, row, 0, 1);
w = i18n("The cover image may be downloaded as well. However, too many large images in the "
"collection may degrade performance.");
- QWhatsThis::add(m_fetchImageCheck, w);
+ TQWhatsThis::add(m_fetchImageCheck, w);
l->setRowStretch(++row, 10);
// now add additional fields widget
- addFieldsWidget(DiscogsFetcher::customFields(), fetcher_ ? fetcher_->m_fields : QStringList());
+ addFieldsWidget(DiscogsFetcher::customFields(), fetcher_ ? fetcher_->m_fields : TQStringList());
if(fetcher_) {
m_apiKeyEdit->setText(fetcher_->m_apiKey);
m_fetchImageCheck->setChecked(fetcher_->m_fetchImages);
} else {
- m_apiKeyEdit->setText(QString::fromLatin1(DISCOGS_API_KEY));
+ m_apiKeyEdit->setText(TQString::tqfromLatin1(DISCOGS_API_KEY));
m_fetchImageCheck->setChecked(true);
}
}
void DiscogsFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) {
- QString apiKey = m_apiKeyEdit->text().stripWhiteSpace();
+ TQString apiKey = m_apiKeyEdit->text().stripWhiteSpace();
if(!apiKey.isEmpty()) {
config_.writeEntry("API Key", apiKey);
}
@@ -398,15 +398,15 @@ void DiscogsFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) {
slotSetModified(false);
}
-QString DiscogsFetcher::ConfigWidget::preferredName() const {
+TQString DiscogsFetcher::ConfigWidget::preferredName() const {
return DiscogsFetcher::defaultName();
}
Tellico::StringMap DiscogsFetcher::customFields() {
StringMap map;
- map[QString::fromLatin1("producer")] = i18n("Producer");
- map[QString::fromLatin1("nationality")] = i18n("Nationality");
- map[QString::fromLatin1("discogs")] = i18n("Discogs Link");
+ map[TQString::tqfromLatin1("producer")] = i18n("Producer");
+ map[TQString::tqfromLatin1("nationality")] = i18n("Nationality");
+ map[TQString::tqfromLatin1("discogs")] = i18n("Discogs Link");
return map;
}