From fca0e76b39f9e678881ab71caf89ba54608418d9 Mon Sep 17 00:00:00 2001 From: Peter Hedlund Date: Sat, 8 Oct 2005 00:24:48 +0000 Subject: [PATCH] Continued refactoring for the future kvtml library svn path=/branches/work/kwordquiz/src/keduvocdocument.h; revision=468408 --- kwordquiz/keduvocdocument.cpp | 121 +++++++++------ kwordquiz/keduvocdocument.h | 7 +- kwordquiz/keduvocgrammar.cpp | 173 ++++++++++----------- kwordquiz/keduvocgrammar.h | 228 ++++++++++++++-------------- kwordquiz/keduvockvtmlreader.cpp | 25 ++- kwordquiz/keduvockvtmlreader.h | 2 +- kwordquiz/keduvocmultiplechoice.cpp | 29 ++-- kwordquiz/keduvocmultiplechoice.h | 8 +- 8 files changed, 302 insertions(+), 291 deletions(-) diff --git a/kwordquiz/keduvocdocument.cpp b/kwordquiz/keduvocdocument.cpp index 7637be3..f139bde 100644 --- a/kwordquiz/keduvocdocument.cpp +++ b/kwordquiz/keduvocdocument.cpp @@ -1,10 +1,9 @@ /*************************************************************************** Vocabulary Document for KDE Edu ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - (C) 2001 The KDE-EDU team - (C) 2005 Peter Hedlund - email : peter.hedlund@kdemail.net + copyright : (C) 1999-2001 Ewald Arnold + (C) 2001 The KDE-EDU team + (C) 2005 Peter Hedlund ***************************************************************************/ /*************************************************************************** @@ -26,10 +25,6 @@ #include #include -using namespace std; - -#include - #include "keduvockvtmlwriter.h" #include "keduvockvtmlreader.h" #include "keduvocwqlwriter.h" @@ -477,7 +472,7 @@ void KEduVocDocument::setSizeHint (int idx, const int width) } } - +/* class eraseTrans : public unary_function { @@ -494,13 +489,16 @@ public: private: int index; }; - +*/ void KEduVocDocument::removeIdentifier(int index) { - if (index < (int)m_identifiers.size() && index >= 1 ) { + if (index < (int)m_identifiers.size() && index >= 1 ) + { m_identifiers.erase(m_identifiers.at(index)); - for_each (m_vocabulary.begin(), m_vocabulary.end(), eraseTrans(index)); + QValueList::iterator it; + for (it = m_vocabulary.begin(); it != m_vocabulary.end(); ++it) + (*it).removeTranslation(index); } } @@ -775,7 +773,7 @@ LeitnerSystem* KEduVocDocument::leitnerSystem() return m_leitnerSystem; } - +/* class resetAll : public unary_function { @@ -836,14 +834,50 @@ public: int index; int lesson; }; +*/ - -void KEduVocDocument::resetEntry (int index, int lesson) +void KEduVocDocument::resetEntry(int index, int lesson) { + QValueList::iterator it; if (index < 0) - for_each (m_vocabulary.begin(), m_vocabulary.end(), resetAll(lesson) ); + { + for (it = m_vocabulary.begin(); it != m_vocabulary.end(); ++it) + for (int i = 0; i <= (*it).numTranslations(); i++) + { + if (lesson == 0 || lesson == (*it).lesson()) + { + (*it).setGrade(i, KV_NORM_GRADE, false); + (*it).setGrade(i, KV_NORM_GRADE, true); + (*it).setQueryCount(i, 0, true); + (*it).setQueryCount(i, 0, false); + (*it).setBadCount(i, 0, true); + (*it).setBadCount(i, 0, false); + QDateTime dt; + dt.setTime_t(0); + (*it).setQueryDate(i, dt, true); + (*it).setQueryDate(i, dt, false); + } + } + //for_each (m_vocabulary.begin(), m_vocabulary.end(), resetAll(lesson) ); + } else - for_each (m_vocabulary.begin(), m_vocabulary.end(), resetOne(index, lesson) ); + { + for (it = m_vocabulary.begin(); it != m_vocabulary.end(); ++it) + if (lesson == 0 || lesson == (*it).lesson()) + { + (*it).setGrade(index, KV_NORM_GRADE, false); + (*it).setGrade(index, KV_NORM_GRADE, true); + (*it).setQueryCount(index, 0, true); + (*it).setQueryCount(index, 0, false); + (*it).setBadCount(index, 0, true); + (*it).setBadCount(index, 0, false); + QDateTime dt; + dt.setTime_t(0); + (*it).setQueryDate(index, dt, true); + (*it).setQueryDate(index, dt, false); + } + //for_each (m_vocabulary.begin(), m_vocabulary.end(), resetOne(index, lesson) ); + } } @@ -1032,50 +1066,51 @@ KEduVocDocument::FileType KEduVocDocument::detectFileType(const QString &filenam } -class expRef { +class ExpRef { public: + ExpRef() {} + ExpRef (KEduVocExpression *_exp, int _idx) + { + idx = _idx; + exp = _exp; + } - expRef (KEduVocExpression *_exp, int _idx) - { - idx = _idx; - exp = _exp; - } + bool operator< (const ExpRef& y) const + { + QString s1 = exp->original(); + QString s2 = y.exp->original(); + int cmp = QString::compare(s1.upper(), s2.upper()); + if (cmp != 0) + return cmp < 0; - bool operator< (const expRef& y) const - { - QString s1 = exp->original(); - QString s2 = y.exp->original(); - int cmp = QString::compare(s1.upper(), s2.upper()); + for (int i = 1; i < (int) exp->numTranslations(); i++) { + + s1 = exp->translation(i); + s2 = y.exp->translation(i); + cmp = QString::compare(s1.upper(), s2.upper() ); if (cmp != 0) return cmp < 0; - - for (int i = 1; i < (int) exp->numTranslations(); i++) { - - s1 = exp->translation(i); - s2 = y.exp->translation(i); - cmp = QString::compare(s1.upper(), s2.upper() ); - if (cmp != 0) - return cmp < 0; - } - return cmp < 0; } + return cmp < 0; + } - int idx; + int idx; KEduVocExpression *exp; }; +typedef QValueList ExpRefList; int KEduVocDocument::cleanUp() { int count = 0; KEduVocExpression *kve1, *kve2; - vector shadow; - vector to_delete; + ExpRefList shadow; + QValueList to_delete; for (int i = 0; i < (int) m_vocabulary.size(); i++) - shadow.push_back (expRef (entry(i), i)); - std::sort(shadow.begin(), shadow.end()); + shadow.push_back (ExpRef (entry(i), i)); + qHeapSort(shadow.begin(), shadow.end()); #ifdef CLEAN_BUG ofstream sso ("shadow.out"); diff --git a/kwordquiz/keduvocdocument.h b/kwordquiz/keduvocdocument.h index 537404b..00ee84f 100644 --- a/kwordquiz/keduvocdocument.h +++ b/kwordquiz/keduvocdocument.h @@ -1,10 +1,9 @@ /*************************************************************************** Vocabulary Document for KDE Edu ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - (C) 2001 The KDE-EDU team - (C) 2005 Peter Hedlund - email : peter.hedlund@kdemail.net + copyright : (C) 1999-2001 Ewald Arnold + (C) 2001 The KDE-EDU team + (C) 2005 Peter Hedlund ***************************************************************************/ /*************************************************************************** diff --git a/kwordquiz/keduvocgrammar.cpp b/kwordquiz/keduvocgrammar.cpp index fac26df..09ddce4 100644 --- a/kwordquiz/keduvocgrammar.cpp +++ b/kwordquiz/keduvocgrammar.cpp @@ -31,8 +31,8 @@ KEduVocConjugation::conjug_name_t KEduVocConjugation::names [] = { { CONJ_SIMPLE_PRESENT, I18N_NOOP("Simple Present") }, - { CONJ_PRESENT_PROGR, I18N_NOOP("Preset Progressive") }, - { CONJ_PRESENT_PERFECT, I18N_NOOP("Preset Perfect") }, + { 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") }, @@ -42,7 +42,7 @@ KEduVocConjugation::names [] = }; -vector KEduVocConjugation::userTenses; +QStringList KEduVocConjugation::userTenses; //================================================================ @@ -53,9 +53,9 @@ KEduVocComparison::KEduVocComparison ( const QString &l3 ) { - setL1 (l1); - setL2 (l2); - setL3 (l3); + setL1 (l1); + setL2 (l2); + setL3 (l3); } @@ -69,9 +69,9 @@ bool KEduVocComparison::isEmpty() const void KEduVocComparison::clear() { - ls1 = ""; - ls2 = ""; - ls3 = ""; + ls1 = ""; + ls2 = ""; + ls3 = ""; } @@ -84,57 +84,51 @@ KEduVocArticle::KEduVocArticle const QString &nat_def, const QString &nat_indef ) { - setFemale (fem_def, fem_indef); - setMale (mal_def, mal_indef); - setNatural (nat_def, nat_indef); + setFemale (fem_def, fem_indef); + setMale (mal_def, mal_indef); + setNatural (nat_def, nat_indef); } -void KEduVocArticle::setFemale - (const QString &def, const QString &indef) +void KEduVocArticle::setFemale(const QString &def, const QString &indef) { - fem_def = def; - fem_indef = indef; + fem_def = def; + fem_indef = indef; } -void KEduVocArticle::setMale - (const QString &def, const QString &indef) +void KEduVocArticle::setMale(const QString &def, const QString &indef) { - mal_def = def; - mal_indef = indef; + mal_def = def; + mal_indef = indef; } -void KEduVocArticle::setNatural - (const QString &def, const QString &indef) +void KEduVocArticle::setNatural(const QString &def, const QString &indef) { - nat_def = def; - nat_indef = indef; + nat_def = def; + nat_indef = indef; } -void KEduVocArticle::female - (QString &def, QString &indef) const +void KEduVocArticle::female(QString &def, QString &indef) const { - def = fem_def; - indef = fem_indef; + def = fem_def; + indef = fem_indef; } -void KEduVocArticle::male - (QString &def, QString &indef) const +void KEduVocArticle::male(QString &def, QString &indef) const { - def = mal_def; - indef = mal_indef; + def = mal_def; + indef = mal_indef; } -void KEduVocArticle::natural - (QString &def, QString &indef) const +void KEduVocArticle::natural(QString &def, QString &indef) const { - def = nat_def; - indef = nat_indef; + def = nat_def; + indef = nat_indef; } @@ -144,31 +138,30 @@ void KEduVocArticle::natural int KEduVocConjugation::numEntries() const { - return conjugations.size(); + return conjugations.size(); } -vector KEduVocConjugation::getRelation () +QValueList KEduVocConjugation::getRelation () { - vector vec; + QValueList vec; for (int i = 0; i < numInternalNames(); i++) { - vec.push_back(KEduVocTenseRelation(names[i].abbrev, - i18n(names[i].name))); + vec.append(KEduVocTenseRelation(names[i].abbrev, i18n(names[i].name))); } for (int i = 0; i < (int) userTenses.size(); i++) { QString s; s.setNum(i+1); s.insert(0, UL_USER_TENSE); - vec.push_back(KEduVocTenseRelation(s, userTenses[i])); + vec.append(KEduVocTenseRelation(s, userTenses[i])); } return vec; } -void KEduVocConjugation::setTenseNames (vector names) +void KEduVocConjugation::setTenseNames (QStringList names) { userTenses = names; } @@ -176,84 +169,84 @@ void KEduVocConjugation::setTenseNames (vector names) QString KEduVocConjugation::getName (const QString &abbrev) { - if (abbrev.length() >= 2 && abbrev[0] == QString(UL_USER_TENSE)) { - QString s = abbrev; - s.remove(0, 1); - int i = s.toInt() - 1; + if (abbrev.length() >= 2 && abbrev[0] == QString(UL_USER_TENSE)) { + QString s = abbrev; + s.remove(0, 1); + int i = s.toInt() - 1; - if (i < (int) userTenses.size() ) - return userTenses[i]; - else - return ""; - } - else { - for (int i = 0; i < (int) numInternalNames(); i++) - if (names[i].abbrev == abbrev) { - return i18n(names[i].name); - } - } + if (i < (int) userTenses.size() ) + return userTenses[i]; + else + return ""; + } + else { + for (int i = 0; i < (int) numInternalNames(); i++) + if (names[i].abbrev == abbrev) { + return i18n(names[i].name); + } + } - return ""; + return ""; } QString KEduVocConjugation::getName (int idx) { - if (idx < numInternalNames() ) - return i18n(names[idx].name); + if (idx < numInternalNames() ) + return i18n(names[idx].name); - else if (idx < numTenses() ) - return userTenses[idx-numInternalNames()]; + else if (idx < numTenses() ) + return userTenses[idx-numInternalNames()]; - else - return ""; + else + return ""; } QString KEduVocConjugation::getAbbrev (const QString &name) { - for (int i = 0; i < (int) userTenses.size(); i++) - if (userTenses[i] == name) { - QString s; - s.setNum(i+1); - s.insert(0, UL_USER_TENSE); - return s; - } + for (int i = 0; i < (int) userTenses.size(); i++) + if (userTenses[i] == name) { + QString s; + s.setNum(i+1); + s.insert(0, UL_USER_TENSE); + return s; + } - for (int i = 0; i < (int) numInternalNames(); i++) - if (names[i].name == name) - return names[i].abbrev; + for (int i = 0; i < (int) numInternalNames(); i++) + if (names[i].name == name) + return names[i].abbrev; - return ""; + return ""; } QString KEduVocConjugation::getAbbrev (int idx) { - if (idx < numInternalNames() ) - return names[idx].abbrev; + if (idx < numInternalNames() ) + return names[idx].abbrev; - else if (idx < numTenses() ) { - QString s; - s.setNum(idx-numInternalNames()+1); - s.insert(0, UL_USER_TENSE); - return s; - } + else if (idx < numTenses() ) { + QString s; + s.setNum(idx-numInternalNames()+1); + s.insert(0, UL_USER_TENSE); + return s; + } - else - return ""; + else + return ""; } int KEduVocConjugation::numInternalNames() { - return sizeof(names) / sizeof(names[0]); + return sizeof(names) / sizeof(names[0]); } int KEduVocConjugation::numTenses() { - return numInternalNames()+userTenses.size(); + return numInternalNames()+userTenses.size(); } @@ -290,7 +283,7 @@ void KEduVocConjugation::cleanUp () && ctp->pers3_f_plur.stripWhiteSpace().isEmpty() && ctp->pers3_n_plur.stripWhiteSpace().isEmpty() ) - conjugations.erase(conjugations.begin() + i); + conjugations.erase(conjugations.at(i)); } } @@ -415,7 +408,7 @@ QString KEduVocConjugation::pers3NaturalPlural conjug_t ct; \ ct.type = type; \ ct.elem = str; \ - conjugations.push_back(ct); + conjugations.append(ct); void KEduVocConjugation::setPers3PluralCommon(const QString &type, bool f) diff --git a/kwordquiz/keduvocgrammar.h b/kwordquiz/keduvocgrammar.h index 420fb56..941c82f 100644 --- a/kwordquiz/keduvocgrammar.h +++ b/kwordquiz/keduvocgrammar.h @@ -28,9 +28,8 @@ #define grammarmanager_included #include - -#include -using namespace std; +#include +#include #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 @@ -44,34 +43,34 @@ using namespace std; #define CONJ_PREFIX "--" // definition of prefixes (I, you, ..) -#define UL_USER_TENSE "#" // designates number of user tense +#define UL_USER_TENSE "#" // designates number of user tense class KEduVocArticle { public: - KEduVocArticle() {} + 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 - ); + 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 + ); - void setFemale (const QString &def, const QString &indef); - void setMale (const QString &def, const QString &indef); - void setNatural (const QString &def, const QString &indef); + void setFemale (const QString &def, const QString &indef); + void setMale (const QString &def, const QString &indef); + void setNatural (const QString &def, const QString &indef); - void female (QString &def, QString &indef) const; - void male (QString &def, QString &indef) const; - void natural (QString &def, QString &indef) const; + void female (QString &def, QString &indef) const; + void male (QString &def, QString &indef) const; + void natural (QString &def, QString &indef) const; protected: - QString fem_def, fem_indef, - mal_def, mal_indef, - nat_def, nat_indef; + QString fem_def, fem_indef, + mal_def, mal_indef, + nat_def, nat_indef; }; @@ -80,134 +79,131 @@ class KEduVocComparison public: - KEduVocComparison() {} + KEduVocComparison() {} - KEduVocComparison ( - const QString &l1, - const QString &l2, - const QString &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; } - void setL3 (const QString &s) { ls3 = s; } + void setL1 (const QString &s) { ls1 = s; } + void setL2 (const QString &s) { ls2 = s; } + void setL3 (const QString &s) { ls3 = s; } - QString l1 () const { return ls1; } - QString l2 () const { return ls2; } - QString l3 () const { return ls3; } + QString l1 () const { return ls1; } + QString l2 () const { return ls2; } + QString l3 () const { return ls3; } - bool isEmpty() const; - void clear(); + bool isEmpty() const; + void clear(); protected: - QString ls1, ls2, ls3; + QString ls1, ls2, ls3; }; class KEduVocTenseRelation { - public: - - KEduVocTenseRelation (const QString & _short, const QString & _long) - : shortId (_short), longId(_long) {} +public: + KEduVocTenseRelation() {} + KEduVocTenseRelation (const QString & _short, const QString & _long): shortId (_short), longId(_long) {} inline QString shortStr() const { return shortId; } inline QString longStr() const { return longId; } - protected: +protected: QString shortId, longId; }; - class KEduVocConjugation { public: - KEduVocConjugation () {} - - int numEntries() const; - - static vector getRelation (); - static void setTenseNames (vector names); - - static QString getName (const QString &abbrev); - static QString getName (int index); - static QString getAbbrev (const QString &name); - static QString getAbbrev (int index); - static int numInternalNames(); - static int numTenses(); - - QString getType (int index); - void setType (int index, const QString & type); - void cleanUp(); - bool isEmpty (int idx); - - QString pers1Singular(const QString &type) const; - QString pers2Singular(const QString &type) const; - bool pers3SingularCommon(const QString &type) const; - QString pers3FemaleSingular(const QString &type) const; - QString pers3MaleSingular(const QString &type) const; - QString pers3NaturalSingular(const QString &type) const; - - QString pers1Plural(const QString &type) const; - QString pers2Plural(const QString &type) const; - bool pers3PluralCommon(const QString &type) const; - QString pers3FemalePlural(const QString &type) const; - QString pers3MalePlural(const QString &type) const; - QString pers3NaturalPlural(const QString &type) const; - - void setPers1Singular(const QString &type, const QString &str); - void setPers2Singular(const QString &type, const QString &str); - void setPers3SingularCommon(const QString &type, bool f); - void setPers3FemaleSingular(const QString &type, const QString &str); - void setPers3MaleSingular(const QString &type, const QString &str); - void setPers3NaturalSingular(const QString &type, const QString &str); - - void setPers1Plural(const QString &type, const QString &str); - void setPers2Plural(const QString &type, const QString &str); - void setPers3PluralCommon(const QString &type, bool f); - void setPers3FemalePlural(const QString &type, const QString &str); - void setPers3MalePlural(const QString &type, const QString &str); - void setPers3NaturalPlural(const QString &type, const QString &str); + KEduVocConjugation () {} + + int numEntries() const; + + static QValueList getRelation (); + static void setTenseNames (QStringList names); + + static QString getName (const QString &abbrev); + static QString getName (int index); + static QString getAbbrev (const QString &name); + static QString getAbbrev (int index); + static int numInternalNames(); + static int numTenses(); + + QString getType (int index); + void setType (int index, const QString & type); + void cleanUp(); + bool isEmpty (int idx); + + QString pers1Singular(const QString &type) const; + QString pers2Singular(const QString &type) const; + bool pers3SingularCommon(const QString &type) const; + QString pers3FemaleSingular(const QString &type) const; + QString pers3MaleSingular(const QString &type) const; + QString pers3NaturalSingular(const QString &type) const; + + QString pers1Plural(const QString &type) const; + QString pers2Plural(const QString &type) const; + bool pers3PluralCommon(const QString &type) const; + QString pers3FemalePlural(const QString &type) const; + QString pers3MalePlural(const QString &type) const; + QString pers3NaturalPlural(const QString &type) const; + + void setPers1Singular(const QString &type, const QString &str); + void setPers2Singular(const QString &type, const QString &str); + void setPers3SingularCommon(const QString &type, bool f); + void setPers3FemaleSingular(const QString &type, const QString &str); + void setPers3MaleSingular(const QString &type, const QString &str); + void setPers3NaturalSingular(const QString &type, const QString &str); + + void setPers1Plural(const QString &type, const QString &str); + void setPers2Plural(const QString &type, const QString &str); + void setPers3PluralCommon(const QString &type, bool f); + void setPers3FemalePlural(const QString &type, const QString &str); + void setPers3MalePlural(const QString &type, const QString &str); + void setPers3NaturalPlural(const QString &type, const QString &str); private: - 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_name_t { - const char *abbrev; - const char *name; - }; + 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; +}; protected: + typedef QValueList conjug_tList; + conjug_tList conjugations; - vector conjugations; - - static conjug_name_t names []; - static vector userTenses; + static conjug_name_t names []; + static QStringList userTenses; }; diff --git a/kwordquiz/keduvockvtmlreader.cpp b/kwordquiz/keduvockvtmlreader.cpp index 7e5bd4a..93d0686 100644 --- a/kwordquiz/keduvockvtmlreader.cpp +++ b/kwordquiz/keduvockvtmlreader.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include "keduvockvtmlreader.h" @@ -744,7 +743,7 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE QString &lang, grade_t &grade, grade_t &rev_grade, int &count, int &rev_count, - time_t &date, time_t &rev_date, + QDateTime &date, QDateTime &rev_date, QString &remark, int &bcount, int &rev_bcount, QString &query_id, @@ -816,19 +815,19 @@ bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementE bcount = s.toInt(); } - date = 0; - rev_date = 0; + date.setTime_t(0); + rev_date.setTime_t(0); QDomAttr domAttrDate = domElementExpressionChild.attributeNode(KV_DATE); if (!domAttrDate.isNull()) { QString s = domAttrDate.value(); if ((pos = s.find(';')) >= 1) { - date = s.left(pos).toInt(); - rev_date = s.mid(pos+1, s.length()).toInt(); + date.setTime_t(s.left(pos).toInt()); + rev_date.setTime_t(s.mid(pos+1, s.length()).toInt()); } else - date = s.toInt(); + date.setTime_t(s.toInt()); } QDomAttr domAttrDate2 = domElementExpressionChild.attributeNode(KV_DATE2); @@ -946,7 +945,7 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) r_bcount; QString remark; QString pronunce; - time_t qdate, + QDateTime qdate, r_qdate; bool inquery; bool active; @@ -1366,11 +1365,11 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) expr.setQueryCount (count, r_qcount, true); expr.setBadCount (count, bcount, false); expr.setBadCount (count, r_bcount, true); - QDateTime dt; - dt.setTime_t(qdate); - expr.setQueryDate(count, dt, false); - dt.setTime_t(r_qdate); - expr.setQueryDate(count, dt, true); + //QDateTime dt; + //dt.setTime_t(qdate); + expr.setQueryDate(count, qdate, false); + //dt.setTime_t(r_qdate); + expr.setQueryDate(count, r_qdate, true); if (conjug.size() > 0) { diff --git a/kwordquiz/keduvockvtmlreader.h b/kwordquiz/keduvockvtmlreader.h index ccc061a..d42bb83 100644 --- a/kwordquiz/keduvockvtmlreader.h +++ b/kwordquiz/keduvockvtmlreader.h @@ -89,7 +89,7 @@ public: QString &lang, grade_t &grade, grade_t &rev_grade, int &count, int &rev_count, - time_t &date, time_t &rev_date, + QDateTime &date, QDateTime &rev_date, QString &remark, int &bcount, int &rev_bcount, QString &query_id, diff --git a/kwordquiz/keduvocmultiplechoice.cpp b/kwordquiz/keduvocmultiplechoice.cpp index 8219517..9cc9243 100644 --- a/kwordquiz/keduvocmultiplechoice.cpp +++ b/kwordquiz/keduvocmultiplechoice.cpp @@ -25,13 +25,8 @@ #include "keduvocmultiplechoice.h" -KEduVocMultipleChoice::KEduVocMultipleChoice ( - const QString &mc1, - const QString &mc2, - const QString &mc3, - const QString &mc4, - const QString &mc5 - ) +KEduVocMultipleChoice::KEduVocMultipleChoice + (const QString &mc1, const QString &mc2, const QString &mc3, const QString &mc4,const QString &mc5) { setMC1 (mc1); setMC2 (mc2); @@ -43,11 +38,11 @@ KEduVocMultipleChoice::KEduVocMultipleChoice ( bool KEduVocMultipleChoice::isEmpty() const { - return muc1.stripWhiteSpace().isEmpty() - && muc2.stripWhiteSpace().isEmpty() - && muc3.stripWhiteSpace().isEmpty() - && muc4.stripWhiteSpace().isEmpty() - && muc5.stripWhiteSpace().isEmpty(); + return muc1.stripWhiteSpace().isEmpty() && + muc2.stripWhiteSpace().isEmpty() && + muc3.stripWhiteSpace().isEmpty() && + muc4.stripWhiteSpace().isEmpty() && + muc5.stripWhiteSpace().isEmpty(); } @@ -78,15 +73,15 @@ unsigned KEduVocMultipleChoice::size() { normalize(); unsigned num = 0; - if (!muc1.isEmpty() ) + if (!muc1.isEmpty()) ++num; - if (!muc2.isEmpty() ) + if (!muc2.isEmpty()) ++num; - if (!muc3.isEmpty() ) + if (!muc3.isEmpty()) ++num; - if (!muc4.isEmpty() ) + if (!muc4.isEmpty()) ++num; - if (!muc5.isEmpty() ) + if (!muc5.isEmpty()) ++num; return num; } diff --git a/kwordquiz/keduvocmultiplechoice.h b/kwordquiz/keduvocmultiplechoice.h index bd34f90..55efe69 100644 --- a/kwordquiz/keduvocmultiplechoice.h +++ b/kwordquiz/keduvocmultiplechoice.h @@ -38,13 +38,7 @@ public: KEduVocMultipleChoice() {} - KEduVocMultipleChoice ( - const QString &mc1, - const QString &mc2, - const QString &mc3, - const QString &mc4, - const QString &mc5 - ); + KEduVocMultipleChoice (const QString &mc1, const QString &mc2, const QString &mc3, const QString &mc4, const QString &mc5); void setMC1 (const QString &s) { muc1 = s; } void setMC2 (const QString &s) { muc2 = s; } -- 2.47.3