-rw-r--r-- | libkcal/calendar.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 1350f6d..9b38d3f 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -166,361 +166,361 @@ void Calendar::setOwner(const QString &os) setModified( true ); } void Calendar::setTimeZone(const QString & tz) { bool neg = FALSE; int hours, minutes; QString tmpStr(tz); if (tmpStr.left(1) == "-") neg = TRUE; if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") tmpStr.remove(0, 1); hours = tmpStr.left(2).toInt(); if (tmpStr.length() > 2) minutes = tmpStr.right(2).toInt(); else minutes = 0; mTimeZone = (60*hours+minutes); if (neg) mTimeZone = -mTimeZone; mLocalTime = false; setModified( true ); } QString Calendar::getTimeZoneStr() const { if (mLocalTime) return ""; QString tmpStr; int hours = abs(mTimeZone / 60); int minutes = abs(mTimeZone % 60); bool neg = mTimeZone < 0; tmpStr.sprintf("%c%.2d%.2d", (neg ? '-' : '+'), hours, minutes); return tmpStr; } void Calendar::setTimeZone(int tz) { mTimeZone = tz; mLocalTime = false; setModified( true ); } int Calendar::getTimeZone() const { return mTimeZone; } void Calendar::setTimeZoneId(const QString &id) { mTimeZoneId = id; mLocalTime = false; mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); if ( mTimeZone > 1000) setLocalTime(); //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); setModified( true ); } QString Calendar::timeZoneId() const { return mTimeZoneId; } void Calendar::setLocalTime() { //qDebug("Calendar::setLocalTime() "); mLocalTime = true; mTimeZone = 0; mTimeZoneId = ""; setModified( true ); } bool Calendar::isLocalTime() const { return mLocalTime; } const QString &Calendar::getEmail() { return mOwnerEmail; } void Calendar::setEmail(const QString &e) { mOwnerEmail = e; setModified( true ); } void Calendar::setFilter(CalFilter *filter) { mFilter = filter; } CalFilter *Calendar::filter() { return mFilter; } QPtrList<Incidence> Calendar::incidences() { QPtrList<Incidence> incidences; Incidence *i; QPtrList<Event> e = events(); for( i = e.first(); i; i = e.next() ) incidences.append( i ); QPtrList<Todo> t = todos(); for( i = t.first(); i; i = t.next() ) incidences.append( i ); QPtrList<Journal> j = journals(); for( i = j.first(); i; i = j.next() ) incidences.append( i ); return incidences; } void Calendar::resetPilotStat(int id ) { QPtrList<Incidence> incidences; Incidence *i; QPtrList<Event> e = rawEvents(); for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); QPtrList<Todo> t = rawTodos(); for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); QPtrList<Journal> j = journals(); for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); } void Calendar::resetTempSyncStat() { QPtrList<Incidence> incidences; Incidence *i; QPtrList<Event> e = rawEvents(); for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); QPtrList<Todo> t = rawTodos(); for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); QPtrList<Journal> j = journals(); for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); } QPtrList<Incidence> Calendar::rawIncidences() { QPtrList<Incidence> incidences; Incidence *i; QPtrList<Event> e = rawEvents(); for( i = e.first(); i; i = e.next() ) incidences.append( i ); QPtrList<Todo> t = rawTodos(); for( i = t.first(); i; i = t.next() ) incidences.append( i ); QPtrList<Journal> j = journals(); for( i = j.first(); i; i = j.next() ) incidences.append( i ); return incidences; } QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) { QPtrList<Event> el = rawEventsForDate(date,sorted); mFilter->apply(&el); return el; } QPtrList<Event> Calendar::events( const QDateTime &qdt ) { QPtrList<Event> el = rawEventsForDate(qdt); mFilter->apply(&el); return el; } QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, bool inclusive) { QPtrList<Event> el = rawEvents(start,end,inclusive); mFilter->apply(&el); return el; } QPtrList<Event> Calendar::events() { QPtrList<Event> el = rawEvents(); mFilter->apply(&el); return el; } void Calendar::addIncidenceBranch(Incidence *i) { addIncidence( i ); Incidence * inc; QPtrList<Incidence> Relations = i->relations(); for (inc=Relations.first();inc;inc=Relations.next()) { addIncidenceBranch( inc ); } } bool Calendar::addIncidence(Incidence *i) { Incidence::AddVisitor<Calendar> v(this); if ( i->calID() == 0 ) i->setCalID_block( mDefaultCalendar ); i->setCalEnabled( true ); return i->accept(v); } void Calendar::deleteIncidence(Incidence *in) { if ( in->typeID() == eventID ) deleteEvent( (Event*) in ); else if ( in->typeID() == todoID ) deleteTodo( (Todo*) in); else if ( in->typeID() == journalID ) deleteJournal( (Journal*) in ); } Incidence* Calendar::incidence( const QString& uid ) { Incidence* i; if( (i = todo( uid )) != 0 ) return i; if( (i = event( uid )) != 0 ) return i; if( (i = journal( uid )) != 0 ) return i; return 0; } QPtrList<Todo> Calendar::todos() { QPtrList<Todo> tl = rawTodos(); mFilter->apply( &tl ); return tl; } // When this is called, the todo have already been added to the calendar. // This method is only about linking related todos void Calendar::setupRelations( Incidence *incidence ) { QString uid = incidence->uid(); - //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); + qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); // First, go over the list of orphans and see if this is their parent while( Incidence* i = mOrphans[ uid ] ) { mOrphans.remove( uid ); i->setRelatedTo( incidence ); - //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); + qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); incidence->addRelation( i ); mOrphanUids.remove( i->uid() ); } // Now see about this incidences parent if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { // This incidence has a uid it is related to, but is not registered to it yet // Try to find it - //qDebug("Test parent for %s", incidence->summary().latin1()); + qDebug("Test parent for %s", incidence->summary().latin1()); Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); if( parent ) { // Found it - // qDebug("parent found for for %s", incidence->summary().latin1()); + qDebug("parent found for for %s", incidence->summary().latin1()); incidence->setRelatedTo( parent ); parent->addRelation( incidence ); } else { - // qDebug("NO parent found for for %s", incidence->summary().latin1()); + qDebug("NO parent found for for %s", incidence->summary().latin1()); // Not found, put this in the mOrphans list mOrphans.insert( incidence->relatedToUid(), incidence ); mOrphanUids.insert( incidence->uid(), incidence ); } } } // If a task with subtasks is deleted, move it's subtasks to the orphans list void Calendar::removeRelations( Incidence *incidence ) { // qDebug("Calendar::removeRelations "); QString uid = incidence->uid(); QPtrList<Incidence> relations = incidence->relations(); for( Incidence* i = relations.first(); i; i = relations.next() ) if( !mOrphanUids.find( i->uid() ) ) { mOrphans.insert( uid, i ); mOrphanUids.insert( i->uid(), i ); i->setRelatedTo( 0 ); i->setRelatedToUid( uid ); } // If this incidence is related to something else, tell that about it if( incidence->relatedTo() ) incidence->relatedTo()->removeRelation( incidence ); // Remove this one from the orphans list if( mOrphanUids.remove( uid ) ) { QString r2uid = incidence->relatedToUid(); QPtrList<Incidence> tempList; while( Incidence* i = mOrphans[ r2uid ] ) { mOrphans.remove( r2uid ); if ( i != incidence ) tempList.append( i ); } Incidence* inc = tempList.first(); while ( inc ) { mOrphans.insert( r2uid, inc ); inc = tempList.next(); } } // LR: and another big bad bug found #if 0 // This incidence is located in the orphans list - it should be removed if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { // Removing wasn't that easy for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { if( it.current()->uid() == uid ) { mOrphans.remove( it.currentKey() ); break; } } } #endif } void Calendar::registerObserver( Observer *observer ) { mObserver = observer; mNewObserver = true; } void Calendar::setModified( bool modified ) { if ( mObserver ) mObserver->calendarModified( modified, this ); if ( modified != mModified || mNewObserver ) { mNewObserver = false; // if ( mObserver ) mObserver->calendarModified( modified, this ); mModified = modified; } } void Calendar::setLoadedProductId( const QString &id ) { mLoadedProductId = id; } QString Calendar::loadedProductId() { return mLoadedProductId; } //#include "calendar.moc" |