domElementKvtml.appendChild(currentElement);
//** NOTE: everything below this point has not been updated to use kvtml2 format****
- if (!writeLesson(m_domDoc, domElementKvtml))
- return false;
-
- QList<KEduVocConjugation> conjugations;
- for (int i = 0; i < m_doc->conjugationCount(); i++)
- conjugations.append(m_doc->conjugation(i));
- if (conjugations.count() > 0) {
- if (!writeConjugHeader(m_domDoc, domElementKvtml, conjugations))
- return false;
- }
-
- if (!writeOption(m_domDoc, domElementKvtml))
- return false;
-
- if (!writeType(m_domDoc, domElementKvtml))
- return false;
-
- if (!writeTense(m_domDoc, domElementKvtml))
- return false;
-
- if (!writeUsage(m_domDoc, domElementKvtml))
- return false;
-
- QString q_org, q_trans;
- m_doc->queryIdentifier(q_org, q_trans);
-
- int entryCount = m_doc->entryCount();
-
- for (int i = 0; i < entryCount; i++)
- {
- KEduVocExpression *entry = m_doc->entry(i);
- QDomElement domElementExpression = m_domDoc.createElement(KV_EXPR);
-
- if (entry->lesson() != 0)
- {
- int lm = entry->lesson();
- if (lm > m_doc->lessonDescriptions().count())
- {
- // should not be
- kError() << "index of lesson member too high: " << lm << endl;
- lm = 0;
- }
- domElementExpression.setAttribute(KV_LESS_MEMBER, lm);
- }
-
- if (entry->isInQuery())
- domElementExpression.setAttribute(KV_SELECTED, 1);
-
- if (!entry->isActive())
- domElementExpression.setAttribute (KV_INACTIVE, 1);
-
- if (entry->uniqueType() && !entry->translation(0).type().isEmpty())
- domElementExpression.setAttribute (KV_EXPRTYPE, entry->translation(0).type());
-
- QDomElement domElementOriginal = m_domDoc.createElement(KV_ORG);
- if (first_expr)
- {
- // save space, only tell language in first entry
- QString s;
- domElementOriginal.setAttribute(KV_SIZEHINT, m_doc->sizeHint(0));
-
- s = m_doc->identifier(0).simplified();
- if (s.isEmpty() )
- s = "original";
- domElementOriginal.setAttribute(KV_LANG, s);
- if (s == q_org)
- domElementOriginal.setAttribute(KV_QUERY, (QString) KV_O);
- else if (s == q_trans)
- domElementOriginal.setAttribute(KV_QUERY, (QString) KV_T);
- }
-
- if (!entry->translation(0).comment().isEmpty() )
- domElementOriginal.setAttribute(KV_REMARK, entry->translation(0).comment());
-
- if (!entry->translation(0).synonym().isEmpty() )
- domElementOriginal.setAttribute(KV_SYNONYM, entry->translation(0).synonym());
-
- if (!entry->translation(0).example().isEmpty() )
- domElementOriginal.setAttribute(KV_EXAMPLE, entry->translation(0).example());
-
- if (!entry->translation(0).usageLabel().isEmpty() )
- domElementOriginal.setAttribute(KV_USAGE, entry->translation(0).usageLabel());
-
- if (!entry->translation(0).paraphrase().isEmpty() )
- domElementOriginal.setAttribute(KV_PARAPHRASE, entry->translation(0).paraphrase());
-
- if (!entry->translation(0).antonym().isEmpty() )
- domElementOriginal.setAttribute(KV_ANTONYM, entry->translation(0).antonym());
-
- if (!entry->translation(0).pronunciation().isEmpty() )
- domElementOriginal.setAttribute(KV_PRONUNCE, entry->translation(0).pronunciation());
-
- if (!entry->uniqueType() && !entry->translation(0).type().isEmpty())
- domElementOriginal.setAttribute(KV_EXPRTYPE, entry->translation(0).type());
-
- if (!writeMultipleChoice(m_domDoc, domElementOriginal, entry->translation(0).multipleChoice()))
- return false;
-
- QString s;
- QString entype = s = entry->translation(0).type();
- int pos;
- if (pos >= 0)
- entype = s.left(pos);
- else
- entype = s;
-
- if (entry->translation(0).conjugation().entryCount() > 0)
- {
- KEduVocConjugation conj = entry->translation(0).conjugation();
- if (!writeConjugEntry(m_domDoc, domElementOriginal, conj))
- return false;
- }
- else if (!entry->translation(0).comparison().isEmpty())
- {
- KEduVocComparison comp = entry->translation(0).comparison();
- if (!writeComparison(m_domDoc, domElementOriginal, comp))
- return false;
- }
-
- QDomText domTextOriginal = m_domDoc.createTextNode(entry->translation(0).translation());
- domElementOriginal.appendChild(domTextOriginal);
- domElementExpression.appendChild(domElementOriginal);
-
- int trans = 1;
- while (trans < m_doc->identifierCount())
- {
- QDomElement domElementTranslation = m_domDoc.createElement(KV_TRANS);
- if (first_expr)
- {
- // save space, only tell language in first entry
- QString s;
- domElementTranslation.setAttribute(KV_SIZEHINT, m_doc->sizeHint(trans));
-
- s = m_doc->identifier(trans).simplified();
- if (s.isEmpty() )
- {
- s.setNum(trans);
- s.prepend("translation ");
- }
- domElementTranslation.setAttribute(KV_LANG, s);
- if (s == q_org)
- domElementTranslation.setAttribute(KV_QUERY, (QString) KV_O);
- else if (s == q_trans)
- domElementTranslation.setAttribute(KV_QUERY, (QString) KV_T);
- }
-
- 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).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).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).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());
-
- if (!entry->translation(trans).falseFriend(0).isEmpty() )
- domElementTranslation.setAttribute(KV_FAUX_AMI_F, entry->translation(trans).falseFriend(0));
-
- if (!entry->translation(0).falseFriend(trans).isEmpty() )
- domElementTranslation.setAttribute(KV_FAUX_AMI_T, entry->translation(0).falseFriend(trans));
-
- if (!entry->translation(trans).synonym().isEmpty() )
- domElementTranslation.setAttribute(KV_SYNONYM, entry->translation(trans).synonym());
-
- if (!entry->translation(trans).example().isEmpty() )
- domElementTranslation.setAttribute(KV_EXAMPLE, entry->translation(trans).example());
-
- if (!entry->translation(trans).usageLabel().isEmpty() )
- domElementTranslation.setAttribute(KV_USAGE, entry->translation(trans).usageLabel());
-
- if (!entry->translation(trans).paraphrase().isEmpty() )
- domElementTranslation.setAttribute(KV_PARAPHRASE, entry->translation(trans).paraphrase());
-
- if (!entry->translation(trans).antonym().isEmpty() )
- domElementTranslation.setAttribute(KV_ANTONYM, entry->translation(trans).antonym());
-
- if (!entry->translation(trans).pronunciation().isEmpty() )
- domElementTranslation.setAttribute(KV_PRONUNCE, entry->translation(trans).pronunciation());
-
- if (!entry->uniqueType() && !entry->translation(trans).type().isEmpty())
- domElementTranslation.setAttribute(KV_EXPRTYPE, entry->translation(trans).type());
-
- if (!writeMultipleChoice(m_domDoc, domElementTranslation, entry->translation(trans).multipleChoice()))
- return false;
-
- QString s;
- QString entype = s = entry->translation(0).type();
- int pos;
- if (pos >= 0)
- entype = s.left (pos);
- else
- entype = s;
-
- if (entry->translation(trans).conjugation().entryCount() > 0)
- {
- KEduVocConjugation conj = entry->translation(trans).conjugation();
- if (!writeConjugEntry(m_domDoc, domElementTranslation, conj))
- return false;
- }
-
- if (!entry->translation(trans).comparison().isEmpty())
- {
- KEduVocComparison comp = entry->translation(trans).comparison();
- if (!writeComparison(m_domDoc, domElementTranslation, comp))
- return false;
- }
-
- QDomText domTextTranslation = m_domDoc.createTextNode(entry->translation(trans).translation());
- domElementTranslation.appendChild(domTextTranslation);
- domElementExpression.appendChild(domElementTranslation);
-
- trans++;
- }
-
- domElementKvtml.appendChild(domElementExpression);
-
- first_expr = false;
- }
+ //if (!writeLesson(m_domDoc, domElementKvtml))
+ // return false;
+
+ //QList<KEduVocConjugation> conjugations;
+ //for (int i = 0; i < m_doc->conjugationCount(); i++)
+ // conjugations.append(m_doc->conjugation(i));
+ //if (conjugations.count() > 0) {
+ // if (!writeConjugHeader(m_domDoc, domElementKvtml, conjugations))
+ // return false;
+ //}
+
+ //if (!writeOption(m_domDoc, domElementKvtml))
+ // return false;
+
+ //if (!writeType(m_domDoc, domElementKvtml))
+ // return false;
+
+ //if (!writeTense(m_domDoc, domElementKvtml))
+ // return false;
+
+ //if (!writeUsage(m_domDoc, domElementKvtml))
+ // return false;
+
+ //QString q_org, q_trans;
+ //m_doc->queryIdentifier(q_org, q_trans);
+
+ //int entryCount = m_doc->entryCount();
+
+ //for (int i = 0; i < entryCount; i++)
+ //{
+ // KEduVocExpression *entry = m_doc->entry(i);
+ // QDomElement domElementExpression = m_domDoc.createElement(KV_EXPR);
+
+ // if (entry->lesson() != 0)
+ // {
+ // int lm = entry->lesson();
+ // if (lm > m_doc->lessonDescriptions().count())
+ // {
+ // // should not be
+ // kError() << "index of lesson member too high: " << lm << endl;
+ // lm = 0;
+ // }
+ // domElementExpression.setAttribute(KV_LESS_MEMBER, lm);
+ // }
+
+ // if (entry->isInQuery())
+ // domElementExpression.setAttribute(KV_SELECTED, 1);
+
+ // if (!entry->isActive())
+ // domElementExpression.setAttribute (KV_INACTIVE, 1);
+
+ // if (entry->uniqueType() && !entry->translation(0).type().isEmpty())
+ // domElementExpression.setAttribute (KV_EXPRTYPE, entry->translation(0).type());
+
+ // QDomElement domElementOriginal = m_domDoc.createElement(KV_ORG);
+ // if (first_expr)
+ // {
+ // // save space, only tell language in first entry
+ // QString s;
+ // domElementOriginal.setAttribute(KV_SIZEHINT, m_doc->sizeHint(0));
+
+ // s = m_doc->identifier(0).simplified();
+ // if (s.isEmpty() )
+ // s = "original";
+ // domElementOriginal.setAttribute(KV_LANG, s);
+ // if (s == q_org)
+ // domElementOriginal.setAttribute(KV_QUERY, (QString) KV_O);
+ // else if (s == q_trans)
+ // domElementOriginal.setAttribute(KV_QUERY, (QString) KV_T);
+ // }
+
+ // if (!entry->translation(0).comment().isEmpty() )
+ // domElementOriginal.setAttribute(KV_REMARK, entry->translation(0).comment());
+
+ // if (!entry->translation(0).synonym().isEmpty() )
+ // domElementOriginal.setAttribute(KV_SYNONYM, entry->translation(0).synonym());
+
+ // if (!entry->translation(0).example().isEmpty() )
+ // domElementOriginal.setAttribute(KV_EXAMPLE, entry->translation(0).example());
+
+ // if (!entry->translation(0).usageLabel().isEmpty() )
+ // domElementOriginal.setAttribute(KV_USAGE, entry->translation(0).usageLabel());
+
+ // if (!entry->translation(0).paraphrase().isEmpty() )
+ // domElementOriginal.setAttribute(KV_PARAPHRASE, entry->translation(0).paraphrase());
+
+ // if (!entry->translation(0).antonym().isEmpty() )
+ // domElementOriginal.setAttribute(KV_ANTONYM, entry->translation(0).antonym());
+
+ // if (!entry->translation(0).pronunciation().isEmpty() )
+ // domElementOriginal.setAttribute(KV_PRONUNCE, entry->translation(0).pronunciation());
+
+ // if (!entry->uniqueType() && !entry->translation(0).type().isEmpty())
+ // domElementOriginal.setAttribute(KV_EXPRTYPE, entry->translation(0).type());
+
+ // if (!writeMultipleChoice(m_domDoc, domElementOriginal, entry->translation(0).multipleChoice()))
+ // return false;
+
+ // QString s;
+ // QString entype = s = entry->translation(0).type();
+ // int pos;
+ // if (pos >= 0)
+ // entype = s.left(pos);
+ // else
+ // entype = s;
+
+ // if (entry->translation(0).conjugation().entryCount() > 0)
+ // {
+ // KEduVocConjugation conj = entry->translation(0).conjugation();
+ // if (!writeConjugEntry(m_domDoc, domElementOriginal, conj))
+ // return false;
+ // }
+ // else if (!entry->translation(0).comparison().isEmpty())
+ // {
+ // KEduVocComparison comp = entry->translation(0).comparison();
+ // if (!writeComparison(m_domDoc, domElementOriginal, comp))
+ // return false;
+ // }
+
+ // QDomText domTextOriginal = m_domDoc.createTextNode(entry->translation(0).translation());
+ // domElementOriginal.appendChild(domTextOriginal);
+ // domElementExpression.appendChild(domElementOriginal);
+
+ // int trans = 1;
+ // while (trans < m_doc->identifierCount())
+ // {
+ // QDomElement domElementTranslation = m_domDoc.createElement(KV_TRANS);
+ // if (first_expr)
+ // {
+ // // save space, only tell language in first entry
+ // QString s;
+ // domElementTranslation.setAttribute(KV_SIZEHINT, m_doc->sizeHint(trans));
+
+ // s = m_doc->identifier(trans).simplified();
+ // if (s.isEmpty() )
+ // {
+ // s.setNum(trans);
+ // s.prepend("translation ");
+ // }
+ // domElementTranslation.setAttribute(KV_LANG, s);
+ // if (s == q_org)
+ // domElementTranslation.setAttribute(KV_QUERY, (QString) KV_O);
+ // else if (s == q_trans)
+ // domElementTranslation.setAttribute(KV_QUERY, (QString) KV_T);
+ // }
+
+ // 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).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).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).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());
+
+ // if (!entry->translation(trans).falseFriend(0).isEmpty() )
+ // domElementTranslation.setAttribute(KV_FAUX_AMI_F, entry->translation(trans).falseFriend(0));
+
+ // if (!entry->translation(0).falseFriend(trans).isEmpty() )
+ // domElementTranslation.setAttribute(KV_FAUX_AMI_T, entry->translation(0).falseFriend(trans));
+
+ // if (!entry->translation(trans).synonym().isEmpty() )
+ // domElementTranslation.setAttribute(KV_SYNONYM, entry->translation(trans).synonym());
+
+ // if (!entry->translation(trans).example().isEmpty() )
+ // domElementTranslation.setAttribute(KV_EXAMPLE, entry->translation(trans).example());
+
+ // if (!entry->translation(trans).usageLabel().isEmpty() )
+ // domElementTranslation.setAttribute(KV_USAGE, entry->translation(trans).usageLabel());
+
+ // if (!entry->translation(trans).paraphrase().isEmpty() )
+ // domElementTranslation.setAttribute(KV_PARAPHRASE, entry->translation(trans).paraphrase());
+
+ // if (!entry->translation(trans).antonym().isEmpty() )
+ // domElementTranslation.setAttribute(KV_ANTONYM, entry->translation(trans).antonym());
+
+ // if (!entry->translation(trans).pronunciation().isEmpty() )
+ // domElementTranslation.setAttribute(KV_PRONUNCE, entry->translation(trans).pronunciation());
+
+ // if (!entry->uniqueType() && !entry->translation(trans).type().isEmpty())
+ // domElementTranslation.setAttribute(KV_EXPRTYPE, entry->translation(trans).type());
+
+ // if (!writeMultipleChoice(m_domDoc, domElementTranslation, entry->translation(trans).multipleChoice()))
+ // return false;
+
+ // QString s;
+ // QString entype = s = entry->translation(0).type();
+ // int pos;
+ // if (pos >= 0)
+ // entype = s.left (pos);
+ // else
+ // entype = s;
+
+ // if (entry->translation(trans).conjugation().entryCount() > 0)
+ // {
+ // KEduVocConjugation conj = entry->translation(trans).conjugation();
+ // if (!writeConjugEntry(m_domDoc, domElementTranslation, conj))
+ // return false;
+ // }
+
+ // if (!entry->translation(trans).comparison().isEmpty())
+ // {
+ // KEduVocComparison comp = entry->translation(trans).comparison();
+ // if (!writeComparison(m_domDoc, domElementTranslation, comp))
+ // return false;
+ // }
+
+ // QDomText domTextTranslation = m_domDoc.createTextNode(entry->translation(trans).translation());
+ // domElementTranslation.appendChild(domTextTranslation);
+ // domElementExpression.appendChild(domElementTranslation);
+
+ // trans++;
+ // }
+
+ // domElementKvtml.appendChild(domElementExpression);
+
+ // first_expr = false;
+ //}
m_domDoc.appendChild(domElementKvtml);
QDomText textNode;
// generator
- currentElement = m_domDoc.createElement(KVTML_GENERATOR);
- textNode = m_domDoc.createTextNode(generator);
- currentElement.appendChild(textNode);
- informationElement.appendChild(currentElement);
+ informationElement.appendChild(newTextElement(KVTML_GENERATOR, generator));
// title
if (!m_doc->title().isEmpty())
{
- currentElement = m_domDoc.createElement(KVTML_TITLE);
- textNode = m_domDoc.createTextNode(m_doc->title());
- currentElement.appendChild(textNode);
- informationElement.appendChild(currentElement);
+ informationElement.appendChild(newTextElement(KVTML_TITLE, m_doc->title()));
}
// author
if (!m_doc->author().isEmpty())
{
- currentElement = m_domDoc.createElement(KVTML_AUTHOR);
- textNode = m_domDoc.createTextNode(m_doc->author());
- currentElement.appendChild(textNode);
- informationElement.appendChild(currentElement);
+ informationElement.appendChild(newTextElement(KVTML_AUTHOR, m_doc->author()));
}
// license
if (!m_doc->license().isEmpty())
{
- currentElement = m_domDoc.createElement(KVTML_LICENSE);
- textNode = m_domDoc.createTextNode(m_doc->license());
- currentElement.appendChild(textNode);
- informationElement.appendChild(currentElement);
+ informationElement.appendChild(newTextElement(KVTML_LICENSE, m_doc->license()));
}
// comment
if (!m_doc->documentRemark().isEmpty())
{
- currentElement = m_domDoc.createElement(KVTML_COMMENT);
- textNode = m_domDoc.createTextNode(m_doc->documentRemark());
- currentElement.appendChild(textNode);
- informationElement.appendChild(currentElement);
+ informationElement.appendChild(newTextElement(KVTML_COMMENT, m_doc->documentRemark()));
}
return true;
// record the identifier as the locale for now
// TODO: when support for more parts of the identifier is in the document class (name, type, etc.) store those here as well
- QDomElement locale = m_domDoc.createElement(KVTML_LOCALE);
- QDomText textNode = m_domDoc.createTextNode(m_doc->identifier(i));
- locale.appendChild(textNode);
- identifier.appendChild(locale);
+ identifier.appendChild(newTextElement(KVTML_LOCALE, m_doc->identifier(i)));
// record articles
QDomElement article = m_domDoc.createElement(KVTML_ARTICLE);
}
// record personalpronouns
+ QDomElement personalpronouns = m_domDoc.createElement(KVTML_PERSONALPRONOUNS);
+ writeConjugation(personalpronouns, m_doc->conjugation(i), QString());
+ if (personalpronouns.hasChildNodes())
+ {
+ identifier.appendChild(personalpronouns);
+ }
// add this identifier to the group
identifiersElement.appendChild(identifier);
QDomElement indefinite = m_domDoc.createElement(KVTML_INDEFINITE);
QString def;
QString indef;
- QDomElement currentElement;
- QDomText textNode;
// male
m_doc->article(article).getMale(&def, &indef);
-
- currentElement = m_domDoc.createElement(KVTML_MALE);
- textNode = m_domDoc.createTextNode(def);
- currentElement.appendChild(textNode);
- definite.appendChild(currentElement);
-
- textNode = m_domDoc.createTextNode(indef);
- currentElement = m_domDoc.createElement(KVTML_MALE);
- currentElement.appendChild(textNode);
- indefinite.appendChild(currentElement);
+ definite.appendChild(newTextElement(KVTML_MALE, def));
+ indefinite.appendChild(newTextElement(KVTML_MALE, indef));
// female
m_doc->article(article).getFemale(&def, &indef);
- currentElement = m_domDoc.createElement(KVTML_FEMALE);
- textNode = m_domDoc.createTextNode(def);
- currentElement.appendChild(textNode);
- definite.appendChild(currentElement);
-
- textNode = m_domDoc.createTextNode(indef);
- currentElement = m_domDoc.createElement(KVTML_FEMALE);
- currentElement.appendChild(textNode);
- indefinite.appendChild(currentElement);
-
+ definite.appendChild(newTextElement(KVTML_FEMALE, def));
+ indefinite.appendChild(newTextElement(KVTML_FEMALE, indef));
+
// neutral
m_doc->article(article).getNatural(&def, &indef);
- currentElement = m_domDoc.createElement(KVTML_NEUTRAL);
- textNode = m_domDoc.createTextNode(def);
- currentElement.appendChild(textNode);
- definite.appendChild(currentElement);
-
- textNode = m_domDoc.createTextNode(indef);
- currentElement = m_domDoc.createElement(KVTML_NEUTRAL);
- currentElement.appendChild(textNode);
- indefinite.appendChild(currentElement);
-
+ definite.appendChild(newTextElement(KVTML_NEUTRAL, def));
+ indefinite.appendChild(newTextElement(KVTML_NEUTRAL, indef));
articleElement.appendChild(definite);
articleElement.appendChild(indefinite);
return true;
}
-
-bool KEduVocKvtml2Writer::writeOption(QDomDocument &domDoc, QDomElement &domElementParent)
-{
- QDomElement domElementOption = domDoc.createElement(KV_OPTION_GRP);
- QDomElement domElementSort = domDoc.createElement(KV_OPT_SORT);
-
- domElementSort.setAttribute(KV_BOOL_FLAG, (m_doc->isSortingEnabled()?1:0));
- domElementOption.appendChild(domElementSort);
-
- domElementParent.appendChild(domElementOption);
- return true;
-}
-
-
bool KEduVocKvtml2Writer::writeType(QDomDocument &domDoc, QDomElement &domElementParent)
{
if (m_doc->typeDescriptions().count() == 0)
return true;
}
-
-bool KEduVocKvtml2Writer::writeConjugHeader(QDomDocument &domDoc, QDomElement &domElementParent, QList<KEduVocConjugation> &curr_conjug)
+bool KEduVocKvtml2Writer::writeConjugation(QDomElement &conjugationElement,
+ const KEduVocConjugation &conjugation, const QString &type)
{
-/*
- <conjugation> used in header for definiton of "prefix"
- <e l="de"> lang determines also lang order in entries !!
- <s1>I</s1> which must NOT differ
- <s2>you<2>
- <s3f common="0">he</s3f>
- <s3m>she</s3m>
- <s3n>it</s3n>
- <p1>we</p1>
- <p2>you</p2>
- <p3f common="1">they</p3f>
- <p3m>they</p3m>
- <p3n>they</p3n>
- </e>
- </conjugation>
-
-*/
- if (curr_conjug.size() == 0)
- return true;
-
- QDomElement domElementConjug = domDoc.createElement(KV_CONJUG_GRP);
- QString s;
-
- for (int ent = 0; ent < qMin(curr_conjug.count(), m_doc->identifierCount()); ent++)
+ // first singular conjugations
+ QString first = conjugation.pers1Singular(type);
+ QString second = conjugation.pers2Singular(type);
+ bool third_common = conjugation.pers3SingularCommon(type);
+ QString third_male = conjugation.pers3MaleSingular(type);
+ QString third_female = conjugation.pers3FemaleSingular(type);
+ QString third_neutral = conjugation.pers3NaturalSingular(type);
+
+ if (!first.isEmpty() || !second.isEmpty() || !third_female.isEmpty() ||
+ !third_male.isEmpty() || !third_neutral.isEmpty())
{
- QDomElement domElementEntry = domDoc.createElement(KV_CON_ENTRY);
-
- s = m_doc->identifier(ent).simplified();
- if (s.isEmpty())
- {
- s.setNum(ent);
- s.prepend("translation ");
- }
-
- domElementEntry.setAttribute(KV_LANG, s);
-
- if (!writeConjug(domDoc, domElementEntry, curr_conjug[ent], CONJ_PREFIX))
- return false;
-
- domElementConjug.appendChild(domElementEntry);
+ QDomElement singular = m_domDoc.createElement(KVTML_SINGULAR);
+
+ singular.appendChild(newTextElement(KVTML_1STPERSON, first));
+ singular.appendChild(newTextElement(KVTML_2NDPERSON, second));
+
+ if (third_common)
+ {
+ singular.appendChild(newTextElement(KVTML_COMMON, third_female));
+ }
+ else
+ {
+ singular.appendChild(newTextElement(KVTML_MALE, third_male));
+ singular.appendChild(newTextElement(KVTML_FEMALE, third_female));
+ singular.appendChild(newTextElement(KVTML_NEUTRAL, third_neutral));
+ }
}
-
- domElementParent.appendChild(domElementConjug);
- return true;
-}
-
-
-bool KEduVocKvtml2Writer::writeConjugEntry(QDomDocument &domDoc, QDomElement &domElementParent, KEduVocConjugation &curr_conjug)
-/*
- <conjugation> in entry for definition of tenses of (irreg.) verbs
- <t n="sipa">
- <s1>go</s1>
- <s2>go</s2>
- <s3f>goes</s3f>
- <s3m>goes</s3m>
- <s3n>goes</s3n>
- <p1>go</p1>
- <p2>go</p2>
- <p3f>go</p3f>
- <p3m>go</p3m>
- <p3n>go</p3n>
- </t>
- </conjugation>
-*/
-{
- curr_conjug.cleanUp();
- if (curr_conjug.entryCount() == 0 )
- return true;
-
- QDomElement domElementConjug = domDoc.createElement(KV_CONJUG_GRP);
- QString type;
-
- for (int lfn = 0; lfn < curr_conjug.entryCount(); lfn++)
+
+ // now for plurals
+ first = conjugation.pers1Plural(type);
+ second = conjugation.pers2Plural(type);
+ third_common = conjugation.pers3PluralCommon(type);
+ third_male = conjugation.pers3MalePlural(type);
+ third_female = conjugation.pers3FemalePlural(type);
+ third_neutral = conjugation.pers3NaturalPlural(type);
+
+ if (!first.isEmpty() || !second.isEmpty() || !third_female.isEmpty() ||
+ !third_male.isEmpty() || !third_neutral.isEmpty())
{
- QDomElement domElementType = domDoc.createElement(KV_CON_TYPE);
-
- type = curr_conjug.getType(lfn);
- domElementType.setAttribute(KV_CON_NAME, type);
-
- if (!writeConjug(domDoc, domElementType, curr_conjug, curr_conjug.getType(lfn)))
- return false;
-
- domElementConjug.appendChild(domElementType);
+ QDomElement plural = m_domDoc.createElement(KVTML_PLURAL);
+
+ plural.appendChild(newTextElement(KVTML_1STPERSON, first));
+ plural.appendChild(newTextElement(KVTML_2NDPERSON, second));
+
+ if (third_common)
+ {
+ plural.appendChild(newTextElement(KVTML_COMMON, third_female));
+ }
+ else
+ {
+ plural.appendChild(newTextElement(KVTML_MALE, third_male));
+ plural.appendChild(newTextElement(KVTML_FEMALE, third_female));
+ plural.appendChild(newTextElement(KVTML_NEUTRAL, third_neutral));
+ }
}
- domElementParent.appendChild(domElementConjug);
return true;
}
-
-bool KEduVocKvtml2Writer::writeConjug(QDomDocument &domDoc, QDomElement &domElementParent, const KEduVocConjugation &curr_conjug, const QString &type)
+QDomElement KEduVocKvtml2Writer::newTextElement(const QString &elementName, const QString &text)
{
- if (!curr_conjug.pers1Singular(type).isEmpty())
- {
- QDomElement domElementP1s = domDoc.createElement(KV_CON_P1S);
- QDomText domTextP1s = domDoc.createTextNode(curr_conjug.pers1Singular(type));
-
- domElementP1s.appendChild(domTextP1s);
- domElementParent.appendChild(domElementP1s);
- }
-
- if (!curr_conjug.pers2Singular(type).isEmpty())
- {
- QDomElement domElementP2s = domDoc.createElement(KV_CON_P2S);
- QDomText domTextP2s = domDoc.createTextNode(curr_conjug.pers2Singular(type));
-
- domElementP2s.appendChild(domTextP2s);
- domElementParent.appendChild(domElementP2s);
- }
-
- if (!curr_conjug.pers3FemaleSingular(type).isEmpty() || curr_conjug.pers3SingularCommon(type))
- {
- QDomElement domElementP3sf = domDoc.createElement(KV_CON_P3SF);
- QDomText domTextP3sf = domDoc.createTextNode(curr_conjug.pers3FemaleSingular(type));
-
- if (curr_conjug.pers3SingularCommon(type))
- domElementP3sf.setAttribute(KV_CONJ_COMMON, 1);
-
- domElementP3sf.appendChild(domTextP3sf);
- domElementParent.appendChild(domElementP3sf);
- }
-
- if (!curr_conjug.pers3MaleSingular(type).isEmpty())
- {
- QDomElement domElementP3sm = domDoc.createElement(KV_CON_P3SM);
- QDomText domTextP3sm = domDoc.createTextNode(curr_conjug.pers3MaleSingular(type));
-
- domElementP3sm.appendChild(domTextP3sm);
- domElementParent.appendChild(domElementP3sm);
- }
-
- if (!curr_conjug.pers3NaturalSingular(type).isEmpty())
- {
- QDomElement domElementP3sn = domDoc.createElement(KV_CON_P3SN);
- QDomText domTextP3sn = domDoc.createTextNode(curr_conjug.pers3NaturalSingular(type));
-
- domElementP3sn.appendChild(domTextP3sn);
- domElementParent.appendChild(domElementP3sn);
- }
-
- if (!curr_conjug.pers1Plural(type).isEmpty())
- {
- QDomElement domElementP1p = domDoc.createElement(KV_CON_P1P);
- QDomText domTextP1p = domDoc.createTextNode(curr_conjug.pers1Plural(type));
-
- domElementP1p.appendChild(domTextP1p);
- domElementParent.appendChild(domElementP1p);
- }
-
- if (!curr_conjug.pers2Plural(type).isEmpty())
- {
- QDomElement domElementP2p = domDoc.createElement(KV_CON_P2P);
- QDomText domTextP2p = domDoc.createTextNode(curr_conjug.pers2Plural(type));
-
- domElementP2p.appendChild(domTextP2p);
- domElementParent.appendChild(domElementP2p);
- }
-
- if (!curr_conjug.pers3FemalePlural(type).isEmpty() || curr_conjug.pers3PluralCommon(type))
- {
- QDomElement domElementP3pf = domDoc.createElement(KV_CON_P3PF);
- QDomText domTextP3pf = domDoc.createTextNode(curr_conjug.pers3FemalePlural(type));
-
- if (curr_conjug.pers3PluralCommon(type))
- domElementP3pf.setAttribute(KV_CONJ_COMMON, 1);
-
- domElementP3pf.appendChild(domTextP3pf);
- domElementParent.appendChild(domElementP3pf);
- }
-
- if (!curr_conjug.pers3MalePlural(type).isEmpty())
- {
- QDomElement domElementP3pm = domDoc.createElement(KV_CON_P3PM);
- QDomText domTextP3pm = domDoc.createTextNode(curr_conjug.pers3MalePlural(type));
-
- domElementP3pm.appendChild(domTextP3pm);
- domElementParent.appendChild(domElementP3pm);
- }
-
- if (!curr_conjug.pers3NaturalPlural(type).isEmpty())
- {
- QDomElement domElementP3pn = domDoc.createElement(KV_CON_P3PN);
- QDomText domTextP3pn = domDoc.createTextNode(curr_conjug.pers3NaturalPlural(type));
-
- domElementP3pn.appendChild(domTextP3pn);
- domElementParent.appendChild(domElementP3pn);
- }
-
- return true;
+ QDomElement retval = m_domDoc.createElement(elementName);
+ QDomText textNode = m_domDoc.createTextNode(text);
+ retval.appendChild(textNode);
+ return retval;
}