From 06f9affeb314dceb32164572b38287215aad23cb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 27 Aug 2007 23:28:20 +0000 Subject: [PATCH] Remove all calls to KEduVocExpression->translationCount() and the function itself, since we use a QMap for translations. Now it will actually be possible to remove translations. Use KEduVocExpression->translationIndices() to get the translations that are present. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=705446 --- keduvocdocument/keduvoccsvreader.cpp | 2 +- keduvocdocument/keduvocdocument.cpp | 2 +- keduvocdocument/keduvocexpression.cpp | 15 ++++----------- keduvocdocument/keduvocexpression.h | 4 ---- keduvocdocument/keduvockvtml2writer.cpp | 3 +-- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/keduvocdocument/keduvoccsvreader.cpp b/keduvocdocument/keduvoccsvreader.cpp index 0ea0f54..d8703be 100644 --- a/keduvocdocument/keduvoccsvreader.cpp +++ b/keduvocdocument/keduvoccsvreader.cpp @@ -59,7 +59,7 @@ bool KEduVocCsvReader::readDoc(KEduVocDocument *doc) if (!s.simplified().isEmpty()) { KEduVocExpression expression(s, separator); - languageCount = qMax(languageCount, expression.translationCount()); + languageCount = qMax(languageCount, expression.translationIndices().count()); m_doc->appendEntry(&expression); } } diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index fc4acf8..243a8c1 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -1263,7 +1263,7 @@ public: QString s1; QString s2; int cmp; - for (int i = 0; i < exp->translationCount(); i++) { + foreach (int i, exp->translationIndices()) { s1 = exp->translation(i).translation(); s2 = y.exp->translation(i).translation(); diff --git a/keduvocdocument/keduvocexpression.cpp b/keduvocdocument/keduvocexpression.cpp index 3d4639a..988ca33 100644 --- a/keduvocdocument/keduvocexpression.cpp +++ b/keduvocdocument/keduvocexpression.cpp @@ -128,14 +128,6 @@ KEduVocExpression::~KEduVocExpression() } -int KEduVocExpression::translationCount() const -{ - /// @todo: maybe this should go away? it is very rare with QMap - // the minus 1 is because traditionally it used to be original + translations - /// @todo get rid of the minus one. but for now this implies too many other changes. - return d->m_translations.size(); -} - void KEduVocExpression::removeTranslation(int index) { /// @todo IMPLEMENT ME - this will be really easy to implement as soon as the translation class contains all this rubbish. @@ -164,12 +156,13 @@ void KEduVocExpression::setTranslation(int index, const QString & expr) bool KEduVocExpression::uniqueType() const { -/// @todo use .keys() instead of translationCount()! bool unique = true; QString type0 = d->m_translations[0].type(); - for (int i = 1; i < translationCount(); i++) - if (type0 != d->m_translations[i].type()) + foreach (int i, translationIndices()) { + if (type0 != d->m_translations[i].type()) { unique = false; + } + } return unique; } diff --git a/keduvocdocument/keduvocexpression.h b/keduvocdocument/keduvocexpression.h index 0f9e947..60f6ad4 100644 --- a/keduvocdocument/keduvocexpression.h +++ b/keduvocdocument/keduvocexpression.h @@ -117,10 +117,6 @@ public: */ void removeTranslation(int index); - /** returns number of max. translations of all expressions - @todo kill this - will be wrong. We now should have a Identifiers class to handle this kind of stuff - */ - int translationCount() const; /** * Get a mutable reference to the translation diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index f06b511..ba1d621 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -584,8 +584,7 @@ bool KEduVocKvtml2Writer::writeEntries(QDomElement &entriesElement) } // loop through translations - for (int trans = 0; trans < thisEntry->translationCount(); ++trans) - { + foreach (int trans, thisEntry->translationIndices()) { // write translations QDomElement translation = m_domDoc.createElement(KVTML_TRANSLATION); translation.setAttribute(KVTML_ID, QString::number(trans)); -- 2.47.3