]> Git trees. - libqmvoc.git/commitdiff
writeTranslation fleshed out enough to convert kanagram and khangman files, todo...
authorJeremy Paul Whiting <jpwhiting@kde.org>
Tue, 24 Jul 2007 14:37:31 +0000 (14:37 +0000)
committerJeremy Paul Whiting <jpwhiting@kde.org>
Tue, 24 Jul 2007 14:37:31 +0000 (14:37 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=691890

kdeeducore/keduvockvtml2writer.cpp
kdeeducore/keduvockvtml2writer.h
kdeeducore/kvtml2todo

index 5bf644a5d65dbea75ca36a62744866e4e1b78d36..27331b91dfb832da60f331e03ff3215d13020c28 100644 (file)
@@ -80,6 +80,13 @@ bool KEduVocKvtml2Writer::writeDoc(KEduVocDocument *doc, const QString &generato
   }
   
   // entries
+  currentElement = m_domDoc.createElement(KVTML_ENTRIES);
+  if (!writeEntries(currentElement))
+  {
+    // at least one entry is required!
+    return false;
+  }
+  domElementKvtml.appendChild(currentElement);
   
   // lessons
   
@@ -489,6 +496,97 @@ bool KEduVocKvtml2Writer::writeUsages(QDomElement &usagesElement)
   return true;
 }
 
+bool KEduVocKvtml2Writer::writeEntries(QDomElement &entriesElement)
+{
+  // loop through entries
+  for (int i = 0; i < m_doc->entryCount(); ++i)
+  {
+    KEduVocExpression *thisEntry = m_doc->entry(i);
+    
+    // write entry tag
+    QDomElement entryElement = m_domDoc.createElement(KVTML_ENTRY);
+
+    // add id
+    entryElement.setAttribute(KVTML_ID, QString::number(i));
+
+    // write inactive
+    entryElement.appendChild(newTextElement(KVTML_INACTIVE, thisEntry->isActive() ? KVTML_FALSE : KVTML_TRUE));
+    
+    // write inquery
+    entryElement.appendChild(newTextElement(KVTML_INQUERY, thisEntry->isInQuery() ? KVTML_TRUE : KVTML_FALSE));
+    
+    // write sizehint
+    entryElement.appendChild(newTextElement(KVTML_SIZEHINT, QString::number(thisEntry->sizeHint()) ));
+
+    // loop through translations
+    for (int trans = 0; trans < thisEntry->translationCount(); ++trans)
+    {
+      // write translations
+      QDomElement translation = m_domDoc.createElement(KVTML_TRANSLATION);
+      translation.setAttribute(KVTML_ID, QString::number(trans));
+      writeTranslation(translation, thisEntry->translation(trans));
+      entryElement.appendChild(translation);
+    }
+    // add this entry to the entriesElement
+    entriesElement.appendChild(entryElement);
+  }
+  return true;
+}
+
+bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation)
+{
+  // <text>Kniebeugen</text>
+  translationElement.appendChild(newTextElement(KVTML_TEXT, translation.translation()));
+  
+  // <type></type>
+  translationElement.appendChild(newTextElement(KVTML_TYPE, translation.type()));
+  
+  // <inquery>1</inquery>
+  // TODO
+  
+  // <comment></comment>
+  translationElement.appendChild(newTextElement(KVTML_COMMENT, translation.comment()));
+
+  // <pronunciation></pronunciation>
+  translationElement.appendChild(newTextElement(KVTML_PRONUNCIATION, translation.pronunciation()));
+  
+  // <falsefriendfrom></falsefriendfrom>
+  // TODO
+  // <falsefriendto></falsefriendto>
+  // <falsefriend></falsefriend>
+
+  // <antonym></antonym>
+  translationElement.appendChild(newTextElement(KVTML_ANTONYM, translation.antonym()));
+  
+  // <synonym></synonym>
+  translationElement.appendChild(newTextElement(KVTML_SYNONYM, translation.synonym()));
+  
+  // <example></example>
+  translationElement.appendChild(newTextElement(KVTML_EXAMPLE, translation.example()));
+  
+  // <usage></usage>
+  translationElement.appendChild(newTextElement(KVTML_USAGE, translation.usageLabel()));
+  
+  // <paraphrase></paraphrase>
+  translationElement.appendChild(newTextElement(KVTML_USAGE, translation.paraphrase()));
+  
+  // grades
+  // TODO
+  
+  // conjugation
+  // TODO
+  
+  // comparison
+  // TODO
+  
+  // multiplechoice
+  // TODO
+  
+  // image
+  // sound
+
+  return true;
+}
 
 bool KEduVocKvtml2Writer::writeComparison(QDomDocument &domDoc, QDomElement &domElementParent, const KEduVocComparison &comp)
 /*
index c377647ff94a6f578a4828c2cf6e3aee85227c07..d2938eafdc51daddeb57d91775d3534bf80704ef 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "keduvocgrammar.h"
 #include "keduvocmultiplechoice.h"
+#include "keduvoctranslation.h"
 
 class KEduVocDocument;
 
@@ -72,6 +73,17 @@ public:
    */
   bool writeUsages(QDomElement &usagesElement);
 
+  /** write entries
+   * @param entriesElement QDomElement <entries> to write to
+   */
+  bool writeEntries(QDomElement &entriesElement);
+  
+  /** write a translation
+   * @param translationElement QDomElement <translation> to write to, with id pre-set
+   * @param translation object to write
+   */
+  bool writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation);
+  
   bool writeLesson(QDomDocument &domDoc, QDomElement &domElementParent);
   bool writeConjugEntry(QDomDocument &domDoc, QDomElement &domElementParent, KEduVocConjugation &curr_conjug);
   bool writeComparison(QDomDocument &domDoc, QDomElement &domElementParent, const KEduVocComparison &comp);
index 3400fbf8ef89a916501104d496bccc67e0d45f3b..e5f40e6929cef9e2681eec4a1e018c02db73e299 100644 (file)
@@ -6,10 +6,6 @@ reader:
   store identifier name, sizehint and type? (need a place to store it first)
 
 writer:
-  write entries
-    write translations
-    write comparisons
-    write multiplechoices
-    write grades
+  write translation sub-parts: comparisons, conjugations, multiplechoices, grades
   write lessons