konsolekalendarexports.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdlib.h>
00029 #include <iostream>
00030
00031 #include <qdatetime.h>
00032
00033 #include <kdebug.h>
00034 #include <klocale.h>
00035
00036 #include <libkcal/calendarlocal.h>
00037 #include <libkcal/calendar.h>
00038 #include <libkcal/event.h>
00039
00040 #include "konsolekalendarexports.h"
00041
00042 using namespace KCal;
00043 using namespace std;
00044
00045 KonsoleKalendarExports::KonsoleKalendarExports( KonsoleKalendarVariables
00046 *variables ) {
00047 m_variables = variables;
00048 m_firstEntry = true;
00049 }
00050
00051
00052 KonsoleKalendarExports::~KonsoleKalendarExports() {
00053 }
00054
00055 bool KonsoleKalendarExports::exportAsTxt( QTextStream *ts,
00056 Event *event, QDate date ) {
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 *ts << i18n( "Date:" )
00074 << "\t"
00075 << KGlobal::locale()->formatDate( date )
00076 << endl;
00077
00078
00079 if ( !event->doesFloat() ) {
00080 *ts << "\t"
00081 << KGlobal::locale()->formatTime( event->dtStart().time() )
00082 << " - "
00083 << KGlobal::locale()->formatTime( event->dtEnd().time() );
00084 }
00085 *ts << endl;
00086
00087
00088 *ts << i18n( "Summary:" )
00089 << endl;
00090 if ( !event->summary().isEmpty() ) {
00091 *ts << "\t"
00092 << event->summary()
00093 << endl;
00094 } else {
00095 *ts << "\t"
00096 << i18n( "(no summary available)" )
00097 << endl;
00098 }
00099
00100
00101 *ts << i18n( "Location:" )
00102 << endl;
00103 if ( !event->location().isEmpty() ) {
00104 *ts << "\t"
00105 <<event->location()
00106 << endl;
00107 } else {
00108 *ts << "\t"
00109 << i18n( "(no location available)" )
00110 << endl;
00111 }
00112
00113
00114 *ts << i18n( "Description:" )
00115 << endl;
00116 if ( !event->description().isEmpty() ) {
00117 *ts << "\t"
00118 << event->description()
00119 << endl;
00120 } else {
00121 *ts << "\t"
00122 << i18n( "(no description available)" )
00123 << endl;
00124 }
00125
00126
00127 *ts << i18n( "UID:" )
00128 << endl
00129 << "\t"
00130 << event->uid()
00131 << endl;
00132
00133
00134 *ts << "--------------------------------------------------"
00135 << endl;
00136
00137 return true;
00138 }
00139
00140 bool KonsoleKalendarExports::exportAsTxtShort( QTextStream *ts,
00141 Event *event, QDate date,
00142 bool sameday ) {
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 if ( !sameday ) {
00153
00154 *ts << KGlobal::locale()->formatDate( date ) << ":"
00155 << endl;
00156 }
00157
00158
00159 if ( !event->doesFloat() ) {
00160 *ts << KGlobal::locale()->formatTime( event->dtStart().time() )
00161 << " - "
00162 << KGlobal::locale()->formatTime( event->dtEnd().time() );
00163 } else {
00164 *ts << i18n( "[all day]\t" );
00165 }
00166 *ts << "\t";
00167
00168
00169 *ts << event->summary().replace( QChar( '\n' ), QChar( ' ' ) );
00170
00171
00172 if ( !event->location().isEmpty() ) {
00173 if ( !event->summary().isEmpty() ) {
00174 *ts << ", ";
00175 }
00176 *ts << event->location().replace( QChar( '\n' ), QChar( ' ' ) );
00177 }
00178 *ts << endl;
00179
00180
00181 if ( !event->description().isEmpty() ) {
00182 *ts << "\t\t\t"
00183 << event->description().replace( QChar( '\n' ), QChar( ' ' ) )
00184 << endl;
00185 }
00186
00187
00188
00189 return true;
00190 }
00191
00192 QString KonsoleKalendarExports::processField( QString field, QString dquote ) {
00193
00194
00195
00196
00197
00198 QString double_dquote = dquote + dquote;
00199 QString retField = dquote + field.replace( dquote, double_dquote ) + dquote;
00200 return retField;
00201 }
00202
00203 #define pF( x ) processField( ( x ), dquote )
00204
00205 bool KonsoleKalendarExports::exportAsCSV( QTextStream *ts,
00206 Event *event, QDate date ) {
00207
00208
00209
00210
00211
00212 QString delim = i18n( "," );
00213 QString dquote = i18n( "\"" );
00214
00215 if ( !event->doesFloat() ) {
00216 *ts << pF( KGlobal::locale()->formatDate( date ) )
00217 << delim << pF( KGlobal::locale()->formatTime( event->dtStart().time() ) )
00218 << delim << pF( KGlobal::locale()->formatDate( date ) )
00219 << delim << pF( KGlobal::locale()->formatTime( event->dtEnd().time() ) );
00220 } else {
00221 *ts << pF( KGlobal::locale()->formatDate( date ) )
00222 << delim << pF( "" )
00223 << delim << pF( KGlobal::locale()->formatDate( date ) )
00224 << delim << pF( "" );
00225 }
00226
00227 *ts << delim << pF( event->summary().replace( QChar('\n'), QChar(' ') ) )
00228 << delim << pF( event->location().replace( QChar('\n'), QChar(' ') ) )
00229 << delim << pF( event->description().replace( QChar('\n'), QChar(' ') ) )
00230 << delim << pF( event->uid() )
00231 << endl;
00232
00233 return true;
00234 }
This file is part of the documentation for konsolekalendar Library Version 3.3.2.