]> Git trees. - libqmvoc.git/commitdiff
Read also false friend and antonym.
authorFrederik Gladhorn <gladhorn@kde.org>
Sun, 23 Mar 2008 03:27:05 +0000 (03:27 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sun, 23 Mar 2008 03:27:05 +0000 (03:27 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=789091

keduvocdocument/keduvockvtml2reader.cpp
keduvocdocument/keduvoctranslation.h

index 764e585aaeaefec0e05feccd60485570961a8392..eb356f7d41e7addc7f24379415b080ca56979a1b 100644 (file)
@@ -388,32 +388,55 @@ bool KEduVocKvtml2Reader::readLesson( KEduVocLesson* parentLesson, QDomElement &
 
 bool KEduVocKvtml2Reader::readSynonymsAntonymsFalseFriends( QDomElement &rootElement )
 {
-    // synonyms
-    QDomElement pairElement = rootElement.firstChildElement( KVTML_SYNONYM );
-    // pair
-    pairElement = pairElement.firstChildElement( KVTML_PAIR );
-    while ( !pairElement.isNull() ) {
-        //<entry id="123"/>
-        QDomElement entryElement = pairElement.firstChildElement( KVTML_ENTRY );
-        int firstEntryId = entryElement.attribute( KVTML_ID ).toInt();
-
-        QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
-        int firstTranslationId = translationElement.attribute( KVTML_ID ).toInt();
-
-        // second entry
-        entryElement = entryElement.nextSiblingElement( KVTML_ENTRY );
-        int secondEntryId = entryElement.attribute( KVTML_ID ).toInt();
-        translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
-        int secondTranslationId = translationElement.attribute( KVTML_ID ).toInt();
-
-        // pair them up
-        KEduVocTranslation *first = m_allEntries[firstEntryId]->translation(firstTranslationId);
-        KEduVocTranslation *second = m_allEntries[secondEntryId]->translation(secondTranslationId);
-
-        first->addSynonym(second);
-        second->addSynonym(first);
-
-        pairElement = pairElement.nextSiblingElement( KVTML_PAIR );
+    QDomElement pairElement;
+    for(int type = KEduVocTranslation::Synonym; type <= KEduVocTranslation::FalseFriend; type++) {
+        switch (type) {
+        case KEduVocTranslation::Synonym:
+            pairElement= rootElement.firstChildElement( KVTML_SYNONYM );
+            break;
+        case KEduVocTranslation::Antonym:
+            pairElement= rootElement.firstChildElement( KVTML_ANTONYM );
+            break;
+        case KEduVocTranslation::FalseFriend:
+            pairElement= rootElement.firstChildElement( KVTML_FALSEFRIEND );
+            break;
+        }
+        // pair
+        pairElement = pairElement.firstChildElement( KVTML_PAIR );
+        while ( !pairElement.isNull() ) {
+            //<entry id="123"/>
+            QDomElement entryElement = pairElement.firstChildElement( KVTML_ENTRY );
+            int firstEntryId = entryElement.attribute( KVTML_ID ).toInt();
+
+            QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
+            int firstTranslationId = translationElement.attribute( KVTML_ID ).toInt();
+
+            // second entry
+            entryElement = entryElement.nextSiblingElement( KVTML_ENTRY );
+            int secondEntryId = entryElement.attribute( KVTML_ID ).toInt();
+            translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
+            int secondTranslationId = translationElement.attribute( KVTML_ID ).toInt();
+
+            // pair them up
+            KEduVocTranslation *first = m_allEntries[firstEntryId]->translation(firstTranslationId);
+            KEduVocTranslation *second = m_allEntries[secondEntryId]->translation(secondTranslationId);
+
+            switch (type) {
+            case KEduVocTranslation::Synonym:
+                first->addSynonym(second);
+                second->addSynonym(first);
+                break;
+            case KEduVocTranslation::Antonym:
+                first->addAntonym(second);
+                second->addAntonym(first);
+                break;
+            case KEduVocTranslation::FalseFriend:
+                first->addFalseFriend(second);
+                second->addFalseFriend(first);
+                break;
+            }
+            pairElement = pairElement.nextSiblingElement( KVTML_PAIR );
+        }
     }
     return true;
 }
index 1b4b5eaf801bf2deba13713c2cf01d66342eeb9a..e4588914f9d2eda267e6b8562b2577fe07009c78 100644 (file)
@@ -36,6 +36,12 @@ class KEDUVOCDOCUMENT_EXPORT KEduVocTranslation
     :public KEduVocText
 {
 public:
+    enum Related {
+        Synonym,
+        Antonym,
+        FalseFriend
+    };
+
     /**
      * Default constructor for an empty translation.
      */