LibKEduVocDocument

keduvockvtml2writer.h
1/*
2 * export a KEduVocDocument to a KVTML file
3 * SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org>
4 * SPDX-FileCopyrightText: 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7#ifndef KEDUVOCKVTML2WRITER_H
8#define KEDUVOCKVTML2WRITER_H
9
10#include <QDomDocument>
11#include <QFile>
12#include <QList>
13
14#include "keduvocarticle.h"
15#include "keduvocmultiplechoice.h"
16#include "keduvocpersonalpronoun.h"
17#include "keduvoctranslation.h"
18
19class KEduVocDocument;
21class KEduVocLesson;
23
24/**
25 * @brief Class to write kvtml2 data files from KEduVocDocument
26 * @author Jeremy Whiting
27 */
28class KEduVocKvtml2Writer
29{
30public:
31 explicit KEduVocKvtml2Writer(QFile *file);
32
33 bool writeDoc(KEduVocDocument *doc, const QString &generator);
34
35 QByteArray toByteArray(KEduVocDocument *doc, const QString &generator);
36
37 /**
38 * Helper function, appends a new element AND a text child to @p parent
39 * Only appends if @p text is NOT empty.
40 * @param parent
41 * @param elementName
42 * @param text
43 */
44 static void appendTextElement(QDomElement &parent, const QString &elementName, const QString &text);
45
46private:
47 bool createXmlDocument(KEduVocDocument *doc, const QString &generator);
48
49 /** write information entries
50 * @param informationElement QDomElement information to write to
51 * @param generator text describing generator
52 */
53 bool writeInformation(QDomElement &informationElement, const QString &generator);
54
55 /** write identifiers group
56 * @param identifiersElement QDomElement identifiers to write to
57 */
58 bool writeIdentifiers(QDomElement &identifiersElement);
59
60 /** write article
61 * @param articleElement QDomElement article to write to
62 * @param article the article number to write
63 */
64 bool writeArticle(QDomElement &articleElement, int article);
65
66 bool writePersonalPronoun(QDomElement &pronounElement, const KEduVocPersonalPronoun &pronoun);
67 /** write types
68 * @param typesElement QDomElement types to write to
69 */
70 bool writeWordTypes(QDomElement &typesElement, KEduVocWordType *parentContainer);
71
72 /**
73 * write the leitner boxes @see KEduVocLeitnerBox
74 * @param leitnerParentElement parent dom element
75 * @param parentContainer parent of the KEduVocLeitnerBoxes to write
76 * @return success
77 */
78 bool writeLeitnerBoxes(QDomElement &leitnerParentElement, KEduVocLeitnerBox *parentContainer);
79
80 /** write entries
81 * @param entriesElement QDomElement entries to write to
82 */
83 bool writeEntries(QDomElement &entriesElement);
84
85 /** write a translation
86 * @param translationElement QDomElement translation to write to, with id pre-set
87 * @param translation object to write
88 */
89 bool writeTranslation(QDomElement &translationElement, KEduVocTranslation *translation);
90
91 /**
92 * Used to write synonym, antonym and false friend lists
93 * @param typesElement
94 * @param parentContainer
95 * @return
96 */
97 bool writeRelated(QDomElement &parentElement, QList<KEduVocTranslation *> relatedList);
98
99 /** write the lesson group
100 * @param parentLesson the parent lesson of the current lesson
101 * @param lessonsElement QDomElement lessons to write to
102 */
103 bool writeLessons(KEduVocLesson *parentLesson, QDomElement &lessonsElement);
104
105 void writeSynonymAntonymFalseFriend(QDomElement &parentElement);
106
107 /** write multiple choice choices
108 * @param multipleChoiceElement QDomElement multiplechoice to write to
109 * @returns success
110 */
111 bool writeMultipleChoice(QDomElement &multipleChoiceElement, KEduVocTranslation *translation);
112
113 QDomElement newTextElement(const QString &elementName, const QString &text);
114
115 QFile *m_outputFile;
116 KEduVocDocument *m_doc;
117
118 QList<KEduVocExpression *> m_allEntries;
121 QList<KEduVocTranslation *> m_falseFriends;
122
123 QDomDocument m_domDoc;
124};
125
126#endif
The primary entry point to the hierarchy of objects describing vocabularies.
This class contains one vocabulary expression as an original with one or more translations.
static void appendTextElement(QDomElement &parent, const QString &elementName, const QString &text)
Helper function, appends a new element AND a text child to parent Only appends if text is NOT empty.
Leitner Boxes are an alternative grading system.
class to store information about a lesson
The conjugation of a verb.
class to store translation word types
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:09:38 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.