]> Git trees. - libqmvoc.git/commitdiff
Reading of old types implemented.
authorFrederik Gladhorn <gladhorn@kde.org>
Sun, 26 Aug 2007 11:18:36 +0000 (11:18 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sun, 26 Aug 2007 11:18:36 +0000 (11:18 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=704821

keduvocdocument/keduvockvtmlreader.cpp
keduvocdocument/keduvocwordtype.cpp
keduvocdocument/keduvocwordtype.h

index 86c3660da94dc4550d2aab52c6d5e68aef0f89b2..e59dea10d8d88f451b3b9ae16dfad5cbcb1229cf 100644 (file)
@@ -152,6 +152,8 @@ bool KEduVocKvtmlReader::readBody(QDomElement &domElementParent)
       return false;
   }
 
+  // initialize the list of predefined types
+  m_doc->wordTypes()->createOldWordTypeLists();
   currentElement = domElementParent.firstChildElement(KV_TYPE_GRP);
   if (!currentElement.isNull()) {
     result = readType(currentElement);
@@ -963,7 +965,6 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE
     if (!attribute.isNull())
     {
         QString oldType = attribute.value();
-
         if (oldType.length() >= 2 && type.left(1) == QM_USER_TYPE)
         {
             // they started counting at 1
@@ -988,7 +989,6 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE
 
             type = m_doc->wordTypes()->mainTypeFromOldFormat(oldType);
             subType = m_doc->wordTypes()->subTypeFromOldFormat(oldType);
-
         } // not user defined - preset types
     }
 
@@ -1022,7 +1022,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent)
   bool                      active;
   QString                   lang;
   QString                   textstr;
-  QString                   exprtype;
   QString                   q_org;
   QString                   q_trans;
   QString                   query_id;
@@ -1105,7 +1104,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent)
 
             type = m_doc->wordTypes()->mainTypeFromOldFormat(oldType);
             subType = m_doc->wordTypes()->subTypeFromOldFormat(oldType);
-
         } // not user defined - preset types
     }
 
@@ -1127,7 +1125,6 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent)
     }
 
     while (!currentElement.isNull()) {
-      type = exprtype; // seems like type can be in the paren element and overwritten in the children here :(
 
       //-----------
       // Attributes
@@ -1238,8 +1235,12 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent)
         mc.clear();
       }
 
-      expr.translation(i).setType(type);
-      expr.translation(i).setType(subType);
+      if (!type.isEmpty()) {
+        expr.translation(i).setType(type);
+        if (!subType.isEmpty()) {
+            expr.translation(i).setSubType(subType);
+        }
+      }
 
       if (!remark.isEmpty() )
         expr.translation(i).setComment (remark);
index f735fdf7f21391d2bbc2a75783d2dafe2f795f3c..c155717354e187e29f0e208e6246e3678d11f47b 100644 (file)
@@ -170,17 +170,17 @@ void KEduVocWordType::initOldTypeLists()
     d->m_oldMainTypeNames.insert("fig", i18n("Figuratively"));
 
     d->m_oldSubTypeNames.clear();
-    d->m_oldSubTypeNames.insert("ord", i18n("Numeral Ordinal"));
-    d->m_oldSubTypeNames.insert("crd", i18n("Numeral Cardinal"));
-    d->m_oldSubTypeNames.insert("def", i18n("Article Definite"));
-    d->m_oldSubTypeNames.insert("ind", i18n("Article Indefinite"));
-    d->m_oldSubTypeNames.insert("re", i18n("Verb Regular"));
-    d->m_oldSubTypeNames.insert("ir", i18n("Verb Irregular"));
-    d->m_oldSubTypeNames.insert("pos", i18n("Pronoun Possessive"));
-    d->m_oldSubTypeNames.insert("per", i18n("Pronoun Personal"));
-    d->m_oldSubTypeNames.insert("m", i18n("Noun Male"));
-    d->m_oldSubTypeNames.insert("f", i18n("Noun Female"));
-    d->m_oldSubTypeNames.insert("s", i18n("Noun Neutral"));
+    d->m_oldSubTypeNames.insert("ord", i18n("Ordinal"));
+    d->m_oldSubTypeNames.insert("crd", i18n("Cardinal"));
+    d->m_oldSubTypeNames.insert("def", i18n("Definite"));
+    d->m_oldSubTypeNames.insert("ind", i18n("Indefinite"));
+    d->m_oldSubTypeNames.insert("re", i18n("Regular"));
+    d->m_oldSubTypeNames.insert("ir", i18n("Irregular"));
+    d->m_oldSubTypeNames.insert("pos", i18n("Possessive"));
+    d->m_oldSubTypeNames.insert("per", i18n("Personal"));
+    d->m_oldSubTypeNames.insert("m", i18n("Male"));
+    d->m_oldSubTypeNames.insert("f", i18n("Female"));
+    d->m_oldSubTypeNames.insert("s", i18n("Neutral"));
 
 }
 
@@ -212,42 +212,47 @@ QString KEduVocWordType::oldType(const QString & mainType, const QString & subTy
 */
 
 
-void KEduVocWordType::createSampleData()
+void KEduVocWordType::createOldWordTypeLists()
 {
-    //d->m_wordTypeList.clear();
-
-    // for now let's create some fantasy word types:
-
+    kDebug() << "Creating word type lists for compability with kvtml-1.";
+    // first the special types which cannot be deleted:
     addType("Noun", "noun", "This holds the words of type noun. You can rename it but not delete since the article training relies on it!");
 
-    int noun = mainTypeIndex("Noun");
     addSubType("Noun", "Male", "noun male", "This holds the words of type noun male. You can rename it but not delete since the article training relies on it!");
 
     addSubType("Noun", "Female", "noun female", "This holds the words of type noun female. You can rename it but not delete since the article training relies on it!");
 
     addSubType("Noun", "Neutral", "noun neutral", "This holds the words of type noun neutral. You can rename it but not delete since the article training relies on it!");
 
-
     addType("Verb", "verb", "This holds the words of type verb. You can rename it but not delete since the article training relies on it!");
 
     addSubType("Verb", "Regular", "regular", "This holds the words of type regular verbs. You can rename it but not delete since the article training relies on it!");
 
     addSubType("Verb", "Irregular", "irregular", "This holds the words of type irregular verbs. You can rename it but not delete since the article training relies on it!");
 
-
     addType("Adjective", "adjective", "This holds the words of type adjective. You can rename it but not delete since the article training relies on it!");
 
     addType("Adverb", "adverb", "This holds the words of type adverb. You can rename it but not delete since the article training relies on it!");
 
     addType("Question");
     addType("Name");
-
-    addType("Rot");
-    addType("Blau");
-    addType("Violett");
-    addType("Rosa");
-    addType("Gelb");
-
+    addType("Article");
+    addSubType("Article", "Definite");
+    addSubType("Article", "Indefinite");
+
+    addType("Pronoun");
+    addSubType("Pronoun", "Possessive");
+    addSubType("Pronoun", "Personal");
+
+    addType("Phrase");
+    addType("Numeral");
+    addSubType("Numeral", "Ordinal");
+    addSubType("Numeral", "Cardinal");
+
+    addType("Conjunction");
+    addType("Preposition");
+    addType("Informal");
+    addType("Figuratively");
 }
 
 
index 5b95d8ddead7f40be016559bb5b326c947ef4f9d..00cdc7919c3b693e7e51a15b8938ca39ad42cd89 100644 (file)
@@ -50,10 +50,7 @@ public:
     /** assignment operator */
     KEduVocWordType& operator=(const KEduVocWordType& other);
 
-    /** will be gone when we have it inside the lib */
-//     void setDocument(KEduVocDocument *doc);
-    void createSampleData();
-
+    void createOldWordTypeLists();
 
     /**
      * Create a new word type in the list of known types