konsolekalendarexports.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00089
00090 QString delim = ",";
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 }
This file is part of the documentation for konsolekalendar Library Version 3.2.2.