#include "keduvocgrade.h"
KEduVocGrade::KEduVocGrade()
+{
+ resetGrades();
+}
+
+
+void KEduVocGrade::resetGrades()
{
m_grade = KV_NORM_GRADE;
m_queryCount = 0;
}
-void KEduVocGrade::resetGrades()
+grade_t KEduVocGrade::grade () const
+{
+ return m_grade;
+}
+
+
+void KEduVocGrade::setGrade ( grade_t grade )
+{
+ if ( grade > KV_MAX_GRADE )
+ grade = KV_MAX_GRADE;
+ if ( grade < KV_MIN_GRADE )
+ grade = KV_MIN_GRADE;
+ m_grade = grade;
+}
+
+
+void KEduVocGrade::incGrade ()
+{
+ setGrade ( grade() + 1 );
+}
+
+
+void KEduVocGrade::decGrade ()
+{
+ setGrade ( grade() - 1 );
+}
+
+
+count_t KEduVocGrade::queryCount ( ) const
+{
+ return m_queryCount;
+}
+
+
+void KEduVocGrade::incQueryCount ( )
+{
+ setQueryCount ( queryCount() + 1 );
+}
+
+
+void KEduVocGrade::incBadCount ( )
+{
+ setBadCount ( badCount() + 1 );
+}
+
+
+void KEduVocGrade::setQueryCount ( count_t count )
+{
+ m_queryCount = count;
+}
+
+
+count_t KEduVocGrade::badCount ( ) const
+{
+ return m_badCount;
+}
+
+
+void KEduVocGrade::setBadCount ( count_t count )
{
+ m_badCount = count;
+}
+
+QDateTime KEduVocGrade::queryDate () const
+{
+ return m_queryDate;
}
+
+void KEduVocGrade::setQueryDate ( const QDateTime & date )
+{
+ m_queryDate = date;
+}
{
public:
KEduVocGrade();
+
+ /** returns query count of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+
+ */
+ count_t queryCount( ) const;
+
+ /** set query count of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ * @param count the new count
+
+ */
+ void setQueryCount( count_t count );
+
+ /** returns bad query count of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ * @param reverse dito, in opposite direction
+ */
+ count_t badCount( ) const;
+
+ /** set bad query count of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ * @param count the new count
+ */
+ void setBadCount( count_t count );
+
+ /** increment bad query count of given translation by 1
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ */
+ void incBadCount( );
+
+ /** increment query count of given translation by 1
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+
+ */
+ void incQueryCount( );
+
+
+ /**
+ * Clears grading and date information.
+ */
void resetGrades();
-/// @todo make these private and write the according functions like updateQueryDate, increaseGrade, decreaseGrade etc.
-public:
+ /** sets grade of given translation
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ * @param grade number of knowlegde: 0=known, x=numbers not knows
+ */
+ void setGrade( grade_t grade );
+
+ /** returns grade of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+ * @return number of knowlegde: 0=known, x=numbers not knows
+ */
+ grade_t grade() const;
+
+ /** increments grade of given translation
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+
+ */
+ void incGrade( );
+
+ /** decrements grade of given translation
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+
+ */
+ void decGrade( );
+
+ /** returns last query date of given translation as int
+ *
+ * @param index index of translation
+ * @param index the identifier displayed to the user
+
+ */
+ QDateTime queryDate( ) const;
+
+
+ /**
+ * Set last query date
+ * @param index index of translation
+ * @param date the new date
+ */
+ void setQueryDate ( const QDateTime & date );
+
+private:
grade_t m_grade;
count_t m_queryCount;
count_t m_badCount;
domElementTranslation.setAttribute(KV_QUERY, (QString) KV_T);
}
- 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->translation(trans).gradeFrom(0).grade() != 0 || entry->translation(0).gradeFrom(trans).grade() != 0)
+ domElementTranslation.setAttribute(KV_GRADE, QString::number(entry->translation(trans).gradeFrom(0).grade()) + ';' + QString::number(entry->translation(0).gradeFrom(trans).grade()));
- 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->translation(trans).gradeFrom(0).queryCount() != 0 || entry->translation(0).gradeFrom(trans).queryCount() != 0)
+ domElementTranslation.setAttribute(KV_COUNT, QString::number(entry->translation(trans).gradeFrom(0).queryCount()) + ';' + QString::number(entry->translation(0).gradeFrom(trans).queryCount()));
- 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->translation(trans).gradeFrom(0).badCount() != 0 || entry->translation(0).gradeFrom(trans).badCount() != 0)
+ domElementTranslation.setAttribute(KV_BAD, QString::number(entry->translation(trans).gradeFrom(0).badCount()) + ';' + QString::number(entry->translation(0).gradeFrom(trans).badCount()));
- 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->translation(trans).gradeFrom(0).queryDate().toTime_t() != 0 || entry->translation(0).gradeFrom(trans).queryDate().toTime_t() != 0)
+ domElementTranslation.setAttribute(KV_DATE, QString::number(entry->translation(trans).gradeFrom(0).queryDate().toTime_t()) + ';' + QString::number(entry->translation(0).gradeFrom(trans).queryDate().toTime_t()));
if (!entry->translation(trans).comment().isEmpty() )
domElementTranslation.setAttribute(KV_REMARK, entry->translation(trans).comment());
}
-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;
-}
-
-
QString KEduVocTranslation::type() const
{
return m_types;
}
-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();
}
return *this;
}
+KEduVocGrade & KEduVocTranslation::gradeFrom(int indexFrom)
+{
+ return m_grades[indexFrom];
+}
+
void setTranslation ( const QString & expr );
- /**
- * Clears grading and date information.
- */
- void resetGrades();
-
-
/** sets the pronunciation of this expression
*
* @param index index of expression
*/
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
+ void resetGrades();
- */
- 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
+ KEduVocGrade & gradeFrom( int indexFrom );
- */
- void setQueryDate( int indexFrom, const QDateTime & date );
/** returns conjugations if available
*
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 );
-
/**
* Equal operator to assing a translation to another one.
* @param translation translation to be copied
KEduVocExpression kve;
kve.setTranslation(0, original);
kve.setTranslation(1, translation);
- kve.translation(1).setGrade(0, 0);
- kve.translation(0).setGrade(1, 0);
+ kve.translation(1).gradeFrom(0).setGrade(0);
+ kve.translation(0).gradeFrom(1).setGrade(0);
kve.setLesson(lesson);
m_doc->appendEntry(&kve);