00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "keduvockvtmlreader.h"
00021
00022 #include <QtCore/QTextStream>
00023 #include <QtCore/QList>
00024 #include <QtCore/QIODevice>
00025
00026 #include <kdebug.h>
00027 #include <klocale.h>
00028 #include <kglobal.h>
00029
00030 #include "keduvocdocument.h"
00031 #include "keduvoclesson.h"
00032 #include "keduvocwordtype.h"
00033 #include "kvtmldefs.h"
00034 #include "keduvoccommon_p.h"
00035
00036 KEduVocKvtmlReader::KEduVocKvtmlReader( QIODevice *file )
00037 {
00038
00039 m_inputFile = file;
00040 m_errorMessage = "";
00041 kDebug() << "KEduVocKvtmlReader for kvtml version 1 files started.";
00042 }
00043
00044
00045 bool KEduVocKvtmlReader::readDoc( KEduVocDocument *doc )
00046 {
00047 m_doc = doc;
00048 m_cols = 0;
00049 m_lines = 0;
00050
00051 QDomDocument domDoc( "KEduVocDocument" );
00052
00053 if ( !domDoc.setContent( m_inputFile, &m_errorMessage ) )
00054 return false;
00055
00056 QDomElement domElementKvtml = domDoc.documentElement();
00057 if ( domElementKvtml.tagName() != KV_DOCTYPE ) {
00058 m_errorMessage = i18n( "This is not a KDE Vocabulary document." );
00059 return false;
00060 }
00061
00062
00063
00064
00065
00066 QDomAttr documentAttribute;
00067 documentAttribute = domElementKvtml.attributeNode( KV_ENCODING );
00068 if ( !documentAttribute.isNull() ) {
00069
00070
00071 }
00072
00073 documentAttribute = domElementKvtml.attributeNode( KV_TITLE );
00074 if ( !documentAttribute.isNull() )
00075 m_doc->setTitle( documentAttribute.value() );
00076
00077 documentAttribute = domElementKvtml.attributeNode( KV_AUTHOR );
00078 if ( !documentAttribute.isNull() )
00079 m_doc->setAuthor( documentAttribute.value() );
00080
00081 documentAttribute = domElementKvtml.attributeNode( KV_LICENSE );
00082 if ( !documentAttribute.isNull() )
00083 m_doc->setLicense( documentAttribute.value() );
00084
00085 documentAttribute = domElementKvtml.attributeNode( KV_DOC_REM );
00086 if ( !documentAttribute.isNull() )
00087 m_doc->setDocumentComment( documentAttribute.value() );
00088
00089 documentAttribute = domElementKvtml.attributeNode( KV_GENERATOR );
00090 if ( !documentAttribute.isNull() ) {
00091 m_doc->setGenerator( documentAttribute.value() );
00092 int pos = m_doc->generator().lastIndexOf( KVD_VERS_PREFIX );
00093 if ( pos >= 0 )
00094 m_doc->setVersion( m_doc->generator().remove( 0, pos + 2 ) );
00095 }
00096
00097 documentAttribute = domElementKvtml.attributeNode( KV_COLS );
00098 if ( !documentAttribute.isNull() )
00099 m_cols = documentAttribute.value().toInt();
00100
00101 documentAttribute = domElementKvtml.attributeNode( KV_LINES );
00102 if ( !documentAttribute.isNull() )
00103 m_lines = documentAttribute.value().toInt();
00104
00105
00106
00107
00108
00109 bool result = readBody( domElementKvtml );
00110
00111 return result;
00112 }
00113
00114
00115 bool KEduVocKvtmlReader::readBody( QDomElement &domElementParent )
00116 {
00117 bool result = false;
00118
00119 QDomElement currentElement;
00120
00121 currentElement = domElementParent.firstChildElement( KV_LESS_GRP );
00122 if ( !currentElement.isNull() ) {
00123 result = readLesson( currentElement );
00124 if ( !result )
00125 return false;
00126 }
00127
00128 currentElement = domElementParent.firstChildElement( KV_ARTICLE_GRP );
00129 if ( !currentElement.isNull() ) {
00130 result = readArticle( currentElement );
00131 if ( !result )
00132 return false;
00133 }
00134
00135 currentElement = domElementParent.firstChildElement( KV_CONJUG_GRP );
00136 if ( !currentElement.isNull() ) {
00137 int count = 0;
00138
00139 QDomElement domElementConjugChild = currentElement.firstChildElement(KV_CON_ENTRY);
00140 while ( !domElementConjugChild.isNull() ) {
00141 QString lang;
00142 QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_LANG );
00143
00144 if (!addLanguage(count, domAttrLang.value())) {
00145 return false;
00146 }
00147
00148 KEduVocPersonalPronoun pronouns;
00149 if (! readPersonalPronouns( domElementConjugChild, pronouns ) ) {
00150 return false;
00151 }
00152 m_doc->identifier(count).setPersonalPronouns( pronouns );
00153
00154 count ++;
00155
00156 domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_ENTRY );
00157 }
00158 }
00159
00160
00161 m_compability.setupWordTypes(m_doc->wordTypeContainer());
00162
00163 currentElement = domElementParent.firstChildElement( KV_TYPE_GRP );
00164 if ( !currentElement.isNull() ) {
00165 result = readType( currentElement );
00166 if ( !result )
00167 return false;
00168 }
00169
00170 currentElement = domElementParent.firstChildElement( KV_TENSE_GRP );
00171 if ( !currentElement.isNull() ) {
00172 result = readTense( currentElement );
00173 if ( !result )
00174 return false;
00175 }
00176
00177 QDomNodeList entryList = domElementParent.elementsByTagName( KV_EXPR );
00178 if ( entryList.length() <= 0 )
00179 return false;
00180
00181 for ( int i = 0; i < entryList.count(); ++i ) {
00182 currentElement = entryList.item( i ).toElement();
00183 if ( currentElement.parentNode() == domElementParent ) {
00184 result = readExpression( currentElement );
00185 if ( !result )
00186 return false;
00187 }
00188 }
00189
00190 for(int i = 0; i < m_doc->identifierCount(); i++) {
00191 m_doc->identifier(i).setTenseList(m_compability.documentTenses());
00192 }
00193
00194 return true;
00195 }
00196
00197
00198 bool KEduVocKvtmlReader::readLesson( QDomElement &domElementParent )
00199 {
00200 QString s;
00201 QDomAttr attribute;
00202 QDomElement currentElement;
00203
00204
00205
00206
00207
00208
00209 QDomNodeList entryList = domElementParent.elementsByTagName( KV_LESS_DESC );
00210 if ( entryList.length() <= 0 )
00211 return false;
00212
00213 for ( int i = 0; i < entryList.count(); ++i ) {
00214 currentElement = entryList.item( i ).toElement();
00215 if ( currentElement.parentNode() == domElementParent ) {
00216 int no = -1;
00217
00218 attribute = currentElement.attributeNode( KV_LESS_NO );
00219 if ( !attribute.isNull() ) {
00220 no = attribute.value().toInt();
00221 }
00222
00223 bool inQuery = false;
00224 attribute = currentElement.attributeNode( KV_LESS_QUERY );
00225 if ( !attribute.isNull() ) {
00226 inQuery = (attribute.value().toInt() != 0);
00227 }
00228
00229 s = currentElement.text();
00230 KEduVocLesson* lesson = new KEduVocLesson(s, m_doc->lesson());
00231 lesson->setInPractice(inQuery);
00232 m_doc->lesson()->appendChildContainer( lesson );
00233 if ( m_doc->lesson()->childContainerCount() != no-1 ) {
00234 kDebug() << "Warning! Lesson order may be confused. Are all lessons in order in the file?";
00235 }
00236 }
00237 }
00238
00239 return true;
00240 }
00241
00242
00243 bool KEduVocKvtmlReader::readArticle( QDomElement &domElementParent )
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 {
00257
00258 QString s;
00259 QDomAttr attribute;
00260 QDomElement currentElement;
00261 QDomElement article;
00262
00263 QDomNodeList entryList = domElementParent.elementsByTagName( KV_ART_ENTRY );
00264 if ( entryList.length() <= 0 )
00265 return false;
00266
00267 for ( int i = 0; i < entryList.count(); ++i ) {
00268
00269
00270 currentElement = entryList.item( i ).toElement();
00271 if ( currentElement.parentNode() == domElementParent ) {
00272 QString lang;
00273 attribute = currentElement.attributeNode( KV_LANG );
00274
00275 if (!addLanguage(i, attribute.value())) {
00276 return false;
00277 }
00278
00279
00280
00281
00282 QString fem_def = "";
00283 QString mal_def = "";
00284 QString nat_def = "";
00285 QString fem_indef = "";
00286 QString mal_indef = "";
00287 QString nat_indef = "";
00288
00289 article = currentElement.firstChildElement( KV_ART_FD );
00290 if ( !article.isNull() ) {
00291 fem_def = article.text();
00292 if ( fem_def.isNull() )
00293 fem_def = "";
00294 }
00295
00296 article = currentElement.firstChildElement( KV_ART_FI );
00297 if ( !article.isNull() ) {
00298 fem_indef = article.text();
00299 if ( fem_indef.isNull() )
00300 fem_indef = "";
00301 }
00302
00303 article = currentElement.firstChildElement( KV_ART_MD );
00304 if ( !article.isNull() ) {
00305 mal_def = article.text();
00306 if ( mal_def.isNull() )
00307 mal_def = "";
00308 }
00309
00310 article = currentElement.firstChildElement( KV_ART_MI );
00311 if ( !article.isNull() ) {
00312 mal_indef = article.text();
00313 if ( mal_indef.isNull() )
00314 mal_indef = "";
00315 }
00316
00317 article = currentElement.firstChildElement( KV_ART_ND );
00318 if ( !article.isNull() ) {
00319 nat_def = article.text();
00320 if ( nat_def.isNull() )
00321 nat_def = "";
00322 }
00323
00324 article = currentElement.firstChildElement( KV_ART_NI );
00325 if ( !article.isNull() ) {
00326 nat_indef = article.text();
00327 if ( nat_indef.isNull() )
00328 nat_indef = "";
00329 }
00330
00331 m_doc->identifier(i).setArticle( KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
00332 }
00333 }
00334
00335 return true;
00336 }
00337
00338
00339 bool KEduVocKvtmlReader::readTranslationConjugations( QDomElement &domElementParent, KEduVocTranslation* translation )
00340 {
00341 QString tense;
00342
00343 QDomElement domElementConjugChild = domElementParent.firstChildElement(KV_CON_TYPE);
00344 while ( !domElementConjugChild.isNull() )
00345 {
00346
00347 QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_CON_NAME );
00348 QString oldShortTense = domAttrLang.value();
00349
00350 tense = m_compability.tenseFromKvtml1( oldShortTense );
00351 KEduVocConjugation conjugation;
00352 readConjugation(domElementConjugChild, conjugation);
00353 translation->setConjugation(tense, conjugation);
00354
00355 domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_TYPE );
00356 }
00357 return true;
00358 }
00359
00360 bool KEduVocKvtmlReader::readConjugation( QDomElement &domElementParent, KEduVocConjugation& conjugation )
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 {
00393
00394 bool p3_common;
00395 bool s3_common;
00396 QString pers1_sing;
00397 QString pers2_sing;
00398 QString pers3_m_sing;
00399 QString pers3_f_sing;
00400 QString pers3_n_sing;
00401 QString pers1_plur;
00402 QString pers2_plur;
00403 QString pers3_m_plur;
00404 QString pers3_f_plur;
00405 QString pers3_n_plur;
00406
00407 p3_common = false;
00408 s3_common = false;
00409
00410
00411 QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement();
00412 while ( !domElementConjugGrandChild.isNull() ) {
00413 if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) {
00414 pers1_sing = domElementConjugGrandChild.text();
00415 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) {
00416 pers2_sing = domElementConjugGrandChild.text();
00417 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) {
00418 QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
00419 if ( !domAttrCommon.isNull() )
00420 s3_common = domAttrCommon.value().toInt();
00421 pers3_f_sing = domElementConjugGrandChild.text();
00422
00423 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) {
00424 pers3_m_sing = domElementConjugGrandChild.text();
00425
00426 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) {
00427 pers3_n_sing = domElementConjugGrandChild.text();
00428
00429 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) {
00430 pers1_plur = domElementConjugGrandChild.text();
00431
00432 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) {
00433 pers2_plur = domElementConjugGrandChild.text();
00434
00435 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) {
00436 QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
00437 if ( !domAttrCommon.isNull() )
00438 p3_common = domAttrCommon.value().toInt();
00439
00440 pers3_f_plur = domElementConjugGrandChild.text();
00441
00442 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) {
00443 pers3_m_plur = domElementConjugGrandChild.text();
00444
00445 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) {
00446 pers3_n_plur = domElementConjugGrandChild.text();
00447
00448 } else {
00449 return false;
00450 }
00451
00452 domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement();
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 const KEduVocWordFlags numS = KEduVocWordFlag::Singular;
00464 const KEduVocWordFlags numP = KEduVocWordFlag::Plural;
00465
00466 conjugation.setConjugation( pers1_sing, KEduVocWordFlag::First | numS);
00467 conjugation.setConjugation( pers2_sing, KEduVocWordFlag::Second | numS);
00468 conjugation.setConjugation( pers1_plur, KEduVocWordFlag::First | numP);
00469 conjugation.setConjugation( pers2_plur, KEduVocWordFlag::Second | numP);
00470
00471 if ( s3_common ) {
00472 conjugation.setConjugation( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular );
00473 } else {
00474 conjugation.setConjugation( pers3_m_sing,
00475 KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Singular );
00476 conjugation.setConjugation( pers3_f_sing,
00477 KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Singular );
00478 conjugation.setConjugation( pers3_n_sing,
00479 KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular );
00480 }
00481
00482 if ( p3_common ) {
00483 conjugation.setConjugation( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural );
00484 } else {
00485 conjugation.setConjugation( pers3_m_plur,
00486 KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Plural );
00487 conjugation.setConjugation( pers3_f_plur,
00488 KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Plural );
00489 conjugation.setConjugation( pers3_n_plur,
00490 KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural );
00491 }
00492
00493 return true;
00494 }
00495
00496
00497
00498
00499 bool KEduVocKvtmlReader::readPersonalPronouns( QDomElement &domElementParent, KEduVocPersonalPronoun& pronouns )
00500 {
00501
00502 bool p3_common;
00503 bool s3_common;
00504 QString pers1_sing;
00505 QString pers2_sing;
00506 QString pers3_m_sing;
00507 QString pers3_f_sing;
00508 QString pers3_n_sing;
00509 QString pers1_plur;
00510 QString pers2_plur;
00511 QString pers3_m_plur;
00512 QString pers3_f_plur;
00513 QString pers3_n_plur;
00514
00515 p3_common = false;
00516 s3_common = false;
00517
00518
00519 QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement();
00520 while ( !domElementConjugGrandChild.isNull() ) {
00521 if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) {
00522 pers1_sing = domElementConjugGrandChild.text();
00523 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) {
00524 pers2_sing = domElementConjugGrandChild.text();
00525 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) {
00526 QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
00527 if ( !domAttrCommon.isNull() )
00528 s3_common = domAttrCommon.value().toInt();
00529 pers3_f_sing = domElementConjugGrandChild.text();
00530
00531 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) {
00532 pers3_m_sing = domElementConjugGrandChild.text();
00533
00534 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) {
00535 pers3_n_sing = domElementConjugGrandChild.text();
00536
00537 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) {
00538 pers1_plur = domElementConjugGrandChild.text();
00539
00540 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) {
00541 pers2_plur = domElementConjugGrandChild.text();
00542
00543 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) {
00544 QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
00545 if ( !domAttrCommon.isNull() )
00546 p3_common = domAttrCommon.value().toInt();
00547
00548 pers3_f_plur = domElementConjugGrandChild.text();
00549
00550 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) {
00551 pers3_m_plur = domElementConjugGrandChild.text();
00552
00553 } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) {
00554 pers3_n_plur = domElementConjugGrandChild.text();
00555
00556 } else {
00557 return false;
00558 }
00559
00560 domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement();
00561 }
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 KEduVocWordFlags numS = KEduVocWordFlag::Singular;
00572 pronouns.setMaleFemaleDifferent(false);
00573 pronouns.setPersonalPronoun( pers1_sing, KEduVocWordFlag::First | numS );
00574 pronouns.setPersonalPronoun( pers2_sing, KEduVocWordFlag::Second | numS );
00575
00576
00577 if ( s3_common ) {
00578 pronouns.setPersonalPronoun( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS );
00579 } else {
00580 pronouns.setPersonalPronoun( pers3_m_sing,
00581 KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numS );
00582 pronouns.setPersonalPronoun( pers3_f_sing,
00583 KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numS );
00584 pronouns.setPersonalPronoun( pers3_n_sing,
00585 KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS );
00586 pronouns.setMaleFemaleDifferent(true);
00587 }
00588
00589 KEduVocWordFlags numP = KEduVocWordFlag::Plural;
00590
00591 pronouns.setPersonalPronoun( pers1_plur, KEduVocWordFlag::First | numP );
00592 pronouns.setPersonalPronoun( pers2_plur, KEduVocWordFlag::Second | numP );
00593 if ( p3_common ) {
00594 pronouns.setPersonalPronoun( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP );
00595 } else {
00596 pronouns.setPersonalPronoun( pers3_m_plur,
00597 KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numP );
00598 pronouns.setPersonalPronoun( pers3_f_plur,
00599 KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numP );
00600 pronouns.setPersonalPronoun( pers3_n_plur,
00601 KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP );
00602 pronouns.setMaleFemaleDifferent(true);
00603 }
00604
00605 return true;
00606 }
00607
00608
00609 bool KEduVocKvtmlReader::readType( QDomElement &domElementParent )
00610 {
00611 QString s;
00612 QDomElement currentElement;
00613
00614 QDomNodeList entryList = domElementParent.elementsByTagName( KV_TYPE_DESC );
00615 if ( entryList.length() <= 0 )
00616 return false;
00617
00618 for ( int i = 0; i < entryList.count(); ++i ) {
00619 currentElement = entryList.item( i ).toElement();
00620 if ( currentElement.parentNode() == domElementParent ) {
00621
00622
00623
00624 kDebug() << "Adding old self defined type: " << currentElement.text();
00625
00626 KEduVocWordType* type = new KEduVocWordType(currentElement.text(), m_doc->wordTypeContainer());
00627 m_doc->wordTypeContainer()->appendChildContainer( type );
00628
00629
00630 m_oldSelfDefinedTypes.append( currentElement.text() );
00631 }
00632 }
00633
00634 return true;
00635 }
00636
00637
00638 bool KEduVocKvtmlReader::readTense( QDomElement &domElementParent )
00639 {
00640 QDomElement currentElement;
00641
00642 currentElement = domElementParent.firstChildElement( KV_TENSE_DESC );
00643 while ( !currentElement.isNull() ) {
00644 kDebug() << "Reading user defined tense description: " << currentElement.text();
00645 m_compability.addUserdefinedTense( currentElement.text() );
00646 currentElement = currentElement.nextSiblingElement( KV_TENSE_DESC );
00647 }
00648 return true;
00649 }
00650
00651
00652 bool KEduVocKvtmlReader::readComparison( QDomElement &domElementParent, KEduVocTranslation * translation )
00653
00654
00655
00656
00657
00658
00659
00660 {
00661 QDomElement currentElement;
00662
00663 currentElement = domElementParent.firstChildElement( KV_COMP_L2 );
00664 translation->setComparative(currentElement.text());
00665
00666 currentElement = domElementParent.firstChildElement( KV_COMP_L3 );
00667 translation->setSuperlative(currentElement.text());
00668
00669 return true;
00670 }
00671
00672
00673 bool KEduVocKvtmlReader::readMultipleChoice( QDomElement &domElementParent, KEduVocTranslation* translation )
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684 {
00685 QDomElement currentElement;
00686
00687 currentElement = domElementParent.firstChildElement( KV_MC_1 );
00688 if ( !currentElement.isNull() ) {
00689 translation->multipleChoice().append( currentElement.text() );
00690 }
00691
00692 currentElement = domElementParent.firstChildElement( KV_MC_2 );
00693 if ( !currentElement.isNull() ) {
00694 translation->multipleChoice().append( currentElement.text() );
00695 }
00696
00697 currentElement = domElementParent.firstChildElement( KV_MC_3 );
00698 if ( !currentElement.isNull() ) {
00699 translation->multipleChoice().append( currentElement.text() );
00700 }
00701
00702 currentElement = domElementParent.firstChildElement( KV_MC_4 );
00703 if ( !currentElement.isNull() ) {
00704 translation->multipleChoice().append( currentElement.text() );
00705 }
00706
00707 currentElement = domElementParent.firstChildElement( KV_MC_5 );
00708 if ( !currentElement.isNull() ) {
00709 translation->multipleChoice().append( currentElement.text() );
00710 }
00711
00712 return true;
00713 }
00714
00715
00716 bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementExpressionChild,
00717 QString &lang,
00718 grade_t &grade, grade_t &rev_grade,
00719 int &count, int &rev_count,
00720 QDateTime &date, QDateTime &rev_date,
00721 QString &remark,
00722 int &bcount, int &rev_bcount,
00723 QString &query_id,
00724 QString &pronunciation,
00725 int &width,
00726 QString &type,
00727 QString &faux_ami_f,
00728 QString &faux_ami_t,
00729 QString &synonym,
00730 QString &example,
00731 QString &antonym,
00732 QSet<QString> &usages,
00733 QString ¶phrase )
00734 {
00735 int pos;
00736 QDomAttr attribute;
00737
00738 lang = "";
00739 attribute = domElementExpressionChild.attributeNode( KV_LANG );
00740 if ( !attribute.isNull() )
00741 lang = attribute.value();
00742
00743 width = -1;
00744 attribute = domElementExpressionChild.attributeNode( KV_SIZEHINT );
00745 if ( !attribute.isNull() )
00746 width = attribute.value().toInt();
00747
00748 grade = KV_NORM_GRADE;
00749 rev_grade = KV_NORM_GRADE;
00750 attribute = domElementExpressionChild.attributeNode( KV_GRADE );
00751 if ( !attribute.isNull() ) {
00752 QString s = attribute.value();
00753 if (( pos = s.indexOf( ';' ) ) >= 1 ) {
00754 grade = s.left( pos ).toInt();
00755 rev_grade = s.mid( pos + 1, s.length() ).toInt();
00756 } else
00757 grade = s.toInt();
00758 }
00759
00760 count = 0;
00761 rev_count = 0;
00762 attribute = domElementExpressionChild.attributeNode( KV_COUNT );
00763 if ( !attribute.isNull() ) {
00764 QString s = attribute.value();
00765 if (( pos = s.indexOf( ';' ) ) >= 1 ) {
00766 count = s.left( pos ).toInt();
00767 rev_count = s.mid( pos + 1, s.length() ).toInt();
00768 } else
00769 count = s.toInt();
00770 }
00771
00772 bcount = 0;
00773 rev_bcount = 0;
00774 attribute = domElementExpressionChild.attributeNode( KV_BAD );
00775 if ( !attribute.isNull() ) {
00776 QString s = attribute.value();
00777 if (( pos = s.indexOf( ';' ) ) >= 1 ) {
00778 bcount = s.left( pos ).toInt();
00779 rev_bcount = s.mid( pos + 1, s.length() ).toInt();
00780 } else
00781 bcount = s.toInt();
00782 }
00783
00784 date.setTime_t( 0 );
00785 rev_date.setTime_t( 0 );
00786 attribute = domElementExpressionChild.attributeNode( KV_DATE );
00787 if ( !attribute.isNull() ) {
00788 QString s = attribute.value();
00789 if (( pos = s.indexOf( ';' ) ) >= 1 ) {
00790 date.setTime_t( s.left( pos ).toInt() );
00791 rev_date.setTime_t( s.mid( pos + 1, s.length() ).toInt() );
00792 } else
00793 date.setTime_t( s.toInt() );
00794 }
00795
00796 attribute = domElementExpressionChild.attributeNode( KV_DATE2 );
00797 if ( !attribute.isNull() ) {
00798
00799 }
00800
00801 remark = "";
00802 attribute = domElementExpressionChild.attributeNode( KV_REMARK );
00803 if ( !attribute.isNull() )
00804 remark = attribute.value();
00805
00806 faux_ami_f = "";
00807 attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_F );
00808 if ( !attribute.isNull() )
00809 faux_ami_f = attribute.value();
00810
00811 faux_ami_t = "";
00812 attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_T );
00813 if ( !attribute.isNull() )
00814 faux_ami_t = attribute.value();
00815
00816 synonym = "";
00817 attribute = domElementExpressionChild.attributeNode( KV_SYNONYM );
00818 if ( !attribute.isNull() )
00819 synonym = attribute.value();
00820
00821 example = "";
00822 attribute = domElementExpressionChild.attributeNode( KV_EXAMPLE );
00823 if ( !attribute.isNull() )
00824 example = attribute.value();
00825
00826 paraphrase = "";
00827 attribute = domElementExpressionChild.attributeNode( KV_PARAPHRASE );
00828 if ( !attribute.isNull() )
00829 paraphrase = attribute.value();
00830
00831 antonym = "";
00832 attribute = domElementExpressionChild.attributeNode( KV_ANTONYM );
00833 if ( !attribute.isNull() )
00834 antonym = attribute.value();
00835
00836
00837 attribute = domElementExpressionChild.attributeNode( KV_EXPRTYPE );
00838 if ( !attribute.isNull() ) {
00839 type = attribute.value();
00840 }
00841
00842 pronunciation = "";
00843 attribute = domElementExpressionChild.attributeNode( KV_PRONUNCE );
00844 if ( !attribute.isNull() )
00845 pronunciation = attribute.value();
00846
00847 query_id = "";
00848 attribute = domElementExpressionChild.attributeNode( KV_QUERY );
00849 if ( !attribute.isNull() )
00850 query_id = attribute.value();
00851
00852 return true;
00853 }
00854
00855
00856 bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent )
00857 {
00858 grade_t grade;
00859 grade_t r_grade;
00860 int qcount;
00861 int r_qcount;
00862 int bcount;
00863 int r_bcount;
00864 QString remark;
00865 QString pronunciation;
00866 QDateTime qdate;
00867 QDateTime r_qdate;
00868 bool inquery;
00869 bool active;
00870