diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
commit | 2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch) | |
tree | 18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/fetch/animenfofetcher.cpp | |
parent | 1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff) | |
download | tellico-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/animenfofetcher.cpp')
-rw-r--r-- | src/fetch/animenfofetcher.cpp | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/src/fetch/animenfofetcher.cpp b/src/fetch/animenfofetcher.cpp index 728c583..3a93281 100644 --- a/src/fetch/animenfofetcher.cpp +++ b/src/fetch/animenfofetcher.cpp @@ -26,10 +26,10 @@ #include <kconfig.h> #include <kio/job.h> -#include <qregexp.h> -#include <qlayout.h> -#include <qlabel.h> -#include <qfile.h> +#include <tqregexp.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqfile.h> //#define ANIMENFO_TEST @@ -39,15 +39,15 @@ namespace { using Tellico::Fetch::AnimeNfoFetcher; -AnimeNfoFetcher::AnimeNfoFetcher(QObject* parent_, const char* name_ /*=0*/) - : Fetcher(parent_, name_), m_started(false) { +AnimeNfoFetcher::AnimeNfoFetcher(TQObject* tqparent_, const char* name_ /*=0*/) + : Fetcher(tqparent_, name_), m_started(false) { } -QString AnimeNfoFetcher::defaultName() { - return QString::fromLatin1("AnimeNfo.com"); +TQString AnimeNfoFetcher::defaultName() { + return TQString::tqfromLatin1("AnimeNfo.com"); } -QString AnimeNfoFetcher::source() const { +TQString AnimeNfoFetcher::source() const { return m_name.isEmpty() ? defaultName() : m_name; } @@ -59,27 +59,27 @@ void AnimeNfoFetcher::readConfigHook(const KConfigGroup& config_) { Q_UNUSED(config_); } -void AnimeNfoFetcher::search(FetchKey key_, const QString& value_) { +void AnimeNfoFetcher::search(FetchKey key_, const TQString& value_) { m_started = true; m_matches.clear(); #ifdef ANIMENFO_TEST - KURL u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/animenfo.html")); + KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/animenfo.html")); #else - KURL u(QString::fromLatin1(ANIMENFO_BASE_URL)); - u.addQueryItem(QString::fromLatin1("action"), QString::fromLatin1("Go")); - u.addQueryItem(QString::fromLatin1("option"), QString::fromLatin1("keywords")); - u.addQueryItem(QString::fromLatin1("queryin"), QString::fromLatin1("anime_titles")); + KURL u(TQString::tqfromLatin1(ANIMENFO_BASE_URL)); + u.addQueryItem(TQString::tqfromLatin1("action"), TQString::tqfromLatin1("Go")); + u.addQueryItem(TQString::tqfromLatin1("option"), TQString::tqfromLatin1("keywords")); + u.addQueryItem(TQString::tqfromLatin1("queryin"), TQString::tqfromLatin1("anime_titles")); 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(key_) { case Keyword: - u.addQueryItem(QString::fromLatin1("query"), value_); + u.addQueryItem(TQString::tqfromLatin1("query"), value_); break; default: @@ -91,10 +91,10 @@ void AnimeNfoFetcher::search(FetchKey key_, const QString& value_) { // myDebug() << "AnimeNfoFetcher::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 AnimeNfoFetcher::stop() { @@ -111,8 +111,8 @@ void AnimeNfoFetcher::stop() { emit signalDone(this); } -void AnimeNfoFetcher::slotData(KIO::Job*, const QByteArray& data_) { - QDataStream stream(m_data, IO_WriteOnly | IO_Append); +void AnimeNfoFetcher::slotData(KIO::Job*, const TQByteArray& data_) { + TQDataStream stream(m_data, IO_WriteOnly | IO_Append); stream.writeRawBytes(data_.data(), data_.size()); } @@ -133,28 +133,28 @@ void AnimeNfoFetcher::slotComplete(KIO::Job* job_) { return; } - QString s = Tellico::decodeHTML(QString(m_data)); + TQString s = Tellico::decodeHTML(TQString(m_data)); - QRegExp infoRx(QString::fromLatin1("<td\\s+[^>]*class\\s*=\\s*[\"']anime_info[\"'][^>]*>(.*)</td>"), false); + TQRegExp infoRx(TQString::tqfromLatin1("<td\\s+[^>]*class\\s*=\\s*[\"']anime_info[\"'][^>]*>(.*)</td>"), false); infoRx.setMinimal(true); - QRegExp anchorRx(QString::fromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](.*)[\"'][^>]*>(.*)</a>"), false); + TQRegExp anchorRx(TQString::tqfromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](.*)[\"'][^>]*>(.*)</a>"), false); anchorRx.setMinimal(true); - QRegExp yearRx(QString::fromLatin1("\\d{4}"), false); + TQRegExp yearRx(TQString::tqfromLatin1("\\d{4}"), false); // search page comes in groups of threes int n = 0; - QString u, t, y; + TQString u, t, y; for(int pos = infoRx.search(s); m_started && pos > -1; pos = infoRx.search(s, pos+1)) { if(n == 0 && !u.isEmpty()) { - SearchResult* r = new SearchResult(this, t, y, QString()); + SearchResult* r = new SearchResult(this, t, y, TQString()); emit signalResultFound(r); #ifdef ANIMENFO_TEST - KURL url = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/animetitle.html")); + KURL url = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/animetitle.html")); #else - KURL url(QString::fromLatin1(ANIMENFO_BASE_URL), u); - url.setQuery(QString::null); + KURL url(TQString::tqfromLatin1(ANIMENFO_BASE_URL), u); + url.setQuery(TQString()); #endif m_matches.insert(r->uid, url); @@ -187,10 +187,10 @@ void AnimeNfoFetcher::slotComplete(KIO::Job* job_) { // grab last response #ifndef ANIMENFO_TEST if(!u.isEmpty()) { - SearchResult* r = new SearchResult(this, t, y, QString()); + SearchResult* r = new SearchResult(this, t, y, TQString()); emit signalResultFound(r); - KURL url(QString::fromLatin1(ANIMENFO_BASE_URL), u); - url.setQuery(QString::null); + KURL url(TQString::tqfromLatin1(ANIMENFO_BASE_URL), u); + url.setQuery(TQString()); m_matches.insert(r->uid, url); } #endif @@ -210,7 +210,7 @@ Tellico::Data::EntryPtr AnimeNfoFetcher::fetchEntry(uint uid_) { return 0; } - QString results = Tellico::decodeHTML(FileHandler::readTextFile(url, true)); + TQString results = Tellico::decodeHTML(FileHandler::readTextFile(url, true)); if(results.isEmpty()) { myDebug() << "AnimeNfoFetcher::fetchEntry() - no text results" << endl; return 0; @@ -218,10 +218,10 @@ Tellico::Data::EntryPtr AnimeNfoFetcher::fetchEntry(uint uid_) { #if 0 kdWarning() << "Remove debug from animenfofetcher.cpp" << endl; - QFile f(QString::fromLatin1("/tmp/test.html")); + TQFile f(TQString::tqfromLatin1("/tmp/test.html")); if(f.open(IO_WriteOnly)) { - QTextStream t(&f); - t.setEncoding(QTextStream::UnicodeUTF8); + TQTextStream t(&f); + t.setEncoding(TQTextStream::UnicodeUTF8); t << results; } f.close(); @@ -236,64 +236,64 @@ Tellico::Data::EntryPtr AnimeNfoFetcher::fetchEntry(uint uid_) { return entry; } -Tellico::Data::EntryPtr AnimeNfoFetcher::parseEntry(const QString& str_) { +Tellico::Data::EntryPtr AnimeNfoFetcher::parseEntry(const TQString& str_) { // myDebug() << "AnimeNfoFetcher::parseEntry()" << endl; // class might be anime_info_top - QRegExp infoRx(QString::fromLatin1("<td\\s+[^>]*class\\s*=\\s*[\"']anime_info[^>]*>(.*)</td>"), false); + TQRegExp infoRx(TQString::tqfromLatin1("<td\\s+[^>]*class\\s*=\\s*[\"']anime_info[^>]*>(.*)</td>"), false); infoRx.setMinimal(true); - QRegExp tagRx(QString::fromLatin1("<.*>")); + TQRegExp tagRx(TQString::tqfromLatin1("<.*>")); tagRx.setMinimal(true); - QRegExp anchorRx(QString::fromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](.*)[\"'][^>]*>(.*)</a>"), false); + TQRegExp anchorRx(TQString::tqfromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](.*)[\"'][^>]*>(.*)</a>"), false); anchorRx.setMinimal(true); - QRegExp jsRx(QString::fromLatin1("<script.*</script>"), false); + TQRegExp jsRx(TQString::tqfromLatin1("<script.*</script>"), false); jsRx.setMinimal(true); - QString s = str_; + TQString s = str_; s.remove(jsRx); Data::CollPtr coll = new Data::VideoCollection(true); // add new fields - Data::FieldPtr f = new Data::Field(QString::fromLatin1("origtitle"), i18n("Original Title")); + Data::FieldPtr f = new Data::Field(TQString::tqfromLatin1("origtitle"), i18n("Original Title")); coll->addField(f); - f = new Data::Field(QString::fromLatin1("alttitle"), i18n("Alternative Titles"), Data::Field::Table); + f = new Data::Field(TQString::tqfromLatin1("alttitle"), i18n("Alternative Titles"), Data::Field::Table); f->setFormatFlag(Data::Field::FormatTitle); coll->addField(f); - f = new Data::Field(QString::fromLatin1("distributor"), i18n("Distributor")); + f = new Data::Field(TQString::tqfromLatin1("distributor"), i18n("Distributor")); f->setCategory(i18n("Other People")); f->setFlags(Data::Field::AllowCompletion | Data::Field::AllowMultiple | Data::Field::AllowGrouped); f->setFormatFlag(Data::Field::FormatPlain); coll->addField(f); - f = new Data::Field(QString::fromLatin1("episodes"), i18n("Episodes"), Data::Field::Number); + f = new Data::Field(TQString::tqfromLatin1("episodes"), i18n("Episodes"), Data::Field::Number); f->setCategory(i18n("Features")); coll->addField(f); // map captions in HTML to field names - QMap<QString, QString> fieldMap; - fieldMap.insert(QString::fromLatin1("Title"), QString::fromLatin1("title")); - fieldMap.insert(QString::fromLatin1("Japanese Title"), QString::fromLatin1("origtitle")); - fieldMap.insert(QString::fromLatin1("Total Episodes"), QString::fromLatin1("episodes")); - fieldMap.insert(QString::fromLatin1("Genres"), QString::fromLatin1("genre")); - fieldMap.insert(QString::fromLatin1("Year Published"), QString::fromLatin1("year")); - fieldMap.insert(QString::fromLatin1("Studio"), QString::fromLatin1("studio")); - fieldMap.insert(QString::fromLatin1("US Distribution"), QString::fromLatin1("distributor")); + TQMap<TQString, TQString> fieldMap; + fieldMap.insert(TQString::tqfromLatin1("Title"), TQString::tqfromLatin1("title")); + fieldMap.insert(TQString::tqfromLatin1("Japanese Title"), TQString::tqfromLatin1("origtitle")); + fieldMap.insert(TQString::tqfromLatin1("Total Episodes"), TQString::tqfromLatin1("episodes")); + fieldMap.insert(TQString::tqfromLatin1("Genres"), TQString::tqfromLatin1("genre")); + fieldMap.insert(TQString::tqfromLatin1("Year Published"), TQString::tqfromLatin1("year")); + fieldMap.insert(TQString::tqfromLatin1("Studio"), TQString::tqfromLatin1("studio")); + fieldMap.insert(TQString::tqfromLatin1("US Distribution"), TQString::tqfromLatin1("distributor")); Data::EntryPtr entry = new Data::Entry(coll); int n = 0; - QString key, value; + TQString key, value; int oldpos = -1; for(int pos = infoRx.search(s); pos > -1; pos = infoRx.search(s, pos+1)) { if(n == 0 && !key.isEmpty()) { - if(fieldMap.contains(key)) { + if(fieldMap.tqcontains(key)) { value = value.simplifyWhiteSpace(); if(value.length() > 2) { // might be "-" if(key == Latin1Literal("Genres")) { - entry->setField(fieldMap[key], QStringList::split(QRegExp(QString::fromLatin1("\\s*,\\s*")), - value).join(QString::fromLatin1("; "))); + entry->setField(fieldMap[key], TQStringList::split(TQRegExp(TQString::tqfromLatin1("\\s*,\\s*")), + value).join(TQString::tqfromLatin1("; "))); } else { entry->setField(fieldMap[key], value); } @@ -315,44 +315,44 @@ Tellico::Data::EntryPtr AnimeNfoFetcher::parseEntry(const QString& str_) { } // image - QRegExp imgRx(QString::fromLatin1("<img\\s+[^>]*src\\s*=\\s*[\"']([^>]*)[\"']\\s+[^>]*alt\\s*=\\s*[\"']%1[\"']") - .arg(entry->field(QString::fromLatin1("title"))), false); + TQRegExp imgRx(TQString::tqfromLatin1("<img\\s+[^>]*src\\s*=\\s*[\"']([^>]*)[\"']\\s+[^>]*alt\\s*=\\s*[\"']%1[\"']") + .tqarg(entry->field(TQString::tqfromLatin1("title"))), false); imgRx.setMinimal(true); int pos = imgRx.search(s); if(pos > -1) { - KURL imgURL(QString::fromLatin1(ANIMENFO_BASE_URL), imgRx.cap(1)); - QString id = ImageFactory::addImage(imgURL, true); + KURL imgURL(TQString::tqfromLatin1(ANIMENFO_BASE_URL), imgRx.cap(1)); + TQString id = ImageFactory::addImage(imgURL, true); if(!id.isEmpty()) { - entry->setField(QString::fromLatin1("cover"), id); + entry->setField(TQString::tqfromLatin1("cover"), id); } } // now look for alternative titles and plot - const QString a = QString::fromLatin1("Alternative titles"); - pos = s.find(a, oldpos+1, false); + const TQString a = TQString::tqfromLatin1("Alternative titles"); + pos = s.tqfind(a, oldpos+1, false); if(pos > -1) { pos += a.length(); } int pos2 = -1; if(pos > -1) { - pos2 = s.find(QString::fromLatin1("Description"), pos+1, true); + pos2 = s.tqfind(TQString::tqfromLatin1("Description"), pos+1, true); if(pos2 > -1) { value = s.mid(pos, pos2-pos).remove(tagRx).simplifyWhiteSpace(); - entry->setField(QString::fromLatin1("alttitle"), value); + entry->setField(TQString::tqfromLatin1("alttitle"), value); } } - QRegExp descRx(QString::fromLatin1("class\\s*=\\s*[\"']description[\"'][^>]*>(.*)<"), false); + TQRegExp descRx(TQString::tqfromLatin1("class\\s*=\\s*[\"']description[\"'][^>]*>(.*)<"), false); descRx.setMinimal(true); - pos = descRx.search(s, QMAX(pos, pos2)); + pos = descRx.search(s, TQMAX(pos, pos2)); if(pos > -1) { - entry->setField(QString::fromLatin1("plot"), descRx.cap(1).simplifyWhiteSpace()); + entry->setField(TQString::tqfromLatin1("plot"), descRx.cap(1).simplifyWhiteSpace()); } return entry; } void AnimeNfoFetcher::updateEntry(Data::EntryPtr entry_) { - QString t = entry_->field(QString::fromLatin1("title")); + TQString t = entry_->field(TQString::tqfromLatin1("title")); if(!t.isEmpty()) { search(Fetch::Keyword, t); return; @@ -360,18 +360,18 @@ void AnimeNfoFetcher::updateEntry(Data::EntryPtr entry_) { emit signalDone(this); // always need to emit this if not continuing with the search } -Tellico::Fetch::ConfigWidget* AnimeNfoFetcher::configWidget(QWidget* parent_) const { - return new AnimeNfoFetcher::ConfigWidget(parent_); +Tellico::Fetch::ConfigWidget* AnimeNfoFetcher::configWidget(TQWidget* tqparent_) const { + return new AnimeNfoFetcher::ConfigWidget(tqparent_); } -AnimeNfoFetcher::ConfigWidget::ConfigWidget(QWidget* parent_) - : Fetch::ConfigWidget(parent_) { - QVBoxLayout* l = new QVBoxLayout(optionsWidget()); - l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget())); +AnimeNfoFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_) + : Fetch::ConfigWidget(tqparent_) { + TQVBoxLayout* l = new TQVBoxLayout(optionsWidget()); + l->addWidget(new TQLabel(i18n("This source has no options."), optionsWidget())); l->addStretch(); } -QString AnimeNfoFetcher::ConfigWidget::preferredName() const { +TQString AnimeNfoFetcher::ConfigWidget::preferredName() const { return AnimeNfoFetcher::defaultName(); } |