summaryrefslogtreecommitdiffstats
path: root/src/translators/bibtexhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/translators/bibtexhandler.cpp')
-rw-r--r--src/translators/bibtexhandler.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/src/translators/bibtexhandler.cpp b/src/translators/bibtexhandler.cpp
index 8c88e43..e6c07fa 100644
--- a/src/translators/bibtexhandler.cpp
+++ b/src/translators/bibtexhandler.cpp
@@ -26,10 +26,10 @@
#include <kstringhandler.h>
#include <klocale.h>
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qregexp.h>
-#include <qdom.h>
+#include <tqstring.h>
+#include <tqstringlist.h>
+#include <tqregexp.h>
+#include <tqdom.h>
// don't add braces around capital letters by default
#define TELLICO_BIBTEX_BRACES 0
@@ -38,12 +38,12 @@ using Tellico::BibtexHandler;
BibtexHandler::StringListMap* BibtexHandler::s_utf8LatexMap = 0;
BibtexHandler::QuoteStyle BibtexHandler::s_quoteStyle = BibtexHandler::BRACES;
-const QRegExp BibtexHandler::s_badKeyChars(QString::fromLatin1("[^0-9a-zA-Z-]"));
+const TQRegExp BibtexHandler::s_badKeyChars(TQString::tqfromLatin1("[^0-9a-zA-Z-]"));
-QStringList BibtexHandler::bibtexKeys(const Data::EntryVec& entries_) {
- QStringList keys;
+TQStringList BibtexHandler::bibtexKeys(const Data::EntryVec& entries_) {
+ TQStringList keys;
for(Data::EntryVec::ConstIterator it = entries_.begin(); it != entries_.end(); ++it) {
- QString s = bibtexKey(it.data());
+ TQString s = bibtexKey(it.data());
if(!s.isEmpty()) {
keys << s;
}
@@ -51,47 +51,47 @@ QStringList BibtexHandler::bibtexKeys(const Data::EntryVec& entries_) {
return keys;
}
-QString BibtexHandler::bibtexKey(Data::ConstEntryPtr entry_) {
+TQString BibtexHandler::bibtexKey(Data::ConstEntryPtr entry_) {
if(!entry_ || !entry_->collection() || entry_->collection()->type() != Data::Collection::Bibtex) {
- return QString::null;
+ return TQString();
}
const Data::BibtexCollection* c = static_cast<const Data::BibtexCollection*>(entry_->collection().data());
- Data::FieldPtr f = c->fieldByBibtexName(QString::fromLatin1("key"));
+ Data::FieldPtr f = c->fieldByBibtexName(TQString::tqfromLatin1("key"));
if(f) {
- QString key = entry_->field(f->name());
+ TQString key = entry_->field(f->name());
if(!key.isEmpty()) {
return key;
}
}
- QString author;
- Data::FieldPtr authorField = c->fieldByBibtexName(QString::fromLatin1("author"));
+ TQString author;
+ Data::FieldPtr authorField = c->fieldByBibtexName(TQString::tqfromLatin1("author"));
if(authorField) {
if(authorField->flags() & Data::Field::AllowMultiple) {
// grab first author only;
- QString tmp = entry_->field(authorField->name());
+ TQString tmp = entry_->field(authorField->name());
author = tmp.section(';', 0, 0);
} else {
author = entry_->field(authorField->name());
}
}
- Data::FieldPtr titleField = c->fieldByBibtexName(QString::fromLatin1("title"));
- QString title;
+ Data::FieldPtr titleField = c->fieldByBibtexName(TQString::tqfromLatin1("title"));
+ TQString title;
if(titleField) {
title = entry_->field(titleField->name());
}
- Data::FieldPtr yearField = c->fieldByBibtexName(QString::fromLatin1("year"));
- QString year;
+ Data::FieldPtr yearField = c->fieldByBibtexName(TQString::tqfromLatin1("year"));
+ TQString year;
if(yearField) {
year = entry_->field(yearField->name());
}
if(year.isEmpty()) {
- year = entry_->field(QString::fromLatin1("pub_year"));
+ year = entry_->field(TQString::tqfromLatin1("pub_year"));
if(year.isEmpty()) {
- year = entry_->field(QString::fromLatin1("cr_year"));
+ year = entry_->field(TQString::tqfromLatin1("cr_year"));
}
}
year = year.section(';', 0, 0);
@@ -99,28 +99,28 @@ QString BibtexHandler::bibtexKey(Data::ConstEntryPtr entry_) {
return bibtexKey(author, title, year);
}
-QString BibtexHandler::bibtexKey(const QString& author_, const QString& title_, const QString& year_) {
- QString key;
+TQString BibtexHandler::bibtexKey(const TQString& author_, const TQString& title_, const TQString& year_) {
+ TQString key;
// if no comma, take the last word
if(!author_.isEmpty()) {
- if(author_.find(',') == -1) {
+ if(author_.tqfind(',') == -1) {
key += author_.section(' ', -1).lower() + '-';
} else {
// if there is a comma, take the string up to the first comma
key += author_.section(',', 0, 0).lower() + '-';
}
}
- QStringList words = QStringList::split(' ', title_);
- for(QStringList::ConstIterator it = words.begin(); it != words.end(); ++it) {
+ TQStringList words = TQStringList::split(' ', title_);
+ for(TQStringList::ConstIterator it = words.begin(); it != words.end(); ++it) {
key += (*it).left(1).lower();
}
key += year_;
// bibtex key may only contain [0-9a-zA-Z-]
- return key.replace(s_badKeyChars, QString::null);
+ return key.tqreplace(s_badKeyChars, TQString());
}
void BibtexHandler::loadTranslationMaps() {
- QString mapfile = locate("appdata", QString::fromLatin1("bibtex-translation.xml"));
+ TQString mapfile = locate("appdata", TQString::tqfromLatin1("bibtex-translation.xml"));
if(mapfile.isEmpty()) {
return;
}
@@ -130,15 +130,15 @@ void BibtexHandler::loadTranslationMaps() {
KURL u;
u.setPath(mapfile);
// no namespace processing
- QDomDocument dom = FileHandler::readXMLFile(u, false);
+ TQDomDocument dom = FileHandler::readXMLFile(u, false);
- QDomNodeList keyList = dom.elementsByTagName(QString::fromLatin1("key"));
+ TQDomNodeList keyList = dom.elementsByTagName(TQString::tqfromLatin1("key"));
for(unsigned i = 0; i < keyList.count(); ++i) {
- QDomNodeList strList = keyList.item(i).toElement().elementsByTagName(QString::fromLatin1("string"));
+ TQDomNodeList strList = keyList.item(i).toElement().elementsByTagName(TQString::tqfromLatin1("string"));
// the strList might have more than one node since there are multiple ways
// to represent a character in LaTex.
- QString s = keyList.item(i).toElement().attribute(QString::fromLatin1("char"));
+ TQString s = keyList.item(i).toElement().attribute(TQString::tqfromLatin1("char"));
for(unsigned j = 0; j < strList.count(); ++j) {
(*s_utf8LatexMap)[s].append(strList.item(j).toElement().text());
// kdDebug() << "BibtexHandler::loadTranslationMaps - "
@@ -147,15 +147,15 @@ void BibtexHandler::loadTranslationMaps() {
}
}
-QString BibtexHandler::importText(char* text_) {
+TQString BibtexHandler::importText(char* text_) {
if(!s_utf8LatexMap) {
loadTranslationMaps();
}
- QString str = QString::fromUtf8(text_);
+ TQString str = TQString::fromUtf8(text_);
for(StringListMap::Iterator it = s_utf8LatexMap->begin(); it != s_utf8LatexMap->end(); ++it) {
- for(QStringList::Iterator sit = it.data().begin(); sit != it.data().end(); ++sit) {
- str.replace(*sit, it.key());
+ for(TQStringList::Iterator sit = it.data().begin(); sit != it.data().end(); ++sit) {
+ str.tqreplace(*sit, it.key());
}
}
@@ -164,34 +164,34 @@ QString BibtexHandler::importText(char* text_) {
// we need to lower-case any capitalized text after the first letter that is
// NOT contained in braces
- QRegExp rx(QString::fromLatin1("\\{([A-Z]+)\\}"));
+ TQRegExp rx(TQString::tqfromLatin1("\\{([A-Z]+)\\}"));
rx.setMinimal(true);
- str.replace(rx, QString::fromLatin1("\\1"));
+ str.tqreplace(rx, TQString::tqfromLatin1("\\1"));
return str;
}
-QString BibtexHandler::exportText(const QString& text_, const QStringList& macros_) {
+TQString BibtexHandler::exportText(const TQString& text_, const TQStringList& macros_) {
if(!s_utf8LatexMap) {
loadTranslationMaps();
}
- QChar lquote, rquote;
+ TQChar lquote, rquote;
switch(s_quoteStyle) {
case BRACES:
lquote = '{';
rquote = '}';
break;
- case QUOTES:
+ case TQUOTES:
lquote = '"';
rquote = '"';
break;
}
- QString text = text_;
+ TQString text = text_;
for(StringListMap::Iterator it = s_utf8LatexMap->begin(); it != s_utf8LatexMap->end(); ++it) {
- text.replace(it.key(), it.data()[0]);
+ text.tqreplace(it.key(), it.data()[0]);
}
if(macros_.isEmpty()) {
@@ -203,13 +203,13 @@ QString BibtexHandler::exportText(const QString& text_, const QStringList& macro
// change it. Then, in case '#' occurs in a non-macro string, replace any occurrences of '}#{' with '#'
// list of new tokens
- QStringList list;
+ TQStringList list;
// first, split the text
- QStringList tokens = QStringList::split('#', text, true);
- for(QStringList::Iterator it = tokens.begin(); it != tokens.end(); ++it) {
+ TQStringList tokens = TQStringList::split('#', text, true);
+ for(TQStringList::Iterator it = tokens.begin(); it != tokens.end(); ++it) {
// check to see if token is a macro
- if(macros_.findIndex((*it).stripWhiteSpace()) == -1) {
+ if(macros_.tqfindIndex((*it).stripWhiteSpace()) == -1) {
// the token is NOT a macro, add braces around whole words and also around capitals
list << lquote + addBraces(*it) + rquote;
} else {
@@ -217,14 +217,14 @@ QString BibtexHandler::exportText(const QString& text_, const QStringList& macro
}
}
- const QChar octo = '#';
+ const TQChar octo = '#';
text = list.join(octo);
- text.replace(QString(rquote)+octo+lquote, octo);
+ text.tqreplace(TQString(rquote)+octo+lquote, octo);
return text;
}
-bool BibtexHandler::setFieldValue(Data::EntryPtr entry_, const QString& bibtexField_, const QString& value_) {
+bool BibtexHandler::setFieldValue(Data::EntryPtr entry_, const TQString& bibtexField_, const TQString& value_) {
Data::BibtexCollection* c = static_cast<Data::BibtexCollection*>(entry_->collection().data());
Data::FieldPtr field = c->fieldByBibtexName(bibtexField_);
if(!field) {
@@ -241,14 +241,14 @@ bool BibtexHandler::setFieldValue(Data::EntryPtr entry_, const QString& bibtexFi
field = new Data::Field(*existingField);
} else if(value_.length() < 100) {
// arbitrarily say if the value has more than 100 chars, then it's a paragraph
- QString vlower = value_.lower();
+ TQString vlower = value_.lower();
// special case, try to detect URLs
- // In qt 3.1, QString::startsWith() is always case-sensitive
+ // In qt 3.1, TQString::startsWith() is always case-sensitive
if(bibtexField_ == Latin1Literal("url")
- || vlower.startsWith(QString::fromLatin1("http")) // may also be https
- || vlower.startsWith(QString::fromLatin1("ftp:/"))
- || vlower.startsWith(QString::fromLatin1("file:/"))
- || vlower.startsWith(QString::fromLatin1("/"))) { // assume this indicates a local path
+ || vlower.startsWith(TQString::tqfromLatin1("http")) // may also be https
+ || vlower.startsWith(TQString::tqfromLatin1("ftp:/"))
+ || vlower.startsWith(TQString::tqfromLatin1("file:/"))
+ || vlower.startsWith(TQString::tqfromLatin1("/"))) { // assume this indicates a local path
myDebug() << "BibtexHandler::setFieldValue() - creating a URL field for " << bibtexField_ << endl;
field = new Data::Field(bibtexField_, KStringHandler::capwords(bibtexField_), Data::Field::URL);
} else {
@@ -258,15 +258,15 @@ bool BibtexHandler::setFieldValue(Data::EntryPtr entry_, const QString& bibtexFi
} else {
field = new Data::Field(bibtexField_, KStringHandler::capwords(bibtexField_), Data::Field::Para);
}
- field->setProperty(QString::fromLatin1("bibtex"), bibtexField_);
+ field->setProperty(TQString::tqfromLatin1("bibtex"), bibtexField_);
c->addField(field);
}
// special case keywords, replace commas with semi-colons so they get separated
- QString value = value_;
- if(field->property(QString::fromLatin1("bibtex")).startsWith(QString::fromLatin1("keyword"))) {
- value.replace(',', ';');
+ TQString value = value_;
+ if(field->property(TQString::tqfromLatin1("bibtex")).startsWith(TQString::tqfromLatin1("keyword"))) {
+ value.tqreplace(',', ';');
// special case refbase bibtex export, with multiple keywords fields
- QString oValue = entry_->field(field);
+ TQString oValue = entry_->field(field);
if(!oValue.isEmpty()) {
value = oValue + "; " + value;
}
@@ -274,19 +274,19 @@ bool BibtexHandler::setFieldValue(Data::EntryPtr entry_, const QString& bibtexFi
return entry_->setField(field, value);
}
-QString& BibtexHandler::cleanText(QString& text_) {
+TQString& BibtexHandler::cleanText(TQString& text_) {
// FIXME: need to improve this for removing all Latex entities
-// QRegExp rx(QString::fromLatin1("(?=[^\\\\])\\\\.+\\{"));
- QRegExp rx(QString::fromLatin1("\\\\.+\\{"));
+// TQRegExp rx(TQString::tqfromLatin1("(?=[^\\\\])\\\\.+\\{"));
+ TQRegExp rx(TQString::tqfromLatin1("\\\\.+\\{"));
rx.setMinimal(true);
- text_.replace(rx, QString::null);
- text_.replace(QRegExp(QString::fromLatin1("[{}]")), QString::null);
- text_.replace('~', ' ');
+ text_.tqreplace(rx, TQString());
+ text_.tqreplace(TQRegExp(TQString::tqfromLatin1("[{}]")), TQString());
+ text_.tqreplace('~', ' ');
return text_;
}
// add braces around capital letters
-QString& BibtexHandler::addBraces(QString& text) {
+TQString& BibtexHandler::addBraces(TQString& text) {
#if !TELLICO_BIBTEX_BRACES
return text;
#else
@@ -294,7 +294,7 @@ QString& BibtexHandler::addBraces(QString& text) {
uint l = text.length();
// start at first letter, but skip if only the first is capitalized
for(uint i = 0; i < l; ++i) {
- const QChar c = text.at(i);
+ const TQChar c = text.at(i);
if(inside == 0 && c >= 'A' && c <= 'Z') {
uint j = i+1;
while(text.at(j) >= 'A' && text.at(j) <= 'Z' && j < l) {