From 7093000d33c478715516f8384331c234a99fc83b Mon Sep 17 00:00:00 2001 From: Reto Zingg Date: Sat, 15 Dec 2012 19:28:48 +0200 Subject: [PATCH] adapt qmvoctext.cpp for querymee --- qmvoctext.cpp | 71 +++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/qmvoctext.cpp b/qmvoctext.cpp index 41d44d0..0d91df9 100644 --- a/qmvoctext.cpp +++ b/qmvoctext.cpp @@ -1,5 +1,10 @@ +/*************************************************************************** +* this file is from kdeedu project. Filename: keduvoctext.cpp +***************************************************************************/ + /*************************************************************************** Copyright 2007-2008 Frederik Gladhorn + Copyright (C) 2010, 2012 Reto Zingg ***************************************************************************/ /*************************************************************************** @@ -11,14 +16,14 @@ * * ***************************************************************************/ -#include "keduvoctext.h" +#include "qmvoctext.h" #include "kvtml2defs.h" -#include "keduvockvtml2writer.h" +#include "qmvockvtml2writer.h" #include -class KEduVocText::KEduVocTextPrivate +class QmVocText::QmVocTextPrivate { public: /// This is the word itself. The vocabulary. This is what it is all about. @@ -30,15 +35,15 @@ public: QDateTime m_practiceDate; }; -KEduVocText::KEduVocText(const QString& text) - :d( new KEduVocTextPrivate ) +QmVocText::QmVocText(const QString& text) + :d( new QmVocTextPrivate ) { d->m_text = text; resetGrades(); } -KEduVocText::KEduVocText( const KEduVocText &other ) - :d( new KEduVocTextPrivate ) +QmVocText::QmVocText( const QmVocText &other ) + :d( new QmVocTextPrivate ) { d->m_text = other.d->m_text; setGrade( other.grade() ); @@ -47,22 +52,22 @@ KEduVocText::KEduVocText( const KEduVocText &other ) setPracticeDate( other.practiceDate() ); } -KEduVocText::~KEduVocText() +QmVocText::~QmVocText() { delete d; } -QString KEduVocText::text() const +QString QmVocText::text() const { return d->m_text; } -void KEduVocText::setText( const QString & expr ) +void QmVocText::setText( const QString & expr ) { d->m_text = expr.simplified(); } -void KEduVocText::resetGrades() +void QmVocText::resetGrades() { d->m_grade = KV_NORM_GRADE; d->m_totalPracticeCount = 0; @@ -74,13 +79,13 @@ void KEduVocText::resetGrades() } -grade_t KEduVocText::grade() const +grade_t QmVocText::grade() const { return d->m_grade; } -void KEduVocText::setGrade( grade_t grade ) +void QmVocText::setGrade( grade_t grade ) { if ( grade > KV_MAX_GRADE ) { grade = KV_MAX_GRADE; @@ -89,13 +94,13 @@ void KEduVocText::setGrade( grade_t grade ) } -void KEduVocText::incGrade() +void QmVocText::incGrade() { setGrade( qMax(grade() + 1, KV_LEV1_GRADE ) ); } -void KEduVocText::decGrade() +void QmVocText::decGrade() { if ( grade() == KV_MIN_GRADE ) { return; @@ -104,54 +109,54 @@ void KEduVocText::decGrade() } -count_t KEduVocText::practiceCount() const +count_t QmVocText::practiceCount() const { return d->m_totalPracticeCount; } -void KEduVocText::incPracticeCount() +void QmVocText::incPracticeCount() { setPracticeCount( practiceCount() + 1 ); } -void KEduVocText::incBadCount() +void QmVocText::incBadCount() { setBadCount( badCount() + 1 ); } -void KEduVocText::setPracticeCount( count_t count ) +void QmVocText::setPracticeCount( count_t count ) { d->m_totalPracticeCount = count; } -count_t KEduVocText::badCount() const +count_t QmVocText::badCount() const { return d->m_badCount; } -void KEduVocText::setBadCount( count_t count ) +void QmVocText::setBadCount( count_t count ) { d->m_badCount = count; } -QDateTime KEduVocText::practiceDate() const +QDateTime QmVocText::practiceDate() const { return d->m_practiceDate; } -void KEduVocText::setPracticeDate( const QDateTime & date ) +void QmVocText::setPracticeDate( const QDateTime & date ) { d->m_practiceDate = date; } -KEduVocText & KEduVocText::operator =(const KEduVocText & other) +QmVocText & QmVocText::operator =(const QmVocText & other) { d->m_text = other.d->m_text; d->m_grade = other.d->m_grade; @@ -162,7 +167,7 @@ KEduVocText & KEduVocText::operator =(const KEduVocText & other) return *this; } -bool KEduVocText::operator ==(const KEduVocText & other) const +bool QmVocText::operator ==(const QmVocText & other) const { return d->m_text == other.d->m_text && @@ -172,7 +177,7 @@ bool KEduVocText::operator ==(const KEduVocText & other) const d->m_practiceDate == other.d->m_practiceDate; } -void KEduVocText::toKVTML2(QDomElement& parent) +void QmVocText::toKVTML2(QDomElement& parent) { QDomDocument domDoc = parent.ownerDocument(); if (d->m_text.isEmpty() && d->m_totalPracticeCount == 0) { @@ -180,29 +185,29 @@ void KEduVocText::toKVTML2(QDomElement& parent) } // the text - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_TEXT, text() ); + QmVocKvtml2Writer::appendTextElement( parent, KVTML_TEXT, text() ); // grades if ( d->m_totalPracticeCount > 0 ) { QDomElement gradeElement = domDoc.createElement( KVTML_GRADE ); //2 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_CURRENTGRADE, QString::number( grade() ) ); + QmVocKvtml2Writer::appendTextElement( gradeElement, KVTML_CURRENTGRADE, QString::number( grade() ) ); //6 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_COUNT, QString::number( practiceCount() ) ); + QmVocKvtml2Writer::appendTextElement( gradeElement, KVTML_COUNT, QString::number( practiceCount() ) ); //1 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_ERRORCOUNT, QString::number( badCount() ) ); + QmVocKvtml2Writer::appendTextElement( gradeElement, KVTML_ERRORCOUNT, QString::number( badCount() ) ); //949757271 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_DATE, practiceDate().toString( Qt::ISODate ) ); + QmVocKvtml2Writer::appendTextElement( gradeElement, KVTML_DATE, practiceDate().toString( Qt::ISODate ) ); parent.appendChild( gradeElement ); } } -void KEduVocText::fromKVTML2(QDomElement & parent) +void QmVocText::fromKVTML2(QDomElement & parent) { setText( parent.firstChildElement( KVTML_TEXT ).text() ); @@ -224,7 +229,7 @@ void KEduVocText::fromKVTML2(QDomElement & parent) } } -bool KEduVocText::isEmpty() +bool QmVocText::isEmpty() { return d->m_text.isEmpty(); } -- 2.47.3