From: Frederik Gladhorn Date: Sat, 1 Sep 2007 14:29:35 +0000 (+0000) Subject: Removed KEduVocConjugation::getType() X-Git-Tag: v3.94.0~97 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=cac1599bf3b0b2595ae056c0d25bd0ad8757f404;p=libqmvoc.git Removed KEduVocConjugation::getType() 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 --- diff --git a/keduvocdocument/keduvocconjugation.cpp b/keduvocdocument/keduvocconjugation.cpp index 66f7889..5a66254 100644 --- a/keduvocdocument/keduvocconjugation.cpp +++ b/keduvocdocument/keduvocconjugation.cpp @@ -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; diff --git a/keduvocdocument/keduvocconjugation.h b/keduvocdocument/keduvocconjugation.h index ed7dc04..122aab0 100644 --- a/keduvocdocument/keduvocconjugation.h +++ b/keduvocdocument/keduvocconjugation.h @@ -51,7 +51,6 @@ public: int entryCount() const; - QString getType( int index ); QStringList tenses() const; QString pers1Singular( const QString &type ) const; diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index adbc5d4..4b63599 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -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 ); } } diff --git a/keduvocdocument/keduvockvtmlcompability.cpp b/keduvocdocument/keduvockvtmlcompability.cpp index 186daaf..1080384 100644 --- a/keduvocdocument/keduvockvtmlcompability.cpp +++ b/keduvocdocument/keduvockvtmlcompability.cpp @@ -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 diff --git a/keduvocdocument/keduvockvtmlcompability.h b/keduvocdocument/keduvockvtmlcompability.h index c8ea170..861d924 100644 --- a/keduvocdocument/keduvockvtmlcompability.h +++ b/keduvocdocument/keduvockvtmlcompability.h @@ -134,6 +134,7 @@ public: void addUserdefinedTense( const QString& tense ); QString tenseFromKvtml1( const QString & oldTense ); QStringList documentTenses() const; + QString oldTense( const QString& tense ); private: /** diff --git a/keduvocdocument/keduvockvtmlwriter.cpp b/keduvocdocument/keduvockvtmlwriter.cpp index dc3e310..9fe7b17 100644 --- a/keduvocdocument/keduvockvtmlwriter.cpp +++ b/keduvocdocument/keduvockvtmlwriter.cpp @@ -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 );