]> Git trees. - libqmvoc.git/commitdiff
Removed KEduVocConjugation::getType()
authorFrederik Gladhorn <gladhorn@kde.org>
Sat, 1 Sep 2007 14:29:35 +0000 (14:29 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sat, 1 Sep 2007 14:29:35 +0000 (14:29 +0000)
Instead, directly use KEduVocConjugation::tenses() to get a list of tenses (that correspond to conjugations).
Cleanup.
KEduVocKvtmlCompability::oldTense() to enable writing of old tenses. Still to do: the user defined tenses are not written correctly I assume.
Rename type to tense in VerbQueryDlg.

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

keduvocdocument/keduvocconjugation.cpp
keduvocdocument/keduvocconjugation.h
keduvocdocument/keduvockvtml2writer.cpp
keduvocdocument/keduvockvtmlcompability.cpp
keduvocdocument/keduvockvtmlcompability.h
keduvocdocument/keduvockvtmlwriter.cpp

index 66f7889d5207e5d127c7ca8ad2a1a7b5b418073c..5a66254df3954a214d5e01fe21ee762aca8caed4 100644 (file)
@@ -83,9 +83,6 @@ KEduVocConjugation& KEduVocConjugation::operator = ( const KEduVocConjugation& a
 
 bool KEduVocConjugation::operator == ( const KEduVocConjugation& a ) const
 {
-///@todo conjugations: rewrite operator==
-kDebug() <<"Implement KEduVocConjugation::operator==";
-//     return d->m_conjugations[0].type == a.d->m_conjugations[0].type;
     return d->m_conjugations == a.d->m_conjugations;
 }
 
@@ -96,18 +93,6 @@ int KEduVocConjugation::entryCount() const
 }
 
 
-QString KEduVocConjugation::getType( int idx )
-{
-    kDebug() << "KEduVocConjugation::getType()" << idx;
-    if ( idx >= d->m_conjugations.count() )
-        return QString();
-
-    return d->m_conjugations.keys().value(idx);
-}
-
-
-
-
 bool KEduVocConjugation::pers3SingularCommon( const QString &type ) const
 {
     return d->m_conjugations.value(type).s3common;
index ed7dc049f47a8d27bb22eafd9ea5ed5d7025444b..122aab0001d4146df0d20328ed033579a736da63 100644 (file)
@@ -51,7 +51,6 @@ public:
 
     int entryCount() const;
 
-    QString getType( int index );
     QStringList tenses() const;
 
     QString pers1Singular( const QString &type ) const;
index adbc5d4d0488730bd188ee63340d9898c441c599..4b6359971daabf628a5c1daad663cb6a3fe07ae1 100644 (file)
@@ -432,11 +432,10 @@ bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEd
 
     // conjugation
     if ( translation.conjugation().entryCount() > 0 ) {
-kDebug() << "Writing conjugations: " << translation.text();
         KEduVocConjugation conjugation = translation.conjugation();
-        for ( int i = 0; i < conjugation.entryCount(); ++i ) {
+        foreach ( QString tense, conjugation.tenses() ) {
             QDomElement thisElement = m_domDoc.createElement( KVTML_CONJUGATION );
-            writeConjugation( thisElement, conjugation, conjugation.getType( i ) );
+            writeConjugation( thisElement, conjugation, tense );
             translationElement.appendChild( thisElement );
         }
     }
index 186daaf7559e036688cc8d754ac5b137246b458b..10803840b464d9c15c1eccaa83167ffb946e4f84 100644 (file)
@@ -253,3 +253,13 @@ QStringList KEduVocKvtmlCompability::documentTenses() const
     return m_tenses.values();
 }
 
+
+QString KEduVocKvtmlCompability::oldTense(const QString & tense)
+{
+///@todo writing of the user defined tenses is probably messed up
+    if ( !m_oldTenses.values().contains(tense) ) {
+        m_userdefinedTenseCounter++;
+        m_oldTenses[KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter )] = tense;
+    }
+    return m_oldTenses.key(tense);
+}
\ No newline at end of file
index c8ea1703766004944a6184742cdf081b413e8e7a..861d92499a5d0ffeba31d5b3a26ec554fa4ecff7 100644 (file)
@@ -134,6 +134,7 @@ public:
     void addUserdefinedTense( const QString& tense );
     QString tenseFromKvtml1( const QString & oldTense );
     QStringList documentTenses() const;
+    QString oldTense( const QString& tense );
 
 private:
     /**
index dc3e31021383262032ba7cba558d9c1aabf58bdc..9fe7b178b81d3d6d0d1ec79ed4f0aec530aba257 100644 (file)
@@ -660,16 +660,13 @@ bool KEduVocKvtmlWriter::writeConjugEntry( QDomDocument &domDoc, QDomElement &do
     }
 
     QDomElement domElementConjug = domDoc.createElement( KV_CONJUG_GRP );
-    QString type;
 
-    for ( int lfn = 0; lfn < curr_conjug.entryCount(); lfn++ )
-    {
+    foreach ( QString tense, curr_conjug.tenses() ) {
         QDomElement domElementType = domDoc.createElement( KV_CON_TYPE );
 
-        type = curr_conjug.getType( lfn );
-        domElementType.setAttribute( KV_CON_NAME, type );
+        domElementType.setAttribute( KV_CON_NAME, m_compability.oldTense(tense) );
 
-        if ( !writeConjug( domDoc, domElementType, curr_conjug, curr_conjug.getType( lfn ) ) )
+        if ( !writeConjug( domDoc, domElementType, curr_conjug, m_compability.oldTense(tense) ) )
             return false;
 
         domElementConjug.appendChild( domElementType );