-rw-r--r-- | libkcal/sharpformat.cpp | 45 | ||||
-rw-r--r-- | libkcal/sharpformat.h | 2 |
2 files changed, 4 insertions, 43 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index b88e729..24b8349 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -64,7 +64,6 @@ class SharpParser : public QObject | |||
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | 66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { |
67 | oldCategories = 0; | ||
68 | } | 67 | } |
69 | 68 | ||
70 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | 69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) |
@@ -170,7 +169,7 @@ class SharpParser : public QObject | |||
170 | } | 169 | } |
171 | 170 | ||
172 | QString categoryList = attList[1] ; | 171 | QString categoryList = attList[1] ; |
173 | event->setCategories( lookupCategories( categoryList ) ); | 172 | event->setCategories( categoryList ); |
174 | 173 | ||
175 | // strange 0 semms to mean: alarm enabled | 174 | // strange 0 semms to mean: alarm enabled |
176 | if ( attList[8] == "0" ) { | 175 | if ( attList[8] == "0" ) { |
@@ -224,7 +223,7 @@ class SharpParser : public QObject | |||
224 | todo->setPriority( priority ); | 223 | todo->setPriority( priority ); |
225 | 224 | ||
226 | QString categoryList = attList[1]; | 225 | QString categoryList = attList[1]; |
227 | todo->setCategories( lookupCategories( categoryList ) ); | 226 | todo->setCategories( categoryList ); |
228 | 227 | ||
229 | 228 | ||
230 | 229 | ||
@@ -271,11 +270,6 @@ class SharpParser : public QObject | |||
271 | } | 270 | } |
272 | 271 | ||
273 | 272 | ||
274 | void setCategoriesList ( QStringList * c ) | ||
275 | { | ||
276 | oldCategories = c; | ||
277 | } | ||
278 | |||
279 | QDateTime fromString ( QString s, bool useTz = true ) { | 273 | QDateTime fromString ( QString s, bool useTz = true ) { |
280 | QDateTime dt; | 274 | QDateTime dt; |
281 | int y,m,t,h,min,sec; | 275 | int y,m,t,h,min,sec; |
@@ -301,45 +295,14 @@ class SharpParser : public QObject | |||
301 | return dt; | 295 | return dt; |
302 | } | 296 | } |
303 | 297 | ||
304 | QStringList lookupCategories( const QString &categoryList ) | ||
305 | { | ||
306 | QStringList categoryIds = QStringList::split( ";", categoryList ); | ||
307 | QStringList categories; | ||
308 | QStringList::ConstIterator it; | ||
309 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | ||
310 | QString cate = category( *it ); | ||
311 | if ( oldCategories ) { | ||
312 | if ( ! oldCategories->contains( cate ) ) | ||
313 | oldCategories->append( cate ); | ||
314 | } | ||
315 | categories.append(cate ); | ||
316 | } | ||
317 | return categories; | ||
318 | } | ||
319 | |||
320 | private: | 298 | private: |
321 | Calendar *mCalendar; | 299 | Calendar *mCalendar; |
322 | QStringList * oldCategories; | ||
323 | static QString category( const QString &id ) | ||
324 | { | ||
325 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | ||
326 | if ( it == mCategoriesMap.end() ) return id; | ||
327 | else return *it; | ||
328 | } | ||
329 | |||
330 | static void setCategory( const QString &id, const QString &name ) | ||
331 | { | ||
332 | mCategoriesMap.insert( id, name ); | ||
333 | } | ||
334 | |||
335 | static QMap<QString,QString> mCategoriesMap; | ||
336 | }; | 300 | }; |
337 | 301 | ||
338 | QMap<QString,QString> SharpParser::mCategoriesMap; | ||
339 | 302 | ||
340 | SharpFormat::SharpFormat() | 303 | SharpFormat::SharpFormat() |
341 | { | 304 | { |
342 | mCategories = 0; | 305 | |
343 | } | 306 | } |
344 | 307 | ||
345 | SharpFormat::~SharpFormat() | 308 | SharpFormat::~SharpFormat() |
@@ -1018,7 +981,7 @@ bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, | |||
1018 | bool ok = true; | 981 | bool ok = true; |
1019 | start = end; | 982 | start = end; |
1020 | SharpParser handler( calendar ); | 983 | SharpParser handler( calendar ); |
1021 | handler.setCategoriesList( mCategories ); | 984 | // handler.setCategoriesList( mCategories ); |
1022 | while ( start > 0 ) { | 985 | while ( start > 0 ) { |
1023 | templist.clear(); | 986 | templist.clear(); |
1024 | ok = true; | 987 | ok = true; |
diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h index 0b13862..a71177d 100644 --- a/libkcal/sharpformat.h +++ b/libkcal/sharpformat.h | |||
@@ -40,7 +40,6 @@ class SharpFormat : public QObject { | |||
40 | 40 | ||
41 | bool load( Calendar * ,Calendar *); | 41 | bool load( Calendar * ,Calendar *); |
42 | bool save( Calendar * ); | 42 | bool save( Calendar * ); |
43 | void setCategoriesList ( QStringList * cat ){ mCategories = cat; } | ||
44 | bool fromString2Cal( Calendar *, Calendar *, const QString & , const QString & ); | 43 | bool fromString2Cal( Calendar *, Calendar *, const QString & , const QString & ); |
45 | bool fromString( Calendar *, const QString & ); | 44 | bool fromString( Calendar *, const QString & ); |
46 | QString toString( Calendar * ); | 45 | QString toString( Calendar * ); |
@@ -51,7 +50,6 @@ class SharpFormat : public QObject { | |||
51 | QString getTodoString( Todo* ); | 50 | QString getTodoString( Todo* ); |
52 | QString dtToString( const QDateTime& dt, bool useTZ = true ); | 51 | QString dtToString( const QDateTime& dt, bool useTZ = true ); |
53 | 52 | ||
54 | QStringList *mCategories; | ||
55 | int getNumFromRecord( QString answer,Incidence* inc ) ; | 53 | int getNumFromRecord( QString answer,Incidence* inc ) ; |
56 | QString getPart( const QString & text, bool &ok, int &start ); | 54 | QString getPart( const QString & text, bool &ok, int &start ); |
57 | }; | 55 | }; |