summaryrefslogtreecommitdiffstats
path: root/src/fetch/yahoofetcher.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
commit2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch)
tree18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/fetch/yahoofetcher.cpp
parent1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff)
downloadtellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz
tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip
TQt4 port tellico
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/fetch/yahoofetcher.cpp')
-rw-r--r--src/fetch/yahoofetcher.cpp174
1 files changed, 87 insertions, 87 deletions
diff --git a/src/fetch/yahoofetcher.cpp b/src/fetch/yahoofetcher.cpp
index 002b63b..d625cad 100644
--- a/src/fetch/yahoofetcher.cpp
+++ b/src/fetch/yahoofetcher.cpp
@@ -27,10 +27,10 @@
#include <kconfig.h>
#include <kio/job.h>
-#include <qdom.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qfile.h>
+#include <tqdom.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqfile.h>
namespace {
static const int YAHOO_MAX_RETURNS_TOTAL = 20;
@@ -40,8 +40,8 @@ namespace {
using Tellico::Fetch::YahooFetcher;
-YahooFetcher::YahooFetcher(QObject* parent_, const char* name_)
- : Fetcher(parent_, name_), m_xsltHandler(0),
+YahooFetcher::YahooFetcher(TQObject* tqparent_, const char* name_)
+ : Fetcher(tqparent_, name_), m_xsltHandler(0),
m_limit(YAHOO_MAX_RETURNS_TOTAL), m_job(0), m_started(false) {
}
@@ -50,11 +50,11 @@ YahooFetcher::~YahooFetcher() {
m_xsltHandler = 0;
}
-QString YahooFetcher::defaultName() {
+TQString YahooFetcher::defaultName() {
return i18n("Yahoo! Audio Search");
}
-QString YahooFetcher::source() const {
+TQString YahooFetcher::source() const {
return m_name.isEmpty() ? defaultName() : m_name;
}
@@ -66,7 +66,7 @@ void YahooFetcher::readConfigHook(const KConfigGroup& config_) {
Q_UNUSED(config_);
}
-void YahooFetcher::search(FetchKey key_, const QString& value_) {
+void YahooFetcher::search(FetchKey key_, const TQString& value_) {
m_key = key_;
m_value = value_;
m_started = true;
@@ -83,32 +83,32 @@ void YahooFetcher::continueSearch() {
void YahooFetcher::doSearch() {
// myDebug() << "YahooFetcher::search() - value = " << value_ << endl;
- KURL u(QString::fromLatin1(YAHOO_BASE_URL));
- u.addQueryItem(QString::fromLatin1("appid"), QString::fromLatin1(YAHOO_APP_ID));
- u.addQueryItem(QString::fromLatin1("type"), QString::fromLatin1("all"));
- u.addQueryItem(QString::fromLatin1("output"), QString::fromLatin1("xml"));
- u.addQueryItem(QString::fromLatin1("start"), QString::number(m_start));
- u.addQueryItem(QString::fromLatin1("results"), QString::number(YAHOO_MAX_RETURNS_TOTAL));
+ KURL u(TQString::tqfromLatin1(YAHOO_BASE_URL));
+ u.addQueryItem(TQString::tqfromLatin1("appid"), TQString::tqfromLatin1(YAHOO_APP_ID));
+ u.addQueryItem(TQString::tqfromLatin1("type"), TQString::tqfromLatin1("all"));
+ u.addQueryItem(TQString::tqfromLatin1("output"), TQString::tqfromLatin1("xml"));
+ u.addQueryItem(TQString::tqfromLatin1("start"), TQString::number(m_start));
+ u.addQueryItem(TQString::tqfromLatin1("results"), TQString::number(YAHOO_MAX_RETURNS_TOTAL));
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.addQueryItem(QString::fromLatin1("album"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("album"), m_value);
break;
case Person:
- u.addQueryItem(QString::fromLatin1("artist"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("artist"), m_value);
break;
// raw is used for the entry updates
case Raw:
-// u.removeQueryItem(QString::fromLatin1("type"));
-// u.addQueryItem(QString::fromLatin1("type"), QString::fromLatin1("phrase"));
+// u.removeQueryItem(TQString::tqfromLatin1("type"));
+// u.addQueryItem(TQString::tqfromLatin1("type"), TQString::tqfromLatin1("phrase"));
u.setQuery(u.query() + '&' + m_value);
break;
@@ -120,10 +120,10 @@ void YahooFetcher::doSearch() {
// myDebug() << "YahooFetcher::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 YahooFetcher::stop() {
@@ -139,8 +139,8 @@ void YahooFetcher::stop() {
emit signalDone(this);
}
-void YahooFetcher::slotData(KIO::Job*, const QByteArray& data_) {
- QDataStream stream(m_data, IO_WriteOnly | IO_Append);
+void YahooFetcher::slotData(KIO::Job*, const TQByteArray& data_) {
+ TQDataStream stream(m_data, IO_WriteOnly | IO_Append);
stream.writeRawBytes(data_.data(), data_.size());
}
@@ -163,11 +163,11 @@ void YahooFetcher::slotComplete(KIO::Job* job_) {
#if 0
kdWarning() << "Remove debug from yahoofetcher.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
@@ -181,20 +181,20 @@ void YahooFetcher::slotComplete(KIO::Job* job_) {
}
if(m_total == -1) {
- QDomDocument dom;
+ TQDomDocument dom;
if(!dom.setContent(m_data, false)) {
kdWarning() << "YahooFetcher::slotComplete() - server did not return valid XML." << endl;
return;
}
// total is top level element, with attribute totalResultsAvailable
- QDomElement e = dom.documentElement();
+ TQDomElement e = dom.documentElement();
if(!e.isNull()) {
- m_total = e.attribute(QString::fromLatin1("totalResultsAvailable")).toInt();
+ m_total = e.attribute(TQString::tqfromLatin1("totalResultsAvailable")).toInt();
}
}
// assume yahoo 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) {
@@ -210,13 +210,13 @@ void YahooFetcher::slotComplete(KIO::Job* job_) {
// might get aborted
break;
}
- QString desc = entry->field(QString::fromLatin1("artist"))
- + QChar('/')
- + entry->field(QString::fromLatin1("label"))
- + QChar('/')
- + entry->field(QString::fromLatin1("year"));
+ TQString desc = entry->field(TQString::tqfromLatin1("artist"))
+ + TQChar('/')
+ + entry->field(TQString::tqfromLatin1("label"))
+ + TQChar('/')
+ + entry->field(TQString::tqfromLatin1("year"));
- SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(QString::fromLatin1("isbn")));
+ SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(TQString::tqfromLatin1("isbn")));
m_entries.insert(r->uid, Data::EntryPtr(entry));
emit signalResultFound(r);
}
@@ -232,30 +232,30 @@ Tellico::Data::EntryPtr YahooFetcher::fetchEntry(uint uid_) {
return 0;
}
- KURL imageURL = entry->field(QString::fromLatin1("image"));
+ KURL imageURL = entry->field(TQString::tqfromLatin1("image"));
if(!imageURL.isEmpty()) {
- QString id = ImageFactory::addImage(imageURL, true);
+ TQString id = ImageFactory::addImage(imageURL, true);
if(id.isEmpty()) {
- // rich text causes layout issues
-// emit signalStatus(i18n("<qt>The cover image for <i>%1</i> could not be loaded.</qt>").arg(
-// entry->field(QString::fromLatin1("title"))));
+ // rich text causes tqlayout issues
+// emit signaltqStatus(i18n("<qt>The cover image for <i>%1</i> could not be loaded.</qt>").tqarg(
+// entry->field(TQString::tqfromLatin1("title"))));
message(i18n("The cover image could not be loaded."), MessageHandler::Warning);
} else {
- entry->setField(QString::fromLatin1("cover"), id);
+ entry->setField(TQString::tqfromLatin1("cover"), id);
}
}
getTracks(entry);
// don't want to show image urls in the fetch dialog
- entry->setField(QString::fromLatin1("image"), QString::null);
+ entry->setField(TQString::tqfromLatin1("image"), TQString());
// no need for album id now ?
- entry->setField(QString::fromLatin1("yahoo"), QString::null);
+ entry->setField(TQString::tqfromLatin1("yahoo"), TQString());
return entry;
}
void YahooFetcher::initXSLTHandler() {
- QString xsltfile = locate("appdata", QString::fromLatin1("yahoo2tellico.xsl"));
+ TQString xsltfile = locate("appdata", TQString::tqfromLatin1("yahoo2tellico.xsl"));
if(xsltfile.isEmpty()) {
kdWarning() << "YahooFetcher::initXSLTHandler() - can not locate yahoo2tellico.xsl." << endl;
return;
@@ -276,23 +276,23 @@ void YahooFetcher::initXSLTHandler() {
void YahooFetcher::getTracks(Data::EntryPtr entry_) {
// get album id
- if(!entry_ || entry_->field(QString::fromLatin1("yahoo")).isEmpty()) {
+ if(!entry_ || entry_->field(TQString::tqfromLatin1("yahoo")).isEmpty()) {
return;
}
- const QString albumid = entry_->field(QString::fromLatin1("yahoo"));
+ const TQString albumid = entry_->field(TQString::tqfromLatin1("yahoo"));
- KURL u(QString::fromLatin1(YAHOO_BASE_URL));
- u.setFileName(QString::fromLatin1("songSearch"));
- u.addQueryItem(QString::fromLatin1("appid"), QString::fromLatin1(YAHOO_APP_ID));
- u.addQueryItem(QString::fromLatin1("type"), QString::fromLatin1("all"));
- u.addQueryItem(QString::fromLatin1("output"), QString::fromLatin1("xml"));
+ KURL u(TQString::tqfromLatin1(YAHOO_BASE_URL));
+ u.setFileName(TQString::tqfromLatin1("songSearch"));
+ u.addQueryItem(TQString::tqfromLatin1("appid"), TQString::tqfromLatin1(YAHOO_APP_ID));
+ u.addQueryItem(TQString::tqfromLatin1("type"), TQString::tqfromLatin1("all"));
+ u.addQueryItem(TQString::tqfromLatin1("output"), TQString::tqfromLatin1("xml"));
// go ahesad and ask for all results, since there might well be more than 10 songs on the CD
- u.addQueryItem(QString::fromLatin1("results"), QString::number(50));
- u.addQueryItem(QString::fromLatin1("albumid"), albumid);
+ u.addQueryItem(TQString::tqfromLatin1("results"), TQString::number(50));
+ u.addQueryItem(TQString::tqfromLatin1("albumid"), albumid);
// myDebug() << "YahooFetcher::getTracks() - url: " << u.url() << endl;
- QDomDocument dom = FileHandler::readXMLFile(u, false /*no namespace*/, true /*quiet*/);
+ TQDomDocument dom = FileHandler::readXMLFile(u, false /*no namespace*/, true /*quiet*/);
if(dom.isNull()) {
myDebug() << "YahooFetcher::getTracks() - null dom returned" << endl;
return;
@@ -300,36 +300,36 @@ void YahooFetcher::getTracks(Data::EntryPtr entry_) {
#if 0
kdWarning() << "Remove debug from yahoofetcher.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 << dom.toString();
}
f.close();
#endif
- const QString track = QString::fromLatin1("track");
+ const TQString track = TQString::tqfromLatin1("track");
- QDomNodeList nodes = dom.documentElement().childNodes();
+ TQDomNodeList nodes = dom.documentElement().childNodes();
for(uint i = 0; i < nodes.count(); ++i) {
- QDomElement e = nodes.item(i).toElement();
+ TQDomElement e = nodes.item(i).toElement();
if(e.isNull()) {
continue;
}
- QString t = e.namedItem(QString::fromLatin1("Title")).toElement().text();
- QString n = e.namedItem(QString::fromLatin1("Track")).toElement().text();
+ TQString t = e.namedItem(TQString::tqfromLatin1("Title")).toElement().text();
+ TQString n = e.namedItem(TQString::tqfromLatin1("Track")).toElement().text();
bool ok;
int trackNum = Tellico::toUInt(n, &ok);
// trackNum might be 0
if(t.isEmpty() || !ok || trackNum < 1) {
continue;
}
- QString a = e.namedItem(QString::fromLatin1("Artist")).toElement().text();
- QString l = e.namedItem(QString::fromLatin1("Length")).toElement().text();
+ TQString a = e.namedItem(TQString::tqfromLatin1("Artist")).toElement().text();
+ TQString l = e.namedItem(TQString::tqfromLatin1("Length")).toElement().text();
int len = Tellico::toUInt(l, &ok);
- QString value = t + "::" + a;
+ TQString value = t + "::" + a;
if(ok && len > 0) {
value += + "::" + Tellico::minutes(len);
}
@@ -338,22 +338,22 @@ void YahooFetcher::getTracks(Data::EntryPtr entry_) {
}
// not zero-based
-QString YahooFetcher::insertValue(const QString& str_, const QString& value_, uint pos_) {
- QStringList list = Data::Field::split(str_, true);
+TQString YahooFetcher::insertValue(const TQString& str_, const TQString& value_, uint pos_) {
+ TQStringList list = Data::Field::split(str_, true);
for(uint i = list.count(); i < pos_; ++i) {
- list += QString::null;
+ list += TQString();
}
bool write = true;
if(!list[pos_-1].isNull()) {
// for some reason, some songs are repeated from yahoo, with 0 length, don't overwrite that
- if(value_.contains(QString::fromLatin1("::")) < 2) { // means no length value
+ if(value_.tqcontains(TQString::tqfromLatin1("::")) < 2) { // means no length value
write = false;
}
}
if(!value_.isEmpty() && write) {
list[pos_-1] = value_;
}
- return list.join(QString::fromLatin1("; "));
+ return list.join(TQString::tqfromLatin1("; "));
}
void YahooFetcher::updateEntry(Data::EntryPtr entry_) {
@@ -361,17 +361,17 @@ void YahooFetcher::updateEntry(Data::EntryPtr entry_) {
// limit to top 5 results
m_limit = 5;
- QString value;
- QString title = entry_->field(QString::fromLatin1("title"));
+ TQString value;
+ TQString title = entry_->field(TQString::tqfromLatin1("title"));
if(!title.isEmpty()) {
- value += QString::fromLatin1("album=") + title;
+ value += TQString::tqfromLatin1("album=") + title;
}
- QString artist = entry_->field(QString::fromLatin1("artist"));
+ TQString artist = entry_->field(TQString::tqfromLatin1("artist"));
if(!artist.isEmpty()) {
if(!value.isEmpty()) {
value += '&';
}
- value += QString::fromLatin1("artist=") + artist;
+ value += TQString::tqfromLatin1("artist=") + artist;
}
if(!value.isEmpty()) {
search(Fetch::Raw, value);
@@ -382,18 +382,18 @@ void YahooFetcher::updateEntry(Data::EntryPtr entry_) {
emit signalDone(this); // always need to emit this if not continuing with the search
}
-Tellico::Fetch::ConfigWidget* YahooFetcher::configWidget(QWidget* parent_) const {
- return new YahooFetcher::ConfigWidget(parent_, this);
+Tellico::Fetch::ConfigWidget* YahooFetcher::configWidget(TQWidget* tqparent_) const {
+ return new YahooFetcher::ConfigWidget(tqparent_, this);
}
-YahooFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const YahooFetcher*/*=0*/)
- : Fetch::ConfigWidget(parent_) {
- QVBoxLayout* l = new QVBoxLayout(optionsWidget());
- l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget()));
+YahooFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const YahooFetcher*/*=0*/)
+ : Fetch::ConfigWidget(tqparent_) {
+ TQVBoxLayout* l = new TQVBoxLayout(optionsWidget());
+ l->addWidget(new TQLabel(i18n("This source has no options."), optionsWidget()));
l->addStretch();
}
-QString YahooFetcher::ConfigWidget::preferredName() const {
+TQString YahooFetcher::ConfigWidget::preferredName() const {
return YahooFetcher::defaultName();
}