author | zautrix <zautrix> | 2004-11-06 14:30:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-06 14:30:14 (UTC) |
commit | f8841c92d5251f713eb7a025af8fdee52de45b3d (patch) (side-by-side diff) | |
tree | 29c3c48e5da5b5ce05126da46475de1a0a845428 /libkcal | |
parent | 71eeea80d9c449bd1983c1a9207c7123e919b55f (diff) | |
download | kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.zip kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.gz kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.bz2 |
category utf8 fixes
-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 @@ -55,25 +55,24 @@ using namespace KCal; // 13 RPOS pos = 4. monday in month // 14 RDYS days: 1 mon/ 2 tue .. 64 sun // 15 REND 0 = no end/ 1 = end // 16 REDT rec end dt //ALSD //ALED //MDAY class SharpParser : public QObject { public: SharpParser( Calendar *calendar ) : mCalendar( calendar ) { - oldCategories = 0; } bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) { int i = 1; bool skip = true; int max = attList.count() -2; while ( i < max ) { if ( !attList[i].isEmpty() ) { skip = false; break; } @@ -161,25 +160,25 @@ class SharpParser : public QObject } else if ( rtype == "4" ) { if ( hasEndDate ) r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); else r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); r->addYearlyNum( startDate.month() ); } } else { event->recurrence()->unsetRecurs(); } QString categoryList = attList[1] ; - event->setCategories( lookupCategories( categoryList ) ); + event->setCategories( categoryList ); // strange 0 semms to mean: alarm enabled if ( attList[8] == "0" ) { Alarm *alarm; if ( event->alarms().count() > 0 ) alarm = event->alarms().first(); else { alarm = new Alarm( event ); event->addAlarm( alarm ); alarm->setType( Alarm::Audio ); } //alarm->setType( Alarm::Audio ); @@ -215,25 +214,25 @@ class SharpParser : public QObject todo->setID( "Sharp_DTM", attList[0]); todo->setCsum( "Sharp_DTM", QString::number( cSum )); todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); todo->setSummary( attList[7] ); todo->setDescription( attList[8]); int priority = attList[6].toInt(); if ( priority == 0 ) priority = 3; todo->setPriority( priority ); QString categoryList = attList[1]; - todo->setCategories( lookupCategories( categoryList ) ); + todo->setCategories( categoryList ); QString hasDateStr = attList[3]; // due if ( !hasDateStr.isEmpty() ) { if ( hasDateStr.right(6) == "000000" ) { todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); todo->setFloats( true ); } else { todo->setDtDue( fromString( hasDateStr ) ); todo->setFloats( false ); @@ -262,29 +261,24 @@ class SharpParser : public QObject } else if ( qName == "Category" ) { /* QString id = attributes.value( "id" ); QString name = attributes.value( "name" ); setCategory( id, name ); */ } //qDebug("end "); return true; } - void setCategoriesList ( QStringList * c ) - { - oldCategories = c; - } - QDateTime fromString ( QString s, bool useTz = true ) { QDateTime dt; int y,m,t,h,min,sec; y = s.mid(0,4).toInt(); m = s.mid(4,2).toInt(); t = s.mid(6,2).toInt(); h = s.mid(9,2).toInt(); min = s.mid(11,2).toInt(); sec = s.mid(13,2).toInt(); dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); int offset = KGlobal::locale()->localTimeOffset( dt ); if ( useTz ) @@ -292,63 +286,32 @@ class SharpParser : public QObject return dt; } protected: QDateTime toDateTime( const QString &value ) { QDateTime dt; dt.setTime_t( value.toUInt() ); return dt; } - QStringList lookupCategories( const QString &categoryList ) - { - QStringList categoryIds = QStringList::split( ";", categoryList ); - QStringList categories; - QStringList::ConstIterator it; - for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { - QString cate = category( *it ); - if ( oldCategories ) { - if ( ! oldCategories->contains( cate ) ) - oldCategories->append( cate ); - } - categories.append(cate ); - } - return categories; - } - private: Calendar *mCalendar; - QStringList * oldCategories; - static QString category( const QString &id ) - { - QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); - if ( it == mCategoriesMap.end() ) return id; - else return *it; - } - - static void setCategory( const QString &id, const QString &name ) - { - mCategoriesMap.insert( id, name ); - } - - static QMap<QString,QString> mCategoriesMap; }; -QMap<QString,QString> SharpParser::mCategoriesMap; SharpFormat::SharpFormat() { - mCategories = 0; + } SharpFormat::~SharpFormat() { } ulong SharpFormat::getCsum( const QStringList & attList) { int max = attList.count() -1; ulong cSum = 0; int j,k,i; int add; for ( i = 1; i < max ; ++i ) { @@ -1009,25 +972,25 @@ bool SharpFormat::fromString( Calendar *calendar, const QString & text) } bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) { // qDebug("test %s ", text.latin1()); QStringList templist; QString tempString; int start = 0; int len = text.length(); int end = text.find ("\n",start)+1; bool ok = true; start = end; SharpParser handler( calendar ); - handler.setCategoriesList( mCategories ); + // handler.setCategoriesList( mCategories ); while ( start > 0 ) { templist.clear(); ok = true; while ( ok ) { tempString = getPart( text, ok, start ); if ( start >= len || start == 0 ) { start = 0; ok = false; } if ( tempString.right(1) =="\n" ) tempString = tempString.left( tempString.length()-1); //if ( ok ) diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h index 0b13862..a71177d 100644 --- a/libkcal/sharpformat.h +++ b/libkcal/sharpformat.h @@ -31,31 +31,29 @@ namespace KCal { /** This class implements the calendar format used by Sharp. */ class SharpFormat : public QObject { public: /** Create new iCalendar format. */ SharpFormat(); virtual ~SharpFormat(); bool load( Calendar * ,Calendar *); bool save( Calendar * ); - void setCategoriesList ( QStringList * cat ){ mCategories = cat; } bool fromString2Cal( Calendar *, Calendar *, const QString & , const QString & ); bool fromString( Calendar *, const QString & ); QString toString( Calendar * ); static ulong getCsum( const QStringList & ); private: QString getEventString( Event* ); QString getTodoString( Todo* ); QString dtToString( const QDateTime& dt, bool useTZ = true ); - QStringList *mCategories; int getNumFromRecord( QString answer,Incidence* inc ) ; QString getPart( const QString & text, bool &ok, int &start ); }; } #endif |