From: Jeremy Paul Whiting Date: Tue, 7 Aug 2007 02:56:57 +0000 (+0000) Subject: writer writes grades and falsefriends X-Git-Tag: v3.93.0~96 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=715eb45a17d12764504c22a7eec6ac7a91c08a54;p=libqmvoc.git writer writes grades and falsefriends svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=697179 --- diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index f0762b0..03e0511 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -571,7 +571,7 @@ bool KEduVocKvtml2Writer::writeEntries(QDomElement &entriesElement) return true; } -bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation) +bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, KEduVocTranslation &translation) { // Kniebeugen translationElement.appendChild(newTextElement(KVTML_TEXT, translation.translation())); @@ -594,8 +594,20 @@ bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, cons translationElement.appendChild(newTextElement(KVTML_PRONUNCIATION, translation.pronunciation())); } - // TODO // + // loop through the identifiers + for (int i = 0; i < m_doc->identifierCount(); ++i) + { + // see if this identifier has a falsefriend in this translation + QString thisFriend = translation.falseFriend(i); + if (!thisFriend.isEmpty()) + { + // if so, create it, and set the fromid to i + QDomElement thisFriendElement = newTextElement(KVTML_FALSEFRIEND, thisFriend); + thisFriendElement.setAttribute(KVTML_FROMID, QString::number(i)); + translationElement.appendChild(thisFriendElement); + } + } // if (!translation.antonym().isEmpty()) @@ -628,7 +640,27 @@ bool KEduVocKvtml2Writer::writeTranslation(QDomElement &translationElement, cons } // grades - // TODO + for (int i = 0; i < m_doc->identifierCount(); ++i) + { + KEduVocGrade thisGrade = translation.gradeFrom(i); + if (thisGrade.queryCount() > 0) + { + QDomElement gradeElement = m_domDoc.createElement(KVTML_GRADE); + gradeElement.setAttribute(KVTML_FROMID, QString::number(i)); + //0.8 + + //6 + gradeElement.appendChild(newTextElement(KVTML_COUNT, QString::number(thisGrade.queryCount()))); + + //1 + gradeElement.appendChild(newTextElement(KVTML_ERRORCOUNT, QString::number(thisGrade.badCount()))); + + //949757271 + gradeElement.appendChild(newTextElement(KVTML_DATE, QString::number(thisGrade.queryDate().toTime_t()))); + + translationElement.appendChild(gradeElement); + } + } // conjugation if (!translation.conjugation().entryCount() > 0) diff --git a/keduvocdocument/keduvockvtml2writer.h b/keduvocdocument/keduvockvtml2writer.h index 3a991e6..33df97b 100644 --- a/keduvocdocument/keduvockvtml2writer.h +++ b/keduvocdocument/keduvockvtml2writer.h @@ -82,7 +82,7 @@ public: * @param translationElement QDomElement to write to, with id pre-set * @param translation object to write */ - bool writeTranslation(QDomElement &translationElement, const KEduVocTranslation &translation); + bool writeTranslation(QDomElement &translationElement, KEduVocTranslation &translation); /** write the lesson group * @param lessonsElement QDomElement to write to diff --git a/keduvocdocument/kvtml2todo b/keduvocdocument/kvtml2todo index 0044402..990b3aa 100644 --- a/keduvocdocument/kvtml2todo +++ b/keduvocdocument/kvtml2todo @@ -1,11 +1,8 @@ -Temporary todo for kvtml2 +todo for kvtml2 reader: store identifier name, sizehint and type? (need a place to store it first) -writer: - write translation sub-parts: falsefriend grades - extra classes: lesson class