]> Git trees. - libqmvoc.git/commitdiff
Changes in the conjugation class. No longer uses a static table to translate abreviat...
authorFrederik Gladhorn <gladhorn@kde.org>
Fri, 31 Aug 2007 07:53:35 +0000 (07:53 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Fri, 31 Aug 2007 07:53:35 +0000 (07:53 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=706748

keduvocdocument/keduvoccommon_p.h
keduvocdocument/keduvocconjugation.cpp
keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvocidentifier.cpp
keduvocdocument/keduvockvtmlcompability.cpp
keduvocdocument/keduvockvtmlcompability.h

index d705a5d7452d21bbb9a729888072224ab1402b15..84bca8902ec89a830fc6d3288475c4c0904ea916 100644 (file)
 
 #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
index ee9d05a3c0c833ff92f6aa895de4f73f2f4c43ab..40f7c19ff6555021d19f2e6240d33c02725c6aa1 100644 (file)
@@ -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_t> 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 )
index 8d38d9586ac968f955c01aa9e8131085b0430549..562fc9ffe6f39a53c99c7fddb219b2df26559fae 100644 (file)
@@ -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];
 }
index 26d8517d505ad881850aa4af9e95b063f07666af..ce50db019df45b7ecf1ea4820d4797134388cd79 100644 (file)
@@ -122,8 +122,6 @@ KEduVocArticle KEduVocIdentifier::article() const
     return d->m_articles;
 }
 
-
-
 KEduVocConjugation KEduVocIdentifier::personalPronouns() const
 {
     return d->m_personalPronouns;
index 46931622d9e4b17426d4b8e41d21bba2d10c1323..0728723540aaa4a6ef7a34a442380a883cc1d6c4 100644 (file)
@@ -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" );
+}
index 12782653272795f9a1ec11bf0ab5e597fb06542e..109812a10eb61489fb11bc4dc0848615839ba222 100644 (file)
@@ -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<QString, QString> m_oldMainTypeNames;
     QMap<QString, QString> m_oldSubTypeNames;
 
     static const QString KVTML_1_TYPE_USER;
     static const QString KVTML_1_TYPE_DIV;
 
+///////////TENSES/CONJUGATIONS///////
+    void initOldConjugations();
+    QMap<QString, QString> m_oldTenses;
+
+
 };