-rw-r--r-- | korganizer/calendarview.cpp | 18 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 2 | ||||
-rw-r--r-- | libkcal/calformat.cpp | 20 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 12 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 7 | ||||
-rw-r--r-- | libkcal/todo.cpp | 38 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 16 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 3 |
8 files changed, 56 insertions, 60 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8512a07..c530037 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -2992,46 +2992,34 @@ void CalendarView::appointment_delete() if (!anEvent) { KNotifyClient::beep(); return; } deleteEvent(anEvent); } void CalendarView::todo_resub( Todo * parent, Todo * sub ) { if (!sub) return; - if (!parent) return; - if ( sub->relatedTo() ) - sub->relatedTo()->removeRelation(sub); + if ( sub->relatedTo() == parent ) + return; sub->setRelatedTo(parent); - sub->setRelatedToUid(parent->uid()); - parent->addRelation(sub); sub->updated(); - parent->updated(); setModified(true); updateView(); } void CalendarView::todo_unsub(Todo *anTodo ) { - // Todo *anTodo = selectedTodo(); - if (!anTodo) return; - if (!anTodo->relatedTo()) return; - anTodo->relatedTo()->removeRelation(anTodo); - anTodo->setRelatedTo(0); - anTodo->updated(); - anTodo->setRelatedToUid(""); - setModified(true); - updateView(); + todo_resub( 0, anTodo ); } void CalendarView::deleteTodo(Todo *todo) { if (!todo) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { QString text = todo->summary().left(20); if (!todo->relations().isEmpty()) { text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index dcfee5d..406cd48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -29,25 +29,25 @@ #include "exceptions.h" #include "calfilter.h" #include "calendar.h" #include "syncdefines.h" using namespace KCal; Calendar::Calendar() { init(); - setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); + setTimeZoneId( " 00:00 Europe/London(UTC)" ); } Calendar::Calendar( const QString &timeZoneId ) { init(); setTimeZoneId(timeZoneId); } void Calendar::init() { mObserver = 0; diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp index 8a3d069..359f65f 100644 --- a/libkcal/calformat.cpp +++ b/libkcal/calformat.cpp @@ -17,37 +17,37 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <klocale.h> #include <kdebug.h> #include <kapplication.h> #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() } }; CalFormat::CalFormat() { mException = 0; } CalFormat::~CalFormat() { delete mException; @@ -69,30 +69,26 @@ ErrorFormat *CalFormat::exception() { return mException; } void CalFormat::setApplication(const QString& application, const QString& productID) { mApplication = application; mProductId = productID; } 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) { for (const CalVersion* cv = prodIds; cv->version; ++cv) { if (!strcmp(prodId, cv->prodId.local8Bit())) return cv->version; } return 0; } diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index eae41aa..fe7413f 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -357,27 +357,27 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) // vcc.y has been hacked to translate the ';' to a ',' when the vcal is // read in. tmpStr += ";"; } if (!tmpStr.isEmpty()) { tmpStr.truncate(tmpStr.length()-1); icalcomponent_add_property(parent,icalproperty_new_categories( writeText(incidence->getCategories().join(";")))); } */ // 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(); if (recur->doesRecur()) { icalcomponent_add_property(parent,writeRecurrenceRule(recur)); } // recurrence excpetion dates DateList dateList = incidence->exDates(); DateList::ConstIterator exIt; @@ -2027,29 +2027,33 @@ bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) ; } else { ; } SKIP: ; } // while #endif // 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; } QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) { // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " // << icalcomponent_as_ical_string(c) << endl; QString errorMessage; diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index a312ba5..6bca12c 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -381,25 +381,30 @@ QString Incidence::relatedToUid() const } void Incidence::setRelatedTo(Incidence *relatedTo) { //qDebug("Incidence::setRelatedTo %d ", relatedTo); //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); if (mReadOnly || mRelatedTo == relatedTo) return; if(mRelatedTo) { // 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 { return mRelatedTo; } QPtrList<Incidence> Incidence::relations() const { return mRelations; } diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 8794f7a..7906046 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -15,24 +15,26 @@ You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kglobal.h> #include <kglobalsettings.h> #include <klocale.h> #include <kdebug.h> #include <qregexp.h> +#include "calendarlocal.h" +#include "icalformat.h" #include "todo.h" using namespace KCal; Todo::Todo(): Incidence() { // mStatus = TENTATIVE; mHasDueDate = false; setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; @@ -46,24 +48,25 @@ Todo::Todo(const Todo &t) : Incidence(t) mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; mRunning = false; mRunSaveTimer = 0; } Todo::~Todo() { setRunning( false ); + qDebug("Todo::~Todo() "); } void Todo::setRunning( bool run ) { if ( run == mRunning ) return; if ( !mRunSaveTimer ) { mRunSaveTimer = new QTimer ( this ); connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); } mRunning = run; if ( mRunning ) { @@ -72,46 +75,41 @@ void Todo::setRunning( bool run ) } else { mRunSaveTimer->stop(); saveRunningInfoToFile(); } } 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() { if ( !mRunning ) return 0; return mRunStart.secsTo( QDateTime::currentDateTime() ); } bool Todo::hasRunningSub() { if ( mRunning ) return true; diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 62a31ae..8efc1ea 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -317,27 +317,27 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) "NEEDS_ACTION"); // completion date if (anEvent->hasCompletedDate()) { tmpStr = qDateTimeToISO(anEvent->completed()); addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); } // priority 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(); tmpStr = ""; QString catStr; for ( QStringList::Iterator it = tmpStrList.begin(); it != tmpStrList.end(); ++it ) { catStr = *it; if (catStr[0] == ' ') tmpStr += catStr.mid(1); @@ -663,27 +663,27 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) } } // priority tmpStr.sprintf("%i",anEvent->priority()); addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); // transparency 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 tmpStr.sprintf("%i",anEvent->pilotId()); addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); tmpStr.sprintf("%i",anEvent->syncStatus()); addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); } return vevent; } @@ -1595,29 +1595,33 @@ void VCalFormat::populate(VObject *vcal) // we have either already processed them or are ignoring them. ; } else { kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; } SKIP: ; } // while // 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) { const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; return days[day]; } int VCalFormat::numFromDay(const QString &day) { diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index e54b0d9..b65ce66 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp @@ -33,25 +33,26 @@ QFont KGlobalSettings::generalMaxFont() size = 18; #endif QFont f = QApplication::font(); if ( f.pointSize() > size ) f.setPointSize( size ); return f; } QString KGlobalSettings::timeTrackerDir() { static QString dir; if ( dir.isEmpty() ) { - dir = locateLocal( "data", "timetracker" ); + dir = locateLocal( "data", "timetrackerdir/d.ttl" ); + dir = dir.left ( dir.length() - 5); } return dir; } QFont KGlobalSettings::toolBarFont() { return QApplication::font(); } QColor KGlobalSettings::toolBarHighlightColor() { return QColor( "black" ); |