]> Git trees. - libqmvoc.git/commitdiff
Remove all calls to KEduVocExpression->translationCount() and the function itself...
authorFrederik Gladhorn <gladhorn@kde.org>
Mon, 27 Aug 2007 23:28:20 +0000 (23:28 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Mon, 27 Aug 2007 23:28:20 +0000 (23:28 +0000)
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
keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvocexpression.cpp
keduvocdocument/keduvocexpression.h
keduvocdocument/keduvockvtml2writer.cpp

index 0ea0f5491b01e1ef8ff1480eb3eb3fc60c4ba51c..d8703be95f7149163bd23e95ced593795066f98d 100644 (file)
@@ -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);
     }
   }
index fc4acf84f5f7eac871e5fc22c812a0563e19bcfa..243a8c1342268239e0ffe0de834f14e2b4e4f22e 100644 (file)
@@ -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();
index 3d4639a758ac6a43d83a3d7c802acd02c96dddab..988ca33bf2f320941dfd881329d7f52e012a0d21 100644 (file)
@@ -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;
 }
 
index 0f9e94704445c55031a70ef341f7a9d4dc9c5d2f..60f6ad4b4686810041ebba1d6455da0764536411 100644 (file)
@@ -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
index f06b511247cfd6f44a847567c3dad7e1f77b9c4c..ba1d6219109a28a9fe10332ba321e209fd6b6f24 100644 (file)
@@ -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));