]> Git trees. - libqmvoc.git/commitdiff
fleshed out readEntry, and implemented missing methods in the expression class for...
authorJeremy Paul Whiting <jpwhiting@kde.org>
Thu, 19 Jul 2007 03:28:40 +0000 (03:28 +0000)
committerJeremy Paul Whiting <jpwhiting@kde.org>
Thu, 19 Jul 2007 03:28:40 +0000 (03:28 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=689759

kdeeducore/keduvocexpression.cpp
kdeeducore/keduvockvtml2reader.cpp
kdeeducore/kvtml2defs.h

index 0fe31365e6ed42dd5a5684c27c6d93e20d7a8845..5c04a8eae4c37be91775b1bcc75fd6e6e757ba9a 100644 (file)
@@ -70,6 +70,7 @@ public:
   int m_lesson;
   bool m_inQuery;
   bool m_active;
+  int m_sizeHint;
 
   QMap <int, KEduVocTranslation> m_translations;
 };
@@ -990,6 +991,15 @@ void KEduVocExpression::setActive(bool flag)
   d->m_active = flag;
 }
 
+int KEduVocExpression::sizeHint() const
+{
+  return d->m_sizeHint;
+}
+
+void KEduVocExpression::setSizeHint(int sizeHint)
+{
+  d->m_sizeHint = sizeHint;
+}
 
 void KEduVocExpression::resetGrades(int index)
 {
index 339c8581f2cf15c2d03b1d9a3fd9255de8313eb4..7e943ab1e9f8e651a38e34f2fbca62b0d2a8f5e0 100644 (file)
@@ -84,15 +84,6 @@ bool KEduVocKvtml2Reader::readDoc(KEduVocDocument *doc)
       return false;
   }
 
-  // possibly add lines support to information section of kvtml2 dtd?
-  //documentAttribute = domElementKvtml.attributeNode(KV_LINES);
-  //if (!documentAttribute.isNull())
-  //  m_lines = documentAttribute.value().toInt();
-
-  //-------------------------------------------------------------------------
-  // Children
-  //-------------------------------------------------------------------------
-
   bool result = readGroups(domElementKvtml);  // read sub-groups
 
   return result;
@@ -156,7 +147,7 @@ bool KEduVocKvtml2Reader::readGroups(QDomElement &domElementParent)
     QDomNodeList entryList = groupElement.elementsByTagName(KVTML_IDENTIFIER);
     if (entryList.length() <= 0)
     {
-      m_errorMessage = i18n("missing identifiers from identifiers tag");
+      m_errorMessage = i18n("missing identifier elements from identifiers tag");
       return false;
     }
 
@@ -256,7 +247,8 @@ bool KEduVocKvtml2Reader::readIdentifier(QDomElement &identifierElement)
   currentElement = identifierElement.firstChildElement(KVTML_LOCALE);
   if (!currentElement.isNull())
   {
-    // TODO: do something with the locale
+    // TODO: do we want to use this for the identifier, or the name?
+    m_doc->setIdentifier(id, currentElement.text());
   }
   
   currentElement = identifierElement.firstChildElement(KVTML_NAME);
@@ -283,6 +275,7 @@ bool KEduVocKvtml2Reader::readIdentifier(QDomElement &identifierElement)
   {
     KEduVocConjugation personalPronouns;
     readConjug(currentElement, personalPronouns);
+    m_doc->setConjugation(id, personalPronouns);
     // TODO: do something with these personalpronouns
   }
   return result;
@@ -303,6 +296,40 @@ bool KEduVocKvtml2Reader::readEntry(QDomElement &entryElement)
   }
   
   // read info tags: inactive, inquery, and sizehint
+  currentElement = entryElement.firstChildElement(KVTML_INACTIVE);
+  if (!currentElement.isNull())
+  {
+    // set the active state of the expression
+    if (currentElement.text() == KVTML_TRUE)
+    {
+      expr.setActive(false);
+    }
+    else
+    {
+      expr.setActive(true);
+    }
+  }
+  
+  currentElement = entryElement.firstChildElement(KVTML_INQUERY);
+  if (!currentElement.isNull())
+  {
+    // set the inquery information
+    if (currentElement.text() == KVTML_TRUE)
+    {
+      expr.setInQuery(true);
+    }
+    else
+    {
+      expr.setInQuery(false);
+    }
+  }
+  
+  currentElement = entryElement.firstChildElement(KVTML_SIZEHINT);
+  if (!currentElement.isNull())
+  {
+    // set the sizehint
+    expr.setSizeHint(currentElement.text().toInt());
+  }
   
   // read translation children
   QDomNodeList translationList = entryElement.elementsByTagName(KVTML_TRANSLATION);
index 21e0da327e1f44b156faf4d5f1ff57ee0e00b5f9..3fa33fed4aa7fe5209a5c6f068e1b7840294867d 100644 (file)
@@ -96,5 +96,8 @@
 #define KVTML_WRONG             "errorcount"
 #define KVTML_DATE              "date"
 
+#define KVTML_TRUE              "true"
+#define KVTML_FALSE             "false"  
+
 #endif