diff options
Diffstat (limited to 'src/fetch/amazonfetcher.cpp')
-rw-r--r-- | src/fetch/amazonfetcher.cpp | 438 |
1 files changed, 219 insertions, 219 deletions
diff --git a/src/fetch/amazonfetcher.cpp b/src/fetch/amazonfetcher.cpp index 36c009f..fee207a 100644 --- a/src/fetch/amazonfetcher.cpp +++ b/src/fetch/amazonfetcher.cpp @@ -36,13 +36,13 @@ #include <kcombobox.h> #include <kaccelmanager.h> -#include <qdom.h> -#include <qlayout.h> -#include <qlabel.h> -#include <qwhatsthis.h> -#include <qcheckbox.h> -#include <qfile.h> -#include <qtextcodec.h> +#include <tqdom.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqwhatsthis.h> +#include <tqcheckbox.h> +#include <tqfile.h> +#include <tqtextcodec.h> namespace { static const int AMAZON_RETURNS_PER_REQUEST = 10; @@ -82,10 +82,10 @@ const AmazonFetcher::SiteData& AmazonFetcher::siteData(int site_) { return dataVector[site_]; } -AmazonFetcher::AmazonFetcher(Site site_, QObject* parent_, const char* name_) - : Fetcher(parent_, name_), m_xsltHandler(0), m_site(site_), m_imageSize(MediumImage), - m_access(QString::fromLatin1(AMAZON_ACCESS_KEY)), - m_assoc(QString::fromLatin1(AMAZON_ASSOC_TOKEN)), m_addLinkField(true), m_limit(AMAZON_MAX_RETURNS_TOTAL), +AmazonFetcher::AmazonFetcher(Site site_, TQObject* tqparent_, const char* name_) + : Fetcher(tqparent_, name_), m_xsltHandler(0), m_site(site_), m_imageSize(MediumImage), + m_access(TQString::tqfromLatin1(AMAZON_ACCESS_KEY)), + m_assoc(TQString::tqfromLatin1(AMAZON_ASSOC_TOKEN)), m_addLinkField(true), m_limit(AMAZON_MAX_RETURNS_TOTAL), m_countOffset(0), m_page(1), m_total(-1), m_numResults(0), m_job(0), m_started(false) { m_name = siteData(site_).title; } @@ -95,11 +95,11 @@ AmazonFetcher::~AmazonFetcher() { m_xsltHandler = 0; } -QString AmazonFetcher::defaultName() { +TQString AmazonFetcher::defaultName() { return i18n("Amazon.com Web Services"); } -QString AmazonFetcher::source() const { +TQString AmazonFetcher::source() const { return m_name.isEmpty() ? defaultName() : m_name; } @@ -113,7 +113,7 @@ bool AmazonFetcher::canFetch(int type) const { } void AmazonFetcher::readConfigHook(const KConfigGroup& config_) { - QString s = config_.readEntry("AccessKey"); + TQString s = config_.readEntry("AccessKey"); if(!s.isEmpty()) { m_access = s; } @@ -125,10 +125,10 @@ void AmazonFetcher::readConfigHook(const KConfigGroup& config_) { if(imageSize > -1) { m_imageSize = static_cast<ImageSize>(imageSize); } - m_fields = config_.readListEntry("Custom Fields", QString::fromLatin1("keyword")); + m_fields = config_.readListEntry("Custom Fields", TQString::tqfromLatin1("keyword")); } -void AmazonFetcher::search(FetchKey key_, const QString& value_) { +void AmazonFetcher::search(FetchKey key_, const TQString& value_) { m_key = key_; m_value = value_.stripWhiteSpace(); m_started = true; @@ -153,34 +153,34 @@ void AmazonFetcher::doSearch() { const SiteData& data = siteData(m_site); KURL u = data.url; - u.addQueryItem(QString::fromLatin1("Service"), QString::fromLatin1("AWSECommerceService")); - u.addQueryItem(QString::fromLatin1("AssociateTag"), m_assoc); - u.addQueryItem(QString::fromLatin1("AWSAccessKeyId"), m_access); - u.addQueryItem(QString::fromLatin1("Operation"), QString::fromLatin1("ItemSearch")); - u.addQueryItem(QString::fromLatin1("ResponseGroup"), QString::fromLatin1("Large")); - u.addQueryItem(QString::fromLatin1("ItemPage"), QString::number(m_page)); - u.addQueryItem(QString::fromLatin1("Version"), QString::fromLatin1("2007-10-29")); + u.addQueryItem(TQString::tqfromLatin1("Service"), TQString::tqfromLatin1("AWSECommerceService")); + u.addQueryItem(TQString::tqfromLatin1("AssociateTag"), m_assoc); + u.addQueryItem(TQString::tqfromLatin1("AWSAccessKeyId"), m_access); + u.addQueryItem(TQString::tqfromLatin1("Operation"), TQString::tqfromLatin1("ItemSearch")); + u.addQueryItem(TQString::tqfromLatin1("ResponseGroup"), TQString::tqfromLatin1("Large")); + u.addQueryItem(TQString::tqfromLatin1("ItemPage"), TQString::number(m_page)); + u.addQueryItem(TQString::tqfromLatin1("Version"), TQString::tqfromLatin1("2007-10-29")); const int type = Kernel::self()->collectionType(); switch(type) { case Data::Collection::Book: case Data::Collection::ComicBook: case Data::Collection::Bibtex: - u.addQueryItem(QString::fromLatin1("SearchIndex"), QString::fromLatin1("Books")); - u.addQueryItem(QString::fromLatin1("SortIndex"), QString::fromLatin1("relevancerank")); + u.addQueryItem(TQString::tqfromLatin1("SearchIndex"), TQString::tqfromLatin1("Books")); + u.addQueryItem(TQString::tqfromLatin1("SortIndex"), TQString::tqfromLatin1("relevancerank")); break; case Data::Collection::Album: - u.addQueryItem(QString::fromLatin1("SearchIndex"), QString::fromLatin1("Music")); + u.addQueryItem(TQString::tqfromLatin1("SearchIndex"), TQString::tqfromLatin1("Music")); break; case Data::Collection::Video: - u.addQueryItem(QString::fromLatin1("SearchIndex"), QString::fromLatin1("Video")); - u.addQueryItem(QString::fromLatin1("SortIndex"), QString::fromLatin1("relevancerank")); + u.addQueryItem(TQString::tqfromLatin1("SearchIndex"), TQString::tqfromLatin1("Video")); + u.addQueryItem(TQString::tqfromLatin1("SortIndex"), TQString::tqfromLatin1("relevancerank")); break; case Data::Collection::Game: - u.addQueryItem(QString::fromLatin1("SearchIndex"), QString::fromLatin1("VideoGames")); + u.addQueryItem(TQString::tqfromLatin1("SearchIndex"), TQString::tqfromLatin1("VideoGames")); break; case Data::Collection::Coin: @@ -189,7 +189,7 @@ void AmazonFetcher::doSearch() { case Data::Collection::Base: case Data::Collection::Card: default: - 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; } @@ -199,48 +199,48 @@ void AmazonFetcher::doSearch() { // that utf8 DOES NOT WORK. So I'm arbitrarily using iso-8859-1, except for JP. // Why different for JP? Well, I've not received any bug reports from that direction yet -// QString value = KURL::decode_string(value_, 106); -// QString value = QString::fromLocal8Bit(value_.utf8()); - QString value = m_value; +// TQString value = KURL::decode_string(value_, 106); +// TQString value = TQString::fromLocal8Bit(value_.utf8()); + TQString value = m_value; // a mibenum of 106 is utf-8, 4 is iso-8859-1, 0 means use user's locale, int mib = m_site == AmazonFetcher::JP ? 106 : 4; switch(m_key) { case Title: - u.addQueryItem(QString::fromLatin1("Title"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Title"), value, mib); break; case Person: if(type == Data::Collection::Video) { - u.addQueryItem(QString::fromLatin1("Actor"), value, mib); - u.addQueryItem(QString::fromLatin1("Director"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Actor"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Director"), value, mib); } else if(type == Data::Collection::Album) { - u.addQueryItem(QString::fromLatin1("Artist"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Artist"), value, mib); } else if(type == Data::Collection::Game) { - u.addQueryItem(QString::fromLatin1("Manufacturer"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Manufacturer"), value, mib); } else { // books and bibtex - QString s = QString::fromLatin1("author:%1 or publisher:%2").arg(value, value); -// u.addQueryItem(QString::fromLatin1("Author"), value, mib); -// u.addQueryItem(QString::fromLatin1("Publisher"), value, mib); - u.addQueryItem(QString::fromLatin1("Power"), s, mib); + TQString s = TQString::tqfromLatin1("author:%1 or publisher:%2").tqarg(value, value); +// u.addQueryItem(TQString::tqfromLatin1("Author"), value, mib); +// u.addQueryItem(TQString::tqfromLatin1("Publisher"), value, mib); + u.addQueryItem(TQString::tqfromLatin1("Power"), s, mib); } break; case ISBN: { - u.removeQueryItem(QString::fromLatin1("Operation")); - u.addQueryItem(QString::fromLatin1("Operation"), QString::fromLatin1("ItemLookup")); + u.removeQueryItem(TQString::tqfromLatin1("Operation")); + u.addQueryItem(TQString::tqfromLatin1("Operation"), TQString::tqfromLatin1("ItemLookup")); - QString s = m_value; // not encValue!!! + TQString s = m_value; // not encValue!!! s.remove('-'); // ISBN only get digits or 'X', and multiple values are connected with "; " - QStringList isbns = QStringList::split(QString::fromLatin1("; "), s); + TQStringList isbns = TQStringList::split(TQString::tqfromLatin1("; "), s); // Amazon isbn13 search is still very flaky, so if possible, we're going to convert // all of them to isbn10. If we run into a 979 isbn13, then we're forced to do an // isbn13 search bool isbn13 = false; - for(QStringList::Iterator it = isbns.begin(); it != isbns.end(); ) { - if(m_value.startsWith(QString::fromLatin1("979"))) { + for(TQStringList::Iterator it = isbns.begin(); it != isbns.end(); ) { + if(m_value.startsWith(TQString::tqfromLatin1("979"))) { if(m_site == JP) { // never works for JP kdWarning() << "AmazonFetcher:doSearch() - ISBN-13 searching not implemented for Japan" << endl; isbns.remove(it); // automatically skips to next @@ -253,53 +253,53 @@ void AmazonFetcher::doSearch() { } // if we want isbn10, then convert all if(!isbn13) { - for(QStringList::Iterator it = isbns.begin(); it != isbns.end(); ++it) { + for(TQStringList::Iterator it = isbns.begin(); it != isbns.end(); ++it) { if((*it).length() > 12) { (*it) = ISBNValidator::isbn10(*it); (*it).remove('-'); } } // the default search is by ASIN, which prohibits SearchIndex - u.removeQueryItem(QString::fromLatin1("SearchIndex")); + u.removeQueryItem(TQString::tqfromLatin1("SearchIndex")); } // limit to first 10 while(isbns.size() > 10) { isbns.pop_back(); } - u.addQueryItem(QString::fromLatin1("ItemId"), isbns.join(QString::fromLatin1(","))); + u.addQueryItem(TQString::tqfromLatin1("ItemId"), isbns.join(TQString::tqfromLatin1(","))); if(isbn13) { - u.addQueryItem(QString::fromLatin1("IdType"), QString::fromLatin1("EAN")); + u.addQueryItem(TQString::tqfromLatin1("IdType"), TQString::tqfromLatin1("EAN")); } } break; case UPC: { - u.removeQueryItem(QString::fromLatin1("Operation")); - u.addQueryItem(QString::fromLatin1("Operation"), QString::fromLatin1("ItemLookup")); + u.removeQueryItem(TQString::tqfromLatin1("Operation")); + u.addQueryItem(TQString::tqfromLatin1("Operation"), TQString::tqfromLatin1("ItemLookup")); // US allows UPC, all others are EAN if(m_site == US) { - u.addQueryItem(QString::fromLatin1("IdType"), QString::fromLatin1("UPC")); + u.addQueryItem(TQString::tqfromLatin1("IdType"), TQString::tqfromLatin1("UPC")); } else { - u.addQueryItem(QString::fromLatin1("IdType"), QString::fromLatin1("EAN")); + u.addQueryItem(TQString::tqfromLatin1("IdType"), TQString::tqfromLatin1("EAN")); } - QString s = m_value; // not encValue!!! + TQString s = m_value; // not encValue!!! s.remove('-'); // limit to first 10 - s.replace(QString::fromLatin1("; "), QString::fromLatin1(",")); + s.tqreplace(TQString::tqfromLatin1("; "), TQString::tqfromLatin1(",")); s = s.section(',', 0, 9); - u.addQueryItem(QString::fromLatin1("ItemId"), s); + u.addQueryItem(TQString::tqfromLatin1("ItemId"), s); } break; case Keyword: - u.addQueryItem(QString::fromLatin1("Keywords"), m_value, mib); + u.addQueryItem(TQString::tqfromLatin1("Keywords"), m_value, mib); break; case Raw: { - QString key = value.section('=', 0, 0).stripWhiteSpace(); - QString str = value.section('=', 1).stripWhiteSpace(); + TQString key = value.section('=', 0, 0).stripWhiteSpace(); + TQString str = value.section('=', 1).stripWhiteSpace(); u.addQueryItem(key, str, mib); } break; @@ -312,10 +312,10 @@ void AmazonFetcher::doSearch() { // myDebug() << "AmazonFetcher::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 AmazonFetcher::stop() { @@ -332,8 +332,8 @@ void AmazonFetcher::stop() { emit signalDone(this); } -void AmazonFetcher::slotData(KIO::Job*, const QByteArray& data_) { - QDataStream stream(m_data, IO_WriteOnly | IO_Append); +void AmazonFetcher::slotData(KIO::Job*, const TQByteArray& data_) { + TQDataStream stream(m_data, IO_WriteOnly | IO_Append); stream.writeRawBytes(data_.data(), data_.size()); } @@ -357,18 +357,18 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { #if 0 kdWarning() << "Remove debug from amazonfetcher.cpp" << endl; - QFile f(QString::fromLatin1("/tmp/test%1.xml").arg(m_page)); + TQFile f(TQString::tqfromLatin1("/tmp/test%1.xml").tqarg(m_page)); 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 - QStringList errors; + TQStringList errors; if(m_total == -1) { - QDomDocument dom; + TQDomDocument dom; if(!dom.setContent(m_data, false)) { kdWarning() << "AmazonFetcher::slotComplete() - server did not return valid XML." << endl; stop(); @@ -377,31 +377,31 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { // find TotalResults element // it's in the first level under the root element //ItemSearchResponse/Items/TotalResults - QDomNode n = dom.documentElement().namedItem(QString::fromLatin1("Items")) - .namedItem(QString::fromLatin1("TotalResults")); - QDomElement e = n.toElement(); + TQDomNode n = dom.documentElement().namedItem(TQString::tqfromLatin1("Items")) + .namedItem(TQString::tqfromLatin1("TotalResults")); + TQDomElement e = n.toElement(); if(!e.isNull()) { m_total = e.text().toInt(); } - n = dom.documentElement().namedItem(QString::fromLatin1("Items")) - .namedItem(QString::fromLatin1("Request")) - .namedItem(QString::fromLatin1("Errors")); + n = dom.documentElement().namedItem(TQString::tqfromLatin1("Items")) + .namedItem(TQString::tqfromLatin1("Request")) + .namedItem(TQString::tqfromLatin1("Errors")); e = n.toElement(); if(!e.isNull()) { - QDomNodeList nodes = e.elementsByTagName(QString::fromLatin1("Error")); + TQDomNodeList nodes = e.elementsByTagName(TQString::tqfromLatin1("Error")); for(uint i = 0; i < nodes.count(); ++i) { - e = nodes.item(i).toElement().namedItem(QString::fromLatin1("Code")).toElement(); + e = nodes.item(i).toElement().namedItem(TQString::tqfromLatin1("Code")).toElement(); if(!e.isNull() && e.text() == Latin1Literal("AWS.ECommerceService.NoExactMatches")) { // no exact match, not a real error, so skip continue; } // for some reason, Amazon will return an error simply when a valid ISBN is not found // I really want to ignore that, so check the IsValid element in the Request element - QDomNode isValidNode = n.parentNode().namedItem(QString::fromLatin1("IsValid")); + TQDomNode isValidNode = n.tqparentNode().namedItem(TQString::tqfromLatin1("IsValid")); if(m_key == ISBN && isValidNode.toElement().text().lower() == Latin1Literal("true")) { continue; } - e = nodes.item(i).toElement().namedItem(QString::fromLatin1("Message")).toElement(); + e = nodes.item(i).toElement().namedItem(TQString::tqfromLatin1("Message")).toElement(); if(!e.isNull()) { errors << e.text(); } @@ -417,11 +417,11 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { } } -// QRegExp stripHTML(QString::fromLatin1("<.*>"), true); +// TQRegExp stripHTML(TQString::tqfromLatin1("<.*>"), true); // stripHTML.setMinimal(true); // assume amazon 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) { @@ -432,12 +432,12 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { if(!m_addLinkField) { // remove amazon field if it's not to be added - coll->removeField(QString::fromLatin1("amazon")); + coll->removeField(TQString::tqfromLatin1("amazon")); } Data::EntryVec entries = coll->entries(); if(entries.isEmpty() && !errors.isEmpty()) { - for(QStringList::ConstIterator it = errors.constBegin(); it != errors.constEnd(); ++it) { + for(TQStringList::ConstIterator it = errors.constBegin(); it != errors.constEnd(); ++it) { myDebug() << "AmazonFetcher::" << *it << endl; } message(errors[0], MessageHandler::Error); @@ -460,64 +460,64 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { // special case book author // amazon is really bad about not putting spaces after periods if(coll->type() == Data::Collection::Book) { - QRegExp rx(QString::fromLatin1("\\.([^\\s])")); - QStringList values = entry->fields(QString::fromLatin1("author"), false); - for(QStringList::Iterator it = values.begin(); it != values.end(); ++it) { - (*it).replace(rx, QString::fromLatin1(". \\1")); + TQRegExp rx(TQString::tqfromLatin1("\\.([^\\s])")); + TQStringList values = entry->fields(TQString::tqfromLatin1("author"), false); + for(TQStringList::Iterator it = values.begin(); it != values.end(); ++it) { + (*it).tqreplace(rx, TQString::tqfromLatin1(". \\1")); } - entry->setField(QString::fromLatin1("author"), values.join(QString::fromLatin1("; "))); + entry->setField(TQString::tqfromLatin1("author"), values.join(TQString::tqfromLatin1("; "))); } // UK puts the year in the title for some reason if(m_site == UK && coll->type() == Data::Collection::Video) { - QRegExp rx(QString::fromLatin1("\\[(\\d{4})\\]")); - QString t = entry->title(); - if(t.find(rx) > -1) { - QString y = rx.cap(1); + TQRegExp rx(TQString::tqfromLatin1("\\[(\\d{4})\\]")); + TQString t = entry->title(); + if(t.tqfind(rx) > -1) { + TQString y = rx.cap(1); t.remove(rx).simplifyWhiteSpace(); - entry->setField(QString::fromLatin1("title"), t); - if(entry->field(QString::fromLatin1("year")).isEmpty()) { - entry->setField(QString::fromLatin1("year"), y); + entry->setField(TQString::tqfromLatin1("title"), t); + if(entry->field(TQString::tqfromLatin1("year")).isEmpty()) { + entry->setField(TQString::tqfromLatin1("year"), y); } } } - QString desc; + TQString desc; switch(coll->type()) { case Data::Collection::Book: case Data::Collection::ComicBook: case Data::Collection::Bibtex: - desc = entry->field(QString::fromLatin1("author")) - + QChar('/') + entry->field(QString::fromLatin1("publisher")); - if(!entry->field(QString::fromLatin1("cr_year")).isEmpty()) { - desc += QChar('/') + entry->field(QString::fromLatin1("cr_year")); - } else if(!entry->field(QString::fromLatin1("pub_year")).isEmpty()){ - desc += QChar('/') + entry->field(QString::fromLatin1("pub_year")); + desc = entry->field(TQString::tqfromLatin1("author")) + + TQChar('/') + entry->field(TQString::tqfromLatin1("publisher")); + if(!entry->field(TQString::tqfromLatin1("cr_year")).isEmpty()) { + desc += TQChar('/') + entry->field(TQString::tqfromLatin1("cr_year")); + } else if(!entry->field(TQString::tqfromLatin1("pub_year")).isEmpty()){ + desc += TQChar('/') + entry->field(TQString::tqfromLatin1("pub_year")); } break; case Data::Collection::Video: - desc = entry->field(QString::fromLatin1("studio")) - + QChar('/') - + entry->field(QString::fromLatin1("director")) - + QChar('/') - + entry->field(QString::fromLatin1("year")) - + QChar('/') - + entry->field(QString::fromLatin1("medium")); + desc = entry->field(TQString::tqfromLatin1("studio")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("director")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("year")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("medium")); break; case Data::Collection::Album: - desc = entry->field(QString::fromLatin1("artist")) - + QChar('/') - + entry->field(QString::fromLatin1("label")) - + QChar('/') - + entry->field(QString::fromLatin1("year")); + desc = entry->field(TQString::tqfromLatin1("artist")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("label")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("year")); break; case Data::Collection::Game: - desc = entry->field(QString::fromLatin1("platform")) - + QChar('/') - + entry->field(QString::fromLatin1("year")); + desc = entry->field(TQString::tqfromLatin1("platform")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("year")); break; default: @@ -528,21 +528,21 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { // tentatively don't do this, looks like ECS 4 cleaned everything up /* if(coll->type() == Data::Collection::Video) { - QString plot = entry->field(QString::fromLatin1("plot")); + TQString plot = entry->field(TQString::tqfromLatin1("plot")); plot.remove(stripHTML); - entry->setField(QString::fromLatin1("plot"), plot); + entry->setField(TQString::tqfromLatin1("plot"), plot); } else if(coll->type() == Data::Collection::Game) { - QString desc = entry->field(QString::fromLatin1("description")); + TQString desc = entry->field(TQString::tqfromLatin1("description")); desc.remove(stripHTML); - entry->setField(QString::fromLatin1("description"), desc); + entry->setField(TQString::tqfromLatin1("description"), desc); } else { - QString comments = entry->field(QString::fromLatin1("comments")); + TQString comments = entry->field(TQString::tqfromLatin1("comments")); comments.remove(stripHTML); - entry->setField(QString::fromLatin1("comments"), comments); + entry->setField(TQString::tqfromLatin1("comments"), comments); } */ // myDebug() << "AmazonFetcher::slotComplete() - " << entry->title() << endl; - 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); ++m_numResults; @@ -556,14 +556,14 @@ void AmazonFetcher::slotComplete(KIO::Job* job_) { // are there any additional results to get? m_hasMoreResults = m_page * AMAZON_RETURNS_PER_REQUEST < m_total; - const int currentTotal = QMIN(m_total, m_limit); + const int currentTotal = TQMIN(m_total, m_limit); if(m_page * AMAZON_RETURNS_PER_REQUEST < currentTotal) { int foundCount = (m_page-1) * AMAZON_RETURNS_PER_REQUEST + coll->entryCount(); - message(i18n("Results from %1: %2/%3").arg(source()).arg(foundCount).arg(m_total), MessageHandler::Status); + message(i18n("Results from %1: %2/%3").tqarg(source()).tqarg(foundCount).tqarg(m_total), MessageHandler::tqStatus); ++m_page; m_countOffset = 0; doSearch(); - } else if(m_value.contains(';') > 9) { + } else if(m_value.tqcontains(';') > 9) { search(m_key, m_value.section(';', 10)); } else { m_countOffset = m_entries.count() % AMAZON_RETURNS_PER_REQUEST; @@ -581,10 +581,10 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { return 0; } - QStringList defaultFields = customFields().keys(); - for(QStringList::Iterator it = defaultFields.begin(); it != defaultFields.end(); ++it) { - if(!m_fields.contains(*it)) { - entry->setField(*it, QString::null); + TQStringList defaultFields = customFields().keys(); + for(TQStringList::Iterator it = defaultFields.begin(); it != defaultFields.end(); ++it) { + if(!m_fields.tqcontains(*it)) { + entry->setField(*it, TQString()); } } @@ -595,44 +595,44 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { case Data::Collection::ComicBook: case Data::Collection::Bibtex: { - const QString keywords = QString::fromLatin1("keyword"); - QStringList oldWords = entry->fields(keywords, false); + const TQString keywords = TQString::tqfromLatin1("keyword"); + TQStringList oldWords = entry->fields(keywords, false); StringSet words; - for(QStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { + for(TQStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { // the amazon2tellico stylesheet separates keywords with '/' - QStringList nodes = QStringList::split('/', *it); - for(QStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { + TQStringList nodes = TQStringList::split('/', *it); + for(TQStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { if(*it2 == Latin1Literal("General") || *it2 == Latin1Literal("Subjects") || *it2 == Latin1Literal("Par prix") || // french stuff *it2 == Latin1Literal("Divers") || // french stuff - (*it2).startsWith(QChar('(')) || - (*it2).startsWith(QString::fromLatin1("Authors"))) { + (*it2).startsWith(TQChar('(')) || + (*it2).startsWith(TQString::tqfromLatin1("Authors"))) { continue; } words.add(*it2); } } - entry->setField(keywords, words.toList().join(QString::fromLatin1("; "))); + entry->setField(keywords, words.toList().join(TQString::tqfromLatin1("; "))); } - entry->setField(QString::fromLatin1("comments"), Tellico::decodeHTML(entry->field(QString::fromLatin1("comments")))); + entry->setField(TQString::tqfromLatin1("comments"), Tellico::decodeHTML(entry->field(TQString::tqfromLatin1("comments")))); break; case Data::Collection::Video: { - const QString genres = QString::fromLatin1("genre"); - QStringList oldWords = entry->fields(genres, false); + const TQString genres = TQString::tqfromLatin1("genre"); + TQStringList oldWords = entry->fields(genres, false); StringSet words; // only care about genres that have "Genres" in the amazon response // and take the first word after that - for(QStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { - if((*it).find(QString::fromLatin1("Genres")) == -1) { + for(TQStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { + if((*it).tqfind(TQString::tqfromLatin1("Genres")) == -1) { continue; } // the amazon2tellico stylesheet separates words with '/' - QStringList nodes = QStringList::split('/', *it); - for(QStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { + TQStringList nodes = TQStringList::split('/', *it); + for(TQStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { if(*it2 != Latin1Literal("Genres")) { continue; } @@ -643,34 +643,34 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { break; // we're done } } - entry->setField(genres, words.toList().join(QString::fromLatin1("; "))); + entry->setField(genres, words.toList().join(TQString::tqfromLatin1("; "))); // language tracks get duplicated, too - QStringList langs = entry->fields(QString::fromLatin1("language"), false); + TQStringList langs = entry->fields(TQString::tqfromLatin1("language"), false); words.clear(); - for(QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it) { + for(TQStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it) { words.add(*it); } - entry->setField(QString::fromLatin1("language"), words.toList().join(QString::fromLatin1("; "))); + entry->setField(TQString::tqfromLatin1("language"), words.toList().join(TQString::tqfromLatin1("; "))); } - entry->setField(QString::fromLatin1("plot"), Tellico::decodeHTML(entry->field(QString::fromLatin1("plot")))); + entry->setField(TQString::tqfromLatin1("plot"), Tellico::decodeHTML(entry->field(TQString::tqfromLatin1("plot")))); break; case Data::Collection::Album: { - const QString genres = QString::fromLatin1("genre"); - QStringList oldWords = entry->fields(genres, false); + const TQString genres = TQString::tqfromLatin1("genre"); + TQStringList oldWords = entry->fields(genres, false); StringSet words; // only care about genres that have "Styles" in the amazon response // and take the first word after that - for(QStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { - if((*it).find(QString::fromLatin1("Styles")) == -1) { + for(TQStringList::Iterator it = oldWords.begin(); it != oldWords.end(); ++it) { + if((*it).tqfind(TQString::tqfromLatin1("Styles")) == -1) { continue; } // the amazon2tellico stylesheet separates words with '/' - QStringList nodes = QStringList::split('/', *it); + TQStringList nodes = TQStringList::split('/', *it); bool isStyle = false; - for(QStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { + for(TQStringList::Iterator it2 = nodes.begin(); it2 != nodes.end(); ++it2) { if(!isStyle) { if(*it2 == Latin1Literal("Styles")) { isStyle = true; @@ -682,13 +682,13 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { } } } - entry->setField(genres, words.toList().join(QString::fromLatin1("; "))); + entry->setField(genres, words.toList().join(TQString::tqfromLatin1("; "))); } - entry->setField(QString::fromLatin1("comments"), Tellico::decodeHTML(entry->field(QString::fromLatin1("comments")))); + entry->setField(TQString::tqfromLatin1("comments"), Tellico::decodeHTML(entry->field(TQString::tqfromLatin1("comments")))); break; case Data::Collection::Game: - entry->setField(QString::fromLatin1("description"), Tellico::decodeHTML(entry->field(QString::fromLatin1("description")))); + entry->setField(TQString::tqfromLatin1("description"), Tellico::decodeHTML(entry->field(TQString::tqfromLatin1("description")))); break; } @@ -697,26 +697,26 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { // also sometimes table fields have rows but no values Data::FieldVec fields = entry->collection()->fields(); - QRegExp blank(QString::fromLatin1("[\\s:;]+")); // only white space, column separators and row separators + TQRegExp blank(TQString::tqfromLatin1("[\\s:;]+")); // only white space, column separators and row separators for(Data::FieldVec::Iterator fIt = fields.begin(); fIt != fields.end(); ++fIt) { if(fIt->type() != Data::Field::Table) { continue; } if(blank.exactMatch(entry->field(fIt))) { - entry->setField(fIt, QString::null); + entry->setField(fIt, TQString()); } } KURL imageURL; switch(m_imageSize) { case SmallImage: - imageURL = entry->field(QString::fromLatin1("small-image")); + imageURL = entry->field(TQString::tqfromLatin1("small-image")); break; case MediumImage: - imageURL = entry->field(QString::fromLatin1("medium-image")); + imageURL = entry->field(TQString::tqfromLatin1("medium-image")); break; case LargeImage: - imageURL = entry->field(QString::fromLatin1("large-image")); + imageURL = entry->field(TQString::tqfromLatin1("large-image")); break; case NoImage: default: @@ -724,25 +724,25 @@ Tellico::Data::EntryPtr AmazonFetcher::fetchEntry(uint uid_) { } // myDebug() << "AmazonFetcher::fetchEntry() - grabbing " << imageURL.prettyURL() << endl; if(!imageURL.isEmpty()) { - QString id = ImageFactory::addImage(imageURL, true); + TQString id = ImageFactory::addImage(imageURL, true); // FIXME: need to add cover image field to bibtex collection if(id.isEmpty()) { message(i18n("The cover image could not be loaded."), MessageHandler::Warning); } else { // amazon serves up 1x1 gifs occasionally, but that's caught in the image constructor // all relevant collection types have cover fields - entry->setField(QString::fromLatin1("cover"), id); + entry->setField(TQString::tqfromLatin1("cover"), id); } } // don't want to show image urls in the fetch dialog - entry->setField(QString::fromLatin1("small-image"), QString::null); - entry->setField(QString::fromLatin1("medium-image"), QString::null); - entry->setField(QString::fromLatin1("large-image"), QString::null); + entry->setField(TQString::tqfromLatin1("small-image"), TQString()); + entry->setField(TQString::tqfromLatin1("medium-image"), TQString()); + entry->setField(TQString::tqfromLatin1("large-image"), TQString()); return entry; } void AmazonFetcher::initXSLTHandler() { - QString xsltfile = locate("appdata", QString::fromLatin1("amazon2tellico.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("amazon2tellico.xsl")); if(xsltfile.isEmpty()) { kdWarning() << "AmazonFetcher::initXSLTHandler() - can not locate amazon2tellico.xsl." << endl; return; @@ -766,14 +766,14 @@ void AmazonFetcher::updateEntry(Data::EntryPtr entry_) { int type = entry_->collection()->type(); if(type == Data::Collection::Book || type == Data::Collection::ComicBook || type == Data::Collection::Bibtex) { - QString isbn = entry_->field(QString::fromLatin1("isbn")); + TQString isbn = entry_->field(TQString::tqfromLatin1("isbn")); if(!isbn.isEmpty()) { m_limit = 5; // no need for more search(Fetch::ISBN, isbn); return; } } else if(type == Data::Collection::Album) { - QString a = entry_->field(QString::fromLatin1("artist")); + TQString a = entry_->field(TQString::tqfromLatin1("artist")); if(!a.isEmpty()) { search(Fetch::Person, a); return; @@ -781,7 +781,7 @@ void AmazonFetcher::updateEntry(Data::EntryPtr entry_) { } // optimistically try searching for title and rely on Collection::sameEntry() to figure things out - QString t = entry_->field(QString::fromLatin1("title")); + TQString t = entry_->field(TQString::tqfromLatin1("title")); if(!t.isEmpty()) { search(Fetch::Title, t); return; @@ -793,10 +793,10 @@ void AmazonFetcher::updateEntry(Data::EntryPtr entry_) { void AmazonFetcher::parseTitle(Data::EntryPtr entry, int collType) { Q_UNUSED(collType); - // assume that everything in brackets or parentheses is extra - QRegExp rx(QString::fromLatin1("[\\(\\[](.*)[\\)\\]]")); + // assume that everything in brackets or tqparentheses is extra + TQRegExp rx(TQString::tqfromLatin1("[\\(\\[](.*)[\\)\\]]")); rx.setMinimal(true); - QString title = entry->field(QString::fromLatin1("title")); + TQString title = entry->field(TQString::tqfromLatin1("title")); int pos = rx.search(title); while(pos > -1) { if(parseTitleToken(entry, rx.cap(1))) { @@ -805,47 +805,47 @@ void AmazonFetcher::parseTitle(Data::EntryPtr entry, int collType) { } pos = rx.search(title, pos+1); } - entry->setField(QString::fromLatin1("title"), title.stripWhiteSpace()); + entry->setField(TQString::tqfromLatin1("title"), title.stripWhiteSpace()); } -bool AmazonFetcher::parseTitleToken(Data::EntryPtr entry, const QString& token) { +bool AmazonFetcher::parseTitleToken(Data::EntryPtr entry, const TQString& token) { // if res = true, then the token gets removed from the title bool res = false; - if(token.find(QString::fromLatin1("widescreen"), 0, false /* case-insensitive*/) > -1 || - token.find(i18n("Widescreen"), 0, false) > -1) { - entry->setField(QString::fromLatin1("widescreen"), QString::fromLatin1("true")); + if(token.tqfind(TQString::tqfromLatin1("widescreen"), 0, false /* case-insensitive*/) > -1 || + token.tqfind(i18n("Widescreen"), 0, false) > -1) { + entry->setField(TQString::tqfromLatin1("widescreen"), TQString::tqfromLatin1("true")); // res = true; leave it in the title - } else if(token.find(QString::fromLatin1("full screen"), 0, false) > -1) { + } else if(token.tqfind(TQString::tqfromLatin1("full screen"), 0, false) > -1) { // skip, but go ahead and remove from title res = true; } - if(token.find(QString::fromLatin1("blu-ray"), 0, false) > -1) { - entry->setField(QString::fromLatin1("medium"), i18n("Blu-ray")); + if(token.tqfind(TQString::tqfromLatin1("blu-ray"), 0, false) > -1) { + entry->setField(TQString::tqfromLatin1("medium"), i18n("Blu-ray")); res = true; - } else if(token.find(QString::fromLatin1("hd dvd"), 0, false) > -1) { - entry->setField(QString::fromLatin1("medium"), i18n("HD DVD")); + } else if(token.tqfind(TQString::tqfromLatin1("hd dvd"), 0, false) > -1) { + entry->setField(TQString::tqfromLatin1("medium"), i18n("HD DVD")); res = true; } - if(token.find(QString::fromLatin1("director's cut"), 0, false) > -1 || - token.find(i18n("Director's Cut"), 0, false) > -1) { - entry->setField(QString::fromLatin1("directors-cut"), QString::fromLatin1("true")); + if(token.tqfind(TQString::tqfromLatin1("director's cut"), 0, false) > -1 || + token.tqfind(i18n("Director's Cut"), 0, false) > -1) { + entry->setField(TQString::tqfromLatin1("directors-cut"), TQString::tqfromLatin1("true")); // res = true; leave it in the title } return res; } -Tellico::Fetch::ConfigWidget* AmazonFetcher::configWidget(QWidget* parent_) const { - return new AmazonFetcher::ConfigWidget(parent_, this); +Tellico::Fetch::ConfigWidget* AmazonFetcher::configWidget(TQWidget* tqparent_) const { + return new AmazonFetcher::ConfigWidget(tqparent_, this); } -AmazonFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const AmazonFetcher* fetcher_/*=0*/) - : Fetch::ConfigWidget(parent_) { - QGridLayout* l = new QGridLayout(optionsWidget(), 4, 2); +AmazonFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const AmazonFetcher* fetcher_/*=0*/) + : Fetch::ConfigWidget(tqparent_) { + TQGridLayout* l = new TQGridLayout(optionsWidget(), 4, 2); l->setSpacing(4); l->setColStretch(1, 10); int row = -1; - QLabel* label = new QLabel(i18n("Co&untry: "), optionsWidget()); + TQLabel* label = new TQLabel(i18n("Co&untry: "), optionsWidget()); l->addWidget(label, ++row, 0); m_siteCombo = new GUI::ComboBox(optionsWidget()); m_siteCombo->insertItem(i18n("United States"), US); @@ -854,39 +854,39 @@ AmazonFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const AmazonFetcher* m_siteCombo->insertItem(i18n("Japan"), JP); m_siteCombo->insertItem(i18n("France"), FR); m_siteCombo->insertItem(i18n("Canada"), CA); - connect(m_siteCombo, SIGNAL(activated(int)), SLOT(slotSetModified())); - connect(m_siteCombo, SIGNAL(activated(int)), SLOT(slotSiteChanged())); + connect(m_siteCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSetModified())); + connect(m_siteCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSiteChanged())); l->addWidget(m_siteCombo, row, 1); - QString w = i18n("Amazon.com provides data from several different localized sites. Choose the one " + TQString w = i18n("Amazon.com provides data from several different localized sites. Choose the one " "you wish to use for this data source."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_siteCombo, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_siteCombo, w); label->setBuddy(m_siteCombo); - label = new QLabel(i18n("&Image size: "), optionsWidget()); + label = new TQLabel(i18n("&Image size: "), optionsWidget()); l->addWidget(label, ++row, 0); m_imageCombo = new GUI::ComboBox(optionsWidget()); m_imageCombo->insertItem(i18n("Small Image"), SmallImage); m_imageCombo->insertItem(i18n("Medium Image"), MediumImage); m_imageCombo->insertItem(i18n("Large Image"), LargeImage); m_imageCombo->insertItem(i18n("No Image"), NoImage); - connect(m_imageCombo, SIGNAL(activated(int)), SLOT(slotSetModified())); + connect(m_imageCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSetModified())); l->addWidget(m_imageCombo, row, 1); w = i18n("The cover image may be downloaded as well. However, too many large images in the " "collection may degrade performance."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_imageCombo, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_imageCombo, w); label->setBuddy(m_imageCombo); - label = new QLabel(i18n("&Associate's ID: "), optionsWidget()); + label = new TQLabel(i18n("&Associate's ID: "), optionsWidget()); l->addWidget(label, ++row, 0); m_assocEdit = new KLineEdit(optionsWidget()); - connect(m_assocEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified())); + connect(m_assocEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified())); l->addWidget(m_assocEdit, row, 1); w = i18n("The associate's id identifies the person accessing the Amazon.com Web Services, and is included " "in any links to the Amazon.com site."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_assocEdit, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_assocEdit, w); label->setBuddy(m_assocEdit); l->setRowStretch(++row, 10); @@ -896,11 +896,11 @@ AmazonFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const AmazonFetcher* m_assocEdit->setText(fetcher_->m_assoc); m_imageCombo->setCurrentData(fetcher_->m_imageSize); } else { // defaults - m_assocEdit->setText(QString::fromLatin1(AMAZON_ASSOC_TOKEN)); + m_assocEdit->setText(TQString::tqfromLatin1(AMAZON_ASSOC_TOKEN)); m_imageCombo->setCurrentData(MediumImage); } - addFieldsWidget(AmazonFetcher::customFields(), fetcher_ ? fetcher_->m_fields : QStringList()); + addFieldsWidget(AmazonFetcher::customFields(), fetcher_ ? fetcher_->m_fields : TQStringList()); KAcceleratorManager::manage(optionsWidget()); } @@ -908,7 +908,7 @@ AmazonFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const AmazonFetcher* void AmazonFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { int n = m_siteCombo->currentData().toInt(); config_.writeEntry("Site", n); - QString s = m_assocEdit->text().stripWhiteSpace(); + TQString s = m_assocEdit->text().stripWhiteSpace(); if(!s.isEmpty()) { config_.writeEntry("AssocToken", s); } @@ -919,7 +919,7 @@ void AmazonFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { slotSetModified(false); } -QString AmazonFetcher::ConfigWidget::preferredName() const { +TQString AmazonFetcher::ConfigWidget::preferredName() const { return AmazonFetcher::siteData(m_siteCombo->currentData().toInt()).title; } @@ -930,7 +930,7 @@ void AmazonFetcher::ConfigWidget::slotSiteChanged() { //static Tellico::StringMap AmazonFetcher::customFields() { StringMap map; - map[QString::fromLatin1("keyword")] = i18n("Keywords"); + map[TQString::tqfromLatin1("keyword")] = i18n("Keywords"); return map; } |