]> Git trees. - libqmvoc.git/commitdiff
Added comments to the conjugation reading function in the desperate attempt to unders...
authorFrederik Gladhorn <gladhorn@kde.org>
Tue, 28 Aug 2007 20:19:17 +0000 (20:19 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Tue, 28 Aug 2007 20:19:17 +0000 (20:19 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=705886

keduvocdocument/keduvocconjugation.cpp
keduvocdocument/keduvocconjugation.h
keduvocdocument/keduvocgrammar.h
keduvocdocument/keduvockvtmlreader.cpp

index 0cc9a8cd12e542048cf97505a8f75e821f2ac069..39ec0f229ffb5838f01d08be5c73d67744491ece 100644 (file)
@@ -24,6 +24,7 @@
 #include "keduvocconjugation.h"
 #include "keduvoccommon_p.h"
 #include <KLocalizedString>
+#include <KDebug>
 
 class KEduVocConjugation::Private
 {
@@ -133,23 +134,23 @@ int KEduVocConjugation::entryCount() const
 }
 
 
-QList<KEduVocTenseRelation> KEduVocConjugation::getRelation ()
-{
-  QList<KEduVocTenseRelation> vec;
-
-  for (int i = 0; i < numInternalNames(); i++) {
-    vec.append(KEduVocTenseRelation(Private::names[i].abbrev, i18n(Private::names[i].name)));
-  }
-
-  for (int i = 0; i < Private::userTenses.count(); i++) {
-    QString s;
-    s.setNum(i + 1);
-    s.prepend(UL_USER_TENSE);
-    vec.append(KEduVocTenseRelation(s, Private::userTenses[i]));
-  }
-
-  return vec;
-}
+// QList<KEduVocTenseRelation> KEduVocConjugation::getRelation ()
+// {
+//   QList<KEduVocTenseRelation> vec;
+//
+//   for (int i = 0; i < numInternalNames(); i++) {
+//     vec.append(KEduVocTenseRelation(Private::names[i].abbrev, i18n(Private::names[i].name)));
+//   }
+//
+//   for (int i = 0; i < Private::userTenses.count(); i++) {
+//     QString s;
+//     s.setNum(i + 1);
+//     s.prepend(UL_USER_TENSE);
+//     vec.append(KEduVocTenseRelation(s, Private::userTenses[i]));
+//   }
+//
+//   return vec;
+// }
 
 
 void KEduVocConjugation::setTenseNames(const QStringList& names)
@@ -241,6 +242,8 @@ int KEduVocConjugation::tenseCount()
 
 QString KEduVocConjugation::getType(int idx)
 {
+
+kDebug() << "KEduVocConjugation::getType()" << idx;
   if (idx >= d->conjugations.count())
     return "";
 
index 957f9f93556f53dc3376b87dbeeaaf5a71b19b6c..b4490ad05f5392987da2e69dd34a1c5be62d63b2 100644 (file)
@@ -80,7 +80,7 @@ public:
   /**
    * @return
    */
-  static QList<KEduVocTenseRelation> getRelation();
+//  static QList<KEduVocTenseRelation> getRelation();
 
   /**
    * @param names
index 64b8ccc3aa39e29c3f52e5ff28509e4ec9b81f96..c2c7046d9c89c18a2fe20ea98424c10865119010 100644 (file)
 
 #include <QtCore/QStringList>
 
-// #define CONJ_PREFIX            "--"   // definition of prefixes (I, you, ..)
-//
-// #define UL_USER_TENSE          "#"   // designates number of user tense
-
 /**
  * Class representing the articles of a language
  *
index 66927e7cc54d33ae42a07cd5066bb04f587d7d91..9afd3b9532dc5dbbc0149ec7fee232a146a80115 100644 (file)
@@ -417,21 +417,24 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList<KEduVoc
   QString type;
   int count = 0;
 
+// reset
   curr_conjug.clear();
+// create new empty one
   curr_conjug.append(KEduVocConjugation());
 
   QDomElement domElementConjugChild = domElementParent.firstChild().toElement();
   while (!domElementConjugChild.isNull())
   {
     if (domElementConjugChild.tagName() == KV_CON_ENTRY)
-    {
+    {               // if KV_CON_ENTRY == "e" is found, we are reading a personal pronun definition.
+      // CONJ_PREFIX is defined as "--"
       type = CONJ_PREFIX;
 
       //----------
       // Attribute
 
       QString lang;
-      QDomAttr domAttrLang = domElementConjugChild.attributeNode(KV_LANG);
+      QDomAttr domAttrLang = domElementConjugChild.attributeNode(KV_LANG); // "l"
 
       if (m_doc->identifierCount() <= count)
       {
@@ -453,15 +456,17 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList<KEduVoc
       }
     }
     else if (domElementConjugChild.tagName() == KV_CON_TYPE)
-    {
+    {                       // this means reading translations KV_CON_TYPE == "t"
       //----------
       // Attribute
 
+        // "n" == is the type is the tense
       QDomAttr domAttrLang = domElementConjugChild.attributeNode(KV_CON_NAME);
       type = domAttrLang.value();
       if (type.isNull())
         type = "";
 
+        // if it starts with "#" the user typed in the tense name
       if (type.length() != 0 && type.left(1) == UL_USER_TENSE)
       {
         int num = qMin(type.mid (1, 40).toInt(), 1000); // paranoia check
@@ -494,6 +499,7 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList<KEduVoc
     p3_common = false;
     s3_common = false;
 
+    // get the individual entries for persons...
     QDomElement domElementConjugGrandChild = domElementConjugChild.firstChild().toElement();
     while (!domElementConjugGrandChild.isNull())
     {
@@ -571,12 +577,21 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList<KEduVoc
       }
 
       domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement();
-    }
+    } // while - probably to be sure, because the persons could be in any order.
+      // I guess this goes over only one set, such as:
+      // <s1>traigo</s1><s2>traes</s2><s3fcommon="1">trae</s3f>
+      // <p1>traemos</p1><p2>traĆ©is</p2><p3f common="1">traen</p3f>
+      // until no elements are left in that soup.
+
+
 
     if (domElementConjugChild.tagName() == KV_CON_ENTRY)
       while (count + 1 > (int) curr_conjug.size() )
         curr_conjug.append(KEduVocConjugation());
 
+    // now set the data: [count] - number of conjug?
+    // type - the tense?
+    // finally the person
     curr_conjug[count].setPers3SingularCommon(type, s3_common);
     curr_conjug[count].setPers3PluralCommon(type, p3_common);
     curr_conjug[count].setPers1Singular(type, pers1_sing);
@@ -594,7 +609,7 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList<KEduVoc
       count++;
 
     domElementConjugChild = domElementConjugChild.nextSibling().toElement();
-  }
+  } // while -> next type, count++
 
   return true;
 }