From: Frederik Gladhorn Date: Tue, 12 Jun 2007 15:08:47 +0000 (+0000) Subject: Move all language specific stuff out of KEduVocExpression into KEduVocTranslation... X-Git-Tag: v3.91.0~22 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=e61af1d81be81e353d7192e08411d3bdf6670dbf;p=libqmvoc.git Move all language specific stuff out of KEduVocExpression into KEduVocTranslation. Also lay the groundwork to finally support arbitrary language combinations. Still the old kvtml of course does not support it, neither any app so far. Only the kvtml reader/writer is ported, the others are commented out and need to be reactivated. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=674555 --- diff --git a/kdeeducore/CMakeLists.txt b/kdeeducore/CMakeLists.txt index a6bd784..4dc9abe 100644 --- a/kdeeducore/CMakeLists.txt +++ b/kdeeducore/CMakeLists.txt @@ -2,19 +2,20 @@ ########### next target ############### set(kdeeducore_LIB_SRCS - keduvoccsvreader.cpp - keduvoccsvwriter.cpp +# keduvoccsvreader.cpp +# keduvoccsvwriter.cpp keduvocdocument.cpp keduvocexpression.cpp keduvoctranslation.cpp + keduvocgrade.cpp keduvocgrammar.cpp keduvockvtmlreader.cpp keduvockvtmlwriter.cpp keduvocmultiplechoice.cpp - keduvocpaukerreader.cpp - keduvocvokabelnreader.cpp - keduvocwqlreader.cpp - keduvocxdxfreader.cpp +# keduvocpaukerreader.cpp +# keduvocvokabelnreader.cpp +# keduvocwqlreader.cpp +# keduvocxdxfreader.cpp leitnerbox.cpp leitnersystem.cpp leitnersystemview.cpp diff --git a/kdeeducore/keduvoccsvreader.cpp b/kdeeducore/keduvoccsvreader.cpp index bcdccf3..433f2dc 100644 --- a/kdeeducore/keduvoccsvreader.cpp +++ b/kdeeducore/keduvoccsvreader.cpp @@ -59,7 +59,7 @@ bool KEduVocCsvReader::readDoc(KEduVocDocument *doc) if (!s.simplified().isEmpty()) { KEduVocExpression expression(s, separator); - languageCount = qMax(languageCount, expression.translationCount() + 1); + languageCount = qMax(languageCount, expression.translationCount()); m_doc->appendEntry(&expression); } } diff --git a/kdeeducore/keduvocdocument.cpp b/kdeeducore/keduvocdocument.cpp index 3e2c202..2692b9b 100644 --- a/kdeeducore/keduvocdocument.cpp +++ b/kdeeducore/keduvocdocument.cpp @@ -41,6 +41,7 @@ #include "keduvocxdxfreader.h" #include "leitnersystem.h" + class KEduVocDocument::KEduVocDocumentPrivate { public: @@ -234,7 +235,7 @@ bool KEduVocDocument::open(const KUrl& url) errorMessage = kvtmlReader.errorMessage(); } break; - +/* case wql: { KEduVocWqlReader wqlReader(f); @@ -283,7 +284,7 @@ bool KEduVocDocument::open(const KUrl& url) errorMessage = i18n("Parse error at line %1, column %2:\n%3", xdxfReader.lineNumber(), xdxfReader.columnNumber(), xdxfReader.errorString()); } break; - +*/ default: { KEduVocKvtmlReader kvtmlReader(f); @@ -342,13 +343,13 @@ bool KEduVocDocument::saveAs(const KUrl & url, FileType ft, const QString & gene saved = kvtmlWriter.writeDoc(this, generator); } break; - +/** @todo include the csv write again, as soon as it's ported to the new classes case csv: { KEduVocCsvWriter csvWriter(&f); saved = csvWriter.writeDoc(this, generator); } break; - +*/ default: { kError() << "kvcotrainDoc::saveAs(): unknown filetype" << endl; } @@ -369,8 +370,12 @@ bool KEduVocDocument::saveAs(const KUrl & url, FileType ft, const QString & gene return true; } + + void KEduVocDocument::merge(KEduVocDocument *docToMerge, bool matchIdentifiers) { + kDebug() << "Merging of docs is not implemented" << endl; /// @todo IMPLEMENT ME +/* if (docToMerge) { QApplication::setOverrideCursor(Qt::WaitCursor); @@ -427,17 +432,17 @@ void KEduVocDocument::merge(KEduVocDocument *docToMerge, bool matchIdentifiers) expr->setLesson(expr->lesson() + lesson_offset); for (int lang = 0; lang <= expr->translationCount(); lang++) { - QString t = expr->type(lang); + QString t = expr->translation(lang).type(); // adjust type offset if (!t.isEmpty() && t.left(1) == QM_USER_TYPE) { QString t2; t.remove(0, 1); t2.setNum(t.toInt() + types_offset); t2.prepend(QM_USER_TYPE); - expr->setType (lang, t2); + expr->translation(lang).setType (t2); } - t = expr->usageLabel(lang); + t = expr->translation(lang).usageLabel(); // adjust usage offset QString tg; if (!t.isEmpty()) { @@ -468,10 +473,10 @@ void KEduVocDocument::merge(KEduVocDocument *docToMerge, bool matchIdentifiers) else if (t.length() != 0) tg += ':' + t; - expr->setUsageLabel (lang, tg); + expr->translation(lang).setUsageLabel (tg); } - KEduVocConjugation conj = expr->conjugation(lang); + KEduVocConjugation conj = expr->translation(lang).conjugation(); bool condirty = false; for (int ci = 0; ci < conj.entryCount(); ci++) { t = conj.getType(ci); @@ -484,7 +489,7 @@ void KEduVocDocument::merge(KEduVocDocument *docToMerge, bool matchIdentifiers) condirty = true; } if (condirty) - expr->setConjugation(lang, conj); + expr->translation(lang).setConjugation(conj); } } @@ -576,8 +581,10 @@ void KEduVocDocument::merge(KEduVocDocument *docToMerge, bool matchIdentifiers) } } QApplication::restoreOverrideCursor(); +*/ } + KEduVocExpression *KEduVocDocument::entry(int index) { if (index < 0 || index >= d->m_vocabulary.size() ) @@ -638,7 +645,7 @@ void KEduVocDocument::setTypeName(int idx, QString &id) { if (idx >= d->m_typeDescriptions.size()) for (int i = d->m_typeDescriptions.size(); i <= idx; i++) - d->m_typeDescriptions.push_back (""); + d->m_typeDescriptions.append (""); d->m_typeDescriptions[idx] = id; } @@ -669,7 +676,7 @@ void KEduVocDocument::setTenseName(int idx, QString &id) { if (idx >= d->m_tenseDescriptions.size()) for (int i = d->m_tenseDescriptions.size(); i <= idx; i++) - d->m_tenseDescriptions.push_back (""); + d->m_tenseDescriptions.append (""); d->m_tenseDescriptions[idx] = id; } @@ -700,7 +707,7 @@ void KEduVocDocument::setUsageName(int idx, QString &id) { if (idx >= d->m_usageDescriptions.size()) for (int i = d->m_usageDescriptions.size(); i <= idx; i++) - d->m_usageDescriptions.push_back (""); + d->m_usageDescriptions.append (""); d->m_usageDescriptions[idx] = id; } @@ -725,7 +732,7 @@ void KEduVocDocument::setConjugation(int idx, const KEduVocConjugation &con) // extend conjugation with empty elements if (d->m_conjugations.size() <= idx ) for (int i = d->m_conjugations.size(); i < idx+1; i++) - d->m_conjugations.push_back (KEduVocConjugation()); + d->m_conjugations.append (KEduVocConjugation()); d->m_conjugations[idx] = con; } @@ -755,7 +762,7 @@ void KEduVocDocument::setArticle(int idx, const KEduVocArticle &art) // extend conjugation with empty elements if (d->m_articles.size() <= idx ) for (int i = d->m_articles.size(); i < idx+1; i++) - d->m_articles.push_back (KEduVocArticle()); + d->m_articles.append (KEduVocArticle()); d->m_articles[idx] = art; } @@ -807,7 +814,7 @@ void KEduVocDocument::setSizeHint (int idx, const int width) idx = -idx; if (idx >= d->m_extraSizeHints.size()) { for (int i = d->m_extraSizeHints.size(); i <= idx; i++) - d->m_extraSizeHints.push_back (80); + d->m_extraSizeHints.append (80); } d->m_extraSizeHints[idx] = width; @@ -815,7 +822,7 @@ void KEduVocDocument::setSizeHint (int idx, const int width) else { if (idx >= d->m_sizeHints.size()) { for (int i = d->m_sizeHints.size(); i <= idx; i++) - d->m_sizeHints.push_back (150); + d->m_sizeHints.append (150); } d->m_sizeHints[idx] = width; } @@ -938,16 +945,8 @@ void KEduVocDocument::resetEntry(int index, int lesson) for (int i = 0; i < d->m_vocabulary.count(); i++) if (/*lesson == 0 ||*/ lesson == d->m_vocabulary[i].lesson()) { - d->m_vocabulary[i].setGrade(index, KV_NORM_GRADE, false); - d->m_vocabulary[i].setGrade(index, KV_NORM_GRADE, true); - d->m_vocabulary[i].setQueryCount(index, 0, true); - d->m_vocabulary[i].setQueryCount(index, 0, false); - d->m_vocabulary[i].setBadCount(index, 0, true); - d->m_vocabulary[i].setBadCount(index, 0, false); - QDateTime dt; - dt.setTime_t(0); - d->m_vocabulary[i].setQueryDate(index, dt, true); - d->m_vocabulary[i].setQueryDate(index, dt, false); + // index is the translation number whose grades are reset + d->m_vocabulary[i].resetGrades(index); } } @@ -1238,29 +1237,17 @@ int KEduVocDocument::search(const QString &substr, int id, int first, int last, if (id >= identifierCount() || last < first) return -1; - if (id == 0) { - for (int i = first; i < last; i++) { - if (word_start) { - if (entry(i)->original().indexOf(substr, 0, Qt::CaseInsensitive) == 0) // case insensitive - return i; - } - else { - if (entry(i)->original().indexOf(substr, 0, Qt::CaseInsensitive) > -1) // case insensitive - return i; - } - } - } - else { + for (int i = first; i < last; i++) { if (word_start) { - if (entry(i)->translation(id).indexOf(substr, 0, Qt::CaseInsensitive) == 0) // case insensitive + if (entry(i)->translation(id).translation().indexOf(substr, 0, Qt::CaseInsensitive) == 0) // case insensitive return i; } else { - if (entry(i)->translation(id).indexOf(substr, 0, Qt::CaseInsensitive) > -1) // case insensitive + if (entry(i)->translation(id).translation().indexOf(substr, 0, Qt::CaseInsensitive) > -1) // case insensitive return i; } - } + } return -1; } @@ -1290,16 +1277,13 @@ public: bool operator< (const ExpRef& y) const { - QString s1 = exp->original(); - QString s2 = y.exp->original(); - int cmp = QString::compare(s1.toUpper(), s2.toUpper()); - if (cmp != 0) - return cmp < 0; - - for (int i = 1; i < exp->translationCount(); i++) { + QString s1; + QString s2; + int cmp; + for (int i = 0; i < exp->translationCount(); i++) { - s1 = exp->translation(i); - s2 = y.exp->translation(i); + s1 = exp->translation(i).translation(); + s2 = y.exp->translation(i).translation(); cmp = QString::compare(s1.toUpper(), s2.toUpper() ); if (cmp != 0) return cmp < 0; @@ -1338,15 +1322,15 @@ int KEduVocDocument::cleanUp() emit progressChanged(this, (int)((ent_no / f_ent_percent) / 2.0)); bool equal = true; - if (kve1->original() == kve2->original() ) { - for (int l = 1; equal && l < identifierCount(); l++ ) - if (kve1->translation(l) != kve2->translation(l)) - equal = false; + for (int l = 0; equal && l < identifierCount(); l++ ) { + if (kve1->translation(l).translation() != kve2->translation(l).translation()) { + equal = false; + } + } - if (equal) { + if (equal) { to_delete.append(shadow[i - 1].idx); count++; - } } } diff --git a/kdeeducore/keduvocexpression.cpp b/kdeeducore/keduvocexpression.cpp index c3153f5..31c8b80 100644 --- a/kdeeducore/keduvocexpression.cpp +++ b/kdeeducore/keduvocexpression.cpp @@ -37,17 +37,19 @@ public: // QString m_original; // all these vectors must be deleted in removeTranslation() - QStringList m_expressionTypes; +// QStringList m_expressionTypes; // QStringList m_translations; - QStringList m_remarks; - QStringList m_usageLabels; - QStringList m_paraphrases; - QStringList m_fauxAmi; - QStringList m_reverseFauxAmi; - QStringList m_synonym; - QStringList m_example; - QStringList m_antonym; - QStringList m_pronunciations; +// QStringList m_remarks; +// QStringList m_usageLabels; +// QStringList m_paraphrases; +// QStringList m_fauxAmi; +// QStringList m_reverseFauxAmi; +// QStringList m_synonym; +// QStringList m_example; +// QStringList m_antonym; +// QStringList m_pronunciations; + +/* QList m_grades; QList m_reverseGrades; QList m_queryCounts; @@ -59,6 +61,7 @@ public: QList m_conjugations; QList m_comparisons; QList m_multipleChoices; +*/ QString m_leitnerBox; int m_sortIndex; @@ -74,17 +77,17 @@ void KEduVocExpression::KEduVocExpressionPrivate::init() { m_translations.clear(); - m_grades.append(KV_NORM_GRADE); - m_reverseGrades.append(KV_NORM_GRADE); +// m_grades.append(KV_NORM_GRADE); +// m_reverseGrades.append(KV_NORM_GRADE); m_inQuery = false; m_active = true; - m_queryCounts.append(0); - m_reverseQueryCounts.append(0); - m_badCounts.append(0); - m_reverseBadCounts.append(0); - QDateTime dt; - m_queryDates.append(dt); - m_reverseQueryDates.append(dt); +// m_queryCounts.append(0); +// m_reverseQueryCounts.append(0); +// m_badCounts.append(0); +// m_reverseBadCounts.append(0); +// QDateTime dt; +// m_queryDates.append(dt); +// m_reverseQueryDates.append(dt); m_lesson = 0; m_sortIndex = 0; } @@ -94,27 +97,27 @@ bool KEduVocExpression::KEduVocExpressionPrivate::operator==(const KEduVocExpres { return m_translations == p.m_translations && - m_expressionTypes == p.m_expressionTypes && - m_remarks == p.m_remarks && - m_usageLabels == p.m_usageLabels && - m_paraphrases == p.m_paraphrases && - m_fauxAmi == p.m_fauxAmi && - m_reverseFauxAmi == p.m_reverseFauxAmi && - m_synonym == p.m_synonym && - m_example == p.m_example && - m_antonym == p.m_antonym && - m_pronunciations == p.m_pronunciations && - m_grades == p.m_grades && - m_reverseGrades == p.m_reverseGrades && - m_queryCounts == p.m_queryCounts && - m_reverseQueryCounts == p.m_reverseQueryCounts && - m_badCounts == p.m_badCounts && - m_reverseBadCounts == p.m_reverseBadCounts && - m_queryDates == p.m_queryDates && - m_reverseQueryDates == p.m_reverseQueryDates && - m_conjugations == p.m_conjugations && - m_comparisons == p.m_comparisons && - m_multipleChoices == p.m_multipleChoices && +// m_expressionTypes == p.m_expressionTypes && +// m_remarks == p.m_remarks && +// m_usageLabels == p.m_usageLabels && +// m_paraphrases == p.m_paraphrases && +// m_fauxAmi == p.m_fauxAmi && +// m_reverseFauxAmi == p.m_reverseFauxAmi && +// m_synonym == p.m_synonym && +// m_example == p.m_example && +// m_antonym == p.m_antonym && +// m_pronunciations == p.m_pronunciations && +// m_grades == p.m_grades && +// m_reverseGrades == p.m_reverseGrades && +// m_queryCounts == p.m_queryCounts && +// m_reverseQueryCounts == p.m_reverseQueryCounts && +// m_badCounts == p.m_badCounts && +// m_reverseBadCounts == p.m_reverseBadCounts && +// m_queryDates == p.m_queryDates && +// m_reverseQueryDates == p.m_reverseQueryDates && +// m_conjugations == p.m_conjugations && +// m_comparisons == p.m_comparisons && +// m_multipleChoices == p.m_multipleChoices && m_leitnerBox == p.m_leitnerBox && m_lesson == p.m_lesson && m_sortIndex == p.m_sortIndex && @@ -149,17 +152,20 @@ KEduVocExpression::KEduVocExpression(const QString & expression, const QString & setTranslation(0, expr.simplified()); ///@todo: no special original treatment } else {*/ + int translationIndex = 0; se = expr.left(pos).simplified(); - setOriginal(se); + setTranslation(translationIndex, se); expr.remove(0, pos + separator.length()); // gather all translations while ((pos = expr.indexOf(separator)) != -1) { + translationIndex++; se = expr.left(pos).simplified(); - addTranslation(se, KV_NORM_GRADE, KV_NORM_GRADE); + setTranslation(translationIndex, se); expr.remove(0, pos + separator.length()); } - addTranslation(expr.simplified(), KV_NORM_GRADE, KV_NORM_GRADE); + translationIndex++; + setTranslation(translationIndex, expr.simplified()); //} } } @@ -182,10 +188,10 @@ int KEduVocExpression::translationCount() const /// @todo: maybe this should go away? it is very rare with QMap // the minus 1 is because traditionally it used to be original + translations /// @todo get rid of the minus one. but for now this implies too many other changes. - return d->m_translations.size() - 1; + return d->m_translations.size(); } - +/* QString KEduVocExpression::remark(int index) const { if (index >= d->m_remarks.count() || index < 0) { @@ -376,8 +382,9 @@ QString KEduVocExpression::antonym(int index) const return d->m_antonym[index]; } } +*/ - +/* void KEduVocExpression::setConjugation(int index, const KEduVocConjugation &con) { if (index < 0) @@ -475,8 +482,9 @@ void KEduVocExpression::setPronunciation(int index, const QString & expr) d->m_pronunciations[index] = expr.simplified(); } +*/ - +/* void KEduVocExpression::addTranslation(const QString & expr, grade_t grade, grade_t rev_grade) { if (d->m_translations.count() > 0) { // we only keep grades for translation 1..n - later this will change, as all combinations are allowed, so only from grades are saved relative to the other languages. As soon as grades are only from grades and moved into the translation class this will become nice and free of sorrows. @@ -496,8 +504,9 @@ void KEduVocExpression::addTranslation(const QString & expr, grade_t grade, grad d->m_translations[d->m_translations.keys()[d->m_translations.keys().count()-1] + 1] = KEduVocTranslation( expr.simplified() ); } +*/ - +/* QString KEduVocExpression::translation(int index) const { if ( !d->m_translations.contains(index) ) { @@ -505,7 +514,7 @@ QString KEduVocExpression::translation(int index) const } return d->m_translations.value(index).translation(); } - +*/ void KEduVocExpression::removeTranslation(int index) { @@ -607,7 +616,7 @@ void KEduVocExpression::setTranslation(int index, const QString & expr) d->m_translations[index] = expr.simplified(); } - +/* grade_t KEduVocExpression::grade(int index, bool rev_grade) const { if (rev_grade) { @@ -857,19 +866,20 @@ void KEduVocExpression::setQueryDate(int index, const QDateTime & date, bool rev d->m_queryDates[index] = date; } } - +*/ bool KEduVocExpression::uniqueType() const { +/// @todo use .keys() instead of translationCount()! bool unique = true; - QString type0 = type(0); + QString type0 = d->m_translations[0].type(); for (int i = 1; i < translationCount(); i++) - if (type0 != type(i)) + if (type0 != d->m_translations[i].type()) unique = false; return unique; } - +/* QString KEduVocExpression::type(int index) const { if (index >= d->m_expressionTypes.count() || index < 0) { @@ -893,7 +903,7 @@ void KEduVocExpression::setType(int index, const QString &type) d->m_expressionTypes[index] = type.simplified(); } - +*/ int KEduVocExpression::lesson() const { @@ -906,7 +916,7 @@ void KEduVocExpression::setLesson(int l) d->m_lesson = l; } - +/* void KEduVocExpression::incQueryCount(int index, bool rev_count) { setQueryCount(index, queryCount(index, rev_count) + 1, rev_count); @@ -932,15 +942,16 @@ void KEduVocExpression::setOriginal(const QString & expr) } else { d->m_translations[0] = KEduVocTranslation(expr); } - +*/ /* if (d->m_translations.count() == 0) { d->m_translations.append(expr); } else { d->m_translations[0] = expr; }*/ +/* } - +*/ QString KEduVocExpression::leitnerBox() { @@ -978,6 +989,22 @@ void KEduVocExpression::setActive(bool flag) } +void KEduVocExpression::resetGrades(int index) +{ + if ( index == -1 ) { // clear grades for all languages + foreach (KEduVocTranslation trans, d->m_translations) { + trans.resetGrades(); + } + return; + } + + // only language index + if ( d->m_translations.contains(index) ) { + d->m_translations[index].resetGrades(); + } +} + + KEduVocExpression& KEduVocExpression::operator=(const KEduVocExpression &expression) { *d = *expression.d; @@ -990,3 +1017,8 @@ bool KEduVocExpression::operator==(const KEduVocExpression &expression) const return (*d == *expression.d); } +KEduVocTranslation & KEduVocExpression::translation(int index) const +{ + return d->m_translations[index]; +} + diff --git a/kdeeducore/keduvocexpression.h b/kdeeducore/keduvocexpression.h index 96987c2..d262616 100644 --- a/kdeeducore/keduvocexpression.h +++ b/kdeeducore/keduvocexpression.h @@ -20,34 +20,6 @@ #include "libkdeedu_core_export.h" -#define KV_MAX_GRADE 7 -#define KV_MIN_GRADE 0 - -#define KV_NORM_GRADE 0 // not queried yet -#define KV_NORM_COLOR Qt::black -#define KV_NORM_TEXT I18N_NOOP("Not Queried Yet") - -#define KV_LEV1_GRADE 1 -#define KV_LEV1_TEXT I18N_NOOP("Level 1") - -#define KV_LEV2_GRADE 2 -#define KV_LEV2_TEXT I18N_NOOP("Level 2") - -#define KV_LEV3_GRADE 3 -#define KV_LEV3_TEXT I18N_NOOP("Level 3") - -#define KV_LEV4_GRADE 4 -#define KV_LEV4_TEXT I18N_NOOP("Level 4") - -#define KV_LEV5_GRADE 5 -#define KV_LEV5_TEXT I18N_NOOP("Level 5") - -#define KV_LEV6_GRADE 6 -#define KV_LEV6_TEXT I18N_NOOP("Level 6") - -#define KV_LEV7_GRADE 7 -#define KV_LEV7_TEXT I18N_NOOP("Level 7") - #include #include "keduvocgrammar.h" @@ -85,19 +57,21 @@ public: ~KEduVocExpression(); - /** adds a new translation of this entry - * @param expression translation - * @param grade grade of knowledge of this translation - * @param reverseGrade dito, in opposite direction - */ - void addTranslation(const QString & expression, grade_t grade = KV_NORM_GRADE, grade_t reverseGrade = KV_NORM_GRADE); - - /** removes translation - * - * @param index number of translation 1..x - */ - void removeTranslation(int index); - +// *********** +// +// /** adds a new translation of this entry +// * @param expression translation +// * @param grade grade of knowledge of this translation +// * @param reverseGrade dito, in opposite direction +// */ +// void addTranslation(const QString & expression, grade_t grade = KV_NORM_GRADE, grade_t reverseGrade = KV_NORM_GRADE); +// +// /** removes translation +// * +// * @param index number of translation 1..x +// */ +// void removeTranslation(int index); +// /** returns index of lesson (0 = none) */ int lesson() const; @@ -105,18 +79,182 @@ public: /** sets index of lesson (0 = none) */ void setLesson(int l); +// +// /** returns original expression of this entry +// */ +// QString original() const; +// +// /** sets original expression of this entry +// */ +// void setOriginal(const QString & expression); +// +// /** returns number of max. translations of all expressions +// */ +// int translationCount() const; - /** returns original expression of this entry - */ - QString original() const; - /** sets original expression of this entry - */ - void setOriginal(const QString & expression); + /** reset all grades of the entry + * @param index identifier (language) + */ + void resetGrades(int index); - /** returns number of max. translations of all expressions + + + + /** all langs have same type ? + * + * @return true if all have same type */ - int translationCount() const; + bool uniqueType () const; +// +// /** sets type of this expression +// * +// * @param index index of type +// * @param type type of this expression ("" = none) +// */ +// void setType(int index, const QString & type); +// +// /** sets grade of given translation +// * +// * @param index index of translation +// * @param grade number of knowlegde: 0=known, x=numbers not knows +// * @param reverse if true, represents the direction translation to original +// */ +// void setGrade(int index, grade_t grade, bool reverse = false); +// +// /** returns grade of given translation as int +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// * @return number of knowlegde: 0=known, x=numbers not knows +// */ +// grade_t grade(int index, bool reverse = false) const; +// +// /** increments grade of given translation +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// void incGrade(int index, bool reverse = false); +// +// /** decrements grade of given translation +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// void decGrade(int index, bool reverse = false); +// +// /** returns last query date of given translation as int +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// QDateTime queryDate(int index, bool reverse = false) const; +// +// /** set last query date of given translation as int +// * +// * @param index index of translation +// * @param date the new date +// * @param reverse if true, represents the direction translation to original +// */ +// void setQueryDate(int index, const QDateTime & date, bool reverse = false); +// +// /** returns conjugations if available +// * +// * @param index index of translation +// */ +// KEduVocConjugation conjugation(int index) const; +// +// /** sets conjugations +// * +// * @param index index of translation +// * @param conjugation conjugation block +// */ +// void setConjugation(int index, const KEduVocConjugation & conjugation); +// +// /** returns comparison if available +// * +// * @param index index of translation +// */ +// KEduVocComparison comparison(int index) const; +// +// /** sets comparison +// * +// * @param index index of translation +// * @param comparison comparison block +// */ +// void setComparison(int index, const KEduVocComparison & comparison); +// +// /** returns multiple choice if available +// * +// * @param index index of multiple choice +// */ +// KEduVocMultipleChoice multipleChoice(int index) const; +// +// /** sets multiple choice +// * +// * @param index index of translation +// * @param mc multiple choice block +// */ +// void setMultipleChoice(int index, const KEduVocMultipleChoice & mc); +// +// /** returns query count of given translation as int +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// count_t queryCount(int index, bool reverse = false) const; +// +// /** set query count of given translation as int +// * +// * @param index index of translation +// * @param count the new count +// * @param reverse if true, represents the direction translation to original +// */ +// void setQueryCount(int index, count_t count, bool reverse = false); +// +// /** returns bad query count of given translation as int +// * +// * @param index index of translation +// * @param reverse dito, in opposite direction +// */ +// count_t badCount(int index, bool reverse = false) const; +// +// /** set bad query count of given translation as int +// * +// * @param index index of translation +// * @param count the new count +// * @param reverse if true, represents the direction translation to original +// */ +// void setBadCount(int index, count_t count, bool reverse = false); +// +// /** increment bad query count of given translation by 1 +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// void incBadCount(int index, bool reverse = false); +// +// /** increment query count of given translation by 1 +// * +// * @param index index of translation +// * @param reverse if true, represents the direction translation to original +// */ +// void incQueryCount(int index, bool reverse = false); +// +// /** sets the box of the Leitner system which actually contains the expression +// * +// * @param box the box's name +// */ +// void setLeitnerBox(const QString & box); +// +// /** returns the name of the Leitner system's box actually containing the expression +// * +// * @return the box's name +// */ +// QString leitnerBox(); +// ************** + /** returns flag if entry is "selected" for queries */ @@ -134,280 +272,54 @@ public: */ void setActive(bool flag = true); - /** returns translation of this expression - * - * @param index number of translation - * @return expression or "" if no translation available - */ - QString translation(int index) const; - - /** sets translation of this expression - * - * @param index number of translation - * @param expression expression of this index - */ - void setTranslation(int index, const QString & expression); - - /** sets pronunciation of this expression - * - * @param index index of expression - * @param expression pronunciation of this index - */ - void setPronunciation(int index, const QString & expression); - - /** returns pronunciation of this expression - * - * @param index index of expression - * @return pronunciation or "" if none available - */ - QString pronunciation(int index) const; - - /** returns remarks of this expression - * - * @param index index of expression - * @return remark or "" if no remark available - */ - QString remark(int index) const; - - /** sets remark of this expression - * - * @param index index of expression - * @param expr remark of this index - */ - void setRemark(int index, const QString & expr); - - /** sets false friend of this expression - * - * @param index index of expression - * @param expression false friend of this index - * @param reverse if true, represents the direction translation to original - */ - void setFauxAmi(int index, const QString & expression, bool reverse = false); - - /** returns false friend of this expression - * - * @param index index of expression - * @param reverse if true, represents the direction translation to original - * @return false friend or "" if no string available - */ - QString fauxAmi(int index, bool reverse = false) const; - - /** sets synonym this expression - * - * @param index index of expression - * @param expression synonym of this index - */ - void setSynonym(int index, const QString & expression); - - /** returns synonym of this expression - * - * @param index index of expression - * @return synonym or "" if no string available - */ - QString synonym(int index) const; - - /** sets example this expression - * - * @param index index of expression - * @param expression example of this index - */ - void setExample(int index, const QString & expression); - - /** returns example of this expression - * - * @param index index of expression - * @return example or "" if no string available - */ - QString example(int index) const; - - /** sets usage label this expression - * - * @param index index of expression - * @param usage usage label of this index - */ - void setUsageLabel(int index, const QString & usage); - - /** returns usage label of this expression - * - * @param index index of expression - * @return usage or "" if no string available - */ - QString usageLabel(int index) const; - - /** sets paraphrase of this expression - * - * @param index index of expression - * @param expression paraphrase of this index - */ - void setParaphrase(int index, const QString & expression); - - /** returns paraphrase of this expression - * - * @param index index of expression - * @return paraphrase or "" if no string available - */ - QString paraphrase(int index) const; - - /** sets antonym this expression - * - * @param index index of expression - * @param expression antonym of this index - */ - void setAntonym(int index, const QString & expression); - - /** returns antonym of this expression - * - * @param index index of expression - * @return antonym or "" if no string available - */ - QString antonym(int index) const; - - /** returns type of this expression - * - * @return type or "" if no type available - */ - QString type(int index) const; - - /** all langs have same type ? - * - * @return true if all have same type - */ - bool uniqueType () const; + int sizeHint() const; + void setSizeHint(int sizeHint); - /** sets type of this expression + /** returns this translation * - * @param index index of type - * @param type type of this expression ("" = none) - */ - void setType(int index, const QString & type); - - /** sets grade of given translation - * - * @param index index of translation - * @param grade number of knowlegde: 0=known, x=numbers not knows - * @param reverse if true, represents the direction translation to original - */ - void setGrade(int index, grade_t grade, bool reverse = false); - - /** returns grade of given translation as int - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original - * @return number of knowlegde: 0=known, x=numbers not knows - */ - grade_t grade(int index, bool reverse = false) const; - - /** increments grade of given translation - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original - */ - void incGrade(int index, bool reverse = false); - - /** decrements grade of given translation - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original + * @return expression or "" if no translation available */ - void decGrade(int index, bool reverse = false); + QString translationString(int index) const; - /** returns last query date of given translation as int - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original - */ - QDateTime queryDate(int index, bool reverse = false) const; +// bad +// QMap allTranslations() const; - /** set last query date of given translation as int - * - * @param index index of translation - * @param date the new date - * @param reverse if true, represents the direction translation to original - */ - void setQueryDate(int index, const QDateTime & date, bool reverse = false); - /** returns conjugations if available - * - * @param index index of translation + void setTranslation(int index, const KEduVocTranslation & translation); + /** + * Add a translation to this expression + * @param index number of translation = the identifier + * @param expression the translation */ - KEduVocConjugation conjugation(int index) const; + void setTranslation(int index, const QString &expression); - /** sets conjugations - * - * @param index index of translation - * @param conjugation conjugation block - */ - void setConjugation(int index, const KEduVocConjugation & conjugation); + void setTranslation(const QString &identifier, const QString & expression); - /** returns comparison if available - * - * @param index index of translation - */ - KEduVocComparison comparison(int index) const; - /** sets comparison - * - * @param index index of translation - * @param comparison comparison block - */ - void setComparison(int index, const KEduVocComparison & comparison); - /** returns multiple choice if available + /** removes a translation * - * @param index index of multiple choice + * @param index number of translation 1..x */ - KEduVocMultipleChoice multipleChoice(int index) const; + void removeTranslation(int index); - /** sets multiple choice - * - * @param index index of translation - * @param mc multiple choice block - */ - void setMultipleChoice(int index, const KEduVocMultipleChoice & mc); - /** returns query count of given translation as int - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original + /** returns number of max. translations of all expressions + @todo kill this - will be wrong. We now should have a Identifiers class to handle this kind of stuff */ - count_t queryCount(int index, bool reverse = false) const; + int translationCount() const; - /** set query count of given translation as int - * - * @param index index of translation - * @param count the new count - * @param reverse if true, represents the direction translation to original - */ - void setQueryCount(int index, count_t count, bool reverse = false); - /** returns bad query count of given translation as int - * - * @param index index of translation - * @param reverse dito, in opposite direction - */ - count_t badCount(int index, bool reverse = false) const; + /** + * Get a mutable reference to the translation + * @param index of the language identifier + * @return the translation + */ + KEduVocTranslation & translation (int index) const; - /** set bad query count of given translation as int - * - * @param index index of translation - * @param count the new count - * @param reverse if true, represents the direction translation to original - */ - void setBadCount(int index, count_t count, bool reverse = false); + QList translationIndices ( ) const; - /** increment bad query count of given translation by 1 - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original - */ - void incBadCount(int index, bool reverse = false); - /** increment query count of given translation by 1 - * - * @param index index of translation - * @param reverse if true, represents the direction translation to original - */ - void incQueryCount(int index, bool reverse = false); /** sets the box of the Leitner system which actually contains the expression * @@ -421,8 +333,8 @@ public: */ QString leitnerBox(); - KEduVocExpression& operator=(const KEduVocExpression &expression); + KEduVocExpression& operator=(const KEduVocExpression &expression); bool operator==(const KEduVocExpression &expression) const; private: diff --git a/kdeeducore/keduvocgrade.cpp b/kdeeducore/keduvocgrade.cpp index 43184ef..a1961f8 100644 --- a/kdeeducore/keduvocgrade.cpp +++ b/kdeeducore/keduvocgrade.cpp @@ -19,3 +19,8 @@ // { // } // + +void KEduVocGrade::resetGrades() +{ + +} diff --git a/kdeeducore/keduvocgrade.h b/kdeeducore/keduvocgrade.h index 0c96afa..8fa2fcd 100644 --- a/kdeeducore/keduvocgrade.h +++ b/kdeeducore/keduvocgrade.h @@ -16,6 +16,8 @@ #ifndef KEDUVOCGRADE_H #define KEDUVOCGRADE_H +#include + typedef signed char grade_t; typedef unsigned short count_t; @@ -26,12 +28,17 @@ Contains grading information (query date, bad count) for one language with respe */ class KEduVocGrade { +public: + void resetGrades(); + /// @todo make these private and write the according functions like updateQueryDate, increaseGrade, decreaseGrade etc. public: grade_t m_grade; count_t m_queryCount; count_t m_badCount; QDateTime m_queryDate; + + }; #endif diff --git a/kdeeducore/keduvockvtmlreader.cpp b/kdeeducore/keduvockvtmlreader.cpp index 05e56d0..32916a1 100644 --- a/kdeeducore/keduvockvtmlreader.cpp +++ b/kdeeducore/keduvockvtmlreader.cpp @@ -571,7 +571,7 @@ bool KEduVocKvtmlReader::readConjug(QDomElement &domElementParent, QList (int) curr_conjug.size() ) - curr_conjug.push_back(KEduVocConjugation()); + curr_conjug.append(KEduVocConjugation()); curr_conjug[count].setPers3SingularCommon(type, s3_common); curr_conjug[count].setPers3PluralCommon(type, p3_common); @@ -1131,7 +1131,7 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) if (i == 0) { currentElement = domElementParent.firstChildElement(KV_ORG); - } + } else { currentElement = translationList.item(i - 1).toElement(); @@ -1187,7 +1187,7 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) else { if (lang != m_doc->identifier(i) && !lang.isEmpty()) - { + { // different language ? m_errorMessage = i18n("ambiguous definition of language code"); return false; @@ -1231,50 +1231,48 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) } else { - expr.addTranslation(textstr, grade, r_grade); - expr.setQueryCount(i, qcount, false); - expr.setQueryCount(i, r_qcount, true); - expr.setBadCount(i, bcount, false); - expr.setBadCount(i, r_bcount, true); - expr.setQueryDate(i, qdate, false); - expr.setQueryDate(i, r_qdate, true); + expr.setTranslation(i, textstr); } if (conjug.size() > 0) { - expr.setConjugation(i, conjug[0]); + for ( int conjugationIndex = 0; conjugationIndex < conjug.size(); conjugationIndex++ ) { + expr.translation(i).setConjugation(conjug[conjugationIndex]); + } + + //expr.setConjugation(i, conjug[0]); ///@todo check if this is better than the above! conjug.clear(); } if (!comparison.isEmpty()) { - expr.setComparison(i, comparison); + expr.translation(i).setComparison(comparison); comparison.clear(); } if (!mc.isEmpty()) { - expr.setMultipleChoice(i, mc); + expr.translation(i).setMultipleChoice(mc); mc.clear(); } if (!type.isEmpty() ) - expr.setType (i, type); + expr.translation(i).setType (type); if (!remark.isEmpty() ) - expr.setRemark (i, remark); + expr.translation(i).setComment (remark); if (!pronunciation.isEmpty() ) - expr.setPronunciation(i, pronunciation); + expr.translation(i).setPronunciation(pronunciation); if (!faux_ami_f.isEmpty() ) - expr.setFauxAmi (i, faux_ami_f, false); + expr.translation(i).setFalseFriend (0, faux_ami_f); if (!faux_ami_t.isEmpty() ) - expr.setFauxAmi (i, faux_ami_t, true); + expr.translation(0).setFalseFriend (i, faux_ami_t); if (!synonym.isEmpty() ) - expr.setSynonym (i, synonym); + expr.translation(i).setSynonym (synonym); if (!example.isEmpty() ) - expr.setExample (i, example); + expr.translation(i).setExample (example); if (!usage.isEmpty() ) - expr.setUsageLabel (i, usage); + expr.translation(i).setUsageLabel (usage); if (!paraphrase.isEmpty() ) - expr.setParaphrase (i, paraphrase); + expr.translation(i).setParaphrase (paraphrase); if (!antonym.isEmpty() ) - expr.setAntonym (i, antonym); + expr.translation(i).setAntonym (antonym); } if (m_doc->entryCount() == 0) diff --git a/kdeeducore/keduvockvtmlwriter.cpp b/kdeeducore/keduvockvtmlwriter.cpp index 2f45e1a..637be68 100644 --- a/kdeeducore/keduvockvtmlwriter.cpp +++ b/kdeeducore/keduvockvtmlwriter.cpp @@ -116,8 +116,8 @@ bool KEduVocKvtmlWriter::writeDoc(KEduVocDocument *doc, const QString &generator if (!entry->isActive()) domElementExpression.setAttribute (KV_INACTIVE, 1); - if (entry->uniqueType() && !entry->type(0).isEmpty()) - domElementExpression.setAttribute (KV_EXPRTYPE, entry->type(0)); + if (entry->uniqueType() && !entry->translation(0).type().isEmpty()) + domElementExpression.setAttribute (KV_EXPRTYPE, entry->translation(0).type()); QDomElement domElementOriginal = domDoc.createElement(KV_ORG); if (first_expr) @@ -136,55 +136,55 @@ bool KEduVocKvtmlWriter::writeDoc(KEduVocDocument *doc, const QString &generator domElementOriginal.setAttribute(KV_QUERY, (QString) KV_T); } - if (!entry->remark(0).isEmpty() ) - domElementOriginal.setAttribute(KV_REMARK, entry->remark(0)); + if (!entry->translation(0).comment().isEmpty() ) + domElementOriginal.setAttribute(KV_REMARK, entry->translation(0).comment()); - if (!entry->synonym(0).isEmpty() ) - domElementOriginal.setAttribute(KV_SYNONYM, entry->synonym(0)); + if (!entry->translation(0).synonym().isEmpty() ) + domElementOriginal.setAttribute(KV_SYNONYM, entry->translation(0).synonym()); - if (!entry->example(0).isEmpty() ) - domElementOriginal.setAttribute(KV_EXAMPLE, entry->example(0)); + if (!entry->translation(0).example().isEmpty() ) + domElementOriginal.setAttribute(KV_EXAMPLE, entry->translation(0).example()); - if (!entry->usageLabel(0).isEmpty() ) - domElementOriginal.setAttribute(KV_USAGE, entry->usageLabel(0)); + if (!entry->translation(0).usageLabel().isEmpty() ) + domElementOriginal.setAttribute(KV_USAGE, entry->translation(0).usageLabel()); - if (!entry->paraphrase(0).isEmpty() ) - domElementOriginal.setAttribute(KV_PARAPHRASE, entry->paraphrase(0)); + if (!entry->translation(0).paraphrase().isEmpty() ) + domElementOriginal.setAttribute(KV_PARAPHRASE, entry->translation(0).paraphrase()); - if (!entry->antonym(0).isEmpty() ) - domElementOriginal.setAttribute(KV_ANTONYM, entry->antonym(0)); + if (!entry->translation(0).antonym().isEmpty() ) + domElementOriginal.setAttribute(KV_ANTONYM, entry->translation(0).antonym()); - if (!entry->pronunciation(0).isEmpty() ) - domElementOriginal.setAttribute(KV_PRONUNCE, entry->pronunciation(0)); + if (!entry->translation(0).pronunciation().isEmpty() ) + domElementOriginal.setAttribute(KV_PRONUNCE, entry->translation(0).pronunciation()); - if (!entry->uniqueType() && !entry->type(0).isEmpty()) - domElementOriginal.setAttribute(KV_EXPRTYPE, entry->type(0)); + if (!entry->uniqueType() && !entry->translation(0).type().isEmpty()) + domElementOriginal.setAttribute(KV_EXPRTYPE, entry->translation(0).type()); - if (!writeMultipleChoice(domDoc, domElementOriginal, entry->multipleChoice(0))) + if (!writeMultipleChoice(domDoc, domElementOriginal, entry->translation(0).multipleChoice())) return false; QString s; - QString entype = s = entry->type(0); + QString entype = s = entry->translation(0).type(); int pos = s.indexOf(QM_TYPE_DIV); if (pos >= 0) entype = s.left(pos); else entype = s; - if (entype == QM_VERB && entry->conjugation(0).entryCount() > 0) + if (entype == QM_VERB && entry->translation(0).conjugation().entryCount() > 0) { - KEduVocConjugation conj = entry->conjugation(0); + KEduVocConjugation conj = entry->translation(0).conjugation(); if (!writeConjugEntry(domDoc, domElementOriginal, conj)) return false; } - else if (entype == QM_ADJ && !entry->comparison(0).isEmpty()) + else if (entype == QM_ADJ && !entry->translation(0).comparison().isEmpty()) { - KEduVocComparison comp = entry->comparison(0); + KEduVocComparison comp = entry->translation(0).comparison(); if (!writeComparison(domDoc, domElementOriginal, comp)) return false; } - QDomText domTextOriginal = domDoc.createTextNode(entry->translation(0)); + QDomText domTextOriginal = domDoc.createTextNode(entry->translation(0).translation()); domElementOriginal.appendChild(domTextOriginal); domElementExpression.appendChild(domElementOriginal); @@ -211,74 +211,74 @@ bool KEduVocKvtmlWriter::writeDoc(KEduVocDocument *doc, const QString &generator domElementTranslation.setAttribute(KV_QUERY, (QString) KV_T); } - if (entry->grade(trans, false) != 0 || entry->grade(trans, true) != 0) - domElementTranslation.setAttribute(KV_GRADE, QString::number(entry->grade(trans, false)) + ';' + QString::number(entry->grade(trans, true))); + if (entry->translation(trans).grade(0) != 0 || entry->translation(0).grade(trans) != 0) + domElementTranslation.setAttribute(KV_GRADE, QString::number(entry->translation(trans).grade(0)) + ';' + QString::number(entry->translation(0).grade(trans))); - if (entry->queryCount(trans, false) != 0 || entry->queryCount(trans, true) != 0) - domElementTranslation.setAttribute(KV_COUNT, QString::number(entry->queryCount(trans, false)) + ';' + QString::number(entry->queryCount(trans, true))); + if (entry->translation(trans).queryCount(0) != 0 || entry->translation(0).queryCount(trans) != 0) + domElementTranslation.setAttribute(KV_COUNT, QString::number(entry->translation(trans).queryCount(0)) + ';' + QString::number(entry->translation(0).queryCount(trans))); - if (entry->badCount(trans, false) != 0 || entry->badCount(trans, true) != 0) - domElementTranslation.setAttribute(KV_BAD, QString::number(entry->badCount(trans, false)) + ';' + QString::number(entry->badCount(trans, true))); + if (entry->translation(trans).badCount(0) != 0 || entry->translation(0).badCount(trans) != 0) + domElementTranslation.setAttribute(KV_BAD, QString::number(entry->translation(trans).badCount(0)) + ';' + QString::number(entry->translation(0).badCount(trans))); - if (entry->queryDate(trans, false).toTime_t() != 0 || entry->queryDate(trans, true).toTime_t() != 0) - domElementTranslation.setAttribute(KV_DATE, QString::number(entry->queryDate(trans, false).toTime_t()) + ';' + QString::number(entry->queryDate(trans, true).toTime_t())); + if (entry->translation(trans).queryDate(0).toTime_t() != 0 || entry->translation(0).queryDate(trans).toTime_t() != 0) + domElementTranslation.setAttribute(KV_DATE, QString::number(entry->translation(trans).queryDate(0).toTime_t()) + ';' + QString::number(entry->translation(0).queryDate(trans).toTime_t())); - if (!entry->remark(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_REMARK, entry->remark(trans)); + if (!entry->translation(trans).comment().isEmpty() ) + domElementTranslation.setAttribute(KV_REMARK, entry->translation(trans).comment()); - if (!entry->fauxAmi(trans, false).isEmpty() ) - domElementTranslation.setAttribute(KV_FAUX_AMI_F, entry->fauxAmi(trans, false)); + if (!entry->translation(trans).falseFriend(0).isEmpty() ) + domElementTranslation.setAttribute(KV_FAUX_AMI_F, entry->translation(trans).falseFriend(0)); - if (!entry->fauxAmi(trans, true).isEmpty() ) - domElementTranslation.setAttribute(KV_FAUX_AMI_T, entry->fauxAmi(trans, true)); + if (!entry->translation(0).falseFriend(trans).isEmpty() ) + domElementTranslation.setAttribute(KV_FAUX_AMI_T, entry->translation(0).falseFriend(trans)); - if (!entry->synonym(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_SYNONYM, entry->synonym(trans)); + if (!entry->translation(trans).synonym().isEmpty() ) + domElementTranslation.setAttribute(KV_SYNONYM, entry->translation(trans).synonym()); - if (!entry->example(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_EXAMPLE, entry->example(trans)); + if (!entry->translation(trans).example().isEmpty() ) + domElementTranslation.setAttribute(KV_EXAMPLE, entry->translation(trans).example()); - if (!entry->usageLabel(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_USAGE, entry->usageLabel(trans)); + if (!entry->translation(trans).usageLabel().isEmpty() ) + domElementTranslation.setAttribute(KV_USAGE, entry->translation(trans).usageLabel()); - if (!entry->paraphrase(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_PARAPHRASE, entry->paraphrase(trans)); + if (!entry->translation(trans).paraphrase().isEmpty() ) + domElementTranslation.setAttribute(KV_PARAPHRASE, entry->translation(trans).paraphrase()); - if (!entry->antonym(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_ANTONYM, entry->antonym(trans)); + if (!entry->translation(trans).antonym().isEmpty() ) + domElementTranslation.setAttribute(KV_ANTONYM, entry->translation(trans).antonym()); - if (!entry->pronunciation(trans).isEmpty() ) - domElementTranslation.setAttribute(KV_PRONUNCE, entry->pronunciation(trans)); + if (!entry->translation(trans).pronunciation().isEmpty() ) + domElementTranslation.setAttribute(KV_PRONUNCE, entry->translation(trans).pronunciation()); - if (!entry->uniqueType() && !entry->type(trans).isEmpty()) - domElementTranslation.setAttribute(KV_EXPRTYPE, entry->type(trans)); + if (!entry->uniqueType() && !entry->translation(trans).type().isEmpty()) + domElementTranslation.setAttribute(KV_EXPRTYPE, entry->translation(trans).type()); - if (!writeMultipleChoice(domDoc, domElementTranslation, entry->multipleChoice(trans))) + if (!writeMultipleChoice(domDoc, domElementTranslation, entry->translation(trans).multipleChoice())) return false; QString s; - QString entype = s = entry->type(0); + QString entype = s = entry->translation(0).type(); int pos = s.indexOf(QM_TYPE_DIV); if (pos >= 0) entype = s.left (pos); else entype = s; - if (entype == QM_VERB && entry->conjugation(trans).entryCount() > 0) + if (entype == QM_VERB && entry->translation(trans).conjugation().entryCount() > 0) { - KEduVocConjugation conj = entry->conjugation(trans); + KEduVocConjugation conj = entry->translation(trans).conjugation(); if (!writeConjugEntry(domDoc, domElementTranslation, conj)) return false; } - if (entype == QM_ADJ && !entry->comparison(trans).isEmpty()) + if (entype == QM_ADJ && !entry->translation(trans).comparison().isEmpty()) { - KEduVocComparison comp = entry->comparison(trans); + KEduVocComparison comp = entry->translation(trans).comparison(); if (!writeComparison(domDoc, domElementTranslation, comp)) return false; } - QDomText domTextTranslation = domDoc.createTextNode(entry->translation(trans)); + QDomText domTextTranslation = domDoc.createTextNode(entry->translation(trans).translation()); domElementTranslation.appendChild(domTextTranslation); domElementExpression.appendChild(domElementTranslation); diff --git a/kdeeducore/keduvoctranslation.cpp b/kdeeducore/keduvoctranslation.cpp index 052e787..49cd7bf 100644 --- a/kdeeducore/keduvoctranslation.cpp +++ b/kdeeducore/keduvoctranslation.cpp @@ -124,203 +124,206 @@ void KEduVocTranslation::setTranslation ( const QString & expr ) */ -// QString KEduVocTranslation::comment ( ) const -// { -// return d->m_comment; -// } -// -// -// void KEduVocTranslation::setComment ( const QString & expr ) -// { -// d->m_comment = expr.simplified(); -// } -// -// -// void KEduVocTranslation::setFalseFriend ( int indexFrom, const QString & expr ) -// { -// // d->m_falseFriends[indexFrom] = expr.simplified(); -// } -// -// -// QString KEduVocTranslation::falseFriend ( int indexFrom ) const -// { -// // return d->m_falseFriends.value(indexFrom); -// return QString(); -// } -// -// -// void KEduVocTranslation::setSynonym ( const QString & expr ) -// { -// d->m_synonym = expr.simplified(); -// } -// -// -// QString KEduVocTranslation::synonym ( ) const -// { -// return d->m_synonym; -// } -// -// -// void KEduVocTranslation::setExample ( const QString & expr ) -// { -// d->m_example = expr.simplified(); -// } -// -// -// QString KEduVocTranslation::example ( ) const -// { -// return d->m_example; -// } -// -// -// void KEduVocTranslation::setUsageLabel ( const QString & usage ) -// { -// d->m_usageLabel = usage; -// } -// -// -// QString KEduVocTranslation::usageLabel () const -// { -// return d->m_usageLabel; -// } -// -// -// void KEduVocTranslation::setParaphrase ( const QString & expr ) -// { -// d->m_paraphrase = expr.simplified(); -// } -// -// -// QString KEduVocTranslation::paraphrase ( ) const -// { -// return d->m_paraphrase; -// } -// -// -// void KEduVocTranslation::setAntonym ( const QString & expr ) -// { -// d->m_antonym = expr.simplified(); -// } -// -// -// QString KEduVocTranslation::antonym ( ) const -// { -// return d->m_antonym; -// } -// -// -// void KEduVocTranslation::setConjugation ( int tense, const KEduVocConjugation &con ) -// { -// // d->m_conjugations[tense] = con; -// } -// -// -// KEduVocConjugation KEduVocTranslation::conjugation ( int tense ) const -// { -// // return d->m_conjugations.value(tense); -// } -// -// -// void KEduVocTranslation::setComparison ( const KEduVocComparison &con ) -// { -// d->m_comparison = con; -// } -// -// -// KEduVocComparison KEduVocTranslation::comparison ( ) const -// { -// return d->m_comparison; -// } -// -// -// void KEduVocTranslation::setMultipleChoice ( const KEduVocMultipleChoice &mc ) -// { -// d->m_multipleChoice = mc; -// } -// -// -// KEduVocMultipleChoice KEduVocTranslation::multipleChoice ( ) const -// { -// return d->m_multipleChoice; -// } -// -// -// QString KEduVocTranslation::pronunciation ( ) const -// { -// return d->m_pronunciation; -// } -// -// -// void KEduVocTranslation::setPronunciation ( const QString & expr ) -// { -// d->m_pronunciation = expr.simplified(); -// } -// -// -// grade_t KEduVocTranslation::grade ( int indexFrom ) const -// { -// // return d->m_grades.value(indexFrom).m_grade; -// } -// -// -// void KEduVocTranslation::setGrade ( int indexFrom, grade_t grade ) -// { -// if ( grade > KV_MAX_GRADE ) -// grade = KV_MAX_GRADE; -// if ( grade < KV_MIN_GRADE ) -// grade = KV_MIN_GRADE; -// // d->m_grades[indexFrom].m_grade = grade; -// } -// -// -// void KEduVocTranslation::incGrade ( int indexFrom ) -// { -// setGrade ( indexFrom, grade( indexFrom) + 1 ); -// } -// -// -// void KEduVocTranslation::decGrade ( int indexFrom ) -// { -// setGrade ( indexFrom, grade( indexFrom) - 1 ); -// } -// -// -// count_t KEduVocTranslation::queryCount ( int indexFrom ) const -// { -// // return d->m_grades.value(indexFrom).m_queryCount; -// } -// -// -// void KEduVocTranslation::setQueryCount ( int indexFrom, count_t count ) -// { -// // d->m_grades[indexFrom].m_queryCount = count; -// } -// -// -// count_t KEduVocTranslation::badCount ( int indexFrom ) const -// { -// // return d->m_grades.value(indexFrom).m_badCount; -// } -// -// -// void KEduVocTranslation::setBadCount ( int indexFrom, count_t count ) -// { -// // d->m_grades[indexFrom].m_badCount = count; -// } -// -// -// QDateTime KEduVocTranslation::queryDate ( int indexFrom ) const -// { -// // return d->m_grades.value(indexFrom).m_queryDate; -// } -// -// -// void KEduVocTranslation::setQueryDate ( int indexFrom, const QDateTime & date ) -// { -// // d->m_grades[indexFrom].m_queryDate = date; -// } -// -// +QString KEduVocTranslation::comment ( ) const +{ + return m_comment; +} + + +void KEduVocTranslation::setComment ( const QString & expr ) +{ + m_comment = expr.simplified(); +} + + +void KEduVocTranslation::setFalseFriend ( int indexFrom, const QString & expr ) +{ +// m_falseFriends[indexFrom] = expr.simplified(); +} + + +QString KEduVocTranslation::falseFriend ( int indexFrom ) const +{ +// return m_falseFriends.value(indexFrom); +return QString(); +} + + +void KEduVocTranslation::setSynonym ( const QString & expr ) +{ + m_synonym = expr.simplified(); +} + + +QString KEduVocTranslation::synonym ( ) const +{ + return m_synonym; +} + + +void KEduVocTranslation::setExample ( const QString & expr ) +{ + m_example = expr.simplified(); +} + + +QString KEduVocTranslation::example ( ) const +{ + return m_example; +} + + +void KEduVocTranslation::setUsageLabel ( const QString & usage ) +{ + m_usageLabel = usage; +} + + +QString KEduVocTranslation::usageLabel () const +{ + return m_usageLabel; +} + + +void KEduVocTranslation::setParaphrase ( const QString & expr ) +{ + m_paraphrase = expr.simplified(); +} + + +QString KEduVocTranslation::paraphrase ( ) const +{ + return m_paraphrase; +} + + +void KEduVocTranslation::setAntonym ( const QString & expr ) +{ + m_antonym = expr.simplified(); +} + + +QString KEduVocTranslation::antonym ( ) const +{ + return m_antonym; +} + + +void KEduVocTranslation::setConjugation ( const KEduVocConjugation &con ) +{ + m_conjugation = con; +} + + +KEduVocConjugation KEduVocTranslation::conjugation ( ) const +{ + return m_conjugation; +} + + +void KEduVocTranslation::setComparison ( const KEduVocComparison &con ) +{ + m_comparison = con; +} + + +KEduVocComparison KEduVocTranslation::comparison ( ) const +{ + return m_comparison; +} + + +void KEduVocTranslation::setMultipleChoice ( const KEduVocMultipleChoice &mc ) +{ + m_multipleChoice = mc; +} + + +KEduVocMultipleChoice KEduVocTranslation::multipleChoice ( ) const +{ + return m_multipleChoice; +} + + +QString KEduVocTranslation::pronunciation ( ) const +{ + return m_pronunciation; +} + + +void KEduVocTranslation::setPronunciation ( const QString & expr ) +{ + m_pronunciation = expr.simplified(); +} + + +grade_t KEduVocTranslation::grade ( int indexFrom ) const +{ + if (m_grades.contains(indexFrom)) { + return m_grades.value(indexFrom).m_grade; + } + return KV_NORM_GRADE; +} + + +void KEduVocTranslation::setGrade ( int indexFrom, grade_t grade ) +{ + if ( grade > KV_MAX_GRADE ) + grade = KV_MAX_GRADE; + if ( grade < KV_MIN_GRADE ) + grade = KV_MIN_GRADE; +// m_grades[indexFrom].m_grade = grade; +} + + +void KEduVocTranslation::incGrade ( int indexFrom ) +{ + setGrade ( indexFrom, grade( indexFrom) + 1 ); +} + + +void KEduVocTranslation::decGrade ( int indexFrom ) +{ + setGrade ( indexFrom, grade( indexFrom) - 1 ); +} + + +count_t KEduVocTranslation::queryCount ( int indexFrom ) const +{ + return m_grades.value(indexFrom).m_queryCount; +} + + +void KEduVocTranslation::setQueryCount ( int indexFrom, count_t count ) +{ + m_grades[indexFrom].m_queryCount = count; +} + + +count_t KEduVocTranslation::badCount ( int indexFrom ) const +{ + return m_grades.value(indexFrom).m_badCount; +} + + +void KEduVocTranslation::setBadCount ( int indexFrom, count_t count ) +{ + m_grades[indexFrom].m_badCount = count; +} + + +QDateTime KEduVocTranslation::queryDate ( int indexFrom ) const +{ + return m_grades.value(indexFrom).m_queryDate; +} + + +void KEduVocTranslation::setQueryDate ( int indexFrom, const QDateTime & date ) +{ + m_grades[indexFrom].m_queryDate = date; +} + + // bool KEduVocTranslation::uniqueType() const // { ///@todo what is this??? I have no clue... help! // /* @@ -333,45 +336,58 @@ void KEduVocTranslation::setTranslation ( const QString & expr ) // return false; // } // -// -// QString KEduVocTranslation::type() const -// { -// return d->m_types; -// } -// -// -// void KEduVocTranslation::setType ( const QString &type ) -// { -// d->m_types = type; -// } -// -// -// void KEduVocTranslation::incQueryCount ( int indexFrom ) -// { -// setQueryCount ( indexFrom, queryCount ( indexFrom ) + 1 ); -// } -// -// -// void KEduVocTranslation::incBadCount ( int indexFrom ) -// { -// setBadCount ( indexFrom, badCount ( indexFrom ) + 1 ); -// } -// -// -// void KEduVocTranslation::resetGrades(){ -// // d->m_grades.clear(); -// } -// -// -// QList< int > KEduVocTranslation::conjugationTenses() const -// { -// // return d->m_conjugations.keys(); -// } + +QString KEduVocTranslation::type() const +{ + return m_types; +} + + +void KEduVocTranslation::setType ( const QString &type ) +{ + m_types = type; +} + + +void KEduVocTranslation::incQueryCount ( int indexFrom ) +{ + setQueryCount ( indexFrom, queryCount ( indexFrom ) + 1 ); +} + + +void KEduVocTranslation::incBadCount ( int indexFrom ) +{ + setBadCount ( indexFrom, badCount ( indexFrom ) + 1 ); +} + + +void KEduVocTranslation::resetGrades(){ +// m_grades.clear(); +} + +/* +QList< int > KEduVocTranslation::conjugationTenses() const +{ + return m_conjugations.keys(); +}*/ bool KEduVocTranslation::operator ==(const KEduVocTranslation & translation) const { - return m_translation == translation.m_translation; - //return ( *d == *translation.d ); + return m_translation == translation.m_translation && + m_types == translation.m_types && + m_usageLabel == translation.m_usageLabel && + m_comment == translation.m_comment && + m_paraphrase == translation.m_paraphrase && + m_synonym == translation.m_synonym && + m_example == translation.m_example && + m_antonym == translation.m_antonym && + m_pronunciation == translation.m_pronunciation && + m_comparison == translation.m_comparison && + m_multipleChoice == translation.m_multipleChoice + /// @todo m_falseFriends == translation.m_falseFriends && + /// @todo m_grades == translation.m_grades && + /// @todo m_conjugations == translation.m_conjugations + ; } diff --git a/kdeeducore/keduvoctranslation.h b/kdeeducore/keduvoctranslation.h index 8aed1c0..1be478d 100644 --- a/kdeeducore/keduvoctranslation.h +++ b/kdeeducore/keduvoctranslation.h @@ -20,7 +20,7 @@ #include -/* + #define KV_MAX_GRADE 7 #define KV_MIN_GRADE 0 @@ -48,7 +48,8 @@ #define KV_LEV7_GRADE 7 #define KV_LEV7_TEXT I18N_NOOP("Level 7") -*/ + + #include #include #include @@ -71,284 +72,283 @@ public: ~KEduVocTranslation(); - QString translation ( ) const; + QString translation () const; void setTranslation ( const QString & expr ); -// void resetGrades(); -// -// -// /** sets the pronunciation of this expression -// * -// * @param index index of expression -// * @param expression pronunciation of this index -// */ -// void setPronunciation( const QString & expression); -// -// /** returns the pronunciation of this expression -// * -// * @param index index of expression -// * @return pronunciation or "" if none available -// */ -// QString pronunciation() const; -// -// /** returns comments of this expression -// * -// * @param index index of expression -// * @return comment or "" if no comment available -// */ -// QString comment() const; -// -// /** sets comment of this expression -// * -// * @param index index of expression -// * @param expr comment of this index -// */ -// void setComment( const QString & expr); -// -// /** sets false friend of this expression -// * -// * @param index index of expression -// * @param indexint indexFrom index of original translation -// * @param expression false friend of this index -// */ -// void setFalseFriend( int indexFrom, const QString & expression ); -// -// /** returns false friend of this expression -// * -// * @param index index of expression -// -// * @return false friend or "" if no string available -// */ -// QString falseFriend( int indexFrom) const; -// -// /** sets synonym this expression -// * -// * @param index index of expression -// * @param expression synonym of this index -// */ -// void setSynonym( const QString & expression); -// -// /** returns synonym of this expression -// * -// * @param index index of expression -// * @return synonym or "" if no string available -// */ -// QString synonym() const; -// -// /** sets example this expression -// * -// * @param index index of expression -// * @param expression example of this index -// */ -// void setExample( const QString & expression); -// -// /** returns example of this expression -// * -// * @param index index of expression -// * @return example or "" if no string available -// */ -// QString example() const; -// -// /** sets usage label this expression -// * -// * @param index index of expression -// * @param usage usage label of this index -// */ -// void setUsageLabel( const QString & usage); -// -// /** returns usage label of this expression -// * -// * @param index index of expression -// * @return usage or "" if no string available -// */ -// QString usageLabel() const; -// -// /** sets paraphrase of this expression -// * -// * @param index index of expression -// * @param expression paraphrase of this index -// */ -// void setParaphrase( const QString & expression); -// -// /** returns paraphrase of this expression -// * -// * @param index index of expression -// * @return paraphrase or "" if no string available -// */ -// QString paraphrase() const; -// -// /** sets antonym this expression -// * -// * @param index index of expression -// * @param expression antonym of this index -// */ -// void setAntonym( const QString & expression); -// -// /** returns antonym of this expression -// * -// * @param index index of expression -// * @return antonym or "" if no string available -// */ -// QString antonym() const; -// -// /** returns type of this expression -// * -// * @return type or "" if no type available -// */ -// QString type() const; -// -// void setType(const QString& type); -// + void resetGrades(); + + + /** sets the pronunciation of this expression + * + * @param index index of expression + * @param expression pronunciation of this index + */ + void setPronunciation( const QString & expression); + + /** returns the pronunciation of this expression + * + * @param index index of expression + * @return pronunciation or "" if none available + */ + QString pronunciation() const; + + /** returns comments of this expression + * + * @param index index of expression + * @return comment or "" if no comment available + */ + QString comment() const; + + /** sets comment of this expression + * + * @param index index of expression + * @param expr comment of this index + */ + void setComment( const QString & expr); + + /** sets false friend of this expression + * + * @param index index of expression + * @param indexint indexFrom index of original translation + * @param expression false friend of this index + */ + void setFalseFriend( int indexFrom, const QString & expression ); + + /** returns false friend of this expression + * + * @param index index of expression + + * @return false friend or "" if no string available + */ + QString falseFriend( int indexFrom) const; + + /** sets synonym this expression + * + * @param index index of expression + * @param expression synonym of this index + */ + void setSynonym( const QString & expression); + + /** returns synonym of this expression + * + * @param index index of expression + * @return synonym or "" if no string available + */ + QString synonym() const; + + /** sets example this expression + * + * @param index index of expression + * @param expression example of this index + */ + void setExample( const QString & expression); + + /** returns example of this expression + * + * @param index index of expression + * @return example or "" if no string available + */ + QString example() const; + + /** sets usage label this expression + * + * @param index index of expression + * @param usage usage label of this index + */ + void setUsageLabel( const QString & usage); + + /** returns usage label of this expression + * + * @param index index of expression + * @return usage or "" if no string available + */ + QString usageLabel() const; + + /** sets paraphrase of this expression + * + * @param index index of expression + * @param expression paraphrase of this index + */ + void setParaphrase( const QString & expression); + + /** returns paraphrase of this expression + * + * @param index index of expression + * @return paraphrase or "" if no string available + */ + QString paraphrase() const; + + /** sets antonym this expression + * + * @param index index of expression + * @param expression antonym of this index + */ + void setAntonym( const QString & expression); + + /** returns antonym of this expression + * + * @param index index of expression + * @return antonym or "" if no string available + */ + QString antonym() const; + + /** returns type of this expression + * + * @return type or "" if no type available + */ + QString type() const; + +/// @todo is this still needed? if so rather in KEduVocExpression // /** all langs have same type ? // * // * @return true if all have same type // */ // bool uniqueType () const; -// -// /** sets type of this expression -// * -// * @param index index of type -// * @param type type of this expression ("" = none) -// */ -// void appendType( const KEduVocType &type); -// -// /** sets grade of given translation -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @param grade number of knowlegde: 0=known, x=numbers not knows -// */ -// void setGrade( int indexFrom, grade_t grade ); -// -// /** returns grade of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @return number of knowlegde: 0=known, x=numbers not knows -// */ -// grade_t grade( int indexFrom ) const; -// -// /** increments grade of given translation -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// -// */ -// void incGrade( int indexFrom ); -// -// /** decrements grade of given translation -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// -// */ -// void decGrade( int indexFrom ); -// -// /** returns last query date of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// -// */ -// QDateTime queryDate( int indexFrom ) const; -// -// /** set last query date of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @param date the new date -// -// */ -// void setQueryDate( int indexFrom, const QDateTime & date ); -// -// /** returns conjugations if available -// * -// * @param index index of translation -// */ -// KEduVocConjugation conjugation( int tense ) const; -// -// /** sets conjugations -// * -// * @param index index of translation -// * @param conjugation conjugation block -// */ -// void setConjugation( int tense, const KEduVocConjugation & conjugation); -// QList conjugationTenses() const; -// /** returns comparison if available -// * -// * @param index index of translation -// */ -// KEduVocComparison comparison() const; -// -// /** sets comparison -// * -// * @param index index of translation -// * @param comparison comparison block -// */ -// void setComparison( const KEduVocComparison & comparison); -// -// /** returns multiple choice if available -// * -// * @param index index of multiple choice -// */ -// KEduVocMultipleChoice multipleChoice() const; -// -// /** sets multiple choice -// * -// * @param index index of translation -// * @param mc multiple choice block -// */ -// void setMultipleChoice( const KEduVocMultipleChoice &mc); -// -// -// /** returns query count of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// -// */ -// count_t queryCount( int indexFrom ) const; -// -// /** set query count of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @param count the new count -// -// */ -// void setQueryCount( int indexFrom, count_t count ); -// -// /** returns bad query count of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @param reverse dito, in opposite direction -// */ -// count_t badCount( int indexFrom ) const; -// -// /** set bad query count of given translation as int -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// * @param count the new count -// */ -// void setBadCount( int indexFrom, count_t count ); -// -// /** increment bad query count of given translation by 1 -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// */ -// void incBadCount( int indexFrom ); -// -// /** increment query count of given translation by 1 -// * -// * @param index index of translation -// * @param indexint indexFrom the identifier displayed to the user -// -// */ -// void incQueryCount( int indexFrom ); + + /** sets type of this expression + * + * @param index index of type + * @param type type of this expression ("" = none) + */ + void setType( const QString &type); + + /** sets grade of given translation + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @param grade number of knowlegde: 0=known, x=numbers not knows + */ + void setGrade( int indexFrom, grade_t grade ); + + /** returns grade of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @return number of knowlegde: 0=known, x=numbers not knows + */ + grade_t grade( int indexFrom ) const; + + /** increments grade of given translation + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + + */ + void incGrade( int indexFrom ); + + /** decrements grade of given translation + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + + */ + void decGrade( int indexFrom ); + + /** returns last query date of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + + */ + QDateTime queryDate( int indexFrom ) const; + + /** set last query date of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @param date the new date + + */ + void setQueryDate( int indexFrom, const QDateTime & date ); + + /** returns conjugations if available + * + * @param index index of translation + */ + KEduVocConjugation conjugation() const; + + /** sets conjugations + * + * @param index index of translation + * @param conjugation conjugation block + */ + void setConjugation(const KEduVocConjugation & conjugation); + + /** returns comparison if available + * + * @param index index of translation + */ + KEduVocComparison comparison() const; + + /** sets comparison + * + * @param index index of translation + * @param comparison comparison block + */ + void setComparison( const KEduVocComparison & comparison); + + /** returns multiple choice if available + * + * @param index index of multiple choice + */ + KEduVocMultipleChoice multipleChoice() const; + + /** sets multiple choice + * + * @param index index of translation + * @param mc multiple choice block + */ + void setMultipleChoice( const KEduVocMultipleChoice &mc); + + + /** returns query count of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + + */ + count_t queryCount( int indexFrom ) const; + + /** set query count of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @param count the new count + + */ + void setQueryCount( int indexFrom, count_t count ); + + /** returns bad query count of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @param reverse dito, in opposite direction + */ + count_t badCount( int indexFrom ) const; + + /** set bad query count of given translation as int + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + * @param count the new count + */ + void setBadCount( int indexFrom, count_t count ); + + /** increment bad query count of given translation by 1 + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + */ + void incBadCount( int indexFrom ); + + /** increment query count of given translation by 1 + * + * @param index index of translation + * @param indexint indexFrom the identifier displayed to the user + + */ + void incQueryCount( int indexFrom ); KEduVocTranslation& operator=(const KEduVocTranslation &translation); bool operator==(const KEduVocTranslation &translation) const; @@ -368,8 +368,7 @@ private: QString m_antonym; QString m_pronunciation; - /// Conjugations are numbered 0..n with respect to the tenses they are for. - QMap m_conjugations; + KEduVocConjugation m_conjugation; KEduVocComparison m_comparison;