summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp118
-rw-r--r--libkcal/phoneformat.cpp44
-rw-r--r--libkcal/vcalformat.cpp19
-rw-r--r--libkcal/vcalformat.h5
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
@@ -381,96 +381,98 @@ QStringList KOPrefs::getDefaultList()
<< i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
<< i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
<< i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
<< i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
<< i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
<< i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
retval.sort();
return retval;
}
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");
if ( KOPrefs::instance()->mLanguageChanged ) {
mLocationDefaults.clear();
mEventSummaryUser.clear();
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();
}
if (mEventSummaryUser.isEmpty()) {
mEventSummaryUser = getDefaultList() ;
}
if (mTodoSummaryUser.isEmpty()) {
mTodoSummaryUser = getDefaultList() ;
}
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 6276498..1769b37 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -437,28 +437,33 @@ public:
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();
}
- 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 )
alarm = event->alarms().first();
else {
alarm = new Alarm( event );
event->addAlarm( alarm );
}
alarm->setType( Alarm::Audio );
alarm->setEnabled( true );
int alarmOffset = alarmDt.secsTo( event->dtStart() );
alarm->setStartOffset( -alarmOffset );
@@ -523,25 +528,25 @@ public:
}
return datestr + timestr;
}
QDate datefromGSM ( GSM_DateTime* dtp ) {
return QDate ( dtp->Year, dtp->Month, dtp->Day );
}
QString getCategory( GSM_CalendarEntry* Note)
{
QString CATEGORY;
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;
case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
@@ -1061,31 +1066,58 @@ bool PhoneFormat::save( Calendar *calendar)
status.setText ( message );
qApp->processEvents();
GSM_Backup Backup;
error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup);
qDebug("Read file result %d ",error );
//algo 4 writing event
int max, i;
procCount = 0;
message = i18n(" Writing event # ");
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
procCount = 0;
message = i18n(" Writing todo # ");
if (Backup.ToDo[0] != NULL) {
max = 0;
while (Backup.ToDo[max]!=NULL) max++;
for (i=0;i<max;i++) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
ToDoEntry = *Backup.ToDo[i];
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 9307f12..0ebd7d1 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -20,41 +20,43 @@
*/
#include <qapplication.h>
#include <qdatetime.h>
#include <qstring.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qclipboard.h>
#include <qdialog.h>
#include <qfile.h>
#include <kdebug.h>
+#include <kglobal.h>
#include <kmessagebox.h>
#include <kiconloader.h>
#include <klocale.h>
#include "vcc.h"
#include "vobject.h"
#include "vcaldrag.h"
#include "calendar.h"
#include "vcalformat.h"
using namespace KCal;
VCalFormat::VCalFormat()
{
mCalendar = 0;
+ useLocalTime = false;
}
VCalFormat::~VCalFormat()
{
}
bool VCalFormat::load(Calendar *calendar, const QString &fileName)
{
mCalendar = calendar;
clearException();
@@ -157,42 +159,50 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text )
calendar->addEvent( event );
} else {
kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl;
deleteVObject( vcal );
return false;
}
deleteVObject( vcal );
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;
}
QString VCalFormat::toString( Calendar *calendar )
{
// TODO: Factor out VCalFormat::asString()
VObject *vcal = newVObject(VCCalProp);
addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
QString tmpStr = mCalendar->getTimeZoneStr();
addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
@@ -1425,27 +1435,26 @@ QString VCalFormat::qDateToISO(const QDate &qd)
tmpStr.sprintf("%.2d%.2d%.2d",
qd.year(), qd.month(), qd.day());
return tmpStr;
}
QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
{
QString tmpStr;
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(),
tmpDT.time().minute(), tmpDT.time().second());
} else {
tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
qdt.date().year(), qdt.date().month(),
qdt.date().day(), qdt.time().hour(),
qdt.time().minute(), qdt.time().second());
}
return tmpStr;
}
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 7b9ca26..848be78 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -53,26 +53,26 @@ class VCalFormat : public CalFormat {
* @param fileName the name of the file
*/
bool save(Calendar *,const QString &fileName);
/**
Parse string and populate calendar with that information.
*/
bool fromString( Calendar *, const QString & );
/**
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 */
Todo *VTodoToEvent(VObject *vtodo);
/** translates a VObject into a Event and returns a pointer to it. */
Event *VEventToEvent(VObject *vevent);
/** translate a Event into a VTodo-type VObject and return pointer */
VObject *eventToVTodo(const Todo *anEvent);
/** translate a Event into a VObject and returns a pointer to it. */
VObject* eventToVEvent(const Event *anEvent);
/** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
@@ -91,20 +91,21 @@ class VCalFormat : public CalFormat {
/** takes a number 0 - 6 and returns the two letter string of that day,
* i.e. MO, TU, WE, etc. */
const char *dayFromNum(int day);
/** the reverse of the above function. */
int numFromDay(const QString &day);
Attendee::PartStat readStatus(const char *s) const;
QCString writeStatus(Attendee::PartStat status) const;
private:
Calendar *mCalendar;
+ bool useLocalTime;
QPtrList<Event> mEventsRelate; // events with relations
QPtrList<Todo> mTodosRelate; // todos with relations
};
}
#endif