summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-10 08:53:14 (UTC)
committer zautrix <zautrix>2005-04-10 08:53:14 (UTC)
commit79b12b680f6a0653bcff84c8ef83b23803246b7d (patch) (side-by-side diff)
tree05e4c6d7ac0446eacb7dff6ca466f656b3152793 /libkcal
parent54f5fe5e6f4909109edf915513c02f7af3e7bb2d (diff)
downloadkdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.zip
kdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.tar.gz
kdepimpi-79b12b680f6a0653bcff84c8ef83b23803246b7d.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp2
-rw-r--r--libkcal/calformat.cpp20
-rw-r--r--libkcal/icalformatimpl.cpp12
-rw-r--r--libkcal/incidence.cpp7
-rw-r--r--libkcal/todo.cpp38
-rw-r--r--libkcal/vcalformat.cpp16
6 files changed, 51 insertions, 44 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index dcfee5d..406cd48 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -37,9 +37,9 @@ using namespace KCal;
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
@@ -25,21 +25,21 @@
#include "calformat.h"
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.
struct CalVersion {
int version;
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() }
};
@@ -77,16 +77,12 @@ 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
@@ -365,11 +365,11 @@ 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
Recurrence *recur = incidence->recurrence();
@@ -2035,13 +2035,17 @@ 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
@@ -389,9 +389,14 @@ void Incidence::setRelatedTo(Incidence *relatedTo)
// updated();
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
@@ -23,8 +23,10 @@
#include <klocale.h>
#include <kdebug.h>
#include <qregexp.h>
+#include "calendarlocal.h"
+#include "icalformat.h"
#include "todo.h"
using namespace KCal;
@@ -54,8 +56,9 @@ Todo::Todo(const Todo &t) : Incidence(t)
Todo::~Todo()
{
setRunning( false );
+ qDebug("Todo::~Todo() ");
}
void Todo::setRunning( bool run )
{
@@ -80,29 +83,24 @@ void Todo::saveRunningInfoToFile()
qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
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
@@ -325,11 +325,11 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
tmpStr.sprintf("%i",anEvent->priority());
addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
// related event
- if (anEvent->relatedTo()) {
+ if (anEvent->relatedToUid()) {
addPropValue(vtodo, VCRelatedToProp,
- anEvent->relatedTo()->uid().local8Bit());
+ anEvent->relatedToUid().local8Bit());
}
// categories
QStringList tmpStrList = anEvent->categories();
@@ -671,11 +671,11 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
tmpStr.sprintf("%i",anEvent->transparency());
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()) {
// pilot sync stuff
@@ -1603,13 +1603,17 @@ 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 );
}
}
const char *VCalFormat::dayFromNum(int day)