-rw-r--r-- | korganizer/koprefs.cpp | 118 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 44 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 19 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 5 |
4 files changed, 115 insertions, 71 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 0db8e6d..dd978bf 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -390,67 +390,69 @@ QStringList KOPrefs::getDefaultList() void KOPrefs::usrReadConfig() { - mLocaleDict = 0; - // pending LR fix translation - // qDebug("KOPrefs::usrReadConfig() fix translation "); - if ( mPreferredLanguage == 1 ) { - mLocaleDict = new QDict<QString>; - int i = 0; - QString fw ( germanwords[i] [0]); - while ( !fw.isEmpty() ) { - mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); - ++i; - fw = germanwords[i] [0]; - } - - setLocaleDict( mLocaleDict ); - } else { - QString fileName ; - if ( mPreferredLanguage == 3 ) - fileName = MainWindow::resourcePath()+"usertranslation.txt"; - else if ( mPreferredLanguage == 2 ) - fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; - else return; - QFile file( fileName ); - if (file.open( IO_ReadOnly ) ) { - QTextStream ts( &file ); - ts.setCodec( QTextCodec::codecForLocale() ); - QString text = ts.read(); - file.close(); - text.replace( QRegExp("\\\\n"), "\n" ); - QString line; - QString we; - QString wt; - int br = 0; - int nbr; - nbr = text.find ( "},", br ); - line = text.mid( br, nbr - br ); - br = nbr+1; - int se, ee, st, et; + mLocaleDict = 0; + // pending LR fix translation + // qDebug("KOPrefs::usrReadConfig() fix translation "); + if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { + if ( mPreferredLanguage == 1 ) { mLocaleDict = new QDict<QString>; - QString end = "{ \"\",\"\" }"; - while ( (line != end) && (br > 1) ) { - //qDebug("%d *%s* ", br, line.latin1()); - se = line.find("\"")+1; - et = line.findRev("\"",-1); - ee = line.find("\",\""); - st = ee+3; - we = line.mid( se, ee-se ); - wt = line.mid( st, et-st ); - //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); - mLocaleDict->insert( we, new QString (wt) ); - nbr = text.find ( "}", br ); - line = text.mid( br, nbr - br ); - br = nbr+1; + int i = 0; + QString fw ( germanwords[i] [0]); + while ( !fw.isEmpty() ) { + mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); + ++i; + fw = germanwords[i] [0]; } - //qDebug("end *%s* ", end.latin1()); - + setLocaleDict( mLocaleDict ); } else { - qDebug("KO: Cannot find translation file %s",fileName.latin1() ); - } + QString fileName ; + if ( mPreferredLanguage == 3 ) + fileName = MainWindow::resourcePath()+"usertranslation.txt"; + else if ( mPreferredLanguage == 2 ) + fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; + QFile file( fileName ); + if (file.open( IO_ReadOnly ) ) { + QTextStream ts( &file ); + ts.setEncoding( QTextStream::Latin1 ); + //ts.setCodec( QTextCodec::latin1 ); + QString text = ts.read(); + file.close(); + text.replace( QRegExp("\\\\n"), "\n" ); + QString line; + QString we; + QString wt; + int br = 0; + int nbr; + nbr = text.find ( "},", br ); + line = text.mid( br, nbr - br ); + br = nbr+1; + int se, ee, st, et; + mLocaleDict = new QDict<QString>; + QString end = "{ \"\",\"\" }"; + while ( (line != end) && (br > 1) ) { + //qDebug("%d *%s* ", br, line.latin1()); + se = line.find("\"")+1; + et = line.findRev("\"",-1); + ee = line.find("\",\""); + st = ee+3; + we = line.mid( se, ee-se ); + wt = line.mid( st, et-st ); + //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); + mLocaleDict->insert( we, new QString (wt) ); + nbr = text.find ( "}", br ); + line = text.mid( br, nbr - br ); + br = nbr+1; + } + //qDebug("end *%s* ", end.latin1()); + + setLocaleDict( mLocaleDict ); + } else { + qDebug("KO: Cannot find translation file %s",fileName.latin1() ); + } -} + } + } config()->setGroup("General"); mCustomCategories = config()->readListEntry("Custom Categories"); @@ -460,8 +462,8 @@ void KOPrefs::usrReadConfig() mTodoSummaryUser.clear(); } if (mLocationDefaults.isEmpty()) { - mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach") - << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden") + mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") + << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") mLocationDefaults.sort(); diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6276498..1769b37 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -446,10 +446,15 @@ public: event->recurrence()->unsetRecurs(); } - QStringList categoryList; - categoryList << getCategory( Note ); - event->setCategories( categoryList ); - // strange 0 semms to mean: alarm enabled + QStringList cat = event->categories(); + QString nCat = getCategory( Note ); + + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + cat << nCat; + event->setCategories( cat ); + } + if ( alarm ) { Alarm *alarm; if ( event->alarms().count() > 0 ) @@ -532,7 +537,7 @@ public: switch (Note->Type) { case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; case GSM_CAL_CALL : CATEGORY = QString("Call"); break; - case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; + //case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; @@ -1070,13 +1075,40 @@ bool PhoneFormat::save( Calendar *calendar) if (Backup.Calendar[0] != NULL) { max = 0; while (Backup.Calendar[max]!=NULL) max++; + + GSM_DateTime* dtp; + for (i=0;i<max;i++) { status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); Note = *Backup.Calendar[i]; + +#if 0 + int j; + for (j=0;j<Note.EntriesNum;j++) { + //qDebug(" for ev"); + switch (Note.Entries[j].EntryType) { + case CAL_START_DATETIME: + //Note->Entries[i].Date.Hour = 5; + dtp = &Note.Entries[j].Date; + qDebug("start event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second ); + break; + case CAL_END_DATETIME: + dtp = &Note.Entries[j].Date; + qDebug("end event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second ); + break; + } + } + int type = Note.Type; + qDebug(" event type %d - %d %d - %d %d %d",type, GSM_CAL_CALL , GSM_CAL_MEETING ,GSM_CAL_BIRTHDAY, GSM_CAL_MEMO ,GSM_CAL_ALARM ); +#endif + + Note.Type = GSM_CAL_MEETING; + // pending: fix in gammu GSM_ReadBackupFile the type settings + int loc = Note.Location; Note.Location = 0; error=Phone->AddCalendar(&s,&Note); - qDebug("add event %d %d", error, Note.Location ); + qDebug("add event %d %d %d", error, Note.Location, loc ); } } //algo 4 writing todo diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 9307f12..0ebd7d1 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -29,6 +29,7 @@ #include <qfile.h> #include <kdebug.h> +#include <kglobal.h> #include <kmessagebox.h> #include <kiconloader.h> #include <klocale.h> @@ -46,6 +47,7 @@ using namespace KCal; VCalFormat::VCalFormat() { mCalendar = 0; + useLocalTime = false; } VCalFormat::~VCalFormat() @@ -166,24 +168,32 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) return true; } -QString VCalFormat::eventToString( Event * event, Calendar *calendar) +QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) { + if ( !event ) return QString::null; + bool useL = useLocalTime; + useLocalTime = useLocal; mCalendar = calendar; VObject *vevent = eventToVEvent( event ); char *buf = writeMemVObject( 0, 0, vevent ); QString result( buf ); cleanVObject( vevent ); + useLocalTime = useL; return result; } -QString VCalFormat::todoToString( Todo * todo, Calendar *calendar ) +QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) { + if ( !todo ) return QString::null; + bool useL = useLocalTime; + useLocalTime = useLocal; mCalendar = calendar; VObject *vevent = eventToVTodo( todo ); char *buf = writeMemVObject( 0, 0, vevent ); QString result( buf ); cleanVObject( vevent ); + useLocalTime = useL; return result; } @@ -1434,9 +1444,8 @@ QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) ASSERT(qdt.date().isValid()); ASSERT(qdt.time().isValid()); - if (zulu) { - QDateTime tmpDT(qdt); - tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. + if (zulu && !useLocalTime ) { + QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", tmpDT.date().year(), tmpDT.date().month(), tmpDT.date().day(), tmpDT.time().hour(), diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index 7b9ca26..848be78 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h @@ -62,8 +62,8 @@ class VCalFormat : public CalFormat { Return calendar information as string. */ QString toString( Calendar * ); - QString eventToString( Event *, Calendar *calendar ); - QString todoToString( Todo * ,Calendar *calendar ); + QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); + QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); protected: /** translates a VObject of the TODO type into a Event */ @@ -100,6 +100,7 @@ class VCalFormat : public CalFormat { private: Calendar *mCalendar; + bool useLocalTime; QPtrList<Event> mEventsRelate; // events with relations QPtrList<Todo> mTodosRelate; // todos with relations |