summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-16 11:22:49 (UTC)
committer zautrix <zautrix>2005-01-16 11:22:49 (UTC)
commitd57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b (patch) (side-by-side diff)
tree522438ce187845f6d74d7888be203759138615fa
parent92b8de5ff678bddf69b9f0a45c1d90829c50c592 (diff)
downloadkdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.zip
kdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.tar.gz
kdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.tar.bz2
filter impl
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp58
-rw-r--r--korganizer/filtereditdialog.cpp7
-rw-r--r--libkcal/calfilter.cpp29
-rw-r--r--libkcal/calfilter.h3
4 files changed, 62 insertions, 35 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8258c74..02c5e45 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1068,39 +1068,43 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
} else { // no conflict ********** add or delete remote
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";
if ( inR->type() == "Todo" )
pref = "t";
if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//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 );
++deletedEventR;
}
}
}
}
inR = er.next();
}
QPtrList<Incidence> el = local->rawIncidences();
inL = el.first();
@@ -1125,46 +1129,50 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) { // no conflict ********** add or delete local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++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 {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++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 );
+ }
}
}
}
}
}
inL = el.next();
}
int delFut = 0;
int remRem = 0;
if ( mSyncManager->mWriteBackInFuture ) {
er = remote->rawIncidences();
remRem = er.count();
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp
index ca09844..df84911 100644
--- a/korganizer/filtereditdialog.cpp
+++ b/korganizer/filtereditdialog.cpp
@@ -226,45 +226,52 @@ void FilterEditDialog::filterSelected()
if (f) readFilter(f);
}
void FilterEditDialog::readFilter(CalFilter *filter)
{
int c = filter->criteria();
mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted);
mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring);
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);
} else {
mEditor->mCatHideCheck->setChecked(true);
}
mEditor->mCatList->clear();
mEditor->mCatList->insertStringList(filter->categoryList());
mCategories = filter->categoryList();
setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 ));
}
void FilterEditDialog::writeFilter(CalFilter *filter)
{
int c = 0;
if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted;
if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring;
if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories;
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);
QStringList categoryList;
for(uint i=0;i<mEditor->mCatList->count();++i) {
categoryList.append(mEditor->mCatList->text(i));
}
filter->setCategoryList(categoryList);
}
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c182db5..c425dfc 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -55,55 +55,66 @@ void CalFilter::apply(QPtrList<Event> *eventlist)
} else {
event = eventlist->next();
}
}
// kdDebug(5800) << "CalFilter::apply() done" << endl;
}
// TODO: avoid duplicating apply() code
void CalFilter::apply(QPtrList<Todo> *eventlist)
{
if (!mEnabled) return;
-
-// kdDebug(5800) << "CalFilter::apply()" << endl;
-
Todo *event = eventlist->first();
while(event) {
if (!filterTodo(event)) {
eventlist->remove();
event = eventlist->current();
} else {
event = eventlist->next();
}
}
// 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;
}
return filterIncidence(todo);
}
bool CalFilter::showCategories()
{
return mCriteria & ShowCategories;
}
int CalFilter::getSecrecy()
{
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 5ad0064..29db441 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -52,25 +52,26 @@ class CalFilter {
/**
Apply filter to eventlist, all events not matching filter criterias are
removed from the list.
*/
void apply(QPtrList<Event> *eventlist);
/**
Apply filter to todolist, all todos not matching filter criterias are
removed from the list.
*/
void apply(QPtrList<Todo> *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.
*/
bool filterEvent(Event *);
/**
Apply filter criteria on the specified todo. Return true, if event passes
criteria, otherwise return false.
*/
bool filterTodo(Todo *);