]> Git trees. - libqmvoc.git/commitdiff
writer writes grades and falsefriends
authorJeremy Paul Whiting <jpwhiting@kde.org>
Tue, 7 Aug 2007 02:56:57 +0000 (02:56 +0000)
committerJeremy Paul Whiting <jpwhiting@kde.org>
Tue, 7 Aug 2007 02:56:57 +0000 (02:56 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=697179

keduvocdocument/keduvockvtml2writer.cpp
keduvocdocument/keduvockvtml2writer.h
keduvocdocument/kvtml2todo

index f0762b058da5a90044abe13623c5c67edf64fa07..03e0511794a625798fc2dd6d8041f73c80de6cba 100644 (file)
@@ -571,7 +571,7 @@ bool KEduVocKvtml2Writer::writeEntries(QDomElement &entriesElement)
   return true;
 }
 
-bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation)
+bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, KEduVocTranslation &translation)
 {
   // <text>Kniebeugen</text>
   translationElement.appendChild(newTextElement(KVTML_TEXT, translation.translation()));
@@ -594,8 +594,20 @@ bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, cons
     translationElement.appendChild(newTextElement(KVTML_PRONUNCIATION, translation.pronunciation()));
   }
   
-  // TODO
   // <falsefriend fromid="0"></falsefriend>
+  // loop through the identifiers
+  for (int i = 0; i < m_doc->identifierCount(); ++i)
+  {
+       // see if this identifier has a falsefriend in this translation
+       QString thisFriend = translation.falseFriend(i);
+       if (!thisFriend.isEmpty())
+       {
+         // if so, create it, and set the fromid to i
+         QDomElement thisFriendElement = newTextElement(KVTML_FALSEFRIEND, thisFriend);
+         thisFriendElement.setAttribute(KVTML_FROMID, QString::number(i));
+         translationElement.appendChild(thisFriendElement);
+       }
+  }
 
   // <antonym></antonym>
   if (!translation.antonym().isEmpty())
@@ -628,7 +640,27 @@ bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, cons
   }
   
   // grades
-  // TODO
+  for (int i = 0; i < m_doc->identifierCount(); ++i)
+  {
+       KEduVocGrade thisGrade = translation.gradeFrom(i);
+       if (thisGrade.queryCount() > 0)
+       {
+         QDomElement gradeElement = m_domDoc.createElement(KVTML_GRADE);
+         gradeElement.setAttribute(KVTML_FROMID, QString::number(i));
+         //<currentgradefloat>0.8</currentgradefloat>
+
+         //<count>6</count>
+         gradeElement.appendChild(newTextElement(KVTML_COUNT, QString::number(thisGrade.queryCount())));
+
+         //<errorcount>1</errorcount>
+         gradeElement.appendChild(newTextElement(KVTML_ERRORCOUNT, QString::number(thisGrade.badCount())));
+
+         //<date>949757271</date>
+         gradeElement.appendChild(newTextElement(KVTML_DATE, QString::number(thisGrade.queryDate().toTime_t())));
+         
+         translationElement.appendChild(gradeElement);
+       }
+  }
   
   // conjugation
   if (!translation.conjugation().entryCount() > 0)
index 3a991e6096b7067d3a39ec0a3849bf5bbd5b9811..33df97b9824b41ae34a3590f2226b2d8ad100f1d 100644 (file)
@@ -82,7 +82,7 @@ public:
    * @param translationElement QDomElement <translation> to write to, with id pre-set
    * @param translation object to write
    */
-  bool writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation);
+  bool writeTranslation(QDomElement &translationElement, KEduVocTranslation &translation);
   
   /** write the lesson group
    * @param lessonsElement QDomElement <lessons> to write to
index 00444029c21f3c4ab7c98e623397e6cbb0949629..990b3aa1f3341b855ddd07844aba63064274c33d 100644 (file)
@@ -1,11 +1,8 @@
-Temporary todo for kvtml2
+todo for kvtml2
 
 reader:
   store identifier name, sizehint and type? (need a place to store it first)
 
-writer:
-  write translation sub-parts: falsefriend grades
-  
 extra classes:
   lesson class