From 79b12b680f6a0653bcff84c8ef83b23803246b7d Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 10 Apr 2005 08:53:14 +0000 Subject: fixes --- (limited to 'libkcal') diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index dcfee5d..406cd48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -38,7 +38,7 @@ Calendar::Calendar() { init(); - setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); + setTimeZoneId( " 00:00 Europe/London(UTC)" ); } Calendar::Calendar( const QString &timeZoneId ) diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp index 8a3d069..359f65f 100644 --- a/libkcal/calformat.cpp +++ b/libkcal/calformat.cpp @@ -26,8 +26,8 @@ using namespace KCal; -QString CalFormat::mApplication = QString::fromLatin1("libkcal"); -QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.1//EN"); +QString CalFormat::mApplication = QString::fromLatin1("libkcal-pi"); +QString CalFormat::mProductId = QString::fromLatin1("-//KDE-Pim//Platform-independent 2.1.0"); // An array containing the PRODID strings indexed against the calendar file format version used. // Every time the calendar file format is changed, add an entry/entries to this list. @@ -36,9 +36,9 @@ struct CalVersion { QString prodId; }; static CalVersion prodIds[] = { - { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") }, - { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") }, - { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") }, + { 220, QString::fromLatin1("-//KDE-Pim//Pi 2.2//EN") }, + { 300, QString::fromLatin1("-//KDE-Pim//Pi 3.0//EN") }, + { 310, QString::fromLatin1("-//KDE-Pim//Pi 3.1//EN") }, { 0 , QString() } }; @@ -78,14 +78,10 @@ void CalFormat::setApplication(const QString& application, const QString& produc QString CalFormat::createUniqueId() { - int hashTime = QTime::currentTime().hour() + - QTime::currentTime().minute() + QTime::currentTime().second() + - QTime::currentTime().msec(); - QString uidStr = QString("%1-%2.%3") - .arg(mApplication) + return QString("%1-%2-%3") + .arg("kopi") .arg(KApplication::random()) - .arg(hashTime); - return uidStr; + .arg(QTime::currentTime().msec()+1); } int CalFormat::calendarVersion(const char* prodId) diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index eae41aa..fe7413f 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -366,9 +366,9 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) */ // related event - if (incidence->relatedTo()) { + if (!incidence->relatedToUid().isEmpty()) { icalcomponent_add_property(parent,icalproperty_new_relatedto( - incidence->relatedTo()->uid().utf8())); + incidence->relatedToUid().utf8())); } // recurrence rule stuff @@ -2036,11 +2036,15 @@ bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) // Post-Process list of events with relations, put Event objects in relation Event *ev; for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { - ev->setRelatedTo(cal->event(ev->relatedToUid())); + Incidence * inc = cal->event(ev->relatedToUid()); + if ( inc ) + ev->setRelatedTo( inc ); } Todo *todo; for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { - todo->setRelatedTo(cal->todo(todo->relatedToUid())); + Incidence * inc = cal->todo(todo->relatedToUid()); + if ( inc ) + todo->setRelatedTo( inc ); } return true; diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index a312ba5..6bca12c 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -390,7 +390,12 @@ void Incidence::setRelatedTo(Incidence *relatedTo) mRelatedTo->removeRelation(this); } mRelatedTo = relatedTo; - if (mRelatedTo) mRelatedTo->addRelation(this); + if (mRelatedTo) { + mRelatedTo->addRelation(this); + mRelatedToUid = mRelatedTo->uid(); + } else { + mRelatedToUid = ""; + } } Incidence *Incidence::relatedTo() const diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 8794f7a..7906046 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -24,6 +24,8 @@ #include #include +#include "calendarlocal.h" +#include "icalformat.h" #include "todo.h" using namespace KCal; @@ -55,6 +57,7 @@ Todo::Todo(const Todo &t) : Incidence(t) Todo::~Todo() { setRunning( false ); + qDebug("Todo::~Todo() "); } void Todo::setRunning( bool run ) @@ -81,28 +84,23 @@ void Todo::saveRunningInfoToFile() QString dir = KGlobalSettings::timeTrackerDir(); qDebug("%s ", dir.latin1()); - QString file = "%1-%2-%3-%4-%5-%6-%7.tt"; - - file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( mRunStart.time().msec(), 3 ); + QString file = "%1%2%3-%4%5%6-%7%8%9-"; + int runtime = mRunStart.secsTo( QDateTime::currentDateTime() ); + runtime = (runtime / 60) +1; + int h = runtime / 60; + int m = runtime % 60; + int d = h / 24; + h = h % 24; + file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( d,3 ).arg( h,2 ).arg( m,2 ); file.replace ( QRegExp (" "), "0" ); - file = dir +"/" +file; - qDebug("%s ", file.latin1()); - QStringList dataList; - - //Summary - //Category - //CategoryColor - //StartRuntime - //Runtime - //Due - //Start - //Prio - //Erledigt - //Uid - //Parents uids + file = dir +"/" +file + uid()+".ics"; + qDebug("File %s ",file.latin1() ); + CalendarLocal cal; + cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); + cal.addIncidence( clone() ); + ICalFormat format; + format.save( &cal, file ); - - } int Todo::runTime() diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 62a31ae..8efc1ea 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -326,9 +326,9 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); // related event - if (anEvent->relatedTo()) { + if (anEvent->relatedToUid()) { addPropValue(vtodo, VCRelatedToProp, - anEvent->relatedTo()->uid().local8Bit()); + anEvent->relatedToUid().local8Bit()); } // categories @@ -672,9 +672,9 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); // related event - if (anEvent->relatedTo()) { + if (anEvent->relatedToUid()) { addPropValue(vevent, VCRelatedToProp, - anEvent->relatedTo()->uid().local8Bit()); + anEvent->relatedToUid().local8Bit()); } if (anEvent->pilotId()) { @@ -1604,11 +1604,15 @@ void VCalFormat::populate(VObject *vcal) // Post-Process list of events with relations, put Event objects in relation Event *ev; for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { - ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); + Incidence * inc = mCalendar->event(ev->relatedToUid()); + if ( inc ) + ev->setRelatedTo( inc ); } Todo *todo; for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { - todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); + Incidence * inc = mCalendar->todo(todo->relatedToUid()); + if ( inc ) + todo->setRelatedTo( inc ); } } -- cgit v0.9.0.2