summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformat.cpp
Unidiff
Diffstat (limited to 'libkcal/icalformat.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/icalformat.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 6f3a799..3829bc1 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -17,17 +17,17 @@
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qclipboard.h> 25#include <qclipboard.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <q3textstream.h>
28#include <qtextcodec.h> 28#include <qtextcodec.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
@@ -67,20 +67,20 @@ ICalFormat::~ICalFormat()
67bool ICalFormat::load( Calendar *calendar, const QString &fileName) 67bool ICalFormat::load( Calendar *calendar, const QString &fileName)
68{ 68{
69 69
70 clearException(); 70 clearException();
71 71
72 QFile file( fileName ); 72 QFile file( fileName );
73 if (!file.open( IO_ReadOnly ) ) { 73 if (!file.open( QIODevice::ReadOnly ) ) {
74 setException(new ErrorFormat(ErrorFormat::LoadError)); 74 setException(new ErrorFormat(ErrorFormat::LoadError));
75 return false; 75 return false;
76 } 76 }
77 QTextStream ts( &file ); 77 Q3TextStream ts( &file );
78 QString text; 78 QString text;
79 79
80 ts.setEncoding( QTextStream::Latin1 ); 80 ts.setEncoding( Q3TextStream::Latin1 );
81 text = ts.read(); 81 text = ts.read();
82 file.close(); 82 file.close();
83 83
84 return fromString( calendar, text ); 84 return fromString( calendar, text );
85} 85}
86 86
@@ -95,20 +95,20 @@ bool ICalFormat::save( Calendar *calendar, const QString &fileName )
95 // qDebug("to string takes ms: %d ",is.elapsed() ); 95 // qDebug("to string takes ms: %d ",is.elapsed() );
96 if ( text.isNull() ) return false; 96 if ( text.isNull() ) return false;
97 97
98 // TODO: write backup file 98 // TODO: write backup file
99 //is.restart(); 99 //is.restart();
100 QFile file( fileName ); 100 QFile file( fileName );
101 if (!file.open( IO_WriteOnly ) ) { 101 if (!file.open( QIODevice::WriteOnly ) ) {
102 setException(new ErrorFormat(ErrorFormat::SaveError, 102 setException(new ErrorFormat(ErrorFormat::SaveError,
103 i18n("Could not open file '%1'").arg(fileName))); 103 i18n("Could not open file '%1'").arg(fileName)));
104 return false; 104 return false;
105 } 105 }
106 QTextStream ts( &file ); 106 Q3TextStream ts( &file );
107 107
108 ts.setEncoding( QTextStream::Latin1 ); 108 ts.setEncoding( Q3TextStream::Latin1 );
109 ts << text; 109 ts << text;
110 file.close(); 110 file.close();
111 //qDebug("saving file takes ms: %d ", is.elapsed() ); 111 //qDebug("saving file takes ms: %d ", is.elapsed() );
112 return true; 112 return true;
113} 113}
114 114
@@ -153,64 +153,64 @@ bool ICalFormat::fromString( Calendar *cal, const QString &text )
153Incidence *ICalFormat::fromString( const QString &text ) 153Incidence *ICalFormat::fromString( const QString &text )
154{ 154{
155 CalendarLocal cal( mTimeZoneId ); 155 CalendarLocal cal( mTimeZoneId );
156 fromString(&cal, text); 156 fromString(&cal, text);
157 157
158 Incidence *ical = 0; 158 Incidence *ical = 0;
159 QPtrList<Event> elist = cal.events(); 159 Q3PtrList<Event> elist = cal.events();
160 if ( elist.count() > 0 ) { 160 if ( elist.count() > 0 ) {
161 ical = elist.first(); 161 ical = elist.first();
162 } else { 162 } else {
163 QPtrList<Todo> tlist = cal.todos(); 163 Q3PtrList<Todo> tlist = cal.todos();
164 if ( tlist.count() > 0 ) { 164 if ( tlist.count() > 0 ) {
165 ical = tlist.first(); 165 ical = tlist.first();
166 } else { 166 } else {
167 QPtrList<Journal> jlist = cal.journals(); 167 Q3PtrList<Journal> jlist = cal.journals();
168 if ( jlist.count() > 0 ) { 168 if ( jlist.count() > 0 ) {
169 ical = jlist.first(); 169 ical = jlist.first();
170 } 170 }
171 } 171 }
172 } 172 }
173 return ical; 173 return ical;
174} 174}
175#include <qapp.h> 175#include <qapplication.h>
176 176
177QString ICalFormat::toString( Calendar *cal ) 177QString ICalFormat::toString( Calendar *cal )
178{ 178{
179 179
180 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 180 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
181 181
182 icalcomponent *calendar = mImpl->createCalendarComponent(cal); 182 icalcomponent *calendar = mImpl->createCalendarComponent(cal);
183 183
184 icalcomponent *component; 184 icalcomponent *component;
185 185
186 // todos 186 // todos
187 QPtrList<Todo> todoList = cal->rawTodos(); 187 Q3PtrList<Todo> todoList = cal->rawTodos();
188 QPtrListIterator<Todo> qlt(todoList); 188 Q3PtrListIterator<Todo> qlt(todoList);
189 for (; qlt.current(); ++qlt) { 189 for (; qlt.current(); ++qlt) {
190 component = mImpl->writeTodo(qlt.current()); 190 component = mImpl->writeTodo(qlt.current());
191 icalcomponent_add_component(calendar,component); 191 icalcomponent_add_component(calendar,component);
192 //qDebug(" todos "); 192 //qDebug(" todos ");
193 if ( mProcessEvents ) { 193 if ( mProcessEvents ) {
194 //qDebug("mProcessEvents "); 194 //qDebug("mProcessEvents ");
195 qApp->processEvents(); 195 qApp->processEvents();
196 } 196 }
197 } 197 }
198 // events 198 // events
199 QPtrList<Event> events = cal->rawEvents(); 199 Q3PtrList<Event> events = cal->rawEvents();
200 Event *ev; 200 Event *ev;
201 for(ev=events.first();ev;ev=events.next()) { 201 for(ev=events.first();ev;ev=events.next()) {
202 component = mImpl->writeEvent(ev); 202 component = mImpl->writeEvent(ev);
203 icalcomponent_add_component(calendar,component); 203 icalcomponent_add_component(calendar,component);
204 //qDebug("events "); 204 //qDebug("events ");
205 if ( mProcessEvents ) 205 if ( mProcessEvents )
206 qApp->processEvents(); 206 qApp->processEvents();
207 } 207 }
208 208
209 // journals 209 // journals
210 QPtrList<Journal> journals = cal->journals(); 210 Q3PtrList<Journal> journals = cal->journals();
211 Journal *j; 211 Journal *j;
212 for(j=journals.first();j;j=journals.next()) { 212 for(j=journals.first();j;j=journals.next()) {
213 component = mImpl->writeJournal(j); 213 component = mImpl->writeJournal(j);
214 icalcomponent_add_component(calendar,component); 214 icalcomponent_add_component(calendar,component);
215 //qDebug("journals "); 215 //qDebug("journals ");
216 if ( mProcessEvents ) 216 if ( mProcessEvents )