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/risimporter.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/risimporter.cpp')
-rw-r--r-- | src/translators/risimporter.cpp | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/src/translators/risimporter.cpp b/src/translators/risimporter.cpp index 0420f66..e0a75a3 100644 --- a/src/translators/risimporter.cpp +++ b/src/translators/risimporter.cpp @@ -24,89 +24,89 @@ #include <kapplication.h> -#include <qdict.h> -#include <qregexp.h> -#include <qmap.h> +#include <tqdict.h> +#include <tqregexp.h> +#include <tqmap.h> using Tellico::Import::RISImporter; -QMap<QString, QString>* RISImporter::s_tagMap = 0; -QMap<QString, QString>* RISImporter::s_typeMap = 0; +TQMap<TQString, TQString>* RISImporter::s_tagMap = 0; +TQMap<TQString, TQString>* RISImporter::s_typeMap = 0; // static void RISImporter::initTagMap() { if(!s_tagMap) { - s_tagMap = new QMap<QString, QString>(); + s_tagMap = new TQMap<TQString, TQString>(); // BT is special and is handled separately - s_tagMap->insert(QString::fromLatin1("TY"), QString::fromLatin1("entry-type")); - s_tagMap->insert(QString::fromLatin1("ID"), QString::fromLatin1("bibtex-key")); - s_tagMap->insert(QString::fromLatin1("T1"), QString::fromLatin1("title")); - s_tagMap->insert(QString::fromLatin1("TI"), QString::fromLatin1("title")); - s_tagMap->insert(QString::fromLatin1("T2"), QString::fromLatin1("booktitle")); - s_tagMap->insert(QString::fromLatin1("A1"), QString::fromLatin1("author")); - s_tagMap->insert(QString::fromLatin1("AU"), QString::fromLatin1("author")); - s_tagMap->insert(QString::fromLatin1("ED"), QString::fromLatin1("editor")); - s_tagMap->insert(QString::fromLatin1("YR"), QString::fromLatin1("year")); - s_tagMap->insert(QString::fromLatin1("PY"), QString::fromLatin1("year")); - s_tagMap->insert(QString::fromLatin1("N1"), QString::fromLatin1("note")); - s_tagMap->insert(QString::fromLatin1("AB"), QString::fromLatin1("abstract")); // should be note? - s_tagMap->insert(QString::fromLatin1("N2"), QString::fromLatin1("abstract")); - s_tagMap->insert(QString::fromLatin1("KW"), QString::fromLatin1("keyword")); - s_tagMap->insert(QString::fromLatin1("JF"), QString::fromLatin1("journal")); - s_tagMap->insert(QString::fromLatin1("JO"), QString::fromLatin1("journal")); - s_tagMap->insert(QString::fromLatin1("JA"), QString::fromLatin1("journal")); - s_tagMap->insert(QString::fromLatin1("VL"), QString::fromLatin1("volume")); - s_tagMap->insert(QString::fromLatin1("IS"), QString::fromLatin1("number")); - s_tagMap->insert(QString::fromLatin1("PB"), QString::fromLatin1("publisher")); - s_tagMap->insert(QString::fromLatin1("SN"), QString::fromLatin1("isbn")); - s_tagMap->insert(QString::fromLatin1("AD"), QString::fromLatin1("address")); - s_tagMap->insert(QString::fromLatin1("CY"), QString::fromLatin1("address")); - s_tagMap->insert(QString::fromLatin1("UR"), QString::fromLatin1("url")); - s_tagMap->insert(QString::fromLatin1("L1"), QString::fromLatin1("pdf")); - s_tagMap->insert(QString::fromLatin1("T3"), QString::fromLatin1("series")); - s_tagMap->insert(QString::fromLatin1("EP"), QString::fromLatin1("pages")); + s_tagMap->insert(TQString::tqfromLatin1("TY"), TQString::tqfromLatin1("entry-type")); + s_tagMap->insert(TQString::tqfromLatin1("ID"), TQString::tqfromLatin1("bibtex-key")); + s_tagMap->insert(TQString::tqfromLatin1("T1"), TQString::tqfromLatin1("title")); + s_tagMap->insert(TQString::tqfromLatin1("TI"), TQString::tqfromLatin1("title")); + s_tagMap->insert(TQString::tqfromLatin1("T2"), TQString::tqfromLatin1("booktitle")); + s_tagMap->insert(TQString::tqfromLatin1("A1"), TQString::tqfromLatin1("author")); + s_tagMap->insert(TQString::tqfromLatin1("AU"), TQString::tqfromLatin1("author")); + s_tagMap->insert(TQString::tqfromLatin1("ED"), TQString::tqfromLatin1("editor")); + s_tagMap->insert(TQString::tqfromLatin1("YR"), TQString::tqfromLatin1("year")); + s_tagMap->insert(TQString::tqfromLatin1("PY"), TQString::tqfromLatin1("year")); + s_tagMap->insert(TQString::tqfromLatin1("N1"), TQString::tqfromLatin1("note")); + s_tagMap->insert(TQString::tqfromLatin1("AB"), TQString::tqfromLatin1("abstract")); // should be note? + s_tagMap->insert(TQString::tqfromLatin1("N2"), TQString::tqfromLatin1("abstract")); + s_tagMap->insert(TQString::tqfromLatin1("KW"), TQString::tqfromLatin1("keyword")); + s_tagMap->insert(TQString::tqfromLatin1("JF"), TQString::tqfromLatin1("journal")); + s_tagMap->insert(TQString::tqfromLatin1("JO"), TQString::tqfromLatin1("journal")); + s_tagMap->insert(TQString::tqfromLatin1("JA"), TQString::tqfromLatin1("journal")); + s_tagMap->insert(TQString::tqfromLatin1("VL"), TQString::tqfromLatin1("volume")); + s_tagMap->insert(TQString::tqfromLatin1("IS"), TQString::tqfromLatin1("number")); + s_tagMap->insert(TQString::tqfromLatin1("PB"), TQString::tqfromLatin1("publisher")); + s_tagMap->insert(TQString::tqfromLatin1("SN"), TQString::tqfromLatin1("isbn")); + s_tagMap->insert(TQString::tqfromLatin1("AD"), TQString::tqfromLatin1("address")); + s_tagMap->insert(TQString::tqfromLatin1("CY"), TQString::tqfromLatin1("address")); + s_tagMap->insert(TQString::tqfromLatin1("UR"), TQString::tqfromLatin1("url")); + s_tagMap->insert(TQString::tqfromLatin1("L1"), TQString::tqfromLatin1("pdf")); + s_tagMap->insert(TQString::tqfromLatin1("T3"), TQString::tqfromLatin1("series")); + s_tagMap->insert(TQString::tqfromLatin1("EP"), TQString::tqfromLatin1("pages")); } } // static void RISImporter::initTypeMap() { if(!s_typeMap) { - s_typeMap = new QMap<QString, QString>(); + s_typeMap = new TQMap<TQString, TQString>(); // leave capitalized, except for bibtex types - s_typeMap->insert(QString::fromLatin1("ABST"), QString::fromLatin1("Abstract")); - s_typeMap->insert(QString::fromLatin1("ADVS"), QString::fromLatin1("Audiovisual material")); - s_typeMap->insert(QString::fromLatin1("ART"), QString::fromLatin1("Art Work")); - s_typeMap->insert(QString::fromLatin1("BILL"), QString::fromLatin1("Bill/Resolution")); - s_typeMap->insert(QString::fromLatin1("BOOK"), QString::fromLatin1("book")); // bibtex - s_typeMap->insert(QString::fromLatin1("CASE"), QString::fromLatin1("Case")); - s_typeMap->insert(QString::fromLatin1("CHAP"), QString::fromLatin1("inbook")); // == "inbook" ? - s_typeMap->insert(QString::fromLatin1("COMP"), QString::fromLatin1("Computer program")); - s_typeMap->insert(QString::fromLatin1("CONF"), QString::fromLatin1("inproceedings")); // == "conference" ? - s_typeMap->insert(QString::fromLatin1("CTLG"), QString::fromLatin1("Catalog")); - s_typeMap->insert(QString::fromLatin1("DATA"), QString::fromLatin1("Data file")); - s_typeMap->insert(QString::fromLatin1("ELEC"), QString::fromLatin1("Electronic Citation")); - s_typeMap->insert(QString::fromLatin1("GEN"), QString::fromLatin1("Generic")); - s_typeMap->insert(QString::fromLatin1("HEAR"), QString::fromLatin1("Hearing")); - s_typeMap->insert(QString::fromLatin1("ICOMM"), QString::fromLatin1("Internet Communication")); - s_typeMap->insert(QString::fromLatin1("INPR"), QString::fromLatin1("In Press")); - s_typeMap->insert(QString::fromLatin1("JFULL"), QString::fromLatin1("Journal (full)")); // = "periodical" ? - s_typeMap->insert(QString::fromLatin1("JOUR"), QString::fromLatin1("article")); // "Journal" - s_typeMap->insert(QString::fromLatin1("MAP"), QString::fromLatin1("Map")); - s_typeMap->insert(QString::fromLatin1("MGZN"), QString::fromLatin1("article")); // bibtex - s_typeMap->insert(QString::fromLatin1("MPCT"), QString::fromLatin1("Motion picture")); - s_typeMap->insert(QString::fromLatin1("MUSIC"), QString::fromLatin1("Music score")); - s_typeMap->insert(QString::fromLatin1("NEWS"), QString::fromLatin1("Newspaper")); - s_typeMap->insert(QString::fromLatin1("PAMP"), QString::fromLatin1("Pamphlet")); // = "booklet" ? - s_typeMap->insert(QString::fromLatin1("PAT"), QString::fromLatin1("Patent")); - s_typeMap->insert(QString::fromLatin1("PCOMM"), QString::fromLatin1("Personal communication")); - s_typeMap->insert(QString::fromLatin1("RPRT"), QString::fromLatin1("Report")); // = "techreport" ? - s_typeMap->insert(QString::fromLatin1("SER"), QString::fromLatin1("Serial (BookMonograph)")); - s_typeMap->insert(QString::fromLatin1("SLIDE"), QString::fromLatin1("Slide")); - s_typeMap->insert(QString::fromLatin1("SOUND"), QString::fromLatin1("Sound recording")); - s_typeMap->insert(QString::fromLatin1("STAT"), QString::fromLatin1("Statute")); - s_typeMap->insert(QString::fromLatin1("THES"), QString::fromLatin1("phdthesis")); // "mastersthesis" ? - s_typeMap->insert(QString::fromLatin1("UNBILL"), QString::fromLatin1("Unenacted bill/resolution")); - s_typeMap->insert(QString::fromLatin1("UNPB"), QString::fromLatin1("unpublished")); // bibtex - s_typeMap->insert(QString::fromLatin1("VIDEO"), QString::fromLatin1("Video recording")); + s_typeMap->insert(TQString::tqfromLatin1("ABST"), TQString::tqfromLatin1("Abstract")); + s_typeMap->insert(TQString::tqfromLatin1("ADVS"), TQString::tqfromLatin1("Audiovisual material")); + s_typeMap->insert(TQString::tqfromLatin1("ART"), TQString::tqfromLatin1("Art Work")); + s_typeMap->insert(TQString::tqfromLatin1("BILL"), TQString::tqfromLatin1("Bill/Resolution")); + s_typeMap->insert(TQString::tqfromLatin1("BOOK"), TQString::tqfromLatin1("book")); // bibtex + s_typeMap->insert(TQString::tqfromLatin1("CASE"), TQString::tqfromLatin1("Case")); + s_typeMap->insert(TQString::tqfromLatin1("CHAP"), TQString::tqfromLatin1("inbook")); // == "inbook" ? + s_typeMap->insert(TQString::tqfromLatin1("COMP"), TQString::tqfromLatin1("Computer program")); + s_typeMap->insert(TQString::tqfromLatin1("CONF"), TQString::tqfromLatin1("inproceedings")); // == "conference" ? + s_typeMap->insert(TQString::tqfromLatin1("CTLG"), TQString::tqfromLatin1("Catalog")); + s_typeMap->insert(TQString::tqfromLatin1("DATA"), TQString::tqfromLatin1("Data file")); + s_typeMap->insert(TQString::tqfromLatin1("ELEC"), TQString::tqfromLatin1("Electronic Citation")); + s_typeMap->insert(TQString::tqfromLatin1("GEN"), TQString::tqfromLatin1("Generic")); + s_typeMap->insert(TQString::tqfromLatin1("HEAR"), TQString::tqfromLatin1("Hearing")); + s_typeMap->insert(TQString::tqfromLatin1("ICOMM"), TQString::tqfromLatin1("Internet Communication")); + s_typeMap->insert(TQString::tqfromLatin1("INPR"), TQString::tqfromLatin1("In Press")); + s_typeMap->insert(TQString::tqfromLatin1("JFULL"), TQString::tqfromLatin1("Journal (full)")); // = "periodical" ? + s_typeMap->insert(TQString::tqfromLatin1("JOUR"), TQString::tqfromLatin1("article")); // "Journal" + s_typeMap->insert(TQString::tqfromLatin1("MAP"), TQString::tqfromLatin1("Map")); + s_typeMap->insert(TQString::tqfromLatin1("MGZN"), TQString::tqfromLatin1("article")); // bibtex + s_typeMap->insert(TQString::tqfromLatin1("MPCT"), TQString::tqfromLatin1("Motion picture")); + s_typeMap->insert(TQString::tqfromLatin1("MUSIC"), TQString::tqfromLatin1("Music score")); + s_typeMap->insert(TQString::tqfromLatin1("NEWS"), TQString::tqfromLatin1("Newspaper")); + s_typeMap->insert(TQString::tqfromLatin1("PAMP"), TQString::tqfromLatin1("Pamphlet")); // = "booklet" ? + s_typeMap->insert(TQString::tqfromLatin1("PAT"), TQString::tqfromLatin1("Patent")); + s_typeMap->insert(TQString::tqfromLatin1("PCOMM"), TQString::tqfromLatin1("Personal communication")); + s_typeMap->insert(TQString::tqfromLatin1("RPRT"), TQString::tqfromLatin1("Report")); // = "techreport" ? + s_typeMap->insert(TQString::tqfromLatin1("SER"), TQString::tqfromLatin1("Serial (BookMonograph)")); + s_typeMap->insert(TQString::tqfromLatin1("SLIDE"), TQString::tqfromLatin1("Slide")); + s_typeMap->insert(TQString::tqfromLatin1("SOUND"), TQString::tqfromLatin1("Sound recording")); + s_typeMap->insert(TQString::tqfromLatin1("STAT"), TQString::tqfromLatin1("Statute")); + s_typeMap->insert(TQString::tqfromLatin1("THES"), TQString::tqfromLatin1("phdthesis")); // "mastersthesis" ? + s_typeMap->insert(TQString::tqfromLatin1("UNBILL"), TQString::tqfromLatin1("Unenacted bill/resolution")); + s_typeMap->insert(TQString::tqfromLatin1("UNPB"), TQString::tqfromLatin1("unpublished")); // bibtex + s_typeMap->insert(TQString::tqfromLatin1("VIDEO"), TQString::tqfromLatin1("Video recording")); } } @@ -126,7 +126,7 @@ Tellico::Data::CollPtr RISImporter::collection() { m_coll = new Data::BibtexCollection(true); - QDict<Data::Field> risFields; + TQDict<Data::Field> risFields; // need to know if any extended properties in current collection point to RIS // if so, add to collection @@ -134,7 +134,7 @@ Tellico::Data::CollPtr RISImporter::collection() { Data::FieldVec vec = currColl->fields(); for(Data::FieldVec::Iterator it = vec.begin(); it != vec.end(); ++it) { // continue if property is empty - QString ris = it->property(QString::fromLatin1("ris")); + TQString ris = it->property(TQString::tqfromLatin1("ris")); if(ris.isEmpty()) { continue; } @@ -144,13 +144,13 @@ Tellico::Data::CollPtr RISImporter::collection() { f = new Data::Field(*it); m_coll->addField(f); } - f->setProperty(QString::fromLatin1("ris"), ris); + f->setProperty(TQString::tqfromLatin1("ris"), ris); risFields.insert(ris, f); } ProgressItem& item = ProgressManager::self()->newProgressItem(this, progressLabel(), true); item.setTotalSteps(urls().count() * 100); - connect(&item, SIGNAL(signalCancelled(ProgressItem*)), SLOT(slotCancel())); + connect(&item, TQT_SIGNAL(signalCancelled(ProgressItem*)), TQT_SLOT(slotCancel())); ProgressItem::Done done(this); int count = 0; @@ -165,23 +165,23 @@ Tellico::Data::CollPtr RISImporter::collection() { return m_coll; } -void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& risFields_) { - QString str = FileHandler::readTextFile(url_); +void RISImporter::readURL(const KURL& url_, int n, const TQDict<Data::Field>& risFields_) { + TQString str = FileHandler::readTextFile(url_); if(str.isEmpty()) { return; } ISBNValidator isbnval(this); - QTextIStream t(&str); + TQTextIStream t(&str); const uint length = str.length(); - const uint stepSize = QMAX(s_stepSize, length/100); + const uint stepSize = TQMAX(s_stepSize, length/100); const bool showProgress = options() & ImportProgress; bool needToAddFinal = false; - QString sp, ep; + TQString sp, ep; uint j = 0; Data::EntryPtr entry = new Data::Entry(m_coll); @@ -189,19 +189,19 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris // however, at least one website (Springer) outputs RIS with no space after the final "ER -" // so just strip the white space later // also be gracious and allow only any amount of space before hyphen - QRegExp rx(QString::fromLatin1("^(\\w\\w)\\s+-(.*)$")); - QString currLine, nextLine; + TQRegExp rx(TQString::tqfromLatin1("^(\\w\\w)\\s+-(.*)$")); + TQString currLine, nextLine; for(currLine = t.readLine(); !m_cancelled && !currLine.isNull(); currLine = nextLine, j += currLine.length()) { nextLine = t.readLine(); rx.search(currLine); - QString tag = rx.cap(1); - QString value = rx.cap(2).stripWhiteSpace(); + TQString tag = rx.cap(1); + TQString value = rx.cap(2).stripWhiteSpace(); if(tag.isEmpty()) { continue; } // myDebug() << tag << ": " << value << endl; // if the next line is not empty and does not match start regexp, append to value - while(!nextLine.isEmpty() && nextLine.find(rx) == -1) { + while(!nextLine.isEmpty() && nextLine.tqfind(rx) == -1) { value += nextLine.stripWhiteSpace(); nextLine = t.readLine(); } @@ -212,7 +212,7 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris entry = new Data::Entry(m_coll); needToAddFinal = false; continue; - } else if(tag == Latin1Literal("TY") && s_typeMap->contains(value)) { + } else if(tag == Latin1Literal("TY") && s_typeMap->tqcontains(value)) { // for entry-type, switch it to normalized type name value = (*s_typeMap)[value]; } else if(tag == Latin1Literal("SN")) { @@ -225,9 +225,9 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris sp = value; if(!ep.isEmpty()) { value = sp + '-' + ep; - tag = QString::fromLatin1("EP"); - sp = QString(); - ep = QString(); + tag = TQString::tqfromLatin1("EP"); + sp = TQString(); + ep = TQString(); } else { // nothing else to do continue; @@ -236,8 +236,8 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris ep = value; if(!sp.isEmpty()) { value = sp + '-' + ep; - sp = QString(); - ep = QString(); + sp = TQString(); + ep = TQString(); } else { continue; } @@ -248,15 +248,15 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris // the lookup scheme is: // 1. any field has an RIS property that matches the tag name // 2. default field mapping tag -> field name - Data::FieldPtr f = risFields_.find(tag); + Data::FieldPtr f = risFields_.tqfind(tag); if(!f) { // special case for BT // primary title for books, secondary for everything else if(tag == Latin1Literal("BT")) { - if(entry->field(QString::fromLatin1("entry-type")) == Latin1Literal("book")) { - f = m_coll->fieldByName(QString::fromLatin1("title")); + if(entry->field(TQString::tqfromLatin1("entry-type")) == Latin1Literal("book")) { + f = m_coll->fieldByName(TQString::tqfromLatin1("title")); } else { - f = m_coll->fieldByName(QString::fromLatin1("booktitle")); + f = m_coll->fieldByName(TQString::tqfromLatin1("booktitle")); } } else { f = fieldByTag(tag); @@ -272,7 +272,7 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris f->addAllowed(value); // if the field can have multiple values, append current values to new value if((f->flags() & Data::Field::AllowMultiple) && !entry->field(f->name()).isEmpty()) { - value.prepend(entry->field(f->name()) + QString::fromLatin1("; ")); + value.prepend(entry->field(f->name()) + TQString::tqfromLatin1("; ")); } entry->setField(f, value); @@ -287,21 +287,21 @@ void RISImporter::readURL(const KURL& url_, int n, const QDict<Data::Field>& ris } } -Tellico::Data::FieldPtr RISImporter::fieldByTag(const QString& tag_) { +Tellico::Data::FieldPtr RISImporter::fieldByTag(const TQString& tag_) { Data::FieldPtr f = 0; - const QString& fieldTag = (*s_tagMap)[tag_]; + const TQString& fieldTag = (*s_tagMap)[tag_]; if(!fieldTag.isEmpty()) { f = m_coll->fieldByName(fieldTag); if(f) { - f->setProperty(QString::fromLatin1("ris"), tag_); + f->setProperty(TQString::tqfromLatin1("ris"), tag_); return f; } } // add non-default fields if not already there if(tag_== Latin1Literal("L1")) { - f = new Data::Field(QString::fromLatin1("pdf"), i18n("PDF"), Data::Field::URL); - f->setProperty(QString::fromLatin1("ris"), QString::fromLatin1("L1")); + f = new Data::Field(TQString::tqfromLatin1("pdf"), i18n("PDF"), Data::Field::URL); + f->setProperty(TQString::tqfromLatin1("ris"), TQString::tqfromLatin1("L1")); f->setCategory(i18n("Miscellaneous")); } m_coll->addField(f); |