summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp78
1 files changed, 67 insertions, 11 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -152,2 +152,4 @@ bool CalendarLocal::addEvent( Event *event )
setModified( true );
+ event->setCalID( mDefaultCalendar );
+ event->setCalEnabled( true );
@@ -172,3 +174,3 @@ Event *CalendarLocal::event( const QString &uid )
for ( event = mEventList.first(); event; event = mEventList.next() ) {
- if ( event->uid() == uid ) {
+ if ( event->uid() == uid && event->calEnabled() ) {
return event;
@@ -200,3 +202,4 @@ bool CalendarLocal::addTodo( Todo *todo )
setModified( true );
-
+ todo->setCalID( mDefaultCalendar );
+ todo->setCalEnabled( true );
return true;
@@ -218,3 +221,6 @@ 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;
}
@@ -224,3 +230,3 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
@@ -269,3 +275,3 @@ Event *CalendarLocal::event( QString syncProf, QString id )
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
@@ -278,3 +284,3 @@ Todo *CalendarLocal::todo( const QString &uid )
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->uid() == uid ) return todo;
+ if ( todo->calEnabled() && todo->uid() == uid ) return todo;
}
@@ -391,2 +397,3 @@ QPtrList<Todo> CalendarLocal::todos( const QDate &date )
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( !todo->calEnabled() ) continue;
if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
@@ -423,2 +430,3 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
@@ -436,2 +444,3 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
@@ -466,2 +475,3 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
@@ -472,2 +482,3 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
appendAlarms( alarms, t, from, to );
@@ -545,2 +556,3 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
@@ -597,2 +609,3 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
@@ -672,3 +685,6 @@ 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;
}
@@ -687,3 +703,4 @@ bool CalendarLocal::addJournal(Journal *journal)
setModified( true );
-
+ journal->setCalID( mDefaultCalendar );
+ journal->setCalEnabled( true );
return true;
@@ -706,3 +723,3 @@ Journal *CalendarLocal::journal( const QDate &date )
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->dtStart().date() == date )
+ if ( it->calEnabled() && it->dtStart().date() == date )
return it;
@@ -715,3 +732,3 @@ 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;
@@ -723,4 +740,43 @@ 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);
+
+}