• 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
keduvocpaukerreader.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  create a KEduVocDocument from a Pauker file
3  -----------------------------------------------------------------------
4  copyright : (C) 2004, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
5 
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "keduvocpaukerreader.h"
18 
19 #include <QIODevice>
20 
21 #include <KLocale>
22 
23 #include "keduvocexpression.h"
24 #include "keduvoclesson.h"
25 #include "keduvocdocument.h"
26 
27 KEduVocPaukerReader::KEduVocPaukerReader( KEduVocDocument * doc )
28 {
29  m_doc = doc;
30 }
31 
32 
33 bool KEduVocPaukerReader::read( QIODevice * device )
34 {
35  setDevice( device );
36 
37  while ( !atEnd() ) {
38  readNext();
39 
40  if ( isStartElement() ) {
41  if ( name() == "Lesson" )
42  readPauker();
43  else
44  raiseError( i18n( "This is not a Pauker document" ) );
45  }
46  }
47 
48  return !error();
49 }
50 
51 
52 void KEduVocPaukerReader::readUnknownElement()
53 {
54  while ( !atEnd() ) {
55  readNext();
56 
57  if ( isEndElement() )
58  break;
59 
60  if ( isStartElement() )
61  readUnknownElement();
62  }
63 }
64 
65 
66 void KEduVocPaukerReader::readPauker()
67 {
68  m_doc->setAuthor( "http://pauker.sf.net" );
70  m_doc->appendIdentifier();
71  m_doc->appendIdentifier();
72 
73  while ( !atEnd() ) {
74  readNext();
75 
76  if ( isEndElement() )
77  break;
78 
79  if ( isStartElement() ) {
80  if ( name() == "Description" )
81  m_doc->setDocumentComment( readElementText() );
82  else if ( name() == "Batch" )
83  readBatch();
84  else
85  readUnknownElement();
86  }
87  }
88 }
89 
90 
91 void KEduVocPaukerReader::readBatch()
92 {
93  while ( !atEnd() ) {
94  readNext();
95 
96  if ( isEndElement() )
97  break;
98 
99  if ( isStartElement() ) {
100  if ( name() == "Card" )
101  readCard();
102  else
103  readUnknownElement();
104  }
105  }
106 }
107 
108 
109 void KEduVocPaukerReader::readCard()
110 {
111  QString front;
112  QString back;
113 
114  while ( !atEnd() ) {
115  readNext();
116 
117  if ( isEndElement() )
118  break;
119 
120  if ( isStartElement() ) {
121  if ( name() == "FrontSide" )
122  front = readText();
123  else if ( name() == "ReverseSide" )
124  back = readText();
125  else
126  readUnknownElement();
127  }
128  }
129 
130  KEduVocLesson* lesson = new KEduVocLesson(i18n("Vocabulary"), m_doc->lesson());
131  m_doc->lesson()->appendChildContainer(lesson);
132 
133  KEduVocExpression* expr = new KEduVocExpression( QStringList() << front << back);
134  lesson->appendEntry( expr );
135 }
136 
137 
138 QString KEduVocPaukerReader::readText()
139 {
140  QString result;
141 
142  while ( !atEnd() ) {
143  readNext();
144 
145  if ( isEndElement() )
146  break;
147 
148  if ( isStartElement() ) {
149  if ( name() == "Text" )
150  result = readElementText();
151  else
152  readUnknownElement();
153  }
154  }
155  return result;
156 }
KEduVocLesson::appendEntry
void appendEntry(KEduVocExpression *entry)
append an entry to the lesson
Definition: keduvoclesson.cpp:67
keduvocexpression.h
keduvocdocument.h
KEduVocLesson
class to store information about a lesson
Definition: keduvoclesson.h:27
KEduVocDocument::setAuthor
void setAuthor(const QString &author)
Set the author of the file.
Definition: keduvocdocument.cpp:761
KEduVocDocument::setDocumentComment
void setDocumentComment(const QString &comment)
Set the comment of the file.
Definition: keduvocdocument.cpp:819
KEduVocPaukerReader::KEduVocPaukerReader
KEduVocPaukerReader(KEduVocDocument *doc)
Definition: keduvocpaukerreader.cpp:27
KEduVocDocument::appendIdentifier
int appendIdentifier(const KEduVocIdentifier &identifier=KEduVocIdentifier())
Appends a new identifier (usually a language)
Definition: keduvocdocument.cpp:699
keduvoclesson.h
KEduVocExpression
This class contains one vocabulary expression as an original with one or more translations.
Definition: keduvocexpression.h:37
KEduVocContainer::appendChildContainer
void appendChildContainer(KEduVocContainer *child)
Definition: keduvoccontainer.cpp:77
KEduVocPaukerReader::read
bool read(QIODevice *device)
Definition: keduvocpaukerreader.cpp:33
KEduVocDocument::lesson
KEduVocLesson * lesson()
Get the lesson root object.
Definition: keduvocdocument.cpp:716
KEduVocDocument
This class contains the expressions of your vocabulary as well as other information about the vocabul...
Definition: keduvocdocument.h:44
keduvocpaukerreader.h
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