konsolekalendar Library API Documentation

konsolekalendarexports.cpp

00001 /***************************************************************************
00002         konsolekalendarexports.cpp  -  description
00003            -------------------
00004     begin                : Sun May 25 2003
00005     copyright            : (C) 2003 by Tuukka Pasanen
00006     copyright            : (C) 2003 by Allen Winter
00007     email                : illuusio@mailcity.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #include <stdlib.h>
00020 #include <iostream>
00021 
00022 #include <qdatetime.h>
00023 
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 
00027 #include <libkcal/calendarlocal.h>
00028 #include <libkcal/calendar.h>
00029 #include <libkcal/event.h>
00030 
00031 
00032 #include "konsolekalendarexports.h"
00033 
00034 using namespace KCal;
00035 using namespace std;
00036 
00037 KonsoleKalendarExports::KonsoleKalendarExports( KonsoleKalendarVariables *variables )
00038 {
00039   m_variables = variables;
00040   m_firstEntry = true;
00041 }
00042 
00043 
00044 KonsoleKalendarExports::~KonsoleKalendarExports()
00045 {
00046 }
00047 
00048 bool KonsoleKalendarExports::exportAsTxt( QTextStream *ts, Event *event, QDate date ){
00049 
00050   if( m_firstEntry == true ||
00051       m_lastDate.day() != date.day() ||
00052       m_lastDate.month() != date.month() ||
00053       m_lastDate.year() != date.year() ){
00054 
00055 
00056     m_firstEntry=false;
00057     QString sDate = date.toString();
00058     *ts << I18N_NOOP("Date:") << "\t" <<  sDate << endl;
00059     m_lastDate = date;
00060 
00061   }
00062 
00063   if ( !event->doesFloat() ) {
00064     *ts << "\t";
00065     *ts <<  event->dtStartStr().remove(0, (event->dtStartStr().find(' ', 0, false) + 1) );
00066     *ts << " - ";
00067     *ts << event->dtEndStr().remove(0, (event->dtEndStr().find(' ', 0, false) + 1) );
00068   }
00069 
00070 
00071   *ts << endl << I18N_NOOP("Summary:") << endl;
00072   *ts << "\t" << event->summary() << endl;
00073   *ts << I18N_NOOP("Description:") << endl;
00074   if( !event->description().isEmpty() ) {
00075     *ts << "\t" << event->description() << endl;
00076   } else {
00077     *ts << "\t" << I18N_NOOP("(no description available)") << endl;
00078   }
00079   *ts << I18N_NOOP("UID:") << endl;
00080   *ts << "\t" << event->uid() << endl;
00081   *ts << "----------------------------------" << endl;
00082 
00083   return true;
00084 }
00085 
00086 bool KonsoleKalendarExports::exportAsCSV( QTextStream *ts, Event *event, QDate date ){
00087 
00088 // startdate,starttime,enddate,endtime,summary,description,UID
00089 
00090   QString delim = ",";  //TODO: the delim character can be an option??
00091 
00092   if ( !event->doesFloat() ) {
00093     *ts <<          date.toString("yyyy-MM-dd");
00094     *ts << delim << event->dtStart().time().toString("hh:mm");
00095     *ts << delim << date.toString("yyyy-MM-dd");
00096     *ts << delim << event->dtEnd().time().toString("hh:mm");
00097   } else {
00098     *ts <<          date.toString("yyyy-MM-dd");
00099     *ts << delim;
00100     *ts << delim << date.toString("yyyy-MM-dd");
00101     *ts << delim;
00102   }
00103 
00104   QString rdelim = "\\" + delim;
00105   *ts << delim << event->summary().replace(delim,rdelim);
00106   *ts << delim << event->description().replace(delim,rdelim);
00107   *ts << delim << event->uid();
00108   *ts << endl;
00109 
00110   return true;
00111 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:15 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003