diff options
Diffstat (limited to 'src/translators/pdfimporter.cpp')
-rw-r--r-- | src/translators/pdfimporter.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/translators/pdfimporter.cpp b/src/translators/pdfimporter.cpp index 09df294..a258995 100644 --- a/src/translators/pdfimporter.cpp +++ b/src/translators/pdfimporter.cpp @@ -48,7 +48,7 @@ bool PDFImporter::canImport(int type_) const { } Tellico::Data::CollPtr PDFImporter::collection() { - TQString xsltfile = ::locate("appdata", TQString::tqfromLatin1("xmp2tellico.xsl")); + TQString xsltfile = ::locate("appdata", TQString::fromLatin1("xmp2tellico.xsl")); if(xsltfile.isEmpty()) { kdWarning() << "DropHandler::handleURL() - can not locate xmp2tellico.xsl" << endl; return 0; @@ -100,7 +100,7 @@ Tellico::Data::CollPtr PDFImporter::collection() { setStatusMessage(i18n("Tellico was unable to read any metadata from the PDF file.")); } else { entry = newColl->entries().front(); - hasDOI |= !entry->field(TQString::tqfromLatin1("doi")).isEmpty(); + hasDOI |= !entry->field(TQString::fromLatin1("doi")).isEmpty(); } } @@ -119,21 +119,21 @@ Tellico::Data::CollPtr PDFImporter::collection() { if(doc && !doc->isLocked()) { // now the question is, do we overwrite XMP data with Poppler data? // for now, let's say yes conditionally - TQString s = doc->getInfo(TQString::tqfromLatin1("Title")).simplifyWhiteSpace(); + TQString s = doc->getInfo(TQString::fromLatin1("Title")).simplifyWhiteSpace(); if(!s.isEmpty()) { - entry->setField(TQString::tqfromLatin1("title"), s); + entry->setField(TQString::fromLatin1("title"), s); } // author could be separated by commas, "and" or whatever // we're not going to overwrite it - if(entry->field(TQString::tqfromLatin1("author")).isEmpty()) { - TQRegExp rx(TQString::tqfromLatin1("\\s*(and|,|;)\\s*")); - TQStringList authors = TQStringList::split(rx, doc->getInfo(TQString::tqfromLatin1("Author")).simplifyWhiteSpace()); - entry->setField(TQString::tqfromLatin1("author"), authors.join(TQString::tqfromLatin1("; "))); + if(entry->field(TQString::fromLatin1("author")).isEmpty()) { + TQRegExp rx(TQString::fromLatin1("\\s*(and|,|;)\\s*")); + TQStringList authors = TQStringList::split(rx, doc->getInfo(TQString::fromLatin1("Author")).simplifyWhiteSpace()); + entry->setField(TQString::fromLatin1("author"), authors.join(TQString::fromLatin1("; "))); } - s = doc->getInfo(TQString::tqfromLatin1("Keywords")).simplifyWhiteSpace(); + s = doc->getInfo(TQString::fromLatin1("Keywords")).simplifyWhiteSpace(); if(!s.isEmpty()) { // keywords are also separated by semi-colons in poppler - entry->setField(TQString::tqfromLatin1("keyword"), s); + entry->setField(TQString::fromLatin1("keyword"), s); } // now parse the first page text and try to guess @@ -142,7 +142,7 @@ Tellico::Data::CollPtr PDFImporter::collection() { // a null rectangle means get all text on page TQString text = page->getText(Poppler::Rectangle()); // borrowed from Referencer - TQRegExp rx(TQString::tqfromLatin1("(?:" + TQRegExp rx(TQString::fromLatin1("(?:" "(?:[Dd][Oo][Ii]:? *)" "|" "(?:[Dd]igital *[Oo]bject *[Ii]dentifier:? *)" @@ -157,10 +157,10 @@ Tellico::Data::CollPtr PDFImporter::collection() { if(rx.search(text) > -1) { TQString doi = rx.cap(1); myDebug() << "PDFImporter::collection() - in PDF file, found DOI: " << doi << endl; - entry->setField(TQString::tqfromLatin1("doi"), doi); + entry->setField(TQString::fromLatin1("doi"), doi); hasDOI = true; } - rx = TQRegExp(TQString::tqfromLatin1("arXiv:" + rx = TQRegExp(TQString::fromLatin1("arXiv:" "(" "[^\\/\\s]+" "[\\/\\.]" @@ -169,12 +169,12 @@ Tellico::Data::CollPtr PDFImporter::collection() { if(rx.search(text) > -1) { TQString arxiv = rx.cap(1); myDebug() << "PDFImporter::collection() - in PDF file, found arxiv: " << arxiv << endl; - if(entry->collection()->fieldByName(TQString::tqfromLatin1("arxiv")) == 0) { - Data::FieldPtr field = new Data::Field(TQString::tqfromLatin1("arxiv"), i18n("arXiv ID")); + if(entry->collection()->fieldByName(TQString::fromLatin1("arxiv")) == 0) { + Data::FieldPtr field = new Data::Field(TQString::fromLatin1("arxiv"), i18n("arXiv ID")); field->setCategory(i18n("Publishing")); entry->collection()->addField(field); } - entry->setField(TQString::tqfromLatin1("arxiv"), arxiv); + entry->setField(TQString::fromLatin1("arxiv"), arxiv); hasArxiv = true; } @@ -186,22 +186,22 @@ Tellico::Data::CollPtr PDFImporter::collection() { delete doc; #endif - entry->setField(TQString::tqfromLatin1("url"), (*it).url()); + entry->setField(TQString::fromLatin1("url"), (*it).url()); // always an article? - entry->setField(TQString::tqfromLatin1("entry-type"), TQString::tqfromLatin1("article")); + entry->setField(TQString::fromLatin1("entry-type"), TQString::fromLatin1("article")); TQPixmap pix = NetAccess::filePreview(ref->fileName(), PDF_FILE_PREVIEW_SIZE); delete ref; // removes temp file if(!pix.isNull()) { // is png best option? - TQString id = ImageFactory::addImage(pix, TQString::tqfromLatin1("PNG")); + TQString id = ImageFactory::addImage(pix, TQString::fromLatin1("PNG")); if(!id.isEmpty()) { - Data::FieldPtr field = newColl->fieldByName(TQString::tqfromLatin1("cover")); + Data::FieldPtr field = newColl->fieldByName(TQString::fromLatin1("cover")); if(!field && !newColl->imageFields().isEmpty()) { field = newColl->imageFields().front(); } else if(!field) { - field = new Data::Field(TQString::tqfromLatin1("cover"), i18n("Front Cover"), Data::Field::Image); + field = new Data::Field(TQString::fromLatin1("cover"), i18n("Front Cover"), Data::Field::Image); newColl->addField(field); } entry->setField(field, id); @@ -233,7 +233,7 @@ Tellico::Data::CollPtr PDFImporter::collection() { "CrossRef.org. However, you must create an CrossRef account and add a new " "data source with your account information."), TQString(), - TQString::tqfromLatin1("CrossRefSourceNeeded")); + TQString::fromLatin1("CrossRefSourceNeeded")); } else { Data::EntryVec entries = coll->entries(); for(Fetch::FetcherVec::Iterator fetcher = vec.begin(); fetcher != vec.end(); ++fetcher) { @@ -263,8 +263,8 @@ Tellico::Data::CollPtr PDFImporter::collection() { for(Data::EntryVecIt entry = entries.begin(); entry != entries.end(); ++entry) { if(entry->title().isEmpty()) { // use file name - KURL u = entry->field(TQString::tqfromLatin1("url")); - entry->setField(TQString::tqfromLatin1("title"), u.fileName()); + KURL u = entry->field(TQString::fromLatin1("url")); + entry->setField(TQString::fromLatin1("title"), u.fileName()); } } |