From d75e50b7fe887f9a70de71c7378f7fe803ceb96b Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 31 Aug 2007 07:53:35 +0000 Subject: [PATCH] Changes in the conjugation class. No longer uses a static table to translate abreviated tense names, only the type field. Still needs cleanup and doesn't work. Conjugations are not saved, because of missing compability functions they are not read from old files either at this point. (Yes, nothing works) svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=706748 --- keduvocdocument/keduvoccommon_p.h | 10 - keduvocdocument/keduvocconjugation.cpp | 208 ++++++++++---------- keduvocdocument/keduvocdocument.cpp | 2 +- keduvocdocument/keduvocidentifier.cpp | 2 - keduvocdocument/keduvockvtmlcompability.cpp | 12 ++ keduvocdocument/keduvockvtmlcompability.h | 15 +- 6 files changed, 118 insertions(+), 131 deletions(-) diff --git a/keduvocdocument/keduvoccommon_p.h b/keduvocdocument/keduvoccommon_p.h index d705a5d..84bca89 100644 --- a/keduvocdocument/keduvoccommon_p.h +++ b/keduvocdocument/keduvoccommon_p.h @@ -13,14 +13,4 @@ #define KVD_VERS_PREFIX " v" // kvoctrain v0.1.0 -#define CONJ_SIMPLE_PRESENT "PrSi" // I live at home what you frequently do -#define CONJ_PRESENT_PROGR "PrPr" // I am working what you currently are doing -#define CONJ_PRESENT_PERFECT "PrPe" // I have cleaned tell, #that# something has happened - -#define CONJ_SIMPLE_PAST "PaSi" // the train left 2 min ago when did it happen -#define CONJ_PAST_PROGR "PaPr" // it was raining what happen at a given time in the past -#define CONJ_PAST_PARTICIPLE "PaPa" // I cleaned tell, #that# it happened - -#define CONJ_FUTURE "FuSi" - #endif diff --git a/keduvocdocument/keduvocconjugation.cpp b/keduvocdocument/keduvocconjugation.cpp index ee9d05a..40f7c19 100644 --- a/keduvocdocument/keduvocconjugation.cpp +++ b/keduvocdocument/keduvocconjugation.cpp @@ -32,15 +32,6 @@ public: Private() {} - QString verbName; // added to have something to compare in operator ==, assumes that there is always only one - // KEduVocConjugation per verb - - struct conjug_name_t - { - const char *abbrev; - const char *name; - }; - struct conjug_t { conjug_t() @@ -67,28 +58,34 @@ public: typedef QList conjug_tList; conjug_tList conjugations; - static conjug_name_t names[]; - static QStringList userTenses; +// // for the static stuff: +// struct conjug_name_t +// { +// const char *abbrev; +// const char *name; +// }; +// static conjug_name_t names[]; +// static QStringList userTenses; }; -KEduVocConjugation::Private::conjug_name_t - -KEduVocConjugation::Private::names [] = - { - { CONJ_SIMPLE_PRESENT, I18N_NOOP( "Simple Present" ) }, - { CONJ_PRESENT_PROGR, I18N_NOOP( "Present Progressive" ) }, - { CONJ_PRESENT_PERFECT, I18N_NOOP( "Present Perfect" ) }, - - { CONJ_SIMPLE_PAST, I18N_NOOP( "Simple Past" ) }, - { CONJ_PAST_PROGR, I18N_NOOP( "Past Progressive" ) }, - { CONJ_PAST_PARTICIPLE, I18N_NOOP( "Past Participle" ) }, - - { CONJ_FUTURE, I18N_NOOP( "Future" ) } - }; +// KEduVocConjugation::Private::conjug_name_t +// +// KEduVocConjugation::Private::names [] = +// { +// { CONJ_SIMPLE_PRESENT, I18N_NOOP( "Simple Present" ) }, +// { CONJ_PRESENT_PROGR, I18N_NOOP( "Present Progressive" ) }, +// { CONJ_PRESENT_PERFECT, I18N_NOOP( "Present Perfect" ) }, +// +// { CONJ_SIMPLE_PAST, I18N_NOOP( "Simple Past" ) }, +// { CONJ_PAST_PROGR, I18N_NOOP( "Past Progressive" ) }, +// { CONJ_PAST_PARTICIPLE, I18N_NOOP( "Past Participle" ) }, +// +// { CONJ_FUTURE, I18N_NOOP( "Future" ) } +// }; -QStringList KEduVocConjugation::Private::userTenses; +// QStringList KEduVocConjugation::Private::userTenses; @@ -99,38 +96,31 @@ KEduVocConjugation::KEduVocConjugation() KEduVocConjugation::KEduVocConjugation( const KEduVocConjugation& rhs ) : d( new Private( *rhs.d ) ) -{} +{ +///@todo something's missing here!?!? +} KEduVocConjugation::~KEduVocConjugation() { - if ( d->conjugations.count() > 0 ) { - kDebug() << "Killing Conjugation d->verbName: " << d->verbName << " conjugations.count(): " << d->conjugations.count() << - - " getType(0): " << getType( 0 ) << " getAbbrev(0): " << getAbbrev( 0 ) << " getName(0): " << getName( 0 ); - } delete d; } KEduVocConjugation& KEduVocConjugation::operator = ( const KEduVocConjugation& a ) { - *d = *a.d; +///@todo return *this; } bool KEduVocConjugation::operator == ( const KEduVocConjugation& a ) const { - return d->verbName == a.getVerbName(); +///@todo conjugations: rewrite operator== + return d->conjugations[1].type == a.d->conjugations[1].type; } -QString KEduVocConjugation::getVerbName() const -{ - return d->verbName; -} - int KEduVocConjugation::entryCount() const { return d->conjugations.count(); @@ -156,88 +146,88 @@ int KEduVocConjugation::entryCount() const // } -void KEduVocConjugation::setTenseNames( const QStringList& names ) -{ - Private::userTenses = names; -} - - -QString KEduVocConjugation::getName( const QString &abbrev ) -{ - if ( abbrev.length() >= 2 && QString( abbrev[0] ) == QString( UL_USER_TENSE ) ) { - QString s = abbrev; - s.remove( 0, 1 ); - int i = s.toInt() - 1; - - if ( i < Private::userTenses.count() ) - return Private::userTenses[i]; - else - return ""; - } else { - for ( int i = 0; i < numInternalNames(); i++ ) - if ( Private::names[i].abbrev == abbrev ) { - return i18n( Private::names[i].name ); - } - } - - return ""; -} - +// void KEduVocConjugation::setTenseNames( const QStringList& names ) +// { +// Private::userTenses = names; +// } -QString KEduVocConjugation::getName( int idx ) -{ - if ( idx < numInternalNames() ) - return i18n( Private::names[idx].name ); - else if ( idx < tenseCount() ) - return Private::userTenses[idx-numInternalNames()]; - else - return ""; -} +// QString KEduVocConjugation::getName( const QString &abbrev ) +// { +// if ( abbrev.length() >= 2 && QString( abbrev[0] ) == QString( UL_USER_TENSE ) ) { +// QString s = abbrev; +// s.remove( 0, 1 ); +// int i = s.toInt() - 1; +// +// if ( i < Private::userTenses.count() ) +// return Private::userTenses[i]; +// else +// return ""; +// } else { +// for ( int i = 0; i < numInternalNames(); i++ ) +// if ( Private::names[i].abbrev == abbrev ) { +// return i18n( Private::names[i].name ); +// } +// } +// +// return ""; +// } -QString KEduVocConjugation::getAbbrev( const QString &name ) -{ - for ( int i = 0; i < Private::userTenses.count(); i++ ) - if ( Private::userTenses[i] == name ) { - QString s; - s.setNum( i + 1 ); - s.prepend( UL_USER_TENSE ); - return s; - } - for ( int i = 0; i < numInternalNames(); i++ ) - if ( Private::names[i].name == name ) - return Private::names[i].abbrev; +// QString KEduVocConjugation::getName( int idx ) +// { +// if ( idx < numInternalNames() ) +// return i18n( Private::names[idx].name ); +// else if ( idx < tenseCount() ) +// return Private::userTenses[idx-numInternalNames()]; +// else +// return ""; +// } - return ""; -} +// QString KEduVocConjugation::getAbbrev( const QString &name ) +// { +// for ( int i = 0; i < Private::userTenses.count(); i++ ) +// if ( Private::userTenses[i] == name ) { +// QString s; +// s.setNum( i + 1 ); +// s.prepend( UL_USER_TENSE ); +// return s; +// } +// +// for ( int i = 0; i < numInternalNames(); i++ ) +// if ( Private::names[i].name == name ) +// return Private::names[i].abbrev; +// +// return ""; +// } -QString KEduVocConjugation::getAbbrev( int idx ) -{ - if ( idx < numInternalNames() ) - return Private::names[idx].abbrev; - else if ( idx < tenseCount() ) { - QString s; - s.setNum( idx - numInternalNames() + 1 ); - s.prepend( UL_USER_TENSE ); - return s; - } else - return ""; -} +// QString KEduVocConjugation::getAbbrev( int idx ) +// { +// if ( idx < numInternalNames() ) +// return Private::names[idx].abbrev; +// +// else if ( idx < tenseCount() ) { +// QString s; +// s.setNum( idx - numInternalNames() + 1 ); +// s.prepend( UL_USER_TENSE ); +// return s; +// } else +// return ""; +// } -int KEduVocConjugation::numInternalNames() -{ - return sizeof( Private::names ) / sizeof( Private::names[0] ); -} +// int KEduVocConjugation::numInternalNames() +// { +// return sizeof( Private::names ) / sizeof( Private::names[0] ); +// } -int KEduVocConjugation::tenseCount() -{ - return numInternalNames() + Private::userTenses.size(); -} +// int KEduVocConjugation::tenseCount() +// { +// return numInternalNames() + Private::userTenses.size(); +// } QString KEduVocConjugation::getType( int idx ) diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index 8d38d95..562fc9f 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -637,7 +637,7 @@ int KEduVocDocument::indexOfIdentifier( const QString& name ) const KEduVocIdentifier& KEduVocDocument::identifier( int index ) { if ( index < 0 || index >= d->m_identifiers.size() ) { - kError() << "Invalid identifier index: " << index; + kError() << " Error: Invalid identifier index: " << index; } return d->m_identifiers[index]; } diff --git a/keduvocdocument/keduvocidentifier.cpp b/keduvocdocument/keduvocidentifier.cpp index 26d8517..ce50db0 100644 --- a/keduvocdocument/keduvocidentifier.cpp +++ b/keduvocdocument/keduvocidentifier.cpp @@ -122,8 +122,6 @@ KEduVocArticle KEduVocIdentifier::article() const return d->m_articles; } - - KEduVocConjugation KEduVocIdentifier::personalPronouns() const { return d->m_personalPronouns; diff --git a/keduvocdocument/keduvockvtmlcompability.cpp b/keduvocdocument/keduvockvtmlcompability.cpp index 4693162..0728723 100644 --- a/keduvocdocument/keduvockvtmlcompability.cpp +++ b/keduvocdocument/keduvockvtmlcompability.cpp @@ -38,6 +38,7 @@ KEduVocKvtmlCompability::KEduVocKvtmlCompability() m_userdefinedUsageCounter = 0; initOldTypeLists(); + initOldConjugations(); } @@ -214,3 +215,14 @@ QString KEduVocKvtmlCompability::oldType( const QString & mainType, const QStrin return oldType; } + +void KEduVocKvtmlCompability::initOldConjugations() +{ + m_oldTenses["PrSi"] = i18n( "Simple Present" ); + m_oldTenses["PrPr"] = i18n( "Present Progressive" ); + m_oldTenses["PrPe"] = i18n( "Present Perfect" ); + m_oldTenses["PaSi"] = i18n( "Simple Past" ); + m_oldTenses["PaPr"] = i18n( "Past Progressive" ); + m_oldTenses["PaPa"] = i18n( "Past Participle" ); + m_oldTenses["FuSi"] = i18n( "Future" ); +} diff --git a/keduvocdocument/keduvockvtmlcompability.h b/keduvocdocument/keduvockvtmlcompability.h index 1278265..109812a 100644 --- a/keduvocdocument/keduvockvtmlcompability.h +++ b/keduvocdocument/keduvockvtmlcompability.h @@ -75,9 +75,6 @@ - - - /** * @file contains defines and constants necessary for reading kvtml files prior to KDE4. kvtml version 1. */ @@ -137,6 +134,7 @@ public: QString oldType( const QString& mainType, const QString& subType ) const; + private: /** * This gives a map of old abbreviations used in the files and their meaning. @@ -160,18 +158,17 @@ private: //////////// TYPES ///////////////// void initOldTypeLists(); - - /// user defined types of old documents -// QStringList m_userTypeDescriptions; - - - QMap m_oldMainTypeNames; QMap m_oldSubTypeNames; static const QString KVTML_1_TYPE_USER; static const QString KVTML_1_TYPE_DIV; +///////////TENSES/CONJUGATIONS/////// + void initOldConjugations(); + QMap m_oldTenses; + + }; -- 2.47.3