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/translators/gcfilmsimporter.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/translators/gcfilmsimporter.cpp')
-rw-r--r-- | src/translators/gcfilmsimporter.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/translators/gcfilmsimporter.cpp b/src/translators/gcfilmsimporter.cpp index e2ff9ca..5b66691 100644 --- a/src/translators/gcfilmsimporter.cpp +++ b/src/translators/gcfilmsimporter.cpp @@ -24,7 +24,7 @@ #include <kapplication.h> #include <kstandarddirs.h> -#include <qtextcodec.h> +#include <tqtextcodec.h> #define CHECKLIMITS(n) if(values.count() <= n) continue @@ -49,57 +49,57 @@ Tellico::Data::CollPtr GCfilmsImporter::collection() { ProgressItem& item = ProgressManager::self()->newProgressItem(this, progressLabel(), true); item.setTotalSteps(100); - connect(&item, SIGNAL(signalCancelled(ProgressItem*)), SLOT(slotCancel())); + connect(&item, TQT_SIGNAL(signalCancelled(ProgressItem*)), TQT_SLOT(slotCancel())); ProgressItem::Done done(this); - QString str = text(); - QTextIStream t(&str); - QString line = t.readLine(); - if(line.startsWith(QString::fromLatin1("GCfilms"))) { + TQString str = text(); + TQTextIStream t(&str); + TQString line = t.readLine(); + if(line.startsWith(TQString::tqfromLatin1("GCfilms"))) { readGCfilms(str); } else { // need to reparse the string if it's in utf-8 - if(line.lower().find(QString::fromLatin1("utf-8")) > 0) { - str = QString::fromUtf8(str.local8Bit()); + if(line.lower().tqfind(TQString::tqfromLatin1("utf-8")) > 0) { + str = TQString::fromUtf8(str.local8Bit()); } readGCstar(str); } return m_coll; } -void GCfilmsImporter::readGCfilms(const QString& text_) { +void GCfilmsImporter::readGCfilms(const TQString& text_) { m_coll = new Data::VideoCollection(true); bool hasURL = false; - if(m_coll->hasField(QString::fromLatin1("url"))) { - hasURL = m_coll->fieldByName(QString::fromLatin1("url"))->type() == Data::Field::URL; + if(m_coll->hasField(TQString::tqfromLatin1("url"))) { + hasURL = m_coll->fieldByName(TQString::tqfromLatin1("url"))->type() == Data::Field::URL; } else { - Data::FieldPtr field = new Data::Field(QString::fromLatin1("url"), i18n("URL"), Data::Field::URL); + Data::FieldPtr field = new Data::Field(TQString::tqfromLatin1("url"), i18n("URL"), Data::Field::URL); field->setCategory(i18n("General")); m_coll->addField(field); hasURL = true; } bool convertUTF8 = false; - QMap<QString, Data::BorrowerPtr> borrowers; - const QRegExp rx(QString::fromLatin1("\\s*,\\s*")); - QRegExp year(QString::fromLatin1("\\d{4}")); - QRegExp runTimeHr(QString::fromLatin1("(\\d+)\\s?hr?")); - QRegExp runTimeMin(QString::fromLatin1("(\\d+)\\s?mi?n?")); + TQMap<TQString, Data::BorrowerPtr> borrowers; + const TQRegExp rx(TQString::tqfromLatin1("\\s*,\\s*")); + TQRegExp year(TQString::tqfromLatin1("\\d{4}")); + TQRegExp runTimeHr(TQString::tqfromLatin1("(\\d+)\\s?hr?")); + TQRegExp runTimeMin(TQString::tqfromLatin1("(\\d+)\\s?mi?n?")); bool gotFirstLine = false; uint total = 0; - QTextIStream t(&text_); + TQTextIStream t(&text_); const uint length = text_.length(); - const uint stepSize = QMAX(s_stepSize, length/100); + const uint stepSize = TQMAX(s_stepSize, length/100); const bool showProgress = options() & ImportProgress; ProgressManager::self()->setTotalSteps(this, length); uint j = 0; - for(QString line = t.readLine(); !m_cancelled && !line.isNull(); line = t.readLine(), j += line.length()) { + for(TQString line = t.readLine(); !m_cancelled && !line.isNull(); line = t.readLine(), j += line.length()) { // string was wrongly converted - QStringList values = QStringList::split('|', (convertUTF8 ? QString::fromUtf8(line.local8Bit()) : line), true); + TQStringList values = TQStringList::split('|', (convertUTF8 ? TQString::fromUtf8(line.local8Bit()) : line), true); if(values.empty()) { continue; } @@ -113,8 +113,8 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { total = Tellico::toUInt(values[1], 0)+1; // number of lines really if(values.size() > 2 && values[2] == Latin1Literal("UTF8")) { // if locale encoding isn't utf8, need to do a reconversion - QTextCodec* codec = QTextCodec::codecForLocale(); - if(QCString(codec->name()).find("utf-8", 0, false) == -1) { + TQTextCodec* codec = TQTextCodec::codecForLocale(); + if(TQCString(codec->name()).tqfind("utf-8", 0, false) == -1) { convertUTF8 = true; } } @@ -126,9 +126,9 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { Data::EntryPtr entry = new Data::Entry(m_coll); entry->setId(Tellico::toUInt(values[0], &ok)); - entry->setField(QString::fromLatin1("title"), values[1]); + entry->setField(TQString::tqfromLatin1("title"), values[1]); if(year.search(values[2]) > -1) { - entry->setField(QString::fromLatin1("year"), year.cap()); + entry->setField(TQString::tqfromLatin1("year"), year.cap()); } uint time = 0; @@ -139,57 +139,57 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { time += Tellico::toUInt(runTimeMin.cap(1), &ok); } if(time > 0) { - entry->setField(QString::fromLatin1("running-time"), QString::number(time)); + entry->setField(TQString::tqfromLatin1("running-time"), TQString::number(time)); } - entry->setField(QString::fromLatin1("director"), splitJoin(rx, values[4])); - entry->setField(QString::fromLatin1("nationality"), splitJoin(rx, values[5])); - entry->setField(QString::fromLatin1("genre"), splitJoin(rx, values[6])); + entry->setField(TQString::tqfromLatin1("director"), splitJoin(rx, values[4])); + entry->setField(TQString::tqfromLatin1("nationality"), splitJoin(rx, values[5])); + entry->setField(TQString::tqfromLatin1("genre"), splitJoin(rx, values[6])); KURL u = KURL::fromPathOrURL(values[7]); if(!u.isEmpty()) { - QString id = ImageFactory::addImage(u, true /* quiet */); + TQString id = ImageFactory::addImage(u, true /* quiet */); if(!id.isEmpty()) { - entry->setField(QString::fromLatin1("cover"), id); + entry->setField(TQString::tqfromLatin1("cover"), id); } } - entry->setField(QString::fromLatin1("cast"), splitJoin(rx, values[8])); + entry->setField(TQString::tqfromLatin1("cast"), splitJoin(rx, values[8])); // values[9] is the original title - entry->setField(QString::fromLatin1("plot"), values[10]); + entry->setField(TQString::tqfromLatin1("plot"), values[10]); if(hasURL) { - entry->setField(QString::fromLatin1("url"), values[11]); + entry->setField(TQString::tqfromLatin1("url"), values[11]); } CHECKLIMITS(12); // values[12] is whether the film has been viewed or not - entry->setField(QString::fromLatin1("medium"), values[13]); + entry->setField(TQString::tqfromLatin1("medium"), values[13]); // values[14] is number of DVDS? // values[15] is place? // gcfilms's ratings go 0-10, just divide by two - entry->setField(QString::fromLatin1("rating"), QString::number(int(Tellico::toUInt(values[16], &ok)/2))); - entry->setField(QString::fromLatin1("comments"), values[17]); + entry->setField(TQString::tqfromLatin1("rating"), TQString::number(int(Tellico::toUInt(values[16], &ok)/2))); + entry->setField(TQString::tqfromLatin1("comments"), values[17]); CHECKLIMITS(18); - QStringList s = QStringList::split(',', values[18]); - QStringList tracks, langs; - for(QStringList::ConstIterator it = s.begin(); it != s.end(); ++it) { + TQStringList s = TQStringList::split(',', values[18]); + TQStringList tracks, langs; + for(TQStringList::ConstIterator it = s.begin(); it != s.end(); ++it) { langs << (*it).section(';', 0, 0); tracks << (*it).section(';', 1, 1); } - entry->setField(QString::fromLatin1("language"), langs.join(QString::fromLatin1("; "))); - entry->setField(QString::fromLatin1("audio-track"), tracks.join(QString::fromLatin1("; "))); + entry->setField(TQString::tqfromLatin1("language"), langs.join(TQString::tqfromLatin1("; "))); + entry->setField(TQString::tqfromLatin1("audio-track"), tracks.join(TQString::tqfromLatin1("; "))); - entry->setField(QString::fromLatin1("subtitle"), splitJoin(rx, values[19])); + entry->setField(TQString::tqfromLatin1("subtitle"), splitJoin(rx, values[19])); CHECKLIMITS(20); // values[20] is borrower name if(!values[20].isEmpty()) { - QString tmp = values[20]; + TQString tmp = values[20]; Data::BorrowerPtr b = borrowers[tmp]; if(!b) { - b = new Data::Borrower(tmp, QString()); + b = new Data::Borrower(tmp, TQString()); borrowers.insert(tmp, b); } // values[21] is loan date @@ -198,8 +198,8 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { int d = Tellico::toUInt(tmp.section('/', 0, 0), &ok); int m = Tellico::toUInt(tmp.section('/', 1, 1), &ok); int y = Tellico::toUInt(tmp.section('/', 2, 2), &ok); - b->addLoan(new Data::Loan(entry, QDate(y, m, d), QDate(), QString())); - entry->setField(QString::fromLatin1("loaned"), QString::fromLatin1("true")); + b->addLoan(new Data::Loan(entry, TQDate(y, m, d), TQDate(), TQString())); + entry->setField(TQString::tqfromLatin1("loaned"), TQString::tqfromLatin1("true")); } } // values[22] is history ? @@ -209,15 +209,15 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { int age = Tellico::toUInt(values[23], &ok); if(age < 2) { - entry->setField(QString::fromLatin1("certification"), QString::fromLatin1("U (USA)")); + entry->setField(TQString::tqfromLatin1("certification"), TQString::tqfromLatin1("U (USA)")); } else if(age < 3) { - entry->setField(QString::fromLatin1("certification"), QString::fromLatin1("G (USA)")); + entry->setField(TQString::tqfromLatin1("certification"), TQString::tqfromLatin1("G (USA)")); } else if(age < 6) { - entry->setField(QString::fromLatin1("certification"), QString::fromLatin1("PG (USA)")); + entry->setField(TQString::tqfromLatin1("certification"), TQString::tqfromLatin1("PG (USA)")); } else if(age < 14) { - entry->setField(QString::fromLatin1("certification"), QString::fromLatin1("PG-13 (USA)")); + entry->setField(TQString::tqfromLatin1("certification"), TQString::tqfromLatin1("PG-13 (USA)")); } else { - entry->setField(QString::fromLatin1("certification"), QString::fromLatin1("R (USA)")); + entry->setField(TQString::tqfromLatin1("certification"), TQString::tqfromLatin1("R (USA)")); } m_coll->addEntries(entry); @@ -233,22 +233,22 @@ void GCfilmsImporter::readGCfilms(const QString& text_) { return; } - for(QMap<QString, Data::BorrowerPtr>::Iterator it = borrowers.begin(); it != borrowers.end(); ++it) { + for(TQMap<TQString, Data::BorrowerPtr>::Iterator it = borrowers.begin(); it != borrowers.end(); ++it) { if(!it.data()->isEmpty()) { m_coll->addBorrower(it.data()); } } } -void GCfilmsImporter::readGCstar(const QString& text_) { - QString xsltFile = locate("appdata", QString::fromLatin1("gcstar2tellico.xsl")); +void GCfilmsImporter::readGCstar(const TQString& text_) { + TQString xsltFile = locate("appdata", TQString::tqfromLatin1("gcstar2tellico.xsl")); XSLTHandler handler(xsltFile); if(!handler.isValid()) { setStatusMessage(i18n("Tellico encountered an error in XSLT processing.")); return; } - QString str = handler.applyStylesheet(text_); + TQString str = handler.applyStylesheet(text_); if(str.isEmpty()) { setStatusMessage(i18n("<qt>The file is not a valid GCstar data file.</qt>")); @@ -261,8 +261,8 @@ void GCfilmsImporter::readGCstar(const QString& text_) { } inline -QString GCfilmsImporter::splitJoin(const QRegExp& rx, const QString& s) { - return QStringList::split(rx, s, false).join(QString::fromLatin1("; ")); +TQString GCfilmsImporter::splitJoin(const TQRegExp& rx, const TQString& s) { + return TQStringList::split(rx, s, false).join(TQString::tqfromLatin1("; ")); } void GCfilmsImporter::slotCancel() { |