]> Git trees. - libqmvoc.git/commitdiff
more reader/writer cleanup
authorFrederik Gladhorn <gladhorn@kde.org>
Sun, 24 Feb 2008 20:34:05 +0000 (20:34 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sun, 24 Feb 2008 20:34:05 +0000 (20:34 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=778893

keduvocdocument/keduvockvtml2reader.cpp
keduvocdocument/keduvoclesson.h
keduvocdocument/keduvoctext.cpp
keduvocdocument/keduvoctranslation.cpp
keduvocdocument/keduvoctranslation.h

index 52d1c7639ecffb34d8fa09424f510d3612b964ec..08f6d6e16b1b7de1f50b5de106661a8332221f1b 100644 (file)
@@ -309,48 +309,13 @@ bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement,
 {
     expr->translation(index)->fromKVTML2(translationElement);
 
-    QDomElement currentElement = translationElement.firstChildElement( KVTML_COMMENT );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setComment( currentElement.text() );
-    }
-
-    //<pronunciation></pronunciation>
-    currentElement = translationElement.firstChildElement( KVTML_PRONUNCIATION );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setPronunciation( currentElement.text() );
-    }
-
     //<falsefriend fromid="1"></falsefriend>
-    currentElement = translationElement.firstChildElement( KVTML_FALSEFRIEND );
+    QDomElement currentElement = translationElement.firstChildElement( KVTML_FALSEFRIEND );
     if ( !currentElement.isNull() ) {
         int fromid = currentElement.attribute( KVTML_FROMID ).toInt();
         expr->translation(index)->setFalseFriend( fromid, currentElement.text() );
     }
 
-    //<antonym></antonym>
-    currentElement = translationElement.firstChildElement( KVTML_ANTONYM );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setAntonym( currentElement.text() );
-    }
-
-    //<synonym></synonym>
-    currentElement = translationElement.firstChildElement( KVTML_SYNONYM );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setSynonym( currentElement.text() );
-    }
-
-    //<example></example>
-    currentElement = translationElement.firstChildElement( KVTML_EXAMPLE );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setExample( currentElement.text() );
-    }
-
-    //<paraphrase></paraphrase>
-    currentElement = translationElement.firstChildElement( KVTML_PARAPHRASE );
-    if ( !currentElement.isNull() ) {
-        expr->translation(index)->setParaphrase( currentElement.text() );
-    }
-
     // conjugations
     currentElement = translationElement.firstChildElement( KVTML_CONJUGATION );
     while ( !currentElement.isNull() ) {
@@ -363,14 +328,6 @@ bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement,
         currentElement = currentElement.nextSiblingElement( KVTML_CONJUGATION );
     }
 
-    // grade elements
-    currentElement = translationElement.firstChildElement( KVTML_GRADE );
-    while ( !currentElement.isNull() ) {
-        // TODO: read grade
-        readGrade( currentElement, expr, index );
-        currentElement = currentElement.nextSiblingElement( KVTML_GRADE );
-    }
-
     // comparisons
     currentElement = translationElement.firstChildElement( KVTML_COMPARISON );
     if ( !currentElement.isNull() ) {
@@ -650,45 +607,6 @@ bool KEduVocKvtml2Reader::readMultipleChoice( QDomElement &multipleChoiceElement
     return true;
 }
 
-bool KEduVocKvtml2Reader::readGrade( QDomElement &gradeElement, KEduVocExpression *expr, int index )
-{
-    bool result = true;
-    if ( !result ) {
-        m_errorMessage = i18n( "identifier missing id" );
-        return false;
-    }
-
-    QDomElement currentElement = gradeElement.firstChildElement( KVTML_CURRENTGRADE );
-    if ( !currentElement.isNull() ) {
-        int value = currentElement.text().toInt();
-        expr->translation(index)->setGrade( value );
-    }
-
-    currentElement = gradeElement.firstChildElement( KVTML_COUNT );
-    if ( !currentElement.isNull() ) {
-        int value = currentElement.text().toInt();
-        expr->translation(index)->setPracticeCount( value );
-    }
-
-    currentElement = gradeElement.firstChildElement( KVTML_ERRORCOUNT );
-    if ( !currentElement.isNull() ) {
-        int value = currentElement.text().toInt();
-        expr->translation(index)->setBadCount( value );
-    }
-
-    currentElement = gradeElement.firstChildElement( KVTML_DATE );
-    if ( !currentElement.isNull() ) {
-        QString dateString = currentElement.text();
-        if ( !dateString.isEmpty() ) {
-            QDateTime value = QDateTime::fromString( dateString, Qt::ISODate );
-            expr->translation(index)->setPracticeDate( value );
-        }
-    }
-
-    return true;
-}
-
-
 bool KEduVocKvtml2Reader::readConjugation( QDomElement &conjugElement, KEduVocConjugation &conjugation )
 /*
  <conjugation>
index e8c562719eb495afff7a4b06f21997043786b069..060c4aa01ff0173a23266e6e7b27609ea0478e02 100644 (file)
@@ -49,7 +49,6 @@ public:
     /** assignment operator */
     KEduVocLesson& operator= ( const KEduVocLesson& );
 
-
     KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive);
 
     /** get a list of all entries in the lesson */
index cf1feb20af3ae4ba2da4535b708cbe3a529d71eb..6a4f4105384ca800b0b0c53e5f8042712dda1268 100644 (file)
@@ -203,4 +203,21 @@ void KEduVocText::toKVTML2(QDomElement& parent)
 void KEduVocText::fromKVTML2(QDomElement & parent)
 {
     setText( parent.firstChildElement( KVTML_TEXT ).text() );
+
+    // grade element
+    parent.firstChildElement() = parent.firstChildElement( KVTML_GRADE );
+    if ( !parent.firstChildElement().isNull() ) {
+
+        setGrade( parent.firstChildElement(KVTML_CURRENTGRADE).text().toInt() );
+
+        setPracticeCount( parent.firstChildElement(KVTML_COUNT).text().toInt() );
+
+        setBadCount( parent.firstChildElement(KVTML_ERRORCOUNT).text().toInt() );
+
+        QString dateString = parent.firstChildElement(KVTML_DATE).text();
+        if ( !dateString.isEmpty() ) {
+            QDateTime value = QDateTime::fromString( dateString, Qt::ISODate );
+            setPracticeDate( value );
+        }
+    }
 }
index 9016377825783369d6fef0a504e0405e41a0160b..466ebff74ce71edd0f4005709d5b80663c34e849 100644 (file)
@@ -384,3 +384,25 @@ void KEduVocTranslation::toKVTML2(QDomElement & parent)
     KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PARAPHRASE, paraphrase() );
 }
 
+void KEduVocTranslation::fromKVTML2(QDomElement & parent)
+{
+    KEduVocText::fromKVTML2(parent);
+
+    setComment( parent.firstChildElement( KVTML_COMMENT ).text() );
+
+    setPronunciation( parent.firstChildElement( KVTML_PRONUNCIATION ).text() );
+
+    //<antonym></antonym>
+    setAntonym( parent.firstChildElement( KVTML_ANTONYM ).text() );
+
+    //<synonym></synonym>
+    setSynonym( parent.firstChildElement( KVTML_SYNONYM ).text() );
+
+    //<example></example>
+    setExample( parent.firstChildElement( KVTML_EXAMPLE ).text() );
+
+    //<paraphrase></paraphrase>
+    setParaphrase( parent.firstChildElement( KVTML_PARAPHRASE ).text() );
+
+}
+
index 309636556a10f1a4100c7e8eb6e26463eca33c9f..1e0b5bbe05eeb45e49bcabe502209afdd46165ef 100644 (file)
@@ -235,7 +235,7 @@ public:
      */
     bool operator== ( const KEduVocTranslation &translation ) const;
 
-//     void fromKVTML2(QDomElement& parent);
+    void fromKVTML2(QDomElement& parent);
     void toKVTML2(QDomElement& parent);
 
 private: