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/entry.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/entry.cpp')
-rw-r--r-- | src/entry.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/src/entry.cpp b/src/entry.cpp index a558ba2..db16e0a 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -25,13 +25,13 @@ #include <klocale.h> -#include <qregexp.h> +#include <tqregexp.h> using Tellico::Data::Entry; using Tellico::Data::EntryGroup; -EntryGroup::EntryGroup(const QString& group, const QString& field) - : QObject(), EntryVec(), m_group(Tellico::shareString(group)), m_field(Tellico::shareString(field)) { +EntryGroup::EntryGroup(const TQString& group, const TQString& field) + : TQObject(), EntryVec(), m_group(Tellico::shareString(group)), m_field(Tellico::shareString(field)) { } EntryGroup::~EntryGroup() { @@ -48,16 +48,16 @@ bool Entry::operator==(const Entry& e1) { e1.m_coll && e1.m_coll->type() == Collection::File) { // don't forget case where both could have empty urls // but different values for other fields - QString u = field(QString::fromLatin1("url")); + TQString u = field(TQString::tqfromLatin1("url")); if(!u.isEmpty()) { // versions before 1.2.7 could have saved the url without the protocol - bool b = KURL::fromPathOrURL(u) == KURL::fromPathOrURL(e1.field(QString::fromLatin1("url"))); + bool b = KURL::fromPathOrURL(u) == KURL::fromPathOrURL(e1.field(TQString::tqfromLatin1("url"))); if(b) { return true; } else { - Data::FieldPtr f = m_coll->fieldByName(QString::fromLatin1("url")); - if(f && f->property(QString::fromLatin1("relative")) == Latin1Literal("true")) { - return KURL(Document::self()->URL(), u) == KURL::fromPathOrURL(e1.field(QString::fromLatin1("url"))); + Data::FieldPtr f = m_coll->fieldByName(TQString::tqfromLatin1("url")); + if(f && f->property(TQString::tqfromLatin1("relative")) == Latin1Literal("true")) { + return KURL(Document::self()->URL(), u) == KURL::fromPathOrURL(e1.field(TQString::tqfromLatin1("url"))); } } } @@ -66,7 +66,7 @@ bool Entry::operator==(const Entry& e1) { return false; } for(StringMap::ConstIterator it = e1.m_fields.begin(); it != e1.m_fields.end(); ++it) { - if(!m_fields.contains(it.key()) || m_fields[it.key()] != it.data()) { + if(!m_fields.tqcontains(it.key()) || m_fields[it.key()] != it.data()) { return false; } } @@ -125,50 +125,50 @@ void Entry::setCollection(CollPtr coll_) { // it would be better to do this in a real OOO way, but this should work const bool addEntryType = m_coll->type() == Collection::Book && coll_->type() == Collection::Bibtex && - !m_coll->hasField(QString::fromLatin1("entry-type")); + !m_coll->hasField(TQString::tqfromLatin1("entry-type")); m_coll = coll_; m_id = -1; // set this after changing the m_coll pointer since setField() checks field validity if(addEntryType) { - setField(QString::fromLatin1("entry-type"), QString::fromLatin1("book")); + setField(TQString::tqfromLatin1("entry-type"), TQString::tqfromLatin1("book")); } } -QString Entry::title() const { - return formattedField(QString::fromLatin1("title")); +TQString Entry::title() const { + return formattedField(TQString::tqfromLatin1("title")); } -QString Entry::field(Data::FieldPtr field_, bool formatted_/*=false*/) const { +TQString Entry::field(Data::FieldPtr field_, bool formatted_/*=false*/) const { return field(field_->name(), formatted_); } -QString Entry::field(const QString& fieldName_, bool formatted_/*=false*/) const { +TQString Entry::field(const TQString& fieldName_, bool formatted_/*=false*/) const { if(formatted_) { return formattedField(fieldName_); } FieldPtr f = m_coll->fieldByName(fieldName_); if(!f) { - return QString::null; + return TQString(); } if(f->type() == Field::Dependent) { return dependentValue(this, f->description(), false); } - if(!m_fields.isEmpty() && m_fields.contains(fieldName_)) { + if(!m_fields.isEmpty() && m_fields.tqcontains(fieldName_)) { return m_fields[fieldName_]; } - return QString::null; + return TQString(); } -QString Entry::formattedField(Data::FieldPtr field_) const { +TQString Entry::formattedField(Data::FieldPtr field_) const { return formattedField(field_->name()); } -QString Entry::formattedField(const QString& fieldName_) const { +TQString Entry::formattedField(const TQString& fieldName_) const { FieldPtr f = m_coll->fieldByName(fieldName_); if(!f) { - return QString::null; + return TQString(); } Field::FormatFlag flag = f->formatFlag(); @@ -186,8 +186,8 @@ QString Entry::formattedField(const QString& fieldName_) const { return field(fieldName_); } - if(m_formattedFields.isEmpty() || !m_formattedFields.contains(fieldName_)) { - QString value = field(fieldName_); + if(m_formattedFields.isEmpty() || !m_formattedFields.tqcontains(fieldName_)) { + TQString value = field(fieldName_); if(!value.isEmpty()) { // special for Bibtex collections if(m_coll->type() == Collection::Bibtex) { @@ -202,33 +202,33 @@ QString Entry::formattedField(const QString& fieldName_) const { return m_formattedFields[fieldName_]; } -QStringList Entry::fields(Data::FieldPtr field_, bool formatted_) const { +TQStringList Entry::fields(Data::FieldPtr field_, bool formatted_) const { return fields(field_->name(), formatted_); } -QStringList Entry::fields(const QString& field_, bool formatted_) const { - QString s = formatted_ ? formattedField(field_) : field(field_); +TQStringList Entry::fields(const TQString& field_, bool formatted_) const { + TQString s = formatted_ ? formattedField(field_) : field(field_); if(s.isEmpty()) { - return QStringList(); + return TQStringList(); } return Field::split(s, true); } -bool Entry::setField(Data::FieldPtr field_, const QString& value_) { +bool Entry::setField(Data::FieldPtr field_, const TQString& value_) { return setField(field_->name(), value_); } -bool Entry::setField(const QString& name_, const QString& value_) { +bool Entry::setField(const TQString& name_, const TQString& value_) { if(name_.isEmpty()) { kdWarning() << "Entry::setField() - empty field name for value: " << value_ << endl; return false; } // an empty value means remove the field if(value_.isEmpty()) { - if(!m_fields.isEmpty() && m_fields.contains(name_)) { + if(!m_fields.isEmpty() && m_fields.tqcontains(name_)) { m_fields.remove(name_); } - invalidateFormattedFieldValue(name_); + tqinvalidateFormattedFieldValue(name_); return true; } @@ -259,12 +259,12 @@ bool Entry::setField(const QString& name_, const QString& value_) { } else { m_fields.insert(Tellico::shareString(name_), value_); } - invalidateFormattedFieldValue(name_); + tqinvalidateFormattedFieldValue(name_); return true; } bool Entry::addToGroup(EntryGroup* group_) { - if(!group_ || m_groups.contains(group_)) { + if(!group_ || m_groups.tqcontains(group_)) { return false; } @@ -295,13 +295,13 @@ void Entry::clearGroups() { // this function gets called before m_groups is updated. In fact, it is used to // update that list. This is the function that actually parses the field values // and returns the list of the group names. -QStringList Entry::groupNamesByFieldName(const QString& fieldName_) const { +TQStringList Entry::groupNamesByFieldName(const TQString& fieldName_) const { // myDebug() << "Entry::groupsByfieldName() - " << fieldName_ << endl; FieldPtr f = m_coll->fieldByName(fieldName_); // easy if not allowing multiple values if(!(f->flags() & Field::AllowMultiple)) { - QString value = formattedField(fieldName_); + TQString value = formattedField(fieldName_); if(value.isEmpty()) { return i18n(Collection::s_emptyGroupTitle); } else { @@ -309,15 +309,15 @@ QStringList Entry::groupNamesByFieldName(const QString& fieldName_) const { } } - QStringList groups = fields(fieldName_, true); + TQStringList groups = fields(fieldName_, true); if(groups.isEmpty()) { return i18n(Collection::s_emptyGroupTitle); } else if(f->type() == Field::Table) { // quick hack for tables, how often will a user have "::" in their value? // only use first column for group - QStringList::Iterator it = groups.begin(); + TQStringList::Iterator it = groups.begin(); while(it != groups.end()) { - (*it) = (*it).section(QString::fromLatin1("::"), 0, 0); + (*it) = (*it).section(TQString::tqfromLatin1("::"), 0, 0); if((*it).isEmpty()) { it = groups.remove(it); // points to next in list } else { @@ -329,33 +329,33 @@ QStringList Entry::groupNamesByFieldName(const QString& fieldName_) const { } bool Entry::isOwned() { - return (m_coll && m_id > -1 && m_coll->entryCount() > 0 && m_coll->entries().contains(this)); + return (m_coll && m_id > -1 && m_coll->entryCount() > 0 && m_coll->entries().tqcontains(this)); } -// a null string means invalidate all -void Entry::invalidateFormattedFieldValue(const QString& name_) { +// a null string means tqinvalidate all +void Entry::tqinvalidateFormattedFieldValue(const TQString& name_) { if(name_.isNull()) { m_formattedFields.clear(); - } else if(!m_formattedFields.isEmpty() && m_formattedFields.contains(name_)) { + } else if(!m_formattedFields.isEmpty() && m_formattedFields.tqcontains(name_)) { m_formattedFields.remove(name_); } } // format is something like "%{year} %{author}" -QString Entry::dependentValue(ConstEntryPtr entry_, const QString& format_, bool formatted_) { +TQString Entry::dependentValue(ConstEntryPtr entry_, const TQString& format_, bool formatted_) { if(!entry_) { return format_; } - QString result, fieldName; + TQString result, fieldName; FieldPtr field; int endPos; int curPos = 0; - int pctPos = format_.find('%', curPos); + int pctPos = format_.tqfind('%', curPos); while(pctPos != -1 && pctPos+1 < static_cast<int>(format_.length())) { if(format_[pctPos+1] == '{') { - endPos = format_.find('}', pctPos+2); + endPos = format_.tqfind('}', pctPos+2); if(endPos > -1) { result += format_.mid(curPos, pctPos-curPos); fieldName = format_.mid(pctPos+2, endPos-pctPos-2); @@ -368,7 +368,7 @@ QString Entry::dependentValue(ConstEntryPtr entry_, const QString& format_, bool // don't format, just capitalize result += entry_->field(field, formatted_); } else if(fieldName == Latin1Literal("id")) { - result += QString::number(entry_->id()); + result += TQString::number(entry_->id()); } else { result += format_.mid(pctPos, endPos-pctPos+1); } @@ -380,7 +380,7 @@ QString Entry::dependentValue(ConstEntryPtr entry_, const QString& format_, bool result += format_.mid(curPos, pctPos-curPos+1); curPos = pctPos+1; } - pctPos = format_.find('%', curPos); + pctPos = format_.tqfind('%', curPos); } result += format_.mid(curPos, format_.length()-curPos); // myDebug() << "Entry::dependentValue() - " << format_ << " = " << result << endl; @@ -389,7 +389,7 @@ QString Entry::dependentValue(ConstEntryPtr entry_, const QString& format_, bool return result.simplifyWhiteSpace(); } -int Entry::compareValues(EntryPtr e1, EntryPtr e2, const QString& f, ConstCollPtr c) { +int Entry::compareValues(EntryPtr e1, EntryPtr e2, const TQString& f, ConstCollPtr c) { return compareValues(e1, e2, c->fieldByName(f)); } @@ -397,8 +397,8 @@ int Entry::compareValues(EntryPtr e1, EntryPtr e2, FieldPtr f) { if(!e1 || !e2 || !f) { return 0; } - QString s1 = e1->field(f).lower(); - QString s2 = e2->field(f).lower(); + TQString s1 = e1->field(f).lower(); + TQString s2 = e2->field(f).lower(); if(s1.isEmpty() || s2.isEmpty()) { return 0; } @@ -423,9 +423,9 @@ int Entry::compareValues(EntryPtr e1, EntryPtr e2, FieldPtr f) { } } // try removing punctuation - QRegExp notAlphaNum(QString::fromLatin1("[^\\s\\w]")); - QString s1a = s1; s1a.remove(notAlphaNum); - QString s2a = s2; s2a.remove(notAlphaNum); + TQRegExp notAlphaNum(TQString::tqfromLatin1("[^\\s\\w]")); + TQString s1a = s1; s1a.remove(notAlphaNum); + TQString s2a = s2; s2a.remove(notAlphaNum); if(!s1a.isEmpty() && s1a == s2a) { // myDebug() << "match without punctuation" << endl; return 5; @@ -436,26 +436,26 @@ int Entry::compareValues(EntryPtr e1, EntryPtr e2, FieldPtr f) { // myDebug() << "match without articles" << endl; return 3; } - // try removing everything between parentheses - QRegExp rx(QString::fromLatin1("\\s*\\(.*\\)\\s*")); + // try removing everything between tqparentheses + TQRegExp rx(TQString::tqfromLatin1("\\s*\\(.*\\)\\s*")); s1.remove(rx); s2.remove(rx); if(!s1.isEmpty() && s1 == s2) { -// myDebug() << "match without parentheses" << endl; +// myDebug() << "match without tqparentheses" << endl; return 2; } if(f->flags() & Field::AllowMultiple) { - QStringList sl1 = e1->fields(f, false); - QStringList sl2 = e2->fields(f, false); + TQStringList sl1 = e1->fields(f, false); + TQStringList sl2 = e2->fields(f, false); int matches = 0; - for(QStringList::ConstIterator it = sl1.begin(); it != sl1.end(); ++it) { - matches += sl2.contains(*it); + for(TQStringList::ConstIterator it = sl1.begin(); it != sl1.end(); ++it) { + matches += sl2.tqcontains(*it); } if(matches == 0 && f->formatFlag() == Field::FormatName) { sl1 = e1->fields(f, true); sl2 = e2->fields(f, true); - for(QStringList::ConstIterator it = sl1.begin(); it != sl1.end(); ++it) { - matches += sl2.contains(*it); + for(TQStringList::ConstIterator it = sl1.begin(); it != sl1.end(); ++it) { + matches += sl2.tqcontains(*it); } } return matches; |