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 | |
parent | 71eeea80d9c449bd1983c1a9207c7123e919b55f (diff) | |
download | kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.zip kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.gz kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.bz2 |
category utf8 fixes
-rw-r--r-- | korganizer/calendarview.cpp | 3 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 45 | ||||
-rw-r--r-- | libkcal/sharpformat.h | 2 | ||||
-rw-r--r-- | microkde/kconfig.cpp | 8 |
4 files changed, 10 insertions, 48 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f8d752a..2321087 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -2290,33 +2290,34 @@ void CalendarView::manageCategories() cp->show(); int w =cp->sizeHint().width() ; int h = cp->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( !cp->exec() ) { delete cp; return; } int count = 0; if ( cp->addCat() ) { count = addCategories(); if ( count ) { topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); writeSettings(); - } + } else + topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); } else { removeCategories(); updateView(); } delete cp; } void CalendarView::beamIncidence(Incidence * Inc) { QPtrList<Incidence> delSel ; delSel.append(Inc); beamIncidenceList( delSel ); } void CalendarView::beamCalendar() { QPtrList<Incidence> delSel = mCalendar->rawIncidences(); diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index b88e729..24b8349 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp @@ -51,33 +51,32 @@ using namespace KCal; //ARSD silentalarm = 0 // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly // 12 RFRQ // 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; } ++i ; } if ( skip ) return false; @@ -157,33 +156,33 @@ class SharpParser : public QObject QBitArray days( 7 ); days.fill( false ); days.setBit( startDate.dayOfWeek() - 1 ); r->addMonthlyPos( pos, days ); } 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 ); alarm->setEnabled( true ); int alarmOffset = attList[9].toInt(); alarm->setStartOffset( alarmOffset * -60 ); } else { @@ -211,33 +210,33 @@ class SharpParser : public QObject //1,,,,,1,4,Loch zumachen,"" //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 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 ); } todo->setHasDueDate( true ); } @@ -258,101 +257,65 @@ class SharpParser : public QObject else todo->setCompleted( false ); mCalendar->addTodo( todo ); } 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 ) dt = dt.addSecs ( offset*60); 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 ) { QString s = attList[i]; if ( ! s.isEmpty() ){ j = s.length(); for ( k = 0; k < j; ++k ) { @@ -1005,33 +968,33 @@ QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) } bool SharpFormat::fromString( Calendar *calendar, const QString & text) { return false; } 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 ) templist.append( tempString ); //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); } handler.startElement( existingCalendar, templist, type ); diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h index 0b13862..a71177d 100644 --- a/libkcal/sharpformat.h +++ b/libkcal/sharpformat.h @@ -27,35 +27,33 @@ #include "calformat.h" 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 diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 5b685d3..862166d 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp @@ -93,62 +93,62 @@ int KConfig::readNumEntry( const QString & key, int def ) QString res = readEntry(key, QString::number(def ) ); bool ok = false; int result = res.toInt(&ok); if ( ok ) return result; return def; } QString KConfig::readEntry( const QString &key, const QString &def ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return def; } - return *it; + return QString::fromUtf8((*it).latin1()); } QSize KConfig::readSizeEntry( const QString &key, QSize* def ) { QValueList<int> intlist = readIntListEntry(key); if (intlist.count() < 2) { if (def) return *def; else return QSize(); } QSize ret; ret.setWidth(intlist[0]); ret.setHeight(intlist[1]); return ret; } QStringList KConfig::readListEntry( const QString &key ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return QStringList(); } - return QStringList::split(":", *it ); + return QStringList::split(":", QString::fromUtf8((*it).latin1())); } bool KConfig::readBoolEntry( const QString &key, bool def ) { QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); if ( it == mBoolMap.end() ) { return def; } return *it; } QColor KConfig::readColorEntry( const QString & e, QColor *def ) { @@ -200,40 +200,40 @@ void KConfig::writeEntry( const QString &key, const QValueList<int> &value) for( it = value.begin(); it != value.end(); ++it ) { valuesAsStrings << QString::number(*it); } mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString & key , int num ) { writeEntry( key, QString::number ( num ) ); } void KConfig::writeEntry( const QString &key, const QString &value ) { - mStringMap.insert( mGroup + key, value ); + mStringMap.insert( mGroup + key, value.utf8() ); mDirty = true; } void KConfig::writeEntry( const QString &key, const QStringList &value ) { - mStringMap.insert( mGroup + key, value.join(":") ); + mStringMap.insert( mGroup + key, value.join(":").utf8() ); mDirty = true; } void KConfig::writeEntry( const QString &key, bool value) { mBoolMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString & e, const QColor & c ) { QStringList l; l.append( QString::number ( c.red() ) ); l.append( QString::number ( c.green() ) ); |