From: Martin Pfeiffer Date: Sat, 22 Oct 2005 01:01:55 +0000 (+0000) Subject: port from Q3ValueList to QList, operator== added, API doc X-Git-Tag: v3.80.2~237^2~6 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=a45e58718c156ff3356979b9b0f263d7175bb3a3;p=libqmvoc.git port from Q3ValueList to QList, operator== added, API doc svn path=/trunk/KDE/kdeedu/kwordquiz/src/keduvocexpression.h; revision=472807 --- diff --git a/kwordquiz/keduvocexpression.cpp b/kwordquiz/keduvocexpression.cpp index 7f2a42d..95af8ca 100644 --- a/kwordquiz/keduvocexpression.cpp +++ b/kwordquiz/keduvocexpression.cpp @@ -403,67 +403,67 @@ void KEduVocExpression::removeTranslation (int idx) return; if (idx <= numTranslations()) - m_translations.remove(m_translations.at(idx - 1)); + m_translations.removeAll(m_translations.at(idx - 1)); if (idx < (int)m_remarks.size() ) - m_remarks.remove(m_remarks.at(idx - 1)); + m_remarks.removeAll(m_remarks.at(idx - 1)); if (idx < (int)m_conjugations.size() ) - m_conjugations.remove(m_conjugations.at(idx -1)); + m_conjugations.removeAll(m_conjugations.at(idx -1)); if (idx < (int)m_comparisons.size() ) - m_comparisons.remove(m_comparisons.at(idx - 1)); + m_comparisons.removeAll(m_comparisons.at(idx - 1)); if (idx < (int)m_fauxAmi.size() ) - m_fauxAmi.remove(m_fauxAmi.at(idx - 1)); + m_fauxAmi.removeAll(m_fauxAmi.at(idx - 1)); if (idx < (int)m_reverseFauxAmi.size() ) - m_reverseFauxAmi.remove(m_reverseFauxAmi.at(idx - 1)); + m_reverseFauxAmi.removeAll(m_reverseFauxAmi.at(idx - 1)); if (idx < (int)m_synonym.size() ) - m_synonym.remove(m_synonym.at(idx - 1)); + m_synonym.removeAll(m_synonym.at(idx - 1)); if (idx < (int)m_example.size() ) - m_example.remove(m_example.at(idx - 1)); + m_example.removeAll(m_example.at(idx - 1)); if (idx < (int)m_usageLabels.size() ) - m_usageLabels.remove(m_usageLabels.at(idx - 1)); + m_usageLabels.removeAll(m_usageLabels.at(idx - 1)); if (idx < (int)m_paraphrases.size() ) - m_paraphrases.remove(m_paraphrases.at(idx - 1)); + m_paraphrases.removeAll(m_paraphrases.at(idx - 1)); if (idx < (int)m_antonym.size() ) - m_antonym.remove(m_antonym.at(idx - 1)); + m_antonym.removeAll(m_antonym.at(idx - 1)); if (idx < (int)m_expressionTypes.size() ) - m_expressionTypes.remove(m_expressionTypes.at(idx - 1)); + m_expressionTypes.removeAll(m_expressionTypes.at(idx - 1)); if (idx < (int)m_pronounciations.size() ) - m_pronounciations.remove(m_pronounciations.at(idx - 1)); + m_pronounciations.removeAll(m_pronounciations.at(idx - 1)); if (idx < (int)m_grades.size() ) - m_grades.remove(m_grades.at(idx - 1)); + m_grades.removeAll(m_grades.at(idx - 1)); if (idx < (int)m_reverseGrades.size() ) - m_reverseGrades.remove(m_reverseGrades.at(idx - 1)); + m_reverseGrades.removeAll(m_reverseGrades.at(idx - 1)); if (idx < (int)m_queryCounts.size() ) - m_queryCounts.remove(m_queryCounts.at(idx - 1)); + m_queryCounts.removeAll(m_queryCounts.at(idx - 1)); if (idx < (int)m_reverseQueryCounts.size() ) - m_reverseQueryCounts.remove(m_reverseQueryCounts.at(idx - 1)); + m_reverseQueryCounts.removeAll(m_reverseQueryCounts.at(idx - 1)); if (idx < (int)m_badCounts.size() ) - m_badCounts.remove(m_badCounts.at(idx - 1)); + m_badCounts.removeAll(m_badCounts.at(idx - 1)); if (idx < (int)m_reverseBadCounts.size() ) - m_reverseBadCounts.remove(m_reverseBadCounts.at(idx - 1)); + m_reverseBadCounts.removeAll(m_reverseBadCounts.at(idx - 1)); if (idx < (int)m_queryDates.size() ) - m_queryDates.remove(m_queryDates.at(idx - 1)); + m_queryDates.removeAll(m_queryDates.at(idx - 1)); if (idx < (int)m_reverseQueryDates.size() ) - m_reverseQueryDates.remove(m_reverseQueryDates.at(idx - 1)); + m_reverseQueryDates.removeAll(m_reverseQueryDates.at(idx - 1)); } diff --git a/kwordquiz/keduvocexpression.h b/kwordquiz/keduvocexpression.h index 1a81a51..2e3087d 100644 --- a/kwordquiz/keduvocexpression.h +++ b/kwordquiz/keduvocexpression.h @@ -47,9 +47,9 @@ #define KV_LEV7_GRADE 7 #define KV_LEV7_TEXT I18N_NOOP("Level 7") -#include -#include -#include +#include +#include +#include #include "keduvocgrammar.h" #include "keduvocmultiplechoice.h" @@ -446,17 +446,17 @@ class KEduVocExpression QStringList m_example; QStringList m_antonym; QStringList m_pronounciations; - Q3ValueList m_grades; - Q3ValueList m_reverseGrades; - Q3ValueList m_queryCounts; - Q3ValueList m_reverseQueryCounts; - Q3ValueList m_badCounts; - Q3ValueList m_reverseBadCounts; - Q3ValueList m_queryDates; - Q3ValueList m_reverseQueryDates; - Q3ValueList m_conjugations; - Q3ValueList m_comparisons; - Q3ValueList m_multipleChoices; + QList m_grades; + QList m_reverseGrades; + QList m_queryCounts; + QList m_reverseQueryCounts; + QList m_badCounts; + QList m_reverseBadCounts; + QList m_queryDates; + QList m_reverseQueryDates; + QList m_conjugations; + QList m_comparisons; + QList m_multipleChoices; QString m_leitnerBox; int m_lesson; diff --git a/kwordquiz/keduvocgrammar.cpp b/kwordquiz/keduvocgrammar.cpp index a55c6f0..4a648b8 100644 --- a/kwordquiz/keduvocgrammar.cpp +++ b/kwordquiz/keduvocgrammar.cpp @@ -26,8 +26,6 @@ #include "keduvocgrammar.h" #include -//Added by qt3to4: -#include KEduVocConjugation::conjug_name_t KEduVocConjugation::names [] = @@ -76,6 +74,14 @@ void KEduVocComparison::clear() ls3 = ""; } +bool KEduVocComparison::operator ==( const KEduVocComparison& a ) const +{ + if ( ls1 == a.l1() && ls2 == a.l2() && ls3 == a.l3() ) + return true; + else + return false; +} + //================================================================= @@ -138,15 +144,29 @@ void KEduVocArticle::natural(QString &def, QString &indef) const //============================================================== +bool KEduVocConjugation::operator ==( const KEduVocConjugation& a ) const +{ + if ( verbName == a.getVerbName() ) + return true; + else + return false; +} + + +const QString& KEduVocConjugation::getVerbName() const +{ + return verbName; +} + int KEduVocConjugation::numEntries() const { return conjugations.size(); } -Q3ValueList KEduVocConjugation::getRelation () +QList KEduVocConjugation::getRelation () { - Q3ValueList vec; + QList vec; for (int i = 0; i < numInternalNames(); i++) { vec.append(KEduVocTenseRelation(names[i].abbrev, i18n(names[i].name))); @@ -285,7 +305,7 @@ void KEduVocConjugation::cleanUp () && ctp->pers3_f_plur.stripWhiteSpace().isEmpty() && ctp->pers3_n_plur.stripWhiteSpace().isEmpty() ) - conjugations.erase(conjugations.at(i)); + conjugations.removeAt( i ); } } diff --git a/kwordquiz/keduvocgrammar.h b/kwordquiz/keduvocgrammar.h index 817a60d..d3dd2e0 100644 --- a/kwordquiz/keduvocgrammar.h +++ b/kwordquiz/keduvocgrammar.h @@ -28,7 +28,7 @@ #define grammarmanager_included #include -#include +#include #include #define CONJ_SIMPLE_PRESENT "PrSi" // I live at home what you frequently do @@ -45,21 +45,53 @@ #define UL_USER_TENSE "#" // designates number of user tense + +/** + * Class representing the articles of a language + * It contains all available articles of the language as QString + */ + class KEduVocArticle { public: + /** + * The constructor without arguments + */ KEduVocArticle() {} - KEduVocArticle ( - const QString &fem_def, const QString &fem_indef, - const QString &mal_def, const QString &mal_indef, - const QString &nat_def, const QString &nat_indef - ); - + /** + * The constructor with arguments + * @param fem_def reference to a QString with the definite female article + * @param fem_indef reference to a QString with the indefinite female article + * @param mal_def reference to a QString with the definite male article + * @param mal_indef reference to a QString with the indefinite male article + * @param nat_def reference to a QString with the definite neutral article + * @param nat_indef reference to a QString with the indefinite neutral article + */ + KEduVocArticle ( const QString &fem_def, const QString &fem_indef, const QString &mal_def, const QString &mal_indef, + const QString &nat_def, const QString &nat_indef ); + + /** + * Sets the female articles + * @param def const reference to a QString with the definite female article + * @param indef const reference to a QString with the indefinite female article + */ void setFemale (const QString &def, const QString &indef); + + /** + * Sets the male articles + * @param def const reference to a QString with the definite male article + * @param indef const reference to a QString with the indefinite male article + */ void setMale (const QString &def, const QString &indef); + + /** + * Sets the neutral articles + * @param def const reference to a QString with the definite neutral article + * @param indef const reference to a QString with the indefinite neutral article + */ void setNatural (const QString &def, const QString &indef); void female (QString &def, QString &indef) const; @@ -79,13 +111,18 @@ class KEduVocComparison public: + /** + * The constructor without arguments + */ KEduVocComparison() {} - KEduVocComparison ( - const QString &l1, - const QString &l2, - const QString &l3 - ); + /** + * The constructor with arguments + * @param l1 + * @param l2 + * @param l3 + */ + KEduVocComparison ( const QString &l1, const QString &l2, const QString &l3 ); void setL1 (const QString &s) { ls1 = s; } void setL2 (const QString &s) { ls2 = s; } @@ -98,6 +135,8 @@ public: bool isEmpty() const; void clear(); + bool operator == ( const KEduVocComparison& a ) const; + protected: QString ls1, ls2, ls3; @@ -118,16 +157,32 @@ protected: QString shortId, longId; }; +/** + * The conjugation of a verb + */ class KEduVocConjugation { public: + /** + * The constructor + */ KEduVocConjugation () {} + /** + * @return + */ int numEntries() const; - static Q3ValueList getRelation (); + /** + * @return + */ + static QList getRelation (); + + /** + * @param names + */ static void setTenseNames (QStringList names); static QString getName (const QString &abbrev); @@ -137,6 +192,8 @@ public: static int numInternalNames(); static int numTenses(); + const QString& getVerbName() const; + QString getType (int index); void setType (int index, const QString & type); void cleanUp(); @@ -170,36 +227,42 @@ public: void setPers3MalePlural(const QString &type, const QString &str); void setPers3NaturalPlural(const QString &type, const QString &str); + bool operator == ( const KEduVocConjugation& a ) const; + 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 { + struct conjug_name_t + { const char *abbrev; const char *name; }; -struct conjug_t -{ - conjug_t() { - p3common = false; - s3common = false; - } - - QString type; - bool p3common, - s3common; - QString pers1_sing, - pers2_sing, - pers3_m_sing, - pers3_f_sing, - pers3_n_sing, - pers1_plur, - pers2_plur, - pers3_m_plur, - pers3_f_plur, - pers3_n_plur; -}; + + struct conjug_t + { + conjug_t() { + p3common = false; + s3common = false; + } + + QString type; + bool p3common, + s3common; + QString pers1_sing, + pers2_sing, + pers3_m_sing, + pers3_f_sing, + pers3_n_sing, + pers1_plur, + pers2_plur, + pers3_m_plur, + pers3_f_plur, + pers3_n_plur; + }; protected: - typedef Q3ValueList conjug_tList; + typedef QList conjug_tList; conjug_tList conjugations; static conjug_name_t names []; diff --git a/kwordquiz/leitnerbox.h b/kwordquiz/leitnerbox.h index c238687..c32fa83 100644 --- a/kwordquiz/leitnerbox.h +++ b/kwordquiz/leitnerbox.h @@ -15,17 +15,34 @@ #include /** -@author Martin Pfeiffer -*/ + * A box in a LeitnerSystem - a LeitnerBox + * This box has a name and a certain number of vocabulars in it. This number changes continuosly + * as the vocab cards increase or decrease in box position. There is a determined order of LeitnerBoxes + * in a LeitnerSystem, therefore each LeitnerBox helds pointers to the LeitnerBox for wrong and correct + * cards of this LeitnerBox + * @author Martin Pfeiffer + */ class LeitnerBox { public: + /** + * The constructor + */ LeitnerBox(); ~LeitnerBox(); - void setCorrectWordBox( LeitnerBox* ); //sets the correct word box - void setWrongWordBox( LeitnerBox* ); //sets the wrong word box + /** + * Sets the LeitnerBox's pointer to the correct word LeitnerBox + * @param correctWordBox a pointer to the LeitnerBox to be set + */ + void setCorrectWordBox( LeitnerBox* correctWordBox ); + + /** + * Sets the LeitnerBox's pointer to the wrong word LeitnerBox + * @param wrongWordBox a pointer to the LeitnerBox to be set + */ + void setWrongWordBox( LeitnerBox* wrongWordBox ); void setBoxName( const QString& ); //sets the boxes name void setVocabCount( int count );