summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
authorzautrix <zautrix>2005-06-10 20:13:31 (UTC)
committer zautrix <zautrix>2005-06-10 20:13:31 (UTC)
commitcdc55afb3d2c3ebd970843b7dce02acb1e6a189b (patch) (side-by-side diff)
tree45f3bfa69a72de4e8b53bbcb2414478ec65cd183 /libkcal/calendarlocal.cpp
parent31fed261955dcb25d06052a8154ac4cc630b0f7d (diff)
downloadkdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.zip
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.gz
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.bz2
many preparations for multiple calendars
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp80
1 files changed, 68 insertions, 12 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -150,6 +150,8 @@ bool CalendarLocal::addEvent( Event *event )
event->registerObserver( this );
setModified( true );
+ event->setCalID( mDefaultCalendar );
+ event->setCalEnabled( true );
return true;
}
@@ -170,7 +172,7 @@ Event *CalendarLocal::event( const QString &uid )
Event *event;
for ( event = mEventList.first(); event; event = mEventList.next() ) {
- if ( event->uid() == uid ) {
+ if ( event->uid() == uid && event->calEnabled() ) {
return event;
}
}
@@ -198,7 +200,8 @@ bool CalendarLocal::addTodo( Todo *todo )
setupRelations( todo );
setModified( true );
-
+ todo->setCalID( mDefaultCalendar );
+ todo->setCalEnabled( true );
return true;
}
@@ -216,13 +219,16 @@ void CalendarLocal::deleteTodo( Todo *todo )
QPtrList<Todo> CalendarLocal::rawTodos()
{
- return mTodoList;
+ QPtrList<Todo> el;
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
Todo *CalendarLocal::todo( QString syncProf, QString id )
{
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
return 0;
@@ -267,7 +273,7 @@ Event *CalendarLocal::event( QString syncProf, QString id )
{
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
return 0;
@@ -276,7 +282,7 @@ Todo *CalendarLocal::todo( const QString &uid )
{
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->uid() == uid ) return todo;
+ if ( todo->calEnabled() && todo->uid() == uid ) return todo;
}
return 0;
@@ -389,6 +395,7 @@ QPtrList<Todo> CalendarLocal::todos( const QDate &date )
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( !todo->calEnabled() ) continue;
if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
todos.append( todo );
}
@@ -421,6 +428,7 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
int offset;
mNextAlarmIncidence = 0;
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( next < nextA ) {
@@ -434,6 +442,7 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
}
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( next < nextA ) {
@@ -464,13 +473,15 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
Event *e;
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
else appendAlarms( alarms, e, from, to );
}
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
- appendAlarms( alarms, t, from, to );
+ if ( !t->calEnabled() ) continue;
+ appendAlarms( alarms, t, from, to );
}
return alarms;
@@ -543,6 +554,7 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
Event *event;
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
if ( event->isMultiDay() ) {
int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
@@ -595,6 +607,7 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
// Get non-recurring events
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
QDate rStart = event->dtStart().date();
bool found = false;
@@ -670,7 +683,10 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
QPtrList<Event> CalendarLocal::rawEvents()
{
- return mEventList;
+ QPtrList<Event> el;
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
bool CalendarLocal::addJournal(Journal *journal)
@@ -685,7 +701,8 @@ bool CalendarLocal::addJournal(Journal *journal)
journal->registerObserver( this );
setModified( true );
-
+ journal->setCalID( mDefaultCalendar );
+ journal->setCalEnabled( true );
return true;
}
@@ -704,7 +721,7 @@ Journal *CalendarLocal::journal( const QDate &date )
// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->dtStart().date() == date )
+ if ( it->calEnabled() && it->dtStart().date() == date )
return it;
return 0;
@@ -713,7 +730,7 @@ Journal *CalendarLocal::journal( const QDate &date )
Journal *CalendarLocal::journal( const QString &uid )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->uid() == uid )
+ if ( it->calEnabled() && it->uid() == uid )
return it;
return 0;
@@ -721,6 +738,45 @@ Journal *CalendarLocal::journal( const QString &uid )
QPtrList<Journal> CalendarLocal::journals()
{
- return mJournalList;
+ QPtrList<Journal> el;
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
+void CalendarLocal::setCalendarEnabled( int id, bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+}
+void CalendarLocal::setAlarmEnabled( int id, bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+}
+void CalendarLocal::setDefaultCalendarEnabledOnly()
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar);
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar);
+
+}