diff options
Diffstat (limited to 'src/collection.cpp')
-rw-r--r-- | src/collection.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/src/collection.cpp b/src/collection.cpp index c6f77ca..0e4b06b 100644 --- a/src/collection.cpp +++ b/src/collection.cpp @@ -24,16 +24,16 @@ #include <klocale.h> -#include <qregexp.h> -#include <qvaluestack.h> +#include <tqregexp.h> +#include <tqvaluestack.h> using Tellico::Data::Collection; const char* Collection::s_emptyGroupTitle = I18N_NOOP("(Empty)"); -const QString Collection::s_peopleGroupName = QString::fromLatin1("_people"); +const TQString Collection::s_peopleGroupName = TQString::tqfromLatin1("_people"); -Collection::Collection(const QString& title_) - : QObject(), KShared(), m_nextEntryId(0), m_title(title_), m_entryIdDict(997) +Collection::Collection(const TQString& title_) + : TQObject(), KShared(), m_nextEntryId(0), m_title(title_), m_entryIdDict(997) , m_trackGroups(false) { m_entryGroupDicts.setAutoDelete(true); @@ -43,7 +43,7 @@ Collection::Collection(const QString& title_) Collection::~Collection() { } -QString Collection::typeName() const { +TQString Collection::typeName() const { return CollectionFactory::typeName(type()); } @@ -68,7 +68,7 @@ bool Collection::addField(FieldPtr field_) { // it's not sufficient to merely check the new field if(dependentFieldHasRecursion(field_)) { - field_->setDescription(QString()); + field_->setDescription(TQString()); } m_fields.append(field_); @@ -76,7 +76,7 @@ bool Collection::addField(FieldPtr field_) { m_peopleFields.append(field_); // list of people attributes if(m_peopleFields.count() > 1) { // the second time that a person field is added, add a "pseudo-group" for people - if(m_entryGroupDicts.find(s_peopleGroupName) == 0) { + if(m_entryGroupDicts.tqfind(s_peopleGroupName) == 0) { EntryGroupDict* d = new EntryGroupDict(); d->setAutoDelete(true); m_entryGroupDicts.insert(s_peopleGroupName, d); @@ -92,12 +92,12 @@ bool Collection::addField(FieldPtr field_) { m_imageFields.append(field_); } - if(!field_->category().isEmpty() && m_fieldCategories.findIndex(field_->category()) == -1) { + if(!field_->category().isEmpty() && m_fieldCategories.tqfindIndex(field_->category()) == -1) { m_fieldCategories << field_->category(); } if(field_->flags() & Field::AllowGrouped) { - // m_entryGroupsDicts autoDeletes each QDict when the Collection d'tor is called + // m_entryGroupsDicts autoDeletes each TQDict when the Collection d'tor is called EntryGroupDict* dict = new EntryGroupDict(); dict->setAutoDelete(true); m_entryGroupDicts.insert(field_->name(), dict); @@ -135,7 +135,7 @@ bool Collection::mergeField(FieldPtr newField_) { if(newField_->type() == Field::Table2) { newField_->setType(Data::Field::Table); - newField_->setProperty(QString::fromLatin1("columns"), QChar('2')); + newField_->setProperty(TQString::tqfromLatin1("columns"), TQChar('2')); } // the original field type is kept @@ -146,10 +146,10 @@ bool Collection::mergeField(FieldPtr newField_) { // if field is a Choice, then make sure all values are there if(currField->type() == Field::Choice && currField->allowed() != newField_->allowed()) { - QStringList allowed = currField->allowed(); - const QStringList& newAllowed = newField_->allowed(); - for(QStringList::ConstIterator it = newAllowed.begin(); it != newAllowed.end(); ++it) { - if(allowed.findIndex(*it) == -1) { + TQStringList allowed = currField->allowed(); + const TQStringList& newAllowed = newField_->allowed(); + for(TQStringList::ConstIterator it = newAllowed.begin(); it != newAllowed.end(); ++it) { + if(allowed.tqfindIndex(*it) == -1) { allowed.append(*it); } } @@ -162,14 +162,14 @@ bool Collection::mergeField(FieldPtr newField_) { if(currField->description().isEmpty()) { currField->setDescription(newField_->description()); if(dependentFieldHasRecursion(currField)) { - currField->setDescription(QString()); + currField->setDescription(TQString()); } } // if new field has additional extended properties, add those for(StringMap::ConstIterator it = newField_->propertyList().begin(); it != newField_->propertyList().end(); ++it) { - const QString propName = it.key(); - const QString currValue = currField->property(propName); + const TQString propName = it.key(); + const TQString currValue = currField->property(propName); if(currValue.isEmpty()) { currField->setProperty(propName, it.data()); } else if (it.data() != currValue) { @@ -181,14 +181,14 @@ bool Collection::mergeField(FieldPtr newField_) { uint currNum = Tellico::toUInt(currValue, &ok); uint newNum = Tellico::toUInt(it.data(), &ok); if(newNum > currNum) { // bigger values - currField->setProperty(propName, QString::number(newNum)); + currField->setProperty(propName, TQString::number(newNum)); } } else if(currField->type() == Field::Rating && propName == Latin1Literal("minimum")) { bool ok; uint currNum = Tellico::toUInt(currValue, &ok); uint newNum = Tellico::toUInt(it.data(), &ok); if(newNum < currNum) { // smaller values - currField->setProperty(propName, QString::number(newNum)); + currField->setProperty(propName, TQString::number(newNum)); } } } @@ -208,7 +208,7 @@ bool Collection::modifyField(FieldPtr newField_) { // myDebug() << "Collection::modifyField() - " << newField_->name() << endl; // the field name never changes - const QString fieldName = newField_->name(); + const TQString fieldName = newField_->name(); FieldPtr oldField = fieldByName(fieldName); if(!oldField) { myDebug() << "Collection::modifyField() - no field named " << fieldName << endl; @@ -216,13 +216,13 @@ bool Collection::modifyField(FieldPtr newField_) { } // update name dict - m_fieldNameDict.replace(fieldName, newField_); + m_fieldNameDict.tqreplace(fieldName, newField_); // update titles - const QString oldTitle = oldField->title(); - const QString newTitle = newField_->title(); + const TQString oldTitle = oldField->title(); + const TQString newTitle = newField_->title(); if(oldTitle == newTitle) { - m_fieldTitleDict.replace(newTitle, newField_); + m_fieldTitleDict.tqreplace(newTitle, newField_); } else { m_fieldTitleDict.remove(oldTitle); m_fieldTitles.remove(oldTitle); @@ -231,7 +231,7 @@ bool Collection::modifyField(FieldPtr newField_) { } // now replace the field pointer in the list - FieldVec::Iterator it = m_fields.find(oldField); + FieldVec::Iterator it = m_fields.tqfind(oldField); if(it != m_fields.end()) { m_fields.insert(it, newField_); m_fields.remove(oldField); @@ -245,24 +245,24 @@ bool Collection::modifyField(FieldPtr newField_) { m_fieldCategories.clear(); for(FieldVec::Iterator it = m_fields.begin(); it != m_fields.end(); ++it) { // add category if it's not in the list yet - if(!it->category().isEmpty() && !m_fieldCategories.contains(it->category())) { + if(!it->category().isEmpty() && !m_fieldCategories.tqcontains(it->category())) { m_fieldCategories += it->category(); } } } if(dependentFieldHasRecursion(newField_)) { - newField_->setDescription(QString()); + newField_->setDescription(TQString()); } // keep track of if the entry groups will need to be reset bool resetGroups = false; - // if format is different, go ahead and invalidate all formatted entry values + // if format is different, go ahead and tqinvalidate all formatted entry values if(oldField->formatFlag() != newField_->formatFlag()) { - // invalidate cached format strings of all entry attributes of this name + // tqinvalidate cached format strings of all entry attributes of this name for(EntryVecIt it = m_entries.begin(); it != m_entries.end(); ++it) { - it->invalidateFormattedFieldValue(fieldName); + it->tqinvalidateFormattedFieldValue(fieldName); } resetGroups = true; } @@ -279,7 +279,7 @@ bool Collection::modifyField(FieldPtr newField_) { } if(isPeople) { // if there's more than one people field and no people dict exists yet, add it - if(m_peopleFields.count() > 1 && m_entryGroupDicts.find(s_peopleGroupName) == 0) { + if(m_peopleFields.count() > 1 && m_entryGroupDicts.tqfind(s_peopleGroupName) == 0) { EntryGroupDict* d = new EntryGroupDict(); d->setAutoDelete(true); m_entryGroupDicts.insert(s_peopleGroupName, d); @@ -303,7 +303,7 @@ bool Collection::modifyField(FieldPtr newField_) { resetGroups = true; } else { // don't do this, it wipes out the old groups! -// m_entryGroupDicts.replace(fieldName, new EntryGroupDict()); +// m_entryGroupDicts.tqreplace(fieldName, new EntryGroupDict()); } } else if(isGrouped) { EntryGroupDict* d = new EntryGroupDict(); @@ -325,7 +325,7 @@ bool Collection::modifyField(FieldPtr newField_) { if(resetGroups) { myLog() << "Collection::modifyField() - invalidating groups" << endl; - invalidateGroups(); + tqinvalidateGroups(); } // now to update all entries if the field is a dependent and the description changed @@ -336,13 +336,13 @@ bool Collection::modifyField(FieldPtr newField_) { return true; } -bool Collection::removeField(const QString& name_, bool force_) { +bool Collection::removeField(const TQString& name_, bool force_) { return removeField(fieldByName(name_), force_); } // force allows me to force the deleting of the title field if I need to bool Collection::removeField(FieldPtr field_, bool force_/*=false*/) { - if(!field_ || !m_fields.contains(field_)) { + if(!field_ || !m_fields.tqcontains(field_)) { if(field_) { myDebug() << "Collection::removeField - false: " << field_->name() << endl; } @@ -374,7 +374,7 @@ bool Collection::removeField(FieldPtr field_, bool force_/*=false*/) { for(EntryVecIt it = m_entries.begin(); it != m_entries.end(); ++it) { // setting the fields to an empty string removes the value from the entry's list - it->setField(field_, QString::null); + it->setField(field_, TQString()); } if(field_->flags() & Field::AllowGrouped) { @@ -406,7 +406,7 @@ void Collection::reorderFields(const FieldVec& list_) { // also reset category list, since the order may have changed m_fieldCategories.clear(); for(FieldVec::Iterator it = m_fields.begin(); it != m_fields.end(); ++it) { - if(!it->category().isEmpty() && !m_fieldCategories.contains(it->category())) { + if(!it->category().isEmpty() && !m_fieldCategories.tqcontains(it->category())) { m_fieldCategories << it->category(); } } @@ -432,7 +432,7 @@ void Collection::addEntries(EntryVec entries_) { } else if(entry->id() == -1) { entry->setId(m_nextEntryId); ++m_nextEntryId; - } else if(m_entryIdDict.find(entry->id())) { + } else if(m_entryIdDict.tqfind(entry->id())) { if(!foster) { myDebug() << "Collection::addEntries() - the collection already has an entry with id = " << entry->id() << endl; } @@ -452,10 +452,10 @@ void Collection::removeEntriesFromDicts(EntryVec entries_) { // need a copy of the vector since it gets changed PtrVector<EntryGroup> groups = entry->groups(); for(PtrVector<EntryGroup>::Iterator group = groups.begin(); group != groups.end(); ++group) { - if(entry->removeFromGroup(group.ptr()) && !modifiedGroups.contains(group.ptr())) { + if(entry->removeFromGroup(group.ptr()) && !modifiedGroups.tqcontains(group.ptr())) { modifiedGroups.push_back(group.ptr()); } - if(group->isEmpty() && !m_groupsToDelete.contains(group.ptr())) { + if(group->isEmpty() && !m_groupsToDelete.tqcontains(group.ptr())) { m_groupsToDelete.push_back(group.ptr()); } } @@ -492,9 +492,9 @@ bool Collection::removeEntries(EntryVec vec_) { return success; } -Tellico::Data::FieldVec Collection::fieldsByCategory(const QString& cat_) { +Tellico::Data::FieldVec Collection::fieldsByCategory(const TQString& cat_) { #ifndef NDEBUG - if(m_fieldCategories.findIndex(cat_) == -1) { + if(m_fieldCategories.tqfindIndex(cat_) == -1) { myDebug() << "Collection::fieldsByCategory() - '" << cat_ << "' is not in category list" << endl; } #endif @@ -512,32 +512,32 @@ Tellico::Data::FieldVec Collection::fieldsByCategory(const QString& cat_) { return list; } -const QString& Collection::fieldNameByTitle(const QString& title_) const { +const TQString& Collection::fieldNameByTitle(const TQString& title_) const { if(title_.isEmpty()) { - return QString::null; + return TQString(); } FieldPtr f = fieldByTitle(title_); if(!f) { // might happen in MainWindow::saveCollectionOptions - return QString::null; + return TQString(); } return f->name(); } -const QString& Collection::fieldTitleByName(const QString& name_) const { +const TQString& Collection::fieldTitleByName(const TQString& name_) const { if(name_.isEmpty()) { - return QString::null; + return TQString(); } FieldPtr f = fieldByName(name_); if(!f) { kdWarning() << "Collection::fieldTitleByName() - no field named " << name_ << endl; - return QString::null; + return TQString(); } return f->title(); } -QStringList Collection::valuesByFieldName(const QString& name_) const { +TQStringList Collection::valuesByFieldName(const TQString& name_) const { if(name_.isEmpty()) { - return QStringList(); + return TQStringList(); } bool multiple = (fieldByName(name_)->flags() & Field::AllowMultiple); @@ -553,19 +553,19 @@ QStringList Collection::valuesByFieldName(const QString& name_) const { return values.toList(); } -Tellico::Data::FieldPtr Collection::fieldByName(const QString& name_) const { - return m_fieldNameDict.isEmpty() ? 0 : name_.isEmpty() ? 0 : m_fieldNameDict.find(name_); +Tellico::Data::FieldPtr Collection::fieldByName(const TQString& name_) const { + return m_fieldNameDict.isEmpty() ? 0 : name_.isEmpty() ? 0 : m_fieldNameDict.tqfind(name_); } -Tellico::Data::FieldPtr Collection::fieldByTitle(const QString& title_) const { - return m_fieldTitleDict.isEmpty() ? 0 : title_.isEmpty() ? 0 : m_fieldTitleDict.find(title_); +Tellico::Data::FieldPtr Collection::fieldByTitle(const TQString& title_) const { + return m_fieldTitleDict.isEmpty() ? 0 : title_.isEmpty() ? 0 : m_fieldTitleDict.tqfind(title_); } -bool Collection::hasField(const QString& name_) const { +bool Collection::hasField(const TQString& name_) const { return fieldByName(name_) != 0; } -bool Collection::isAllowed(const QString& key_, const QString& value_) const { +bool Collection::isAllowed(const TQString& key_, const TQString& value_) const { // empty string is always allowed if(value_.isEmpty()) { return true; @@ -575,19 +575,19 @@ bool Collection::isAllowed(const QString& key_, const QString& value_) const { FieldPtr field = fieldByName(key_); // if the type is not multiple choice or if value_ is allowed, return true - if(field && (field->type() != Field::Choice || field->allowed().findIndex(value_) > -1)) { + if(field && (field->type() != Field::Choice || field->allowed().tqfindIndex(value_) > -1)) { return true; } return false; } -Tellico::Data::EntryGroupDict* Collection::entryGroupDictByName(const QString& name_) { +Tellico::Data::EntryGroupDict* Collection::entryGroupDictByName(const TQString& name_) { // myDebug() << "Collection::entryGroupDictByName() - " << name_ << endl; if(name_.isEmpty()) { return 0; } - EntryGroupDict* dict = m_entryGroupDicts.isEmpty() ? 0 : m_entryGroupDicts.find(name_); + EntryGroupDict* dict = m_entryGroupDicts.isEmpty() ? 0 : m_entryGroupDicts.tqfind(name_); if(dict && dict->isEmpty()) { GUI::CursorSaver cs; const bool b = signalsBlocked(); @@ -599,21 +599,21 @@ Tellico::Data::EntryGroupDict* Collection::entryGroupDictByName(const QString& n return dict; } -void Collection::populateDict(EntryGroupDict* dict_, const QString& fieldName_, EntryVec entries_) { +void Collection::populateDict(EntryGroupDict* dict_, const TQString& fieldName_, EntryVec entries_) { // myDebug() << "Collection::populateDict() - " << fieldName_ << endl; bool isBool = hasField(fieldName_) && fieldByName(fieldName_)->type() == Field::Bool; PtrVector<EntryGroup> modifiedGroups; for(EntryVecIt entry = entries_.begin(); entry != entries_.end(); ++entry) { - QStringList groups = entryGroupNamesByField(entry, fieldName_); - for(QStringList::ConstIterator groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) { + TQStringList groups = entryGroupNamesByField(entry, fieldName_); + for(TQStringList::ConstIterator groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) { // find the group for this group name // bool fields used the field title - QString groupTitle = *groupIt; + TQString groupTitle = *groupIt; if(isBool && groupTitle != i18n(s_emptyGroupTitle)) { groupTitle = fieldTitleByName(fieldName_); } - EntryGroup* group = dict_->find(groupTitle); + EntryGroup* group = dict_->tqfind(groupTitle); // if the group doesn't exist, create it if(!group) { group = new EntryGroup(groupTitle, fieldName_); @@ -644,7 +644,7 @@ void Collection::populateCurrentDicts(EntryVec entries_) { // for each dict, get the value of that field for the entry // if multiple values are allowed, split the value and then insert the // entry pointer into the dict for each value - QDictIterator<EntryGroupDict> dictIt(m_entryGroupDicts); + TQDictIterator<EntryGroupDict> dictIt(m_entryGroupDicts); for( ; dictIt.current(); ++dictIt) { // only populate if it's not empty, since they are // populated on demand @@ -656,7 +656,7 @@ void Collection::populateCurrentDicts(EntryVec entries_) { if(allEmpty) { // need to populate the current group dict - const QString group = Controller::self()->groupBy(); + const TQString group = Controller::self()->groupBy(); EntryGroupDict* dict = m_entryGroupDicts[group]; if(dict) { populateDict(dict, group, entries_); @@ -668,7 +668,7 @@ void Collection::populateCurrentDicts(EntryVec entries_) { // for a given field. Normally, this would just be splitting the entry's value // for the field, but if the field name is the people pseudo-group, then it gets // a bit more complicated -QStringList Collection::entryGroupNamesByField(EntryPtr entry_, const QString& fieldName_) { +TQStringList Collection::entryGroupNamesByField(EntryPtr entry_, const TQString& fieldName_) { if(fieldName_ != s_peopleGroupName) { return entry_->groupNamesByFieldName(fieldName_); } @@ -681,8 +681,8 @@ QStringList Collection::entryGroupNamesByField(EntryPtr entry_, const QString& f return values.toList(); } -void Collection::invalidateGroups() { - QDictIterator<EntryGroupDict> dictIt(m_entryGroupDicts); +void Collection::tqinvalidateGroups() { + TQDictIterator<EntryGroupDict> dictIt(m_entryGroupDicts); for( ; dictIt.current(); ++dictIt) { dictIt.current()->clear(); } @@ -690,7 +690,7 @@ void Collection::invalidateGroups() { // populateDicts() will make signals that the group view is connected to, block those blockSignals(true); for(EntryVecIt it = m_entries.begin(); it != m_entries.end(); ++it) { - it->invalidateFormattedFieldValue(); + it->tqinvalidateFormattedFieldValue(); it->clearGroups(); } blockSignals(false); @@ -762,12 +762,12 @@ bool Collection::dependentFieldHasRecursion(FieldPtr field_) { StringSet fieldNamesFound; fieldNamesFound.add(field_->name()); - QValueStack<FieldPtr> fieldsToCheck; + TQValueStack<FieldPtr> fieldsToCheck; fieldsToCheck.push(field_); while(!fieldsToCheck.isEmpty()) { FieldPtr f = fieldsToCheck.pop(); - const QStringList depFields = f->dependsOn(); - for(QStringList::ConstIterator it = depFields.begin(); it != depFields.end(); ++it) { + const TQStringList depFields = f->dependsOn(); + for(TQStringList::ConstIterator it = depFields.begin(); it != depFields.end(); ++it) { if(fieldNamesFound.has(*it)) { // we have recursion return true; @@ -794,7 +794,7 @@ int Collection::sameEntry(Data::EntryPtr entry1_, Data::EntryPtr entry2_) const // start with twice the title score // and since the minimum is > 10, then need more than just a perfect title match - int res = 2*Entry::compareValues(entry1_, entry2_, QString::fromLatin1("title"), this); + int res = 2*Entry::compareValues(entry1_, entry2_, TQString::tqfromLatin1("title"), this); // then add score for each field FieldVec fields = entry1_->collection()->fields(); for(Data::FieldVecIt it = fields.begin(); it != fields.end(); ++it) { @@ -825,17 +825,17 @@ bool Collection::mergeEntry(EntryPtr e1, EntryPtr e2, bool overwrite_, bool askU continue; } else if(field->type() == Field::Para) { // for paragraph fields, concatenate the values, if they're not equal - e1->setField(field, e1->field(field) + QString::fromLatin1("<br/><br/>") + e2->field(field)); + e1->setField(field, e1->field(field) + TQString::tqfromLatin1("<br/><br/>") + e2->field(field)); ret = true; } else if(field->type() == Field::Table) { // if field F is a table-type field (album tracks, files, etc.), merge rows (keep their position) // if e1's F val in [row i, column j] empty, replace with e2's val at same position // if different (non-empty) vals at same position, CONFLICT! - const QString sep = QString::fromLatin1("::"); - QStringList vals1 = e1->fields(field, false); - QStringList vals2 = e2->fields(field, false); + const TQString sep = TQString::tqfromLatin1("::"); + TQStringList vals1 = e1->fields(field, false); + TQStringList vals2 = e2->fields(field, false); while(vals1.count() < vals2.count()) { - vals1 += QString(); + vals1 += TQString(); } for(uint i = 0; i < vals2.count(); ++i) { if(vals2[i].isEmpty()) { @@ -845,11 +845,11 @@ bool Collection::mergeEntry(EntryPtr e1, EntryPtr e2, bool overwrite_, bool askU vals1[i] = vals2[i]; ret = true; } else { - QStringList parts1 = QStringList::split(sep, vals1[i], true); - QStringList parts2 = QStringList::split(sep, vals2[i], true); + TQStringList parts1 = TQStringList::split(sep, vals1[i], true); + TQStringList parts2 = TQStringList::split(sep, vals2[i], true); bool changedPart = false; while(parts1.count() < parts2.count()) { - parts1 += QString(); + parts1 += TQString(); } for(uint j = 0; j < parts2.count(); ++j) { if(parts2[j].isEmpty()) { @@ -876,23 +876,23 @@ bool Collection::mergeEntry(EntryPtr e1, EntryPtr e2, bool overwrite_, bool askU } } if(ret) { - e1->setField(field, vals1.join(QString::fromLatin1("; "))); + e1->setField(field, vals1.join(TQString::tqfromLatin1("; "))); } } else if(field->flags() & Data::Field::AllowMultiple) { // if field F allows multiple values and not a Table (see above case), // e1's F values = (e1's F values) U (e2's F values) (union) // replace e1's field with union of e1's and e2's values for this field - QStringList items1 = e1->fields(field, false); - QStringList items2 = e2->fields(field, false); - for(QStringList::ConstIterator it = items2.begin(); it != items2.end(); ++it) { + TQStringList items1 = e1->fields(field, false); + TQStringList items2 = e2->fields(field, false); + for(TQStringList::ConstIterator it = items2.begin(); it != items2.end(); ++it) { // possible to have one value formatted and the other one not... - if(!items1.contains(*it) && !items1.contains(Field::format(*it, field->formatFlag()))) { + if(!items1.tqcontains(*it) && !items1.tqcontains(Field::format(*it, field->formatFlag()))) { items1.append(*it); } } // not sure if I think it should be sorted or not // items1.sort(); - e1->setField(field, items1.join(QString::fromLatin1("; "))); + e1->setField(field, items1.join(TQString::tqfromLatin1("; "))); ret = true; } else if(askUser_ && e1->field(field) != e2->field(field)) { int ret = Kernel::self()->askAndMerge(e1, e2, field); |