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

libkdeedu/keduvocdocument

keduvoccsvwriter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                    export a KEduVocDocument to a delimited text file
00003     -----------------------------------------------------------------------
00004     copyright       : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00005 
00006                       (C) 2007 Peter Hedlund <peter.hedlund@kdemail.net>
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "keduvoccsvwriter.h"
00019 
00020 #include <QFile>
00021 #include <QTextStream>
00022 
00023 #include <KLocale>
00024 
00025 #include "keduvocdocument.h"
00026 #include "keduvocexpression.h"
00027 
00028 KEduVocCsvWriter::KEduVocCsvWriter( QFile *file )
00029 {
00030     // the file must be already open
00031     m_outputFile = file;
00032 }
00033 
00034 
00035 bool KEduVocCsvWriter::writeDoc( KEduVocDocument *doc, const QString &generator )
00036 {
00037     Q_UNUSED( generator );
00038 
00039     m_doc = doc;
00040 
00041     QString separator = m_doc->csvDelimiter();
00042     ;
00043 
00044     QTextStream outputStream;
00045     outputStream.setDevice( m_outputFile );
00046     outputStream.setCodec( "UTF-8" );
00047 
00048     outputStream << i18nc( "@item:intable the title of the document will be written here", "Title:" )  << separator << m_doc->title() << "\n";
00049     outputStream << i18nc( "@item:intable the author will be written here", "Author:" ) << separator << m_doc->author() << "\n";
00050 
00051     KEduVocExpression *expression;
00052     int idCount = m_doc->identifierCount();
00053     QString currentRow;
00054 
00055     for ( int e = 0; e < m_doc->entryCount(); e++ ) {
00056         expression = m_doc->entry( e );
00057         currentRow = "";
00058         bool sep = false;
00059 
00060         for ( int i = 0; i < idCount; i++ ) {
00061             if ( !sep )
00062                 sep = true;
00063             else
00064                 currentRow += separator;
00065 
00066             currentRow += expression->translation( i ).text();
00067         }
00068 
00069         if ( !currentRow.isEmpty() )
00070             outputStream << currentRow << "\n";
00071     }
00072 
00073     return true;
00074 }
00075 

libkdeedu/keduvocdocument

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

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal