summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp66
1 files changed, 34 insertions, 32 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 9b38d3f..bf095cf 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -9,48 +9,50 @@
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 <stdlib.h>
#include <time.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include "exceptions.h"
#include "calfilter.h"
#include "calendar.h"
#include "syncdefines.h"
+//Added by qt3to4:
+#include <Q3PtrList>
using namespace KCal;
Calendar::Calendar()
{
init();
setTimeZoneId( " 00:00 Europe/London(UTC)" );
}
Calendar::Calendar( const QString &timeZoneId )
{
init();
setTimeZoneId(timeZoneId);
}
void Calendar::init()
{
mObserver = 0;
mNewObserver = false;
mUndoIncidence = 0;
mDeleteIncidencesOnClose = true;
mModified = false;
@@ -250,265 +252,265 @@ bool Calendar::isLocalTime() const
}
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()
+Q3PtrList<Incidence> Calendar::incidences()
{
- QPtrList<Incidence> incidences;
+ Q3PtrList<Incidence> incidences;
Incidence *i;
- QPtrList<Event> e = events();
+ Q3PtrList<Event> e = events();
for( i = e.first(); i; i = e.next() ) incidences.append( i );
- QPtrList<Todo> t = todos();
+ Q3PtrList<Todo> t = todos();
for( i = t.first(); i; i = t.next() ) incidences.append( i );
- QPtrList<Journal> j = journals();
+ Q3PtrList<Journal> j = journals();
for( i = j.first(); i; i = j.next() ) incidences.append( i );
return incidences;
}
void Calendar::resetPilotStat(int id )
{
- QPtrList<Incidence> incidences;
+ Q3PtrList<Incidence> incidences;
Incidence *i;
- QPtrList<Event> e = rawEvents();
+ Q3PtrList<Event> e = rawEvents();
for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
- QPtrList<Todo> t = rawTodos();
+ Q3PtrList<Todo> t = rawTodos();
for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
- QPtrList<Journal> j = journals();
+ Q3PtrList<Journal> j = journals();
for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
}
void Calendar::resetTempSyncStat()
{
- QPtrList<Incidence> incidences;
+ Q3PtrList<Incidence> incidences;
Incidence *i;
- QPtrList<Event> e = rawEvents();
+ Q3PtrList<Event> e = rawEvents();
for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
- QPtrList<Todo> t = rawTodos();
+ Q3PtrList<Todo> t = rawTodos();
for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
- QPtrList<Journal> j = journals();
+ Q3PtrList<Journal> j = journals();
for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
}
-QPtrList<Incidence> Calendar::rawIncidences()
+Q3PtrList<Incidence> Calendar::rawIncidences()
{
- QPtrList<Incidence> incidences;
+ Q3PtrList<Incidence> incidences;
Incidence *i;
- QPtrList<Event> e = rawEvents();
+ Q3PtrList<Event> e = rawEvents();
for( i = e.first(); i; i = e.next() ) incidences.append( i );
- QPtrList<Todo> t = rawTodos();
+ Q3PtrList<Todo> t = rawTodos();
for( i = t.first(); i; i = t.next() ) incidences.append( i );
- QPtrList<Journal> j = journals();
+ Q3PtrList<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 )
+Q3PtrList<Event> Calendar::events( const QDate &date, bool sorted )
{
- QPtrList<Event> el = rawEventsForDate(date,sorted);
+ Q3PtrList<Event> el = rawEventsForDate(date,sorted);
mFilter->apply(&el);
return el;
}
-QPtrList<Event> Calendar::events( const QDateTime &qdt )
+Q3PtrList<Event> Calendar::events( const QDateTime &qdt )
{
- QPtrList<Event> el = rawEventsForDate(qdt);
+ Q3PtrList<Event> el = rawEventsForDate(qdt);
mFilter->apply(&el);
return el;
}
-QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
+Q3PtrList<Event> Calendar::events( const QDate &start, const QDate &end,
bool inclusive)
{
- QPtrList<Event> el = rawEvents(start,end,inclusive);
+ Q3PtrList<Event> el = rawEvents(start,end,inclusive);
mFilter->apply(&el);
return el;
}
-QPtrList<Event> Calendar::events()
+Q3PtrList<Event> Calendar::events()
{
- QPtrList<Event> el = rawEvents();
+ Q3PtrList<Event> el = rawEvents();
mFilter->apply(&el);
return el;
}
void Calendar::addIncidenceBranch(Incidence *i)
{
addIncidence( i );
Incidence * inc;
- QPtrList<Incidence> Relations = i->relations();
+ Q3PtrList<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()
+Q3PtrList<Todo> Calendar::todos()
{
- QPtrList<Todo> tl = rawTodos();
+ Q3PtrList<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());
// 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());
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());
Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true );
if( parent ) {
// Found it
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());
// 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();
+ Q3PtrList<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;
+ Q3PtrList<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 ) {
+ for( Q3DictIterator<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;
}
}