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 #include <libkcal/htmlexport.h>
00031 
00032 
00033 #include "konsolekalendarexports.h"
00034 
00035 using namespace KCal;
00036 using namespace std;
00037 
00038 KonsoleKalendarExports::KonsoleKalendarExports( KonsoleKalendarVariables *variables )
00039 {
00040   m_variables = variables;
00041   m_firstEntry = true;
00042 }
00043 
00044 
00045 KonsoleKalendarExports::~KonsoleKalendarExports()
00046 {
00047 }
00048 
00049 bool KonsoleKalendarExports::exportAsTxt( QTextStream *ts, Event *event ){
00050 
00051   if( m_firstEntry == true || 
00052       m_lastDate.day() != event->dtStart().date().day() ||
00053       m_lastDate.month() != event->dtStart().date().month() ||
00054       m_lastDate.year() != event->dtStart().date().year() ){
00055       
00056       
00057     m_firstEntry=false;   
00058     int len = event->dtStartStr().length();
00059     QString date = event->dtStartStr();
00060     date.truncate( len - 5 );
00061     *ts << I18N_NOOP("Date:") << "\t" <<  date.local8Bit() << endl;
00062     m_lastDate = event->dtStart().date();
00063       
00064   }
00065 
00066   if ( !event->doesFloat() ) {
00067     *ts << "\t";
00068     *ts <<  event->dtStartStr().remove(0, (event->dtStartStr().find(' ', 0, false) + 1) ).local8Bit();
00069     *ts << " - ";
00070     *ts << event->dtEndStr().remove(0, (event->dtEndStr().find(' ', 0, false) + 1) ).local8Bit();
00071   }
00072 
00073 
00074   *ts << endl << I18N_NOOP("Summary:") << endl;
00075   *ts << "\t" << event->summary().local8Bit() << endl;
00076   *ts << I18N_NOOP("Description:") << endl;  
00077   if( !event->description().isEmpty() ) {
00078     *ts << "\t" << event->description().local8Bit() << endl;
00079   } else {
00080     *ts << "\t" << I18N_NOOP("(no description available)") << endl;  
00081   }
00082   *ts << I18N_NOOP("UID:") << endl;  
00083   *ts << "\t" << event->uid().local8Bit() << endl;
00084   *ts << "----------------------------------" << endl;
00085 
00086   return true;
00087 }
00088 
00089 bool KonsoleKalendarExports::exportAsCSV( QTextStream *ts, Event *event ){
00090 
00091 // startdate,starttime,enddate,endtime,summary,description,UID
00092 
00093   QString delim = ",";  //one day maybe the delim character can be an option??
00094 
00095   if ( !event->doesFloat() ) {
00096     *ts <<          event->dtStart().date().toString("yyyy-M-d");
00097     *ts << delim << event->dtStart().time().toString("hh:mm");
00098     *ts << delim << event->dtEnd().date().toString("yyyy-M-d");
00099     *ts << delim << event->dtEnd().time().toString("hh:mm");
00100   } else {
00101     *ts << ",,,";
00102   }
00103 
00104   *ts << delim << event->summary().local8Bit();
00105   *ts << delim << event->description().local8Bit();
00106   *ts << delim << event->uid().local8Bit();
00107   *ts << endl;
00108 
00109   return true;
00110 }
00111 
00112 // Old function for printing out as keyword:<tab>value
00113 //bool KonsoleKalendarExports::exportAsCSV( QTextStream *ts, Event *event ){
00114 //
00115 //  if ( !event->doesFloat() ) {
00116 //    *ts <<  event->dtStartStr().remove(0, (event->dtStartStr().find(' ', 0, false) + 1) ).local8Bit();
00117 //    *ts << "\t";
00118 //    *ts << event->dtEndStr().remove(0, (event->dtEndStr().find(' ', 0, false) + 1) ).local8Bit();
00119 // }
00120 //
00121 //  *ts << "\t" << I18N_NOOP("Summary:");
00122 //  *ts << "\t\"" << event->summary().local8Bit() << "\"";
00123 //  *ts << "\t" << I18N_NOOP("Description:");
00124 //  *ts << "\t\"" << event->description().local8Bit() << "\"";
00125 //  *ts << "\t" << I18N_NOOP("UID:");
00126 //  *ts << "\t" << event->uid().local8Bit() << endl;
00127 //
00128 //  return true;
00129 //}
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Mar 6 17:18:34 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003