• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

libkdeedu/keduvocdocument

  • sources
  • kde-4.12
  • kdeedu
  • libkdeedu
  • keduvocdocument
keduvockvtmlreader.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  read a KEduVocDocument from a KVTML file
3  -----------------------------------------------------------------------
4  copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
5 
6  (C) 2005 Eric Pignet <eric at erixpage.com>
7  (C) 2007 Peter Hedlund <peter.hedlund@kdemail.net>
8  (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #include "keduvockvtmlreader.h"
21 
22 #include <QtCore/QTextStream>
23 #include <QtCore/QList>
24 #include <QtCore/QIODevice>
25 
26 #include <kdebug.h>
27 #include <klocale.h>
28 #include <kglobal.h>
29 
30 #include "keduvocdocument.h"
31 #include "keduvoclesson.h"
32 #include "keduvocwordtype.h"
33 #include "kvtmldefs.h"
34 #include "keduvoccommon_p.h"
35 
36 KEduVocKvtmlReader::KEduVocKvtmlReader( QIODevice *file )
37 {
38  // the file must be already open
39  m_inputFile = file;
40  m_errorMessage = "";
41  kDebug() << "KEduVocKvtmlReader for kvtml version 1 files started.";
42 }
43 
44 
45 bool KEduVocKvtmlReader::readDoc( KEduVocDocument *doc )
46 {
47  m_doc = doc;
48  m_cols = 0;
49  m_lines = 0;
50 
51  QDomDocument domDoc( "KEduVocDocument" );
52 
53  if ( !domDoc.setContent( m_inputFile, &m_errorMessage ) )
54  return false;
55 
56  QDomElement domElementKvtml = domDoc.documentElement();
57  if ( domElementKvtml.tagName() != KV_DOCTYPE ) {
58  m_errorMessage = i18n( "This is not a KDE Vocabulary document." );
59  return false;
60  }
61 
62  //-------------------------------------------------------------------------
63  // Attributes
64  //-------------------------------------------------------------------------
65 
66  QDomAttr documentAttribute;
67  documentAttribute = domElementKvtml.attributeNode( KV_ENCODING );
68  if ( !documentAttribute.isNull() ) {
69  // TODO handle old encodings
70  // Qt DOM API autodetects encoding, so is there anything to do ?
71  }
72 
73  documentAttribute = domElementKvtml.attributeNode( KV_TITLE );
74  if ( !documentAttribute.isNull() )
75  m_doc->setTitle( documentAttribute.value() );
76 
77  documentAttribute = domElementKvtml.attributeNode( KV_AUTHOR );
78  if ( !documentAttribute.isNull() )
79  m_doc->setAuthor( documentAttribute.value() );
80 
81  documentAttribute = domElementKvtml.attributeNode( KV_LICENSE );
82  if ( !documentAttribute.isNull() )
83  m_doc->setLicense( documentAttribute.value() );
84 
85  documentAttribute = domElementKvtml.attributeNode( KV_DOC_REM );
86  if ( !documentAttribute.isNull() )
87  m_doc->setDocumentComment( documentAttribute.value() );
88 
89  documentAttribute = domElementKvtml.attributeNode( KV_GENERATOR );
90  if ( !documentAttribute.isNull() ) {
91  m_doc->setGenerator( documentAttribute.value() );
92  int pos = m_doc->generator().lastIndexOf( KVD_VERS_PREFIX );
93  if ( pos >= 0 )
94  m_doc->setVersion( m_doc->generator().remove( 0, pos + 2 ) );
95  }
96 
97  documentAttribute = domElementKvtml.attributeNode( KV_COLS );
98  if ( !documentAttribute.isNull() )
99  m_cols = documentAttribute.value().toInt();
100 
101  documentAttribute = domElementKvtml.attributeNode( KV_LINES );
102  if ( !documentAttribute.isNull() )
103  m_lines = documentAttribute.value().toInt();
104 
105  //-------------------------------------------------------------------------
106  // Children
107  //-------------------------------------------------------------------------
108 
109  bool result = readBody( domElementKvtml ); // read vocabulary
110 
111  return result;
112 }
113 
114 
115 bool KEduVocKvtmlReader::readBody( QDomElement &domElementParent )
116 {
117  bool result = false;
118 
119  QDomElement currentElement;
120 
121  currentElement = domElementParent.firstChildElement( KV_LESS_GRP );
122  if ( !currentElement.isNull() ) {
123  result = readLesson( currentElement );
124  if ( !result )
125  return false;
126  }
127 
128  currentElement = domElementParent.firstChildElement( KV_ARTICLE_GRP );
129  if ( !currentElement.isNull() ) {
130  result = readArticle( currentElement );
131  if ( !result )
132  return false;
133  }
134 
135  currentElement = domElementParent.firstChildElement( KV_CONJUG_GRP );
136  if ( !currentElement.isNull() ) {
137  int count = 0;
138 
139  QDomElement domElementConjugChild = currentElement.firstChildElement(KV_CON_ENTRY);
140  while ( !domElementConjugChild.isNull() ) {
141  QString lang;
142  QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_LANG ); // "l"
143  // make sure, the identifier is there
144  if (!addLanguage(count, domAttrLang.value())) {
145  return false;
146  }
147 
148  KEduVocPersonalPronoun pronouns;
149  if (! readPersonalPronouns( domElementConjugChild, pronouns ) ) {
150  return false;
151  }
152  m_doc->identifier(count).setPersonalPronouns( pronouns );
153 
154  count ++;
155 
156  domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_ENTRY );
157  }
158  }
159 
160  // initialize the list of predefined types
161  m_compability.setupWordTypes(m_doc->wordTypeContainer());
162 
163  currentElement = domElementParent.firstChildElement( KV_TYPE_GRP );
164  if ( !currentElement.isNull() ) {
165  result = readType( currentElement );
166  if ( !result )
167  return false;
168  }
169 
170  currentElement = domElementParent.firstChildElement( KV_TENSE_GRP );
171  if ( !currentElement.isNull() ) {
172  result = readTense( currentElement );
173  if ( !result )
174  return false;
175  }
176 
177  QDomNodeList entryList = domElementParent.elementsByTagName( KV_EXPR );
178  if ( entryList.length() <= 0 )
179  return false;
180 
181  for ( int i = 0; i < entryList.count(); ++i ) {
182  currentElement = entryList.item( i ).toElement();
183  if ( currentElement.parentNode() == domElementParent ) {
184  result = readExpression( currentElement );
185  if ( !result )
186  return false;
187  }
188  }
189 
190  for(int i = 0; i < m_doc->identifierCount(); i++) {
191  m_doc->identifier(i).setTenseList(m_compability.documentTenses());
192  }
193 
194  return true;
195 }
196 
197 
198 bool KEduVocKvtmlReader::readLesson( QDomElement &domElementParent )
199 {
200  QString s;
201  QDomAttr attribute;
202  QDomElement currentElement;
203 
204 
205  //-------------------------------------------------------------------------
206  // Children
207  //-------------------------------------------------------------------------
208 
209  QDomNodeList entryList = domElementParent.elementsByTagName( KV_LESS_DESC );
210  if ( entryList.length() <= 0 )
211  return false;
212 
213  for ( int i = 0; i < entryList.count(); ++i ) {
214  currentElement = entryList.item( i ).toElement();
215  if ( currentElement.parentNode() == domElementParent ) {
216  int no = -1;
217 
218  attribute = currentElement.attributeNode( KV_LESS_NO );
219  if ( !attribute.isNull() ) {
220  no = attribute.value().toInt();
221  }
222 
223  bool inQuery = false;
224  attribute = currentElement.attributeNode( KV_LESS_QUERY );
225  if ( !attribute.isNull() ) {
226  inQuery = (attribute.value().toInt() != 0);
227  }
228 
229  s = currentElement.text();
230  KEduVocLesson* lesson = new KEduVocLesson(s, m_doc->lesson());
231  lesson->setInPractice(inQuery);
232  m_doc->lesson()->appendChildContainer( lesson );
233  if ( m_doc->lesson()->childContainerCount() != no-1 ) {
234  kDebug() << "Warning! Lesson order may be confused. Are all lessons in order in the file?";
235  }
236  }
237  }
238 
239  return true;
240 }
241 
242 
243 bool KEduVocKvtmlReader::readArticle( QDomElement &domElementParent )
244 /*
245  <article>
246  <e l="de"> lang determines also lang order in entries !!
247  <fi>eine</fi> which must NOT differ
248  <fd>die</fd>
249  <mi>ein</mi>
250  <md>der</md>
251  <ni>ein</ni>
252  <nd>das</nd>
253  </e>
254  </article>
255 */
256 {
257 
258  QString s;
259  QDomAttr attribute;
260  QDomElement currentElement;
261  QDomElement article;
262 
263  QDomNodeList entryList = domElementParent.elementsByTagName( KV_ART_ENTRY );
264  if ( entryList.length() <= 0 )
265  return false;
266 
267  for ( int i = 0; i < entryList.count(); ++i ) {
268 
269 //kDebug() << "KEduVocKvtmlReader::readArticle() read " << entryList.count() << " articles. ";
270  currentElement = entryList.item( i ).toElement();
271  if ( currentElement.parentNode() == domElementParent ) {
272  QString lang;
273  attribute = currentElement.attributeNode( KV_LANG );
274 
275  if (!addLanguage(i, attribute.value())) {
276  return false;
277  }
278 
279  //---------
280  // Children
281 
282  QString fem_def = "";
283  QString mal_def = "";
284  QString nat_def = "";
285  QString fem_indef = "";
286  QString mal_indef = "";
287  QString nat_indef = "";
288 
289  article = currentElement.firstChildElement( KV_ART_FD );
290  if ( !article.isNull() ) {
291  fem_def = article.text();
292  if ( fem_def.isNull() )
293  fem_def = "";
294  }
295 
296  article = currentElement.firstChildElement( KV_ART_FI );
297  if ( !article.isNull() ) {
298  fem_indef = article.text();
299  if ( fem_indef.isNull() )
300  fem_indef = "";
301  }
302 
303  article = currentElement.firstChildElement( KV_ART_MD );
304  if ( !article.isNull() ) {
305  mal_def = article.text();
306  if ( mal_def.isNull() )
307  mal_def = "";
308  }
309 
310  article = currentElement.firstChildElement( KV_ART_MI );
311  if ( !article.isNull() ) {
312  mal_indef = article.text();
313  if ( mal_indef.isNull() )
314  mal_indef = "";
315  }
316 
317  article = currentElement.firstChildElement( KV_ART_ND );
318  if ( !article.isNull() ) {
319  nat_def = article.text();
320  if ( nat_def.isNull() )
321  nat_def = "";
322  }
323 
324  article = currentElement.firstChildElement( KV_ART_NI );
325  if ( !article.isNull() ) {
326  nat_indef = article.text();
327  if ( nat_indef.isNull() )
328  nat_indef = "";
329  }
330 
331  m_doc->identifier(i).setArticle( KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
332  }
333  }
334 
335  return true;
336 }
337 
338 
339 bool KEduVocKvtmlReader::readTranslationConjugations( QDomElement &domElementParent, KEduVocTranslation* translation )
340 {
341  QString tense;
342 
343  QDomElement domElementConjugChild = domElementParent.firstChildElement(KV_CON_TYPE);
344  while ( !domElementConjugChild.isNull() )
345  {
346  // "n" == is the type is the tense
347  QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_CON_NAME );
348  QString oldShortTense = domAttrLang.value();
349 
350  tense = m_compability.tenseFromKvtml1( oldShortTense );
351  KEduVocConjugation conjugation;
352  readConjugation(domElementConjugChild, conjugation);
353  translation->setConjugation(tense, conjugation);
354 
355  domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_TYPE );
356  } // while -> next tense, count++
357  return true;
358 }
359 
360 bool KEduVocKvtmlReader::readConjugation( QDomElement &domElementParent, KEduVocConjugation& conjugation )
361 /*
362  <conjugation> used in header for definiton of "prefix"
363  <e l="de"> lang determines also lang order in entries !!
364  <s1>I</s1> which must NOT differ
365  <s2>you<2>
366  <s3f>he</s3f>
367  <s3m>she</s3m>
368  <s3n>it</s3n>
369  <p1>we</p1>
370  <p2>you</p2>
371  <p3f>they</p3f>
372  <p3m>they</p3m>
373  <p3n>they</p3n>
374  </e>
375  </conjugation>
376 
377  <conjugation> and in entry for definition of tenses of (irreg.) verbs
378  <t n="sipa">
379  <s1>go</s1>
380  <s2>go</s2>
381  <s3f>goes</s3f>
382  <s3m>goes</s3m>
383  <s3n>goes</s3n>
384  <p1>go</p1>
385  <p2>go</p2>
386  <p3f>go</p3f>
387  <p3m>go</p3m>
388  <p3n>go</p3n>
389  </t>
390  </conjugation>
391 */
392 {
393 // QString s;
394  bool p3_common;
395  bool s3_common;
396  QString pers1_sing;
397  QString pers2_sing;
398  QString pers3_m_sing;
399  QString pers3_f_sing;
400  QString pers3_n_sing;
401  QString pers1_plur;
402  QString pers2_plur;
403  QString pers3_m_plur;
404  QString pers3_f_plur;
405  QString pers3_n_plur;
406 
407  p3_common = false;
408  s3_common = false;
409 
410  // get the individual entries for persons...
411  QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement();
412  while ( !domElementConjugGrandChild.isNull() ) {
413  if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) {
414  pers1_sing = domElementConjugGrandChild.text();
415  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) {
416  pers2_sing = domElementConjugGrandChild.text();
417  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) {
418  QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
419  if ( !domAttrCommon.isNull() )
420  s3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails
421  pers3_f_sing = domElementConjugGrandChild.text();
422 
423  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) {
424  pers3_m_sing = domElementConjugGrandChild.text();
425 
426  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) {
427  pers3_n_sing = domElementConjugGrandChild.text();
428 
429  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) {
430  pers1_plur = domElementConjugGrandChild.text();
431 
432  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) {
433  pers2_plur = domElementConjugGrandChild.text();
434 
435  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) {
436  QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
437  if ( !domAttrCommon.isNull() )
438  p3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails
439 
440  pers3_f_plur = domElementConjugGrandChild.text();
441 
442  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) {
443  pers3_m_plur = domElementConjugGrandChild.text();
444 
445  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) {
446  pers3_n_plur = domElementConjugGrandChild.text();
447 
448  } else {
449  return false;
450  }
451 
452  domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement();
453  } // while - probably to be sure, because the persons could be in any order.
454  // I guess this goes over only one set, such as:
455  // <s1>traigo</s1><s2>traes</s2><s3fcommon="1">trae</s3f>
456  // <p1>traemos</p1><p2>traéis</p2><p3f common="1">traen</p3f>
457  // until no elements are left in that soup.
458 
459  // now set the data: [count] - number of conjug?
460  // type - the tense?
461  // finally the person
462 
463  const KEduVocWordFlags numS = KEduVocWordFlag::Singular;
464  const KEduVocWordFlags numP = KEduVocWordFlag::Plural;
465 
466  conjugation.setConjugation( pers1_sing, KEduVocWordFlag::First | numS);
467  conjugation.setConjugation( pers2_sing, KEduVocWordFlag::Second | numS);
468  conjugation.setConjugation( pers1_plur, KEduVocWordFlag::First | numP);
469  conjugation.setConjugation( pers2_plur, KEduVocWordFlag::Second | numP);
470 
471  if ( s3_common ) {
472  conjugation.setConjugation( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular );
473  } else {
474  conjugation.setConjugation( pers3_m_sing,
475  KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Singular );
476  conjugation.setConjugation( pers3_f_sing,
477  KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Singular );
478  conjugation.setConjugation( pers3_n_sing,
479  KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular );
480  }
481 
482  if ( p3_common ) {
483  conjugation.setConjugation( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural );
484  } else {
485  conjugation.setConjugation( pers3_m_plur,
486  KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Plural );
487  conjugation.setConjugation( pers3_f_plur,
488  KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Plural );
489  conjugation.setConjugation( pers3_n_plur,
490  KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural );
491  }
492 
493  return true;
494 }
495 
496 
497 
498 
499 bool KEduVocKvtmlReader::readPersonalPronouns( QDomElement &domElementParent, KEduVocPersonalPronoun& pronouns )
500 {
501 // QString s;
502  bool p3_common;
503  bool s3_common;
504  QString pers1_sing;
505  QString pers2_sing;
506  QString pers3_m_sing;
507  QString pers3_f_sing;
508  QString pers3_n_sing;
509  QString pers1_plur;
510  QString pers2_plur;
511  QString pers3_m_plur;
512  QString pers3_f_plur;
513  QString pers3_n_plur;
514 
515  p3_common = false;
516  s3_common = false;
517 
518  // get the individual entries for persons...
519  QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement();
520  while ( !domElementConjugGrandChild.isNull() ) {
521  if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) {
522  pers1_sing = domElementConjugGrandChild.text();
523  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) {
524  pers2_sing = domElementConjugGrandChild.text();
525  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) {
526  QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
527  if ( !domAttrCommon.isNull() )
528  s3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails
529  pers3_f_sing = domElementConjugGrandChild.text();
530 
531  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) {
532  pers3_m_sing = domElementConjugGrandChild.text();
533 
534  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) {
535  pers3_n_sing = domElementConjugGrandChild.text();
536 
537  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) {
538  pers1_plur = domElementConjugGrandChild.text();
539 
540  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) {
541  pers2_plur = domElementConjugGrandChild.text();
542 
543  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) {
544  QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON );
545  if ( !domAttrCommon.isNull() )
546  p3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails
547 
548  pers3_f_plur = domElementConjugGrandChild.text();
549 
550  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) {
551  pers3_m_plur = domElementConjugGrandChild.text();
552 
553  } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) {
554  pers3_n_plur = domElementConjugGrandChild.text();
555 
556  } else {
557  return false;
558  }
559 
560  domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement();
561  } // while - probably to be sure, because the persons could be in any order.
562  // I guess this goes over only one set, such as:
563  // <s1>traigo</s1><s2>traes</s2><s3fcommon="1">trae</s3f>
564  // <p1>traemos</p1><p2>traéis</p2><p3f common="1">traen</p3f>
565  // until no elements are left in that soup.
566 
567  // now set the data: [count] - number of conjug?
568  // type - the tense?
569  // finally the person
570 
571  KEduVocWordFlags numS = KEduVocWordFlag::Singular;
572  pronouns.setMaleFemaleDifferent(false);
573  pronouns.setPersonalPronoun( pers1_sing, KEduVocWordFlag::First | numS );
574  pronouns.setPersonalPronoun( pers2_sing, KEduVocWordFlag::Second | numS );
575 
576  // used to have common in female
577  if ( s3_common ) {
578  pronouns.setPersonalPronoun( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS );
579  } else {
580  pronouns.setPersonalPronoun( pers3_m_sing,
581  KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numS );
582  pronouns.setPersonalPronoun( pers3_f_sing,
583  KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numS );
584  pronouns.setPersonalPronoun( pers3_n_sing,
585  KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS );
586  pronouns.setMaleFemaleDifferent(true);
587  }
588 
589  KEduVocWordFlags numP = KEduVocWordFlag::Plural;
590 
591  pronouns.setPersonalPronoun( pers1_plur, KEduVocWordFlag::First | numP );
592  pronouns.setPersonalPronoun( pers2_plur, KEduVocWordFlag::Second | numP );
593  if ( p3_common ) {
594  pronouns.setPersonalPronoun( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP );
595  } else {
596  pronouns.setPersonalPronoun( pers3_m_plur,
597  KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numP );
598  pronouns.setPersonalPronoun( pers3_f_plur,
599  KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numP );
600  pronouns.setPersonalPronoun( pers3_n_plur,
601  KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP );
602  pronouns.setMaleFemaleDifferent(true);
603  }
604 
605  return true;
606 }
607 
608 
609 bool KEduVocKvtmlReader::readType( QDomElement &domElementParent )
610 {
611  QString s;
612  QDomElement currentElement;
613 
614  QDomNodeList entryList = domElementParent.elementsByTagName( KV_TYPE_DESC );
615  if ( entryList.length() <= 0 )
616  return false;
617 
618  for ( int i = 0; i < entryList.count(); ++i ) {
619  currentElement = entryList.item( i ).toElement();
620  if ( currentElement.parentNode() == domElementParent ) {
621  // We need to even add empty elements since the old system relied on
622  // the order. So "type1" "" "type2" should be just like that.
623 
624  kDebug() << "Adding old self defined type: " << currentElement.text();
625  // add the type to the list of available types
626  KEduVocWordType* type = new KEduVocWordType(currentElement.text(), m_doc->wordTypeContainer());
627  m_doc->wordTypeContainer()->appendChildContainer( type );
628 
629  // from this the #1 are transformed to something sensible again
630  m_oldSelfDefinedTypes.append( currentElement.text() );
631  }
632  }
633 
634  return true;
635 }
636 
637 
638 bool KEduVocKvtmlReader::readTense( QDomElement &domElementParent )
639 {
640  QDomElement currentElement;
641 
642  currentElement = domElementParent.firstChildElement( KV_TENSE_DESC );
643  while ( !currentElement.isNull() ) {
644  kDebug() << "Reading user defined tense description: " << currentElement.text();
645  m_compability.addUserdefinedTense( currentElement.text() );
646  currentElement = currentElement.nextSiblingElement( KV_TENSE_DESC );
647  }
648  return true;
649 }
650 
651 
652 bool KEduVocKvtmlReader::readComparison( QDomElement &domElementParent, KEduVocTranslation * translation )
653 /*
654  <comparison>
655  <l1>good</l1> --- this one is dead as it always has to be the word itself
656  <l2>better</l2>
657  <l3>best</l3>
658  </comparison>
659 */
660 {
661  QDomElement currentElement;
662 
663  currentElement = domElementParent.firstChildElement( KV_COMP_L2 );
664  translation->setComparative(currentElement.text());
665 
666  currentElement = domElementParent.firstChildElement( KV_COMP_L3 );
667  translation->setSuperlative(currentElement.text());
668 
669  return true;
670 }
671 
672 
673 bool KEduVocKvtmlReader::readMultipleChoice( QDomElement &domElementParent, KEduVocTranslation* translation )
674 /*
675  <multiplechoice>
676  <mc1>good</mc1>
677  <mc2>better</mc2>
678  <mc3>best</mc3>
679  <mc4>best 2</mc4>
680  <mc5>best 3</mc5>
681  </multiplechoice>
682 */
683 
684 {
685  QDomElement currentElement;
686 
687  currentElement = domElementParent.firstChildElement( KV_MC_1 );
688  if ( !currentElement.isNull() ) {
689  translation->multipleChoice().append( currentElement.text() );
690  }
691 
692  currentElement = domElementParent.firstChildElement( KV_MC_2 );
693  if ( !currentElement.isNull() ) {
694  translation->multipleChoice().append( currentElement.text() );
695  }
696 
697  currentElement = domElementParent.firstChildElement( KV_MC_3 );
698  if ( !currentElement.isNull() ) {
699  translation->multipleChoice().append( currentElement.text() );
700  }
701 
702  currentElement = domElementParent.firstChildElement( KV_MC_4 );
703  if ( !currentElement.isNull() ) {
704  translation->multipleChoice().append( currentElement.text() );
705  }
706 
707  currentElement = domElementParent.firstChildElement( KV_MC_5 );
708  if ( !currentElement.isNull() ) {
709  translation->multipleChoice().append( currentElement.text() );
710  }
711 
712  return true;
713 }
714 
715 
716 bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementExpressionChild,
717  QString &lang,
718  grade_t &grade, grade_t &rev_grade,
719  int &count, int &rev_count,
720  QDateTime &date, QDateTime &rev_date,
721  QString &remark,
722  int &bcount, int &rev_bcount,
723  QString &query_id,
724  QString &pronunciation,
725  int &width,
726  QString &type,
727  QString &faux_ami_f,
728  QString &faux_ami_t,
729  QString &synonym,
730  QString &example,
731  QString &antonym,
732  QSet<QString> &usages,
733  QString &paraphrase )
734 {
735  Q_UNUSED(usages)
736  int pos;
737  QDomAttr attribute;
738 
739  lang = "";
740  attribute = domElementExpressionChild.attributeNode( KV_LANG );
741  if ( !attribute.isNull() )
742  lang = attribute.value();
743 
744  width = -1;
745  attribute = domElementExpressionChild.attributeNode( KV_SIZEHINT );
746  if ( !attribute.isNull() )
747  width = attribute.value().toInt();
748 
749  grade = KV_NORM_GRADE;
750  rev_grade = KV_NORM_GRADE;
751  attribute = domElementExpressionChild.attributeNode( KV_GRADE );
752  if ( !attribute.isNull() ) {
753  QString s = attribute.value();
754  if (( pos = s.indexOf( ';' ) ) >= 1 ) {
755  grade = s.left( pos ).toInt();
756  rev_grade = s.mid( pos + 1, s.length() ).toInt();
757  } else
758  grade = s.toInt();
759  }
760 
761  count = 0;
762  rev_count = 0;
763  attribute = domElementExpressionChild.attributeNode( KV_COUNT );
764  if ( !attribute.isNull() ) {
765  QString s = attribute.value();
766  if (( pos = s.indexOf( ';' ) ) >= 1 ) {
767  count = s.left( pos ).toInt();
768  rev_count = s.mid( pos + 1, s.length() ).toInt();
769  } else
770  count = s.toInt();
771  }
772 
773  bcount = 0;
774  rev_bcount = 0;
775  attribute = domElementExpressionChild.attributeNode( KV_BAD );
776  if ( !attribute.isNull() ) {
777  QString s = attribute.value();
778  if (( pos = s.indexOf( ';' ) ) >= 1 ) {
779  bcount = s.left( pos ).toInt();
780  rev_bcount = s.mid( pos + 1, s.length() ).toInt();
781  } else
782  bcount = s.toInt();
783  }
784 
785  date.setTime_t( 0 );
786  rev_date.setTime_t( 0 );
787  attribute = domElementExpressionChild.attributeNode( KV_DATE );
788  if ( !attribute.isNull() ) {
789  QString s = attribute.value();
790  if (( pos = s.indexOf( ';' ) ) >= 1 ) {
791  date.setTime_t( s.left( pos ).toInt() );
792  rev_date.setTime_t( s.mid( pos + 1, s.length() ).toInt() );
793  } else
794  date.setTime_t( s.toInt() );
795  }
796 
797  attribute = domElementExpressionChild.attributeNode( KV_DATE2 );
798  if ( !attribute.isNull() ) {
799  //this format is deprecated and ignored.
800  }
801 
802  remark = "";
803  attribute = domElementExpressionChild.attributeNode( KV_REMARK );
804  if ( !attribute.isNull() )
805  remark = attribute.value();
806 
807  faux_ami_f = "";
808  attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_F );
809  if ( !attribute.isNull() )
810  faux_ami_f = attribute.value();
811 
812  faux_ami_t = "";
813  attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_T );
814  if ( !attribute.isNull() )
815  faux_ami_t = attribute.value();
816 
817  synonym = "";
818  attribute = domElementExpressionChild.attributeNode( KV_SYNONYM );
819  if ( !attribute.isNull() )
820  synonym = attribute.value();
821 
822  example = "";
823  attribute = domElementExpressionChild.attributeNode( KV_EXAMPLE );
824  if ( !attribute.isNull() )
825  example = attribute.value();
826 
827  paraphrase = "";
828  attribute = domElementExpressionChild.attributeNode( KV_PARAPHRASE );
829  if ( !attribute.isNull() )
830  paraphrase = attribute.value();
831 
832  antonym = "";
833  attribute = domElementExpressionChild.attributeNode( KV_ANTONYM );
834  if ( !attribute.isNull() )
835  antonym = attribute.value();
836 
837  // this is all done by reference - so we have to care about "type" :(
838  attribute = domElementExpressionChild.attributeNode( KV_EXPRTYPE );
839  if ( !attribute.isNull() ) {
840  type = attribute.value();
841  }
842 
843  pronunciation = "";
844  attribute = domElementExpressionChild.attributeNode( KV_PRONUNCE );
845  if ( !attribute.isNull() )
846  pronunciation = attribute.value();
847 
848  query_id = "";
849  attribute = domElementExpressionChild.attributeNode( KV_QUERY );
850  if ( !attribute.isNull() )
851  query_id = attribute.value();
852 
853  return true;
854 }
855 
856 
857 bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent )
858 {
859  grade_t grade;
860  grade_t r_grade;
861  int qcount;
862  int r_qcount;
863  int bcount;
864  int r_bcount;
865  QString remark;
866  QString pronunciation;
867  QDateTime qdate;
868  QDateTime r_qdate;
869  bool inquery;
870  bool active;
871  QString lang;
872  QString textstr;
873  QString q_org;
874  QString q_trans;
875  QString query_id;
876  int width;
877  QString type;
878  QString faux_ami_f;
879  QString faux_ami_t;
880  QString synonym;
881  QString example;
882  QString antonym;
883  QSet<QString> usage;
884  QString paraphrase;
885 
886  QDomAttr attribute;
887  QDomElement currentElement;
888  QDomElement currentChild;
889 
890  int lessonNumber = -1;
891 
892  //-------------------------------------------------------------------------
893  // Attributes
894  //-------------------------------------------------------------------------
895 
896  attribute = domElementParent.attributeNode( KV_LESS_MEMBER );
897  if ( !attribute.isNull() ) {
898  // we start conting from 0 in new documents
899  lessonNumber = attribute.value().toInt() - 1;
900  if ( lessonNumber > m_doc->lesson()->childContainerCount() ) {
902  // it's from a lesson that hasn't been added yet
903  // so make sure this lesson is in the document
904  kDebug() << "Warning: lesson > m_doc->lessonCount() in readExpression.";
905 
906  KEduVocLesson* lesson = new KEduVocLesson(i18nc("A generic name for a new lesson and its number.", "Lesson %1", lessonNumber ), m_doc->lesson());
907  m_doc->lesson()->appendChildContainer(lesson);
908  }
909  }
910 
911  attribute = domElementParent.attributeNode( KV_SELECTED );
912  if ( !attribute.isNull() )
913  inquery = attribute.value() == "1" ? true : false;
914  else
915  inquery = false;
916 
917  attribute = domElementParent.attributeNode( KV_INACTIVE );
918  if ( !attribute.isNull() )
919  active = attribute.value() == "1" ? false : true;
920  else
921  active = true;
922 
923  // this is all done by reference - so we have to care about "type" :(
924  attribute = domElementParent.attributeNode( KV_EXPRTYPE );
925  if ( !attribute.isNull() ) {
926  type = attribute.value();
927  }
928 
929 
930 
931 
932 
933 
934  //-------------------------------------------------------------------------
935  // Children 'Translation'
936  //-------------------------------------------------------------------------
937 
938  //QDomNodeList translationList = domElementParent.elementsByTagName(KV_TRANS);
939 
940  // count which translation we are on
941  int i=0;
942 
943  // kvtml 1: we always have an original element (required)
944  currentElement = domElementParent.firstChildElement( KV_ORG );
945  if ( currentElement.isNull() ) { // sanity check
946  m_errorMessage = i18n( "Data for original language missing" );
947  return false;
948  }
949 
950  KEduVocExpression* entry = 0;
951 
952  while ( !currentElement.isNull() ) {
953 
954  //-----------
955  // Attributes
956  //-----------
957 
958  // read attributes - the order of the query grades is interchanged!
959  if ( i == 0 && !readExpressionChildAttributes( currentElement, lang, grade, r_grade, qcount, r_qcount, qdate, r_qdate, remark, bcount, r_bcount, query_id,
960  pronunciation, width, type, faux_ami_t, faux_ami_f, synonym, example, antonym, usage, paraphrase ) ) {
961  return false;
962  }
963 
964  if ( i != 0 && !readExpressionChildAttributes( currentElement, lang, grade, r_grade, qcount, r_qcount, qdate, r_qdate, remark, bcount, r_bcount, query_id,
965  pronunciation, width, type, faux_ami_f, faux_ami_t, synonym, example, antonym, usage, paraphrase ) ) {
966  return false;
967  }
968 
969 
970  //---------
971  // Children
972 
973  textstr = currentElement.lastChild().toText().data();
974 
975  if ( i == 0 ) {
976  entry = new KEduVocExpression( textstr );
977  entry->setActive( active );
978  if ( lessonNumber != -1 ) {
979  static_cast<KEduVocLesson*>(m_doc->lesson()->childContainer(lessonNumber))->appendEntry(entry);
980  } else {
981  m_doc->lesson()->appendEntry(entry);
982  }
983  } else {
984  entry->setTranslation( i, textstr );
985  }
986 
987  if ( m_doc->lesson()->entries(KEduVocLesson::Recursive).count() == 1 ) { // this is because in kvtml the languages are saved in the FIRST ENTRY ONLY.
988  // new translation
989  if (!addLanguage(i, lang)) {
990  return false;
991  }
992  }
993 
994  // better make sure, translation(i) already exists...
995  currentChild = currentElement.firstChildElement( KV_CONJUG_GRP );
996  if ( !currentChild.isNull() ) {
997  if ( !readTranslationConjugations( currentChild, entry->translation(i) ) ) {
998  return false;
999  }
1000  }
1001 
1002  currentChild = currentElement.firstChildElement( KV_MULTIPLECHOICE_GRP );
1003  if ( !currentChild.isNull() ) {
1004  if ( !readMultipleChoice( currentChild, entry->translation(i) ) ) {
1005  return false;
1006  }
1007  }
1008 
1009  currentChild = currentElement.firstChildElement( KV_COMPARISON_GRP );
1010  if ( !currentChild.isNull() ) {
1011  if ( !readComparison( currentChild, entry->translation(i) ) ) {
1012  return false;
1013  }
1014  }
1015 
1016  if ( !type.isEmpty() ) {
1017  KEduVocWordType* wordType = m_compability.typeFromOldFormat(m_doc->wordTypeContainer(), type);
1018  entry->translation(i)->setWordType(wordType);
1019  }
1020 
1021  if ( !remark.isEmpty() )
1022  entry->translation( i )->setComment( remark );
1023  if ( !pronunciation.isEmpty() )
1024  entry->translation( i )->setPronunciation( pronunciation );
1025 
1027 // if ( !faux_ami_f.isEmpty() )
1028 // entry->translation( i )->setFalseFriend( 0, faux_ami_f );
1029 // if ( !faux_ami_t.isEmpty() )
1030 // entry->translation( 0 )->setFalseFriend( i, faux_ami_t );
1032 // if ( !synonym.isEmpty() )
1033 // entry->translation( i )->setSynonym( synonym );
1034 // if ( !antonym.isEmpty() )
1035 // entry->translation( i )->setAntonym( antonym );
1036 
1037  if ( !example.isEmpty() )
1038  entry->translation( i )->setExample( example );
1039  if ( !paraphrase.isEmpty() )
1040  entry->translation( i )->setParaphrase( paraphrase );
1041 
1042  if ( i != 0 ) {
1043  entry->translation( i )->setGrade( grade );
1044  entry->translation( 0 )->setGrade( r_grade );
1045  entry->translation( i )->setPracticeCount( qcount );
1046  entry->translation( 0 )->setPracticeCount( r_qcount );
1047  entry->translation( i )->setBadCount( bcount );
1048  entry->translation( 0 )->setBadCount( r_bcount );
1049  entry->translation( i )->setPracticeDate( qdate );
1050  entry->translation( 0 )->setPracticeDate( r_qdate );
1051  }
1052 
1053  // Next translation
1054  currentElement = currentElement.nextSiblingElement( KV_TRANS );
1055  i++;
1056  }
1057 
1058  return true;
1059 }
1060 
1061 
1062 bool KEduVocKvtmlReader::addLanguage( int languageId, const QString& locale)
1063 {
1064  if ( m_doc->identifierCount() <= languageId ) {
1065  m_doc->appendIdentifier();
1066  // first entry
1067  if ( !locale.isEmpty() ) { // no definition in first entry
1068  m_doc->identifier(languageId).setLocale(locale);
1069 
1070  QString languageName;
1071  if (KGlobal::locale()) {
1072  // when using from qt-only apps this would crash (converter)
1073  languageName = KGlobal::locale()->languageCodeToName(locale);
1074  }
1075  if ( languageName.isEmpty() ) {
1076  languageName = locale;
1077  }
1078 
1079  m_doc->identifier(languageId).setName(languageName);
1080  kDebug() << "addLanguage( " << languageId << ", " << locale << "): " << languageName;
1081 
1082  }
1083  } else {
1084  if ( !locale.isEmpty() ) {
1085  if ( locale != m_doc->identifier(languageId).locale() ) {
1086  // different originals ?
1087  m_errorMessage = i18n( "Ambiguous definition of language code" );
1088  return false;
1089  }
1090  }
1091  }
1092  return true;
1093 }
1094 
1095 
1096 #include "keduvockvtmlreader.moc"
KV_LANG
#define KV_LANG
Definition: kvtmldefs.h:39
KV_BAD
#define KV_BAD
Definition: kvtmldefs.h:48
KEduVocKvtmlReader::readPersonalPronouns
bool readPersonalPronouns(QDomElement &domElementParent, KEduVocPersonalPronoun &pronouns)
Definition: keduvockvtmlreader.cpp:499
KV_MC_2
#define KV_MC_2
Definition: kvtmldefs.h:167
KV_LINES
#define KV_LINES
Definition: kvtmldefs.h:31
KEduVocLesson::appendEntry
void appendEntry(KEduVocExpression *entry)
append an entry to the lesson
Definition: keduvoclesson.cpp:67
KV_CON_P3SF
#define KV_CON_P3SF
Definition: kvtmldefs.h:210
KV_LESS_NO
#define KV_LESS_NO
Definition: kvtmldefs.h:97
keduvocdocument.h
KV_PRONUNCE
#define KV_PRONUNCE
Definition: kvtmldefs.h:56
KEduVocLesson
class to store information about a lesson
Definition: keduvoclesson.h:27
KV_SYNONYM
#define KV_SYNONYM
Definition: kvtmldefs.h:54
KV_TITLE
#define KV_TITLE
Definition: kvtmldefs.h:27
KV_ART_NI
#define KV_ART_NI
Definition: kvtmldefs.h:140
keduvoccommon_p.h
KV_ART_MI
#define KV_ART_MI
Definition: kvtmldefs.h:139
KEduVocKvtmlCompability::typeFromOldFormat
KEduVocWordType * typeFromOldFormat(KEduVocWordType *parent, const QString &typeSubtypeString) const
Get the type from an old type definition.
Definition: keduvockvtmlcompability.cpp:77
KEduVocKvtmlReader::KEduVocKvtmlReader
KEduVocKvtmlReader(QIODevice *file)
Definition: keduvockvtmlreader.cpp:36
KEduVocPersonalPronoun::setMaleFemaleDifferent
void setMaleFemaleDifferent(bool different)
Definition: keduvocpersonalpronoun.cpp:101
KEduVocWordFlag::Singular
Definition: keduvocwordflags.h:33
KEduVocTranslation::setComment
void setComment(const QString &expr)
Sets comment of this expression.
Definition: keduvoctranslation.cpp:208
KEduVocKvtmlReader::readLesson
bool readLesson(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:198
KEduVocWordFlag::Third
Definition: keduvocwordflags.h:49
KV_NORM_GRADE
#define KV_NORM_GRADE
Definition: keduvoctext.h:24
KV_ART_FI
#define KV_ART_FI
Definition: kvtmldefs.h:138
KEduVocTranslation::multipleChoice
QStringList & multipleChoice()
Returns multiple choice if available.
Definition: keduvoctranslation.cpp:296
KV_LESS_DESC
#define KV_LESS_DESC
Definition: kvtmldefs.h:95
KV_ANTONYM
#define KV_ANTONYM
Definition: kvtmldefs.h:55
KEduVocWordFlag::Masculine
Definition: keduvocwordflags.h:28
keduvocwordtype.h
KEduVocDocument::setAuthor
void setAuthor(const QString &author)
Set the author of the file.
Definition: keduvocdocument.cpp:761
KV_TENSE_GRP
#define KV_TENSE_GRP
Definition: kvtmldefs.h:106
KEduVocTranslation::setParaphrase
void setParaphrase(const QString &expression)
Sets paraphrase of this expression.
Definition: keduvoctranslation.cpp:272
KEduVocDocument::setDocumentComment
void setDocumentComment(const QString &comment)
Set the comment of the file.
Definition: keduvocdocument.cpp:819
KV_DATE2
#define KV_DATE2
Definition: kvtmldefs.h:50
KV_ART_MD
#define KV_ART_MD
Definition: kvtmldefs.h:136
KEduVocWordFlag::First
Definition: keduvocwordflags.h:47
KEduVocConjugation
The conjugation of a verb.
Definition: keduvocconjugation.h:37
KEduVocDocument::appendIdentifier
int appendIdentifier(const KEduVocIdentifier &identifier=KEduVocIdentifier())
Appends a new identifier (usually a language)
Definition: keduvocdocument.cpp:699
KV_CON_NAME
#define KV_CON_NAME
Definition: kvtmldefs.h:207
KEduVocKvtmlCompability::documentTenses
QStringList documentTenses() const
Definition: keduvockvtmlcompability.cpp:209
KV_SELECTED
#define KV_SELECTED
Definition: kvtmldefs.h:57
KEduVocContainer::childContainer
KEduVocContainer * childContainer(int row)
Definition: keduvoccontainer.cpp:85
KV_CON_P3PN
#define KV_CON_P3PN
Definition: kvtmldefs.h:217
KEduVocKvtmlReader::readType
bool readType(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:609
KV_MC_1
#define KV_MC_1
Definition: kvtmldefs.h:166
KV_CON_P2P
#define KV_CON_P2P
Definition: kvtmldefs.h:214
KEduVocConjugation::setConjugation
void setConjugation(const KEduVocText &conjugation, KEduVocWordFlags flags)
Updates or creates the conjugation object for the given word flags.
Definition: keduvocconjugation.cpp:75
keduvoclesson.h
KV_LESS_QUERY
#define KV_LESS_QUERY
Definition: kvtmldefs.h:96
KEduVocTranslation::setComparative
KDE_DEPRECATED void setComparative(const QString &comparative)
Definition: keduvoctranslation.cpp:404
KEduVocIdentifier::setTenseList
void setTenseList(const QStringList &tenses)
Definition: keduvocidentifier.cpp:142
KV_MULTIPLECHOICE_GRP
#define KV_MULTIPLECHOICE_GRP
Definition: kvtmldefs.h:165
KEduVocDocument::setVersion
void setVersion(const QString &ver)
Sets version of the loaded file.
Definition: keduvocdocument.cpp:841
KV_EXPR
#define KV_EXPR
Definition: kvtmldefs.h:36
KV_EXPRTYPE
#define KV_EXPRTYPE
Definition: kvtmldefs.h:59
KEduVocPersonalPronoun
The conjugation of a verb.
Definition: keduvocpersonalpronoun.h:25
KEduVocKvtmlReader::readConjugation
bool readConjugation(QDomElement &domElementParent, KEduVocConjugation &conjugation)
Definition: keduvockvtmlreader.cpp:360
KV_LICENSE
#define KV_LICENSE
Definition: kvtmldefs.h:29
KV_CON_P3SN
#define KV_CON_P3SN
Definition: kvtmldefs.h:212
KV_TYPE_GRP
#define KV_TYPE_GRP
Definition: kvtmldefs.h:71
KV_COLS
#define KV_COLS
Definition: kvtmldefs.h:33
KV_QUERY
#define KV_QUERY
Definition: kvtmldefs.h:40
KEduVocTranslation::setPronunciation
void setPronunciation(const QString &expression)
Sets the pronunciation of this expression.
Definition: keduvoctranslation.cpp:308
KEduVocWordType
class to store translation word types
Definition: keduvocwordtype.h:33
KV_CONJUG_GRP
#define KV_CONJUG_GRP
Definition: kvtmldefs.h:204
KEduVocDocument::generator
QString generator() const
Definition: keduvocdocument.cpp:831
KEduVocExpression::setTranslation
void setTranslation(int index, KEduVocTranslation *translation)
KEduVocArticle
Class representing the articles of a language.
Definition: keduvocarticle.h:33
KEduVocDocument::identifier
KEduVocIdentifier & identifier(int index)
Returns the identifier of translation index.
Definition: keduvocdocument.cpp:654
KV_DATE
#define KV_DATE
Definition: kvtmldefs.h:49
keduvockvtmlreader.h
KEduVocContainer::childContainerCount
int childContainerCount() const
Find a child container.
Definition: keduvoccontainer.cpp:122
KV_COUNT
#define KV_COUNT
Definition: kvtmldefs.h:45
KV_CONJ_COMMON
#define KV_CONJ_COMMON
Definition: kvtmldefs.h:218
KEduVocTranslation::setExample
void setExample(const QString &expression)
Sets example this expression.
Definition: keduvoctranslation.cpp:260
KEduVocIdentifier::setName
void setName(const QString &name)
Set the name.
Definition: keduvocidentifier.cpp:86
KEduVocText::setBadCount
void setBadCount(count_t count)
set bad query count as int
Definition: keduvoctext.cpp:137
KEduVocIdentifier::setArticle
void setArticle(const KEduVocArticle &article)
Sets the articles for this identifier.
Definition: keduvocidentifier.cpp:101
KEduVocKvtmlCompability::setupWordTypes
void setupWordTypes(KEduVocWordType *parent)
Definition: keduvockvtmlcompability.cpp:225
kvtmldefs.h
KEduVocKvtmlReader::readBody
bool readBody(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:115
KEduVocDocument::setGenerator
void setGenerator(const QString &generator)
Sets the generator of the file.
Definition: keduvocdocument.cpp:825
KEduVocContainer::setInPractice
void setInPractice(bool inPractice)
Definition: keduvoccontainer.cpp:166
KEduVocDocument::wordTypeContainer
KEduVocWordType * wordTypeContainer()
Definition: keduvocdocument.cpp:721
KV_COMP_L2
#define KV_COMP_L2
Definition: kvtmldefs.h:152
KV_GRADE
#define KV_GRADE
Definition: kvtmldefs.h:43
KEduVocExpression::setActive
void setActive(bool flag=true)
set entry active (enabled for queries)
Definition: keduvocexpression.cpp:156
KV_CON_ENTRY
#define KV_CON_ENTRY
Definition: kvtmldefs.h:205
KV_TYPE_DESC
#define KV_TYPE_DESC
Definition: kvtmldefs.h:72
KV_MC_4
#define KV_MC_4
Definition: kvtmldefs.h:169
KEduVocIdentifier::locale
QString locale() const
The locale of the contents: en, de, es, ...
Definition: keduvocidentifier.cpp:91
KV_MC_5
#define KV_MC_5
Definition: kvtmldefs.h:170
KV_LESS_GRP
#define KV_LESS_GRP
Definition: kvtmldefs.h:93
KV_ARTICLE_GRP
#define KV_ARTICLE_GRP
Definition: kvtmldefs.h:133
KV_ART_FD
#define KV_ART_FD
Definition: kvtmldefs.h:135
KV_ORG
static const QLatin1String KV_ORG("o")
KV_FAUX_AMI_F
#define KV_FAUX_AMI_F
Definition: kvtmldefs.h:52
KEduVocText::setGrade
void setGrade(grade_t grade)
sets the grade
Definition: keduvoctext.cpp:83
KEduVocWordFlag::Plural
Definition: keduvocwordflags.h:35
KV_GENERATOR
#define KV_GENERATOR
Definition: kvtmldefs.h:32
grade_t
unsigned short grade_t
Definition: keduvoctext.h:49
KV_COMP_L3
#define KV_COMP_L3
Definition: kvtmldefs.h:153
KV_TENSE_DESC
#define KV_TENSE_DESC
Definition: kvtmldefs.h:107
KV_LESS_MEMBER
#define KV_LESS_MEMBER
Definition: kvtmldefs.h:44
KV_FAUX_AMI_T
#define KV_FAUX_AMI_T
Definition: kvtmldefs.h:53
KEduVocLesson::entries
QList< KEduVocExpression * > entries(EnumEntriesRecursive recursive=NotRecursive)
get a list of all entries in the lesson
Definition: keduvoclesson.cpp:51
KEduVocKvtmlReader::readTranslationConjugations
bool readTranslationConjugations(QDomElement &domElementParent, KEduVocTranslation *translation)
Definition: keduvockvtmlreader.cpp:339
KV_TRANS
static const QLatin1String KV_TRANS("t")
KEduVocTranslation
Definition: keduvoctranslation.h:35
KEduVocContainer::Recursive
Definition: keduvoccontainer.h:44
KV_CON_P1P
#define KV_CON_P1P
Definition: kvtmldefs.h:213
KV_ART_ENTRY
static const QLatin1String KV_ART_ENTRY("e")
KV_CON_P2S
#define KV_CON_P2S
Definition: kvtmldefs.h:209
KEduVocExpression
This class contains one vocabulary expression as an original with one or more translations.
Definition: keduvocexpression.h:37
KV_CON_TYPE
#define KV_CON_TYPE
Definition: kvtmldefs.h:206
KV_ART_ND
#define KV_ART_ND
Definition: kvtmldefs.h:137
KEduVocKvtmlReader::readMultipleChoice
bool readMultipleChoice(QDomElement &domElementParent, KEduVocTranslation *translation)
Definition: keduvockvtmlreader.cpp:673
KEduVocDocument::identifierCount
int identifierCount() const
Definition: keduvocdocument.cpp:694
KEduVocKvtmlReader::readDoc
bool readDoc(KEduVocDocument *doc)
Definition: keduvockvtmlreader.cpp:45
KEduVocTranslation::setSuperlative
KDE_DEPRECATED void setSuperlative(const QString &superlative)
Definition: keduvoctranslation.cpp:421
KV_SIZEHINT
#define KV_SIZEHINT
Definition: kvtmldefs.h:46
KEduVocKvtmlReader::readArticle
bool readArticle(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:243
KV_EXAMPLE
#define KV_EXAMPLE
Definition: kvtmldefs.h:60
KEduVocDocument::setLicense
void setLicense(const QString &license)
Set the license of the file.
Definition: keduvocdocument.cpp:813
KEduVocKvtmlCompability::addUserdefinedTense
void addUserdefinedTense(const QString &tense)
Definition: keduvockvtmlcompability.cpp:187
KV_PARAPHRASE
#define KV_PARAPHRASE
Definition: kvtmldefs.h:62
KEduVocContainer::appendChildContainer
void appendChildContainer(KEduVocContainer *child)
Definition: keduvoccontainer.cpp:77
KV_CON_P1S
#define KV_CON_P1S
Definition: kvtmldefs.h:208
KVD_VERS_PREFIX
#define KVD_VERS_PREFIX
Definition: keduvoccommon_p.h:14
KEduVocExpression::translation
KEduVocTranslation * translation(int index)
Get a pointer to the translation.
Definition: keduvocexpression.cpp:182
KV_REMARK
#define KV_REMARK
Definition: kvtmldefs.h:51
KV_CON_P3PF
#define KV_CON_P3PF
Definition: kvtmldefs.h:215
KV_INACTIVE
#define KV_INACTIVE
Definition: kvtmldefs.h:58
KV_COMPARISON_GRP
#define KV_COMPARISON_GRP
Definition: kvtmldefs.h:150
KEduVocKvtmlReader::addLanguage
bool addLanguage(int languageId, const QString &language)
Attempt to add a language/locale.
Definition: keduvockvtmlreader.cpp:1062
KEduVocKvtmlReader::readComparison
bool readComparison(QDomElement &domElementParent, KEduVocTranslation *translation)
Definition: keduvockvtmlreader.cpp:652
KEduVocIdentifier::setPersonalPronouns
void setPersonalPronouns(const KEduVocPersonalPronoun &pronouns)
Sets personal pronouns.
Definition: keduvocidentifier.cpp:116
KV_CON_P3SM
#define KV_CON_P3SM
Definition: kvtmldefs.h:211
KEduVocTranslation::setWordType
void setWordType(KEduVocWordType *wordType)
Sets the word type of this expression.
Definition: keduvoctranslation.cpp:364
KEduVocDocument::setTitle
void setTitle(const QString &title)
Set the title of the file.
Definition: keduvocdocument.cpp:749
KEduVocText::setPracticeDate
void setPracticeDate(const QDateTime &date)
Set last query date.
Definition: keduvoctext.cpp:149
KEduVocKvtmlReader::readExpression
bool readExpression(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:857
KEduVocKvtmlCompability::tenseFromKvtml1
QString tenseFromKvtml1(const QString &oldTense)
Definition: keduvockvtmlcompability.cpp:197
KV_MC_3
#define KV_MC_3
Definition: kvtmldefs.h:168
KV_AUTHOR
#define KV_AUTHOR
Definition: kvtmldefs.h:28
KEduVocWordFlag::Neuter
Definition: keduvocwordflags.h:30
KEduVocDocument::lesson
KEduVocLesson * lesson()
Get the lesson root object.
Definition: keduvocdocument.cpp:716
KV_DOC_REM
#define KV_DOC_REM
Definition: kvtmldefs.h:30
KEduVocDocument
This class contains the expressions of your vocabulary as well as other information about the vocabul...
Definition: keduvocdocument.h:44
KEduVocTranslation::setConjugation
void setConjugation(const QString &tense, const KEduVocConjugation &conjugation)
adds conjugations or replaces them, if they exist.
Definition: keduvoctranslation.cpp:284
KEduVocWordFlag::Feminine
Definition: keduvocwordflags.h:29
KEduVocWordFlag::Second
Definition: keduvocwordflags.h:48
KEduVocKvtmlReader::readExpressionChildAttributes
bool readExpressionChildAttributes(QDomElement &domElementExpressionChild, QString &lang, grade_t &grade, grade_t &rev_grade, int &count, int &rev_count, QDateTime &date, QDateTime &rev_date, QString &remark, int &bcount, int &rev_bcount, QString &query_id, QString &pronunciation, int &width, QString &type, QString &faux_ami_f, QString &faux_ami_t, QString &synonym, QString &example, QString &antonym, QSet< QString > &usage, QString &paraphrase)
Definition: keduvockvtmlreader.cpp:716
KV_ENCODING
#define KV_ENCODING
Definition: kvtmldefs.h:34
KEduVocText::setPracticeCount
void setPracticeCount(count_t count)
set how often this entry has been practiced as int
Definition: keduvoctext.cpp:125
KV_CON_P3PM
#define KV_CON_P3PM
Definition: kvtmldefs.h:216
KV_DOCTYPE
static const QLatin1String KV_DOCTYPE("kvtml")
XML tags and attribute names.
KEduVocPersonalPronoun::setPersonalPronoun
void setPersonalPronoun(const QString &conjugation, KEduVocWordFlags flags)
Definition: keduvocpersonalpronoun.cpp:90
KEduVocKvtmlReader::readTense
bool readTense(QDomElement &domElementParent)
Definition: keduvockvtmlreader.cpp:638
KEduVocIdentifier::setLocale
void setLocale(const QString &name)
Set the locale.
Definition: keduvocidentifier.cpp:96
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:37:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdeedu/keduvocdocument

Skip menu "libkdeedu/keduvocdocument"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal