// so far only for KEduVocWord - text and grades
translation->toKVTML2(translationElement);
- ///@todo move into translation->toXML()
-
- // <comment></comment>
- if ( !translation->comment().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_COMMENT, translation->comment() ) );
- }
-
- // <pronunciation></pronunciation>
- if ( !translation->pronunciation().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_PRONUNCIATION, translation->pronunciation() ) );
- }
-
// <falsefriend fromid="0"></falsefriend>
// loop through the identifiers
for ( int i = 0; i < m_doc->identifierCount(); ++i ) {
}
}
- // <antonym></antonym>
- if ( !translation->antonym().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_ANTONYM, translation->antonym() ) );
- }
-
- // <synonym></synonym>
- if ( !translation->synonym().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_SYNONYM, translation->synonym() ) );
- }
-
- // <example></example>
- if ( !translation->example().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_EXAMPLE, translation->example() ) );
- }
-
- // <paraphrase></paraphrase>
- if ( !translation->paraphrase().isEmpty() ) {
- translationElement.appendChild( newTextElement( KVTML_PARAPHRASE, translation->paraphrase() ) );
- }
-
// conjugation
foreach ( const QString &tense, translation->conjugationTenses() ) {
QDomElement thisElement = m_domDoc.createElement( KVTML_CONJUGATION );
void KEduVocKvtml2Writer::appendTextElement(QDomElement & parent, const QString & elementName, const QString & text)
{
+ // empty will never be written
+ if (text.isEmpty()) {
+ return;
+ }
+
QDomDocument domDoc = parent.ownerDocument();
QDomElement element = domDoc.createElement( elementName );
parent.appendChild( element );
*/
bool writeMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation );
+ /**
+ * Helper function, appends a new element AND a text child to @p parent
+ * Only appends if @p text is NOT empty.
+ * @param parent
+ * @param elementName
+ * @param text
+ */
static void appendTextElement( QDomElement &parent, const QString &elementName, const QString &text );
private:
#include "keduvoctranslation.h"
-#include <QtCore/QMap>
-
-#include <KDebug>
-
#include "keduvocdeclension.h"
#include "keduvocwordtype.h"
+#include "kvtml2defs.h"
+#include "keduvockvtml2writer.h"
+#include <KDebug>
+#include <QtCore/QMap>
class KEduVocTranslation::KEduVocTranslationPrivate
{
void KEduVocTranslation::toKVTML2(QDomElement & parent)
{
- kDebug() << "Write translation xml.";
KEduVocText::toKVTML2(parent);
if (d->m_declension) {
d->m_declension->toKVTML2(parent);
}
+
+ // <comment>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_COMMENT, comment() );
+
+ // <pronunciation>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PRONUNCIATION, pronunciation() );
+
+ // <antonym>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_ANTONYM, antonym() );
+
+ // <synonym>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_SYNONYM, synonym() );
+
+ // <example>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_EXAMPLE, example() );
+
+ // <paraphrase>
+ KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PARAPHRASE, paraphrase() );
}