summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-08-20 23:53:07 (UTC)
committer zautrix <zautrix>2004-08-20 23:53:07 (UTC)
commitab07441b413dff6d478e2c3a39b823b4269931c5 (patch) (side-by-side diff)
tree5de6576a6c0e20e4af2db7baa5019aa983e2195a /libkcal
parentbc33238f8038a03e04f25ea608c53e784616fee6 (diff)
downloadkdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.zip
kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.gz
kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.bz2
Sync fixes and fix of config loading bug
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp44
-rw-r--r--libkcal/vcalformat.cpp19
-rw-r--r--libkcal/vcalformat.h5
3 files changed, 55 insertions, 13 deletions
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