From 033056cde1aff7b1fde26c7944b147e2431c0211 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 14 Jun 2007 12:19:46 +0000 Subject: [PATCH] Use childElement functions instead of elementsByTagName. When parsing for the identifiers in the first expression, this found conjugations which also have the tag otherwise. Hurray to kvtml. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=675541 --- kdeeducore/keduvockvtmlreader.cpp | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/kdeeducore/keduvockvtmlreader.cpp b/kdeeducore/keduvockvtmlreader.cpp index 2a059c2..5753449 100644 --- a/kdeeducore/keduvockvtmlreader.cpp +++ b/kdeeducore/keduvockvtmlreader.cpp @@ -1127,27 +1127,26 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) // Children 'Translation' //------------------------------------------------------------------------- - QDomNodeList translationList = domElementParent.elementsByTagName(KV_TRANS); - for (int i = 0; i < 1 + translationList.count(); ++i) - { - if (i == 0) - { - currentElement = domElementParent.firstChildElement(KV_ORG); - } - else - { - currentElement = translationList.item(i - 1).toElement(); - } - if (i == 0 && currentElement.isNull()) - { - m_errorMessage = i18n("Data for original language missing"); - return false; + //QDomNodeList translationList = domElementParent.elementsByTagName(KV_TRANS); + + // count which translation we are on + int i=0; + + // kvtml 1: we always have an original element (required) + currentElement = domElementParent.firstChildElement(KV_ORG); + if (currentElement.isNull()) { // sanity check + m_errorMessage = i18n("Data for original language missing"); + return false; } + while (!currentElement.isNull()) { type = exprtype; //----------- // Attributes + //----------- + + // read attributes - the order of the query grades is interchanged! if (i == 0 && !readExpressionChildAttributes( currentElement, lang, grade, r_grade, qcount, r_qcount, qdate, r_qdate, remark, bcount, r_bcount, query_id, pronunciation, width, type, faux_ami_t, faux_ami_f, synonym, example, antonym, usage, paraphrase)) return false; @@ -1159,6 +1158,8 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) if (m_doc->entryCount() == 0) { + + // only accept in first entry if (width >= 0) m_doc->setSizeHint(i, width); @@ -1167,9 +1168,10 @@ bool KEduVocKvtmlReader::readExpression(QDomElement &domElementParent) q_org = lang; if (query_id == KV_T) + q_trans = lang; } -kDebug() << " Entry count: " << m_doc->entryCount() << endl; +//kDebug() << " TranslationList.count(): " << translationList.count() << " Entry count: " << m_doc->entryCount() << endl; if (m_doc->entryCount() == 0) { // this is because in kvtml the languages are saved in the FIRST ENTRY ONLY. kDebug() << " Read Expression with identifiers: " << i << endl; // new translation @@ -1225,20 +1227,16 @@ kDebug() << " Read Expression with identifiers: " << i << endl; if (textstr.isNull()) textstr = ""; - if (i == 0) - { + if (i == 0) { expr = KEduVocExpression(textstr); expr.setLesson(lesson); expr.setInQuery(inquery); expr.setActive(active); - } - else - { + } else { expr.setTranslation(i, textstr); } - if (conjug.size() > 0) - { + if (conjug.size() > 0) { for ( int conjugationIndex = 0; conjugationIndex < conjug.size(); conjugationIndex++ ) { expr.translation(i).setConjugation(conjug[conjugationIndex]); } @@ -1276,6 +1274,10 @@ kDebug() << " Read Expression with identifiers: " << i << endl; expr.translation(i).setParaphrase (paraphrase); if (!antonym.isEmpty() ) expr.translation(i).setAntonym (antonym); + + // Next translation + currentElement = currentElement.nextSiblingElement(KV_TRANS); + i++; } if (m_doc->entryCount() == 0) -- 2.47.3