]> Git trees. - libqmvoc.git/commitdiff
Remove synonyms, antonyms and false friends completely.
authorFrederik Gladhorn <gladhorn@kde.org>
Sun, 23 Mar 2008 03:26:46 +0000 (03:26 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sun, 23 Mar 2008 03:26:46 +0000 (03:26 +0000)
Add lists of pointers to keduvoctranslation to the translation class for them instead.

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=789084

keduvocdocument/keduvockvtml2reader.cpp
keduvocdocument/keduvockvtml2writer.cpp
keduvocdocument/keduvockvtmlreader.cpp
keduvocdocument/keduvoctranslation.cpp
keduvocdocument/keduvoctranslation.h

index f288e7dd2b8c40096d4fc82d62d4466188466b1e..40700f2da24e435cff7a94550d0b6ae8966133d2 100644 (file)
@@ -309,13 +309,15 @@ bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement,
 {
     // read the text, grade, declension and conjugation
     expr->translation(index)->fromKVTML2(translationElement);
+    QDomElement currentElement;
 
     //<falsefriend fromid="1"></falsefriend>
-    QDomElement currentElement = translationElement.firstChildElement( KVTML_FALSEFRIEND );
-    if ( !currentElement.isNull() ) {
-        int fromid = currentElement.attribute( KVTML_FROMID ).toInt();
-        expr->translation(index)->setFalseFriend( fromid, currentElement.text() );
-    }
+    /// @todo false friends
+//     currentElement = translationElement.firstChildElement( KVTML_FALSEFRIEND );
+//     if ( !currentElement.isNull() ) {
+//         int fromid = currentElement.attribute( KVTML_FROMID ).toInt();
+//         expr->translation(index)->setFalseFriend( fromid, currentElement.text() );
+//     }
 
     // comparisons
     currentElement = translationElement.firstChildElement( KVTML_COMPARISON );
index 7b8af3802496ef45ef1c53989b08d86b86ff41f3..68cbd21a9dc1a34912e5333797a3b59b05d43cf4 100644 (file)
@@ -337,18 +337,19 @@ bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEd
     // so far only for KEduVocWord - text and grades
     translation->toKVTML2(translationElement);
 
+    ///@todo write false friends
     // <falsefriend fromid="0"></falsefriend>
     // loop through the identifiers
-    for ( int i = 0; i < m_doc->identifierCount(); ++i ) {
-        // see if this identifier has a falsefriend in this translation
-        QString thisFriend = translation->falseFriend( i );
-        if ( !thisFriend.isEmpty() ) {
-            // if so, create it, and set the fromid to i
-            QDomElement thisFriendElement = newTextElement( KVTML_FALSEFRIEND, thisFriend );
-            thisFriendElement.setAttribute( KVTML_FROMID, QString::number( i ) );
-            translationElement.appendChild( thisFriendElement );
-        }
-    }
+//     for ( int i = 0; i < m_doc->identifierCount(); ++i ) {
+//         // see if this identifier has a falsefriend in this translation
+//         QString thisFriend = translation->falseFriend( i );
+//         if ( !thisFriend.isEmpty() ) {
+//             // if so, create it, and set the fromid to i
+//             QDomElement thisFriendElement = newTextElement( KVTML_FALSEFRIEND, thisFriend );
+//             thisFriendElement.setAttribute( KVTML_FROMID, QString::number( i ) );
+//             translationElement.appendChild( thisFriendElement );
+//         }
+//     }
 
     // comparison
     if ( !(translation->comparative().isEmpty() || translation->comparative().isEmpty())) {
index 88ca25f1c9d8c20754a6439199079e96693279b0..ae86547fcb89c324872ff1b1313f42628f52b6eb 100644 (file)
@@ -1019,18 +1019,22 @@ bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent )
             entry->translation( i )->setComment( remark );
         if ( !pronunciation.isEmpty() )
             entry->translation( i )->setPronunciation( pronunciation );
-        if ( !faux_ami_f.isEmpty() )
-            entry->translation( i )->setFalseFriend( 0, faux_ami_f );
-        if ( !faux_ami_t.isEmpty() )
-            entry->translation( 0 )->setFalseFriend( i, faux_ami_t );
-        if ( !synonym.isEmpty() )
-            entry->translation( i )->setSynonym( synonym );
+
+        ///@todo include false friends from kvtml-1 again?
+//         if ( !faux_ami_f.isEmpty() )
+//             entry->translation( i )->setFalseFriend( 0, faux_ami_f );
+//         if ( !faux_ami_t.isEmpty() )
+//             entry->translation( 0 )->setFalseFriend( i, faux_ami_t );
+        ///@todo include synonyms from kvtml-1 again?
+//         if ( !synonym.isEmpty() )
+//             entry->translation( i )->setSynonym( synonym );
+//         if ( !antonym.isEmpty() )
+//             entry->translation( i )->setAntonym( antonym );
+
         if ( !example.isEmpty() )
             entry->translation( i )->setExample( example );
         if ( !paraphrase.isEmpty() )
             entry->translation( i )->setParaphrase( paraphrase );
-        if ( !antonym.isEmpty() )
-            entry->translation( i )->setAntonym( antonym );
 
         if ( i != 0 ) {
             entry->translation( i )->setGrade( grade );
index 12bf5aa41aea36f1df6d94c5e5caf099a025e015..d72a377024a0ad101566087a459555225e9096f0 100644 (file)
@@ -42,12 +42,8 @@ public:
     QString m_hint;
     /// Paraphrase
     QString m_paraphrase;
-    /// A synonyme for a word: sick and ill, student and pupil
-    QString m_synonym;
     /// An example
     QString m_example;
-    /// An antonym - the opposite: hot - cold
-    QString m_antonym;
     /// Pronunciation
     QString m_pronunciation;
     /// Image url
@@ -67,8 +63,13 @@ public:
 
     KEduVocDeclension* m_declension;
 
-    /// One false friend string per other language
-    QMap<int, QString> m_falseFriends;
+    // connections to other translations
+    /// Synonyms for a word: sick and ill, student and pupil
+    QList< KEduVocTranslation* > m_synonyms;
+    /// An antonym - the opposite: hot - cold
+    QList< KEduVocTranslation* > m_antonyms;
+    /// List of false friends
+    QList< KEduVocTranslation* > m_falseFriends;
 };
 
 
@@ -101,18 +102,20 @@ KEduVocTranslation::KEduVocTranslation( const KEduVocTranslation &other )
     d->m_wordType = other.d->m_wordType;
     d->m_comment = other.d->m_comment;
     d->m_paraphrase = other.d->m_paraphrase;
-    d->m_synonym = other.d->m_synonym;
     d->m_example = other.d->m_example;
-    d->m_antonym = other.d->m_antonym;
     d->m_pronunciation = other.d->m_pronunciation;
     d->m_conjugations = other.d->m_conjugations;
     d->m_comparative = other.d->m_comparative;
     d->m_superlative = other.d->m_superlative;
     d->m_multipleChoice = other.d->m_multipleChoice;
-    d->m_falseFriends = other.d->m_falseFriends;
     d->m_imageUrl = other.d->m_imageUrl;
     d->m_soundUrl = other.d->m_soundUrl;
-    /// @todo add declensions
+    d->m_synonyms = other.d->m_synonyms;
+    d->m_antonyms = other.d->m_antonyms;
+    d->m_falseFriends = other.d->m_falseFriends;
+    if (other.d->m_declension) {
+        d->m_declension = new KEduVocDeclension(*other.d->m_declension);
+    }
 }
 
 KEduVocTranslation::~KEduVocTranslation()
@@ -124,20 +127,21 @@ KEduVocTranslation::~KEduVocTranslation()
 bool KEduVocTranslation::operator == ( const KEduVocTranslation & translation ) const
 {
     return KEduVocText::operator==(translation) &&
-           d->m_wordType == translation.d->m_wordType &&
-           d->m_comment == translation.d->m_comment &&
-           d->m_paraphrase == translation.d->m_paraphrase &&
-           d->m_synonym == translation.d->m_synonym &&
-           d->m_example == translation.d->m_example &&
-           d->m_antonym == translation.d->m_antonym &&
-           d->m_pronunciation == translation.d->m_pronunciation &&
-           d->m_imageUrl == translation.d->m_imageUrl &&
-           d->m_soundUrl == translation.d->m_soundUrl &&
-           d->m_comparative == translation.d->m_comparative &&
-           d->m_superlative == translation.d->m_superlative &&
-           d->m_multipleChoice == translation.d->m_multipleChoice &&
-           d->m_falseFriends == translation.d->m_falseFriends &&
-           d->m_conjugations == translation.d->m_conjugations;
+        d->m_wordType == translation.d->m_wordType &&
+        d->m_comment == translation.d->m_comment &&
+        d->m_paraphrase == translation.d->m_paraphrase &&
+        d->m_example == translation.d->m_example &&
+        d->m_pronunciation == translation.d->m_pronunciation &&
+        d->m_imageUrl == translation.d->m_imageUrl &&
+        d->m_soundUrl == translation.d->m_soundUrl &&
+        d->m_comparative == translation.d->m_comparative &&
+        d->m_superlative == translation.d->m_superlative &&
+        d->m_multipleChoice == translation.d->m_multipleChoice &&
+        d->m_synonyms == translation.d->m_synonyms &&
+        d->m_antonyms == translation.d->m_antonyms &&
+        d->m_falseFriends == translation.d->m_falseFriends &&
+        d->m_conjugations == translation.d->m_conjugations;
+           /// @todo check and include declensions d->m_declension == translation.d->m_declension;
 }
 
 KEduVocTranslation & KEduVocTranslation::operator = ( const KEduVocTranslation & translation )
@@ -147,9 +151,7 @@ KEduVocTranslation & KEduVocTranslation::operator = ( const KEduVocTranslation &
     d->m_wordType = translation.d->m_wordType;
     d->m_comment = translation.d->m_comment;
     d->m_paraphrase = translation.d->m_paraphrase;
-    d->m_synonym = translation.d->m_synonym;
     d->m_example = translation.d->m_example;
-    d->m_antonym = translation.d->m_antonym;
     d->m_pronunciation = translation.d->m_pronunciation;
     d->m_imageUrl = translation.d->m_imageUrl;
     d->m_soundUrl = translation.d->m_soundUrl;
@@ -157,7 +159,12 @@ KEduVocTranslation & KEduVocTranslation::operator = ( const KEduVocTranslation &
     d->m_superlative = translation.d->m_superlative;
     d->m_multipleChoice = translation.d->m_multipleChoice;
     d->m_falseFriends = translation.d->m_falseFriends;
+    d->m_synonyms = translation.d->m_synonyms;
+    d->m_antonyms = translation.d->m_antonyms;
     d->m_conjugations = translation.d->m_conjugations;
+    if (translation.d->m_declension) {
+        d->m_declension = new KEduVocDeclension(*translation.d->m_declension);
+    }
     return *this;
 }
 
@@ -174,63 +181,63 @@ void KEduVocTranslation::setComment( const QString & expr )
 }
 
 
-void KEduVocTranslation::setFalseFriend( int indexFrom, const QString & expr )
+void KEduVocTranslation::addFalseFriend( KEduVocTranslation* falseFriend )
 {
-    d->m_falseFriends[indexFrom] = expr.simplified();
+    d->m_falseFriends.append(falseFriend);
 }
 
 
-QString KEduVocTranslation::falseFriend( int indexFrom ) const
+QList< KEduVocTranslation* > KEduVocTranslation::falseFriends() const
 {
-    return d->m_falseFriends.value( indexFrom );
+    return d->m_falseFriends;
 }
 
 
-void KEduVocTranslation::setSynonym( const QString & expr )
+void KEduVocTranslation::addSynonym( KEduVocTranslation* synonym )
 {
-    d->m_synonym = expr.simplified();
+    d->m_synonyms.append(synonym);
 }
 
 
-QString KEduVocTranslation::synonym() const
+QList<KEduVocTranslation*> KEduVocTranslation::synonyms() const
 {
-    return d->m_synonym;
+    return d->m_synonyms;
 }
 
 
-void KEduVocTranslation::setExample( const QString & expr )
+void KEduVocTranslation::addAntonym( KEduVocTranslation* antonym )
 {
-    d->m_example = expr.simplified();
+    d->m_antonyms.append(antonym);
 }
 
 
-QString KEduVocTranslation::example() const
+QList<KEduVocTranslation*> KEduVocTranslation::antonyms() const
 {
-    return d->m_example;
+    return d->m_antonyms;
 }
 
 
-void KEduVocTranslation::setParaphrase( const QString & expr )
+void KEduVocTranslation::setExample( const QString & expr )
 {
-    d->m_paraphrase = expr.simplified();
+    d->m_example = expr.simplified();
 }
 
 
-QString KEduVocTranslation::paraphrase() const
+QString KEduVocTranslation::example() const
 {
-    return d->m_paraphrase;
+    return d->m_example;
 }
 
 
-void KEduVocTranslation::setAntonym( const QString & expr )
+void KEduVocTranslation::setParaphrase( const QString & expr )
 {
-    d->m_antonym = expr.simplified();
+    d->m_paraphrase = expr.simplified();
 }
 
 
-QString KEduVocTranslation::antonym() const
+QString KEduVocTranslation::paraphrase() const
 {
-    return d->m_antonym;
+    return d->m_paraphrase;
 }
 
 
@@ -383,17 +390,14 @@ void KEduVocTranslation::toKVTML2(QDomElement & parent)
     // <pronunciation>
     KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PRONUNCIATION, pronunciation() );
 
-    // <antonym>
-    KEduVocKvtml2Writer::appendTextElement( parent, KVTML_ANTONYM, antonym() );
-
-    // <synonym>
-    KEduVocKvtml2Writer::appendTextElement( parent, KVTML_SYNONYM, synonym() );
-
     // <example>
     KEduVocKvtml2Writer::appendTextElement( parent, KVTML_EXAMPLE, example() );
 
     // <paraphrase>
     KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PARAPHRASE, paraphrase() );
+
+    ///@todo synonyms, antonyms
+    ///@todo false friends
 }
 
 void KEduVocTranslation::fromKVTML2(QDomElement & parent)
@@ -406,19 +410,12 @@ void KEduVocTranslation::fromKVTML2(QDomElement & parent)
 
     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() );
 
-
     // conjugations
     QDomElement conjugationElement = parent.firstChildElement( KVTML_CONJUGATION );
     while ( !conjugationElement.isNull() ) {
@@ -430,5 +427,7 @@ void KEduVocTranslation::fromKVTML2(QDomElement & parent)
         conjugationElement = conjugationElement.nextSiblingElement( KVTML_CONJUGATION );
     }
 
+    ///@todo synonyms, antonym
+    ///@todo false friends
 }
 
index eef83449e549559d7ebab8fa4323c727a2e7d6b3..1b4b5eaf801bf2deba13713c2cf01d66342eeb9a 100644 (file)
@@ -77,29 +77,6 @@ public:
     */
     void setComment( const QString & expr );
 
-    /** sets false friend of this expression
-    * @param indexFrom        index of original translation
-    * @param expression       false friend of this index
-    */
-    void setFalseFriend( int indexFrom, const QString & expression );
-
-    /**
-    * returns false friend of this expression
-    * @param indexFrom index of original translation
-    * @return false friend or "" if no string available
-    */
-    QString falseFriend( int indexFrom ) const;
-
-    /** sets synonym this expression
-    * @param expression       synonym of this index
-    */
-    void setSynonym( const QString & expression );
-
-    /** returns synonym of this expression
-    * @return                 synonym or "" if no string available
-    */
-    QString synonym() const;
-
     /** sets example this expression
     * @param expression       example of this index
     */
@@ -221,6 +198,42 @@ public:
      */
     void setImageUrl(const KUrl &url);
 
+    /**
+     * add a false friend
+     * @param falseFriend false friend of this index
+     */
+    void addFalseFriend( KEduVocTranslation* falseFriend );
+
+    /**
+     * returns false friends of this expression
+     * @return list of false friends
+     */
+    QList<KEduVocTranslation*> falseFriends() const;
+
+    /**
+     * add a synonym
+     * @param synonym
+     */
+    void addSynonym( KEduVocTranslation* synonym );
+
+    /**
+     * returns synonyms of this expression
+     * @return synonyms
+     */
+    QList<KEduVocTranslation*> synonyms() const;
+
+    /**
+     * add a antonym
+     * @param antonym
+         */
+    void addAntonym( KEduVocTranslation* antonym );
+
+    /**
+     * returns antonyms of this expression
+     * @return antonyms
+     */
+    QList<KEduVocTranslation*> antonyms() const;
+
     /**
      * Equal operator to assing a translation to another one.
      * @param translation translation to be copied