From d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 16 Jan 2005 11:22:49 +0000 Subject: filter impl --- diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8258c74..02c5e45 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1077,21 +1077,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int //remote->deleteIncidence( inR ); ++deletedEventR; } else { - inR->setLastModified( modifiedCalendar ); - inL = inR->clone(); - inL->setIDStr( ":" ); - inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); - inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); - local->addIncidence( inL ); - ++addedEvent; + if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ + inR->setLastModified( modifiedCalendar ); + inL = inR->clone(); + inL->setIDStr( ":" ); + inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); + inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); + local->addIncidence( inL ); + ++addedEvent; + } } } else { if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { - inR->setLastModified( modifiedCalendar ); - inL = inR->clone(); - inL->setIDStr( ":" ); - local->addIncidence( inL ); - ++addedEvent; + if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ + inR->setLastModified( modifiedCalendar ); + inL = inR->clone(); + inL->setIDStr( ":" ); + local->addIncidence( inL ); + ++addedEvent; + } } else { checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); @@ -1134,14 +1138,16 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++deletedEventL; } else { if ( ! mSyncManager->mWriteBackExistingOnly ) { - inL->removeID(mCurrentSyncDevice ); - ++addedEventR; - //qDebug("remote added Incidence %s ", inL->summary().latin1()); - inL->setLastModified( modifiedCalendar ); - inR = inL->clone(); - inR->setIDStr( ":" ); - inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); - remote->addIncidence( inR ); + if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ + inL->removeID(mCurrentSyncDevice ); + ++addedEventR; + //qDebug("remote added Incidence %s ", inL->summary().latin1()); + inL->setLastModified( modifiedCalendar ); + inR = inL->clone(); + inR->setIDStr( ":" ); + inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + remote->addIncidence( inR ); + } } } } else { @@ -1151,11 +1157,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++deletedEventL; } else { if ( ! mSyncManager->mWriteBackExistingOnly ) { - ++addedEventR; - inL->setLastModified( modifiedCalendar ); - inR = inL->clone(); - inR->setIDStr( ":" ); - remote->addIncidence( inR ); + if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ + ++addedEventR; + inL->setLastModified( modifiedCalendar ); + inR = inL->clone(); + inR->setIDStr( ":" ); + remote->addIncidence( inR ); + } } } } diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp index ca09844..df84911 100644 --- a/korganizer/filtereditdialog.cpp +++ b/korganizer/filtereditdialog.cpp @@ -235,6 +235,10 @@ void FilterEditDialog::readFilter(CalFilter *filter) mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic); mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); + + mEditor->mEventCheck->setChecked(c & CalFilter::HideEvents); + mEditor->mTodoCheck->setChecked(c & CalFilter::HideTodos); + mEditor->mJournalCheck->setChecked(c & CalFilter::HideJournals); if (c & CalFilter::ShowCategories) { mEditor->mCatShowCheck->setChecked(true); @@ -259,6 +263,9 @@ void FilterEditDialog::writeFilter(CalFilter *filter) if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; + if (mEditor->mEventCheck->isChecked()) c |= CalFilter::HideEvents; + if (mEditor->mTodoCheck->isChecked()) c |= CalFilter::HideTodos; + if (mEditor->mJournalCheck->isChecked()) c |= CalFilter::HideJournals; filter->setCriteria(c); diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index c182db5..c425dfc 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp @@ -64,9 +64,6 @@ void CalFilter::apply(QPtrList *eventlist) void CalFilter::apply(QPtrList *eventlist) { if (!mEnabled) return; - -// kdDebug(5800) << "CalFilter::apply()" << endl; - Todo *event = eventlist->first(); while(event) { if (!filterTodo(event)) { @@ -79,22 +76,36 @@ void CalFilter::apply(QPtrList *eventlist) // kdDebug(5800) << "CalFilter::apply() done" << endl; } - +bool CalFilter::filterCalendarItem(Incidence *in) +{ + if ( in->type() == "Event" ) + return filterEvent( (Event*) in ); + else if ( in->type() =="Todo" ) + return filterTodo( (Todo*) in); + else if ( in->type() =="Journal" ) + return filterJournal( (Journal*) in ); + return false; +} bool CalFilter::filterEvent(Event *event) { -// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; - + if (mCriteria & HideEvents) + return false; if (mCriteria & HideRecurring) { if (event->recurrence()->doesRecur()) return false; } return filterIncidence(event); } - +bool CalFilter::filterJournal(Journal *j) +{ + if (mCriteria & HideJournals) + return false; + return true; +} bool CalFilter::filterTodo(Todo *todo) { -// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; - + if (mCriteria & HideTodos) + return false; if (mCriteria & HideCompleted) { if (todo->isCompleted()) return false; } diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h index 5ad0064..29db441 100644 --- a/libkcal/calfilter.h +++ b/libkcal/calfilter.h @@ -61,7 +61,8 @@ class CalFilter { removed from the list. */ void apply(QPtrList *todolist); - + bool CalFilter::filterCalendarItem(Incidence *in); + bool CalFilter::filterJournal(Journal *in); /** Apply filter criteria on the specified event. Return true, if event passes criteria, otherwise return false. -- cgit v0.9.0.2