• 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
keduvoccsvwriter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  export a KEduVocDocument to a delimited text file
3  -----------------------------------------------------------------------
4  copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
5 
6  (C) 2007 Peter Hedlund <peter.hedlund@kdemail.net>
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "keduvoccsvwriter.h"
19 
20 #include <QFile>
21 #include <QTextStream>
22 
23 #include <KLocale>
24 
25 #include "keduvocdocument.h"
26 #include "keduvoclesson.h"
27 #include "keduvocexpression.h"
28 
29 KEduVocCsvWriter::KEduVocCsvWriter( QFile *file )
30 {
31  // the file must be already open
32  m_outputFile = file;
33 }
34 
35 
36 bool KEduVocCsvWriter::writeDoc( KEduVocDocument *doc, const QString &generator )
37 {
38  Q_UNUSED( generator );
39 
40  m_doc = doc;
41 
42  QString separator = m_doc->csvDelimiter();
43  ;
44 
45  QTextStream outputStream;
46  outputStream.setDevice( m_outputFile );
47  outputStream.setCodec( "UTF-8" );
48 
49  outputStream << i18nc( "@item:intable the title of the document will be written here", "Title:" ) << separator << m_doc->title() << "\n";
50  outputStream << i18nc( "@item:intable the author will be written here", "Author:" ) << separator << m_doc->author() << "\n";
51 
52  KEduVocExpression *expression;
53  int idCount = m_doc->identifierCount();
54  QString currentRow;
55 
56  for ( int e = 0; e < m_doc->lesson()->entryCount(KEduVocLesson::Recursive); e++ ) {
57  expression = m_doc->lesson()->entries(KEduVocLesson::Recursive).value( e );
58  currentRow = "";
59  bool sep = false;
60 
61  for ( int i = 0; i < idCount; i++ ) {
62  if ( !sep )
63  sep = true;
64  else
65  currentRow += separator;
66 
67  currentRow += expression->translation( i )->text();
68  }
69 
70  if ( !currentRow.isEmpty() )
71  outputStream << currentRow << "\n";
72  }
73 
74  return true;
75 }
76 
KEduVocCsvWriter::KEduVocCsvWriter
KEduVocCsvWriter(QFile *file)
Definition: keduvoccsvwriter.cpp:29
keduvocexpression.h
keduvocdocument.h
KEduVocCsvWriter::writeDoc
bool writeDoc(KEduVocDocument *doc, const QString &generator)
Definition: keduvoccsvwriter.cpp:36
keduvoclesson.h
keduvoccsvwriter.h
KEduVocDocument::title
QString title() const
Definition: keduvocdocument.cpp:741
KEduVocDocument::author
QString author() const
Definition: keduvocdocument.cpp:756
KEduVocLesson::entries
QList< KEduVocExpression * > entries(EnumEntriesRecursive recursive=NotRecursive)
get a list of all entries in the lesson
Definition: keduvoclesson.cpp:51
KEduVocContainer::Recursive
Definition: keduvoccontainer.h:44
KEduVocExpression
This class contains one vocabulary expression as an original with one or more translations.
Definition: keduvocexpression.h:37
KEduVocDocument::identifierCount
int identifierCount() const
Definition: keduvocdocument.cpp:694
KEduVocText::text
QString text() const
The translation as string (the word itself)
Definition: keduvoctext.cpp:55
KEduVocDocument::csvDelimiter
QString csvDelimiter() const
Returns the delimiter (separator) used for csv import and export.
Definition: keduvocdocument.cpp:847
KEduVocExpression::translation
KEduVocTranslation * translation(int index)
Get a pointer to the translation.
Definition: keduvocexpression.cpp:182
KEduVocLesson::entryCount
int entryCount(EnumEntriesRecursive recursive=NotRecursive)
get the number of entries in the lesson
Definition: keduvoclesson.cpp:59
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
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