summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -984,271 +984,279 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
984 else 984 else
985 mLastCalendarSync = eventLSync->dtStart(); 985 mLastCalendarSync = eventLSync->dtStart();
986 // for resyncing if own file has changed 986 // for resyncing if own file has changed
987 if ( mCurrentSyncDevice == "deleteaftersync" ) { 987 if ( mCurrentSyncDevice == "deleteaftersync" ) {
988 mLastCalendarSync = loadedFileVersion; 988 mLastCalendarSync = loadedFileVersion;
989 //qDebug("setting mLastCalendarSync "); 989 //qDebug("setting mLastCalendarSync ");
990 } 990 }
991 //qDebug("*************************** "); 991 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
993 QPtrList<Incidence> er = remote->rawIncidences(); 993 QPtrList<Incidence> er = remote->rawIncidences();
994 Incidence* inR = er.first(); 994 Incidence* inR = er.first();
995 Incidence* inL; 995 Incidence* inL;
996 QProgressBar bar( er.count(),0 ); 996 QProgressBar bar( er.count(),0 );
997 bar.setCaption (i18n("Syncing - close to abort!") ); 997 bar.setCaption (i18n("Syncing - close to abort!") );
998 998
999 // ************** setting up filter ************* 999 // ************** setting up filter *************
1000 CalFilter *filterIN = 0; 1000 CalFilter *filterIN = 0;
1001 CalFilter *filterOUT = 0; 1001 CalFilter *filterOUT = 0;
1002 CalFilter *filter = mFilters.first(); 1002 CalFilter *filter = mFilters.first();
1003 while(filter) { 1003 while(filter) {
1004 if ( filter->name() == mSyncManager->mFilterInCal ) 1004 if ( filter->name() == mSyncManager->mFilterInCal )
1005 filterIN = filter; 1005 filterIN = filter;
1006 if ( filter->name() == mSyncManager->mFilterOutCal ) 1006 if ( filter->name() == mSyncManager->mFilterOutCal )
1007 filterOUT = filter; 1007 filterOUT = filter;
1008 filter = mFilters.next(); 1008 filter = mFilters.next();
1009 } 1009 }
1010 int w = 300; 1010 int w = 300;
1011 if ( QApplication::desktop()->width() < 320 ) 1011 if ( QApplication::desktop()->width() < 320 )
1012 w = 220; 1012 w = 220;
1013 int h = bar.sizeHint().height() ; 1013 int h = bar.sizeHint().height() ;
1014 int dw = QApplication::desktop()->width(); 1014 int dw = QApplication::desktop()->width();
1015 int dh = QApplication::desktop()->height(); 1015 int dh = QApplication::desktop()->height();
1016 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1016 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1017 bar.show(); 1017 bar.show();
1018 int modulo = (er.count()/10)+1; 1018 int modulo = (er.count()/10)+1;
1019 int incCounter = 0; 1019 int incCounter = 0;
1020 while ( inR ) { 1020 while ( inR ) {
1021 if ( ! bar.isVisible() ) 1021 if ( ! bar.isVisible() )
1022 return false; 1022 return false;
1023 if ( incCounter % modulo == 0 ) 1023 if ( incCounter % modulo == 0 )
1024 bar.setProgress( incCounter ); 1024 bar.setProgress( incCounter );
1025 ++incCounter; 1025 ++incCounter;
1026 uid = inR->uid(); 1026 uid = inR->uid();
1027 bool skipIncidence = false; 1027 bool skipIncidence = false;
1028 if ( uid.left(15) == QString("last-syncEvent-") ) 1028 if ( uid.left(15) == QString("last-syncEvent-") )
1029 skipIncidence = true; 1029 skipIncidence = true;
1030 QString idS; 1030 QString idS;
1031 qApp->processEvents(); 1031 qApp->processEvents();
1032 if ( !skipIncidence ) { 1032 if ( !skipIncidence ) {
1033 inL = local->incidence( uid ); 1033 inL = local->incidence( uid );
1034 if ( inL ) { // maybe conflict - same uid in both calendars 1034 if ( inL ) { // maybe conflict - same uid in both calendars
1035 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1035 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1036 //qDebug("take %d %s ", take, inL->summary().latin1()); 1036 //qDebug("take %d %s ", take, inL->summary().latin1());
1037 if ( take == 3 ) 1037 if ( take == 3 )
1038 return false; 1038 return false;
1039 if ( take == 1 ) {// take local ********************** 1039 if ( take == 1 ) {// take local **********************
1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1042 else 1042 else
1043 idS = inR->IDStr(); 1043 idS = inR->IDStr();
1044 remote->deleteIncidence( inR ); 1044 remote->deleteIncidence( inR );
1045 inR = inL->clone(); 1045 inR = inL->clone();
1046 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1046 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1047 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1047 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1048 inR->setIDStr( idS ); 1048 inR->setIDStr( idS );
1049 remote->addIncidence( inR ); 1049 remote->addIncidence( inR );
1050 if ( mSyncManager->syncWithDesktop() ) 1050 if ( mSyncManager->syncWithDesktop() )
1051 inR->setPilotId( 2 ); 1051 inR->setPilotId( 2 );
1052 ++changedRemote; 1052 ++changedRemote;
1053 } else {// take remote ********************** 1053 } else {// take remote **********************
1054 idS = inL->IDStr(); 1054 idS = inL->IDStr();
1055 int pid = inL->pilotId(); 1055 int pid = inL->pilotId();
1056 local->deleteIncidence( inL ); 1056 local->deleteIncidence( inL );
1057 inL = inR->clone(); 1057 inL = inR->clone();
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inL->setPilotId( pid ); 1059 inL->setPilotId( pid );
1060 inL->setIDStr( idS ); 1060 inL->setIDStr( idS );
1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1064 } 1064 }
1065 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1066 ++changedLocal; 1066 ++changedLocal;
1067 } 1067 }
1068 } 1068 }
1069 } else { // no conflict ********** add or delete remote 1069 } else { // no conflict ********** add or delete remote
1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1071 QString des = eventLSync->description(); 1071 QString des = eventLSync->description();
1072 QString pref = "e"; 1072 QString pref = "e";
1073 if ( inR->type() == "Todo" ) 1073 if ( inR->type() == "Todo" )
1074 pref = "t"; 1074 pref = "t";
1075 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1075 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1077 //remote->deleteIncidence( inR ); 1077 //remote->deleteIncidence( inR );
1078 ++deletedEventR; 1078 ++deletedEventR;
1079 } else { 1079 } else {
1080 inR->setLastModified( modifiedCalendar ); 1080 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1081 inL = inR->clone(); 1081 inR->setLastModified( modifiedCalendar );
1082 inL->setIDStr( ":" ); 1082 inL = inR->clone();
1083 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1083 inL->setIDStr( ":" );
1084 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1084 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1085 local->addIncidence( inL ); 1085 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1086 ++addedEvent; 1086 local->addIncidence( inL );
1087 ++addedEvent;
1088 }
1087 } 1089 }
1088 } else { 1090 } else {
1089 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1091 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1090 inR->setLastModified( modifiedCalendar ); 1092 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1091 inL = inR->clone(); 1093 inR->setLastModified( modifiedCalendar );
1092 inL->setIDStr( ":" ); 1094 inL = inR->clone();
1093 local->addIncidence( inL ); 1095 inL->setIDStr( ":" );
1094 ++addedEvent; 1096 local->addIncidence( inL );
1097 ++addedEvent;
1098 }
1095 } else { 1099 } else {
1096 checkExternSyncEvent(eventRSyncSharp, inR); 1100 checkExternSyncEvent(eventRSyncSharp, inR);
1097 remote->deleteIncidence( inR ); 1101 remote->deleteIncidence( inR );
1098 ++deletedEventR; 1102 ++deletedEventR;
1099 } 1103 }
1100 } 1104 }
1101 } 1105 }
1102 } 1106 }
1103 inR = er.next(); 1107 inR = er.next();
1104 } 1108 }
1105 QPtrList<Incidence> el = local->rawIncidences(); 1109 QPtrList<Incidence> el = local->rawIncidences();
1106 inL = el.first(); 1110 inL = el.first();
1107 modulo = (el.count()/10)+1; 1111 modulo = (el.count()/10)+1;
1108 bar.setCaption (i18n("Add / remove events") ); 1112 bar.setCaption (i18n("Add / remove events") );
1109 bar.setTotalSteps ( el.count() ) ; 1113 bar.setTotalSteps ( el.count() ) ;
1110 bar.show(); 1114 bar.show();
1111 incCounter = 0; 1115 incCounter = 0;
1112 1116
1113 while ( inL ) { 1117 while ( inL ) {
1114 1118
1115 qApp->processEvents(); 1119 qApp->processEvents();
1116 if ( ! bar.isVisible() ) 1120 if ( ! bar.isVisible() )
1117 return false; 1121 return false;
1118 if ( incCounter % modulo == 0 ) 1122 if ( incCounter % modulo == 0 )
1119 bar.setProgress( incCounter ); 1123 bar.setProgress( incCounter );
1120 ++incCounter; 1124 ++incCounter;
1121 uid = inL->uid(); 1125 uid = inL->uid();
1122 bool skipIncidence = false; 1126 bool skipIncidence = false;
1123 if ( uid.left(15) == QString("last-syncEvent-") ) 1127 if ( uid.left(15) == QString("last-syncEvent-") )
1124 skipIncidence = true; 1128 skipIncidence = true;
1125 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1126 skipIncidence = true; 1130 skipIncidence = true;
1127 if ( !skipIncidence ) { 1131 if ( !skipIncidence ) {
1128 inR = remote->incidence( uid ); 1132 inR = remote->incidence( uid );
1129 if ( ! inR ) { // no conflict ********** add or delete local 1133 if ( ! inR ) { // no conflict ********** add or delete local
1130 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1131 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1135 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1132 checkExternSyncEvent(eventLSyncSharp, inL); 1136 checkExternSyncEvent(eventLSyncSharp, inL);
1133 local->deleteIncidence( inL ); 1137 local->deleteIncidence( inL );
1134 ++deletedEventL; 1138 ++deletedEventL;
1135 } else { 1139 } else {
1136 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1140 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1137 inL->removeID(mCurrentSyncDevice ); 1141 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1138 ++addedEventR; 1142 inL->removeID(mCurrentSyncDevice );
1139 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1143 ++addedEventR;
1140 inL->setLastModified( modifiedCalendar ); 1144 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1141 inR = inL->clone(); 1145 inL->setLastModified( modifiedCalendar );
1142 inR->setIDStr( ":" ); 1146 inR = inL->clone();
1143 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1147 inR->setIDStr( ":" );
1144 remote->addIncidence( inR ); 1148 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1149 remote->addIncidence( inR );
1150 }
1145 } 1151 }
1146 } 1152 }
1147 } else { 1153 } else {
1148 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1154 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1149 checkExternSyncEvent(eventLSyncSharp, inL); 1155 checkExternSyncEvent(eventLSyncSharp, inL);
1150 local->deleteIncidence( inL ); 1156 local->deleteIncidence( inL );
1151 ++deletedEventL; 1157 ++deletedEventL;
1152 } else { 1158 } else {
1153 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1159 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1154 ++addedEventR; 1160 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1155 inL->setLastModified( modifiedCalendar ); 1161 ++addedEventR;
1156 inR = inL->clone(); 1162 inL->setLastModified( modifiedCalendar );
1157 inR->setIDStr( ":" ); 1163 inR = inL->clone();
1158 remote->addIncidence( inR ); 1164 inR->setIDStr( ":" );
1165 remote->addIncidence( inR );
1166 }
1159 } 1167 }
1160 } 1168 }
1161 } 1169 }
1162 } 1170 }
1163 } 1171 }
1164 inL = el.next(); 1172 inL = el.next();
1165 } 1173 }
1166 int delFut = 0; 1174 int delFut = 0;
1167 int remRem = 0; 1175 int remRem = 0;
1168 if ( mSyncManager->mWriteBackInFuture ) { 1176 if ( mSyncManager->mWriteBackInFuture ) {
1169 er = remote->rawIncidences(); 1177 er = remote->rawIncidences();
1170 remRem = er.count(); 1178 remRem = er.count();
1171 inR = er.first(); 1179 inR = er.first();
1172 QDateTime dt; 1180 QDateTime dt;
1173 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1181 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1174 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1182 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1175 while ( inR ) { 1183 while ( inR ) {
1176 if ( inR->type() == "Todo" ) { 1184 if ( inR->type() == "Todo" ) {
1177 Todo * t = (Todo*)inR; 1185 Todo * t = (Todo*)inR;
1178 if ( t->hasDueDate() ) 1186 if ( t->hasDueDate() )
1179 dt = t->dtDue(); 1187 dt = t->dtDue();
1180 else 1188 else
1181 dt = cur.addSecs( 62 ); 1189 dt = cur.addSecs( 62 );
1182 } 1190 }
1183 else if (inR->type() == "Event" ) { 1191 else if (inR->type() == "Event" ) {
1184 bool ok; 1192 bool ok;
1185 dt = inR->getNextOccurence( cur, &ok ); 1193 dt = inR->getNextOccurence( cur, &ok );
1186 if ( !ok ) 1194 if ( !ok )
1187 dt = cur.addSecs( -62 ); 1195 dt = cur.addSecs( -62 );
1188 } 1196 }
1189 else 1197 else
1190 dt = inR->dtStart(); 1198 dt = inR->dtStart();
1191 if ( dt < cur || dt > end ) { 1199 if ( dt < cur || dt > end ) {
1192 remote->deleteIncidence( inR ); 1200 remote->deleteIncidence( inR );
1193 ++delFut; 1201 ++delFut;
1194 } 1202 }
1195 inR = er.next(); 1203 inR = er.next();
1196 } 1204 }
1197 } 1205 }
1198 bar.hide(); 1206 bar.hide();
1199 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1207 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1200 eventLSync->setReadOnly( false ); 1208 eventLSync->setReadOnly( false );
1201 eventLSync->setDtStart( mLastCalendarSync ); 1209 eventLSync->setDtStart( mLastCalendarSync );
1202 eventRSync->setDtStart( mLastCalendarSync ); 1210 eventRSync->setDtStart( mLastCalendarSync );
1203 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1211 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1204 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1212 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1205 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1213 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1206 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1214 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1207 eventLSync->setReadOnly( true ); 1215 eventLSync->setReadOnly( true );
1208 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1216 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1209 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1217 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1210 remote->addEvent( eventRSync ); 1218 remote->addEvent( eventRSync );
1211 else 1219 else
1212 delete eventRSync; 1220 delete eventRSync;
1213 QString mes; 1221 QString mes;
1214 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1222 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1215 QString delmess; 1223 QString delmess;
1216 if ( delFut ) { 1224 if ( delFut ) {
1217 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1225 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1218 mes += delmess; 1226 mes += delmess;
1219 } 1227 }
1220 mes = i18n("Local calendar changed!\n") +mes; 1228 mes = i18n("Local calendar changed!\n") +mes;
1221 mCalendar->checkAlarmForIncidence( 0, true ); 1229 mCalendar->checkAlarmForIncidence( 0, true );
1222 qDebug( mes ); 1230 qDebug( mes );
1223 if ( mSyncManager->mShowSyncSummary ) { 1231 if ( mSyncManager->mShowSyncSummary ) {
1224 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1232 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1225 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1233 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1226 qDebug("cancelled "); 1234 qDebug("cancelled ");
1227 return false; 1235 return false;
1228 } 1236 }
1229 } 1237 }
1230 return syncOK; 1238 return syncOK;
1231} 1239}
1232 1240
1233void CalendarView::setSyncDevice( QString s ) 1241void CalendarView::setSyncDevice( QString s )
1234{ 1242{
1235 mCurrentSyncDevice= s; 1243 mCurrentSyncDevice= s;
1236} 1244}
1237void CalendarView::setSyncName( QString s ) 1245void CalendarView::setSyncName( QString s )
1238{ 1246{
1239 mCurrentSyncName= s; 1247 mCurrentSyncName= s;
1240} 1248}
1241bool CalendarView::syncCalendar(QString filename, int mode) 1249bool CalendarView::syncCalendar(QString filename, int mode)
1242{ 1250{
1243 //qDebug("syncCalendar %s ", filename.latin1()); 1251 //qDebug("syncCalendar %s ", filename.latin1());
1244 mGlobalSyncMode = SYNC_MODE_NORMAL; 1252 mGlobalSyncMode = SYNC_MODE_NORMAL;
1245 CalendarLocal* calendar = new CalendarLocal(); 1253 CalendarLocal* calendar = new CalendarLocal();
1246 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1254 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1247 FileStorage* storage = new FileStorage( calendar ); 1255 FileStorage* storage = new FileStorage( calendar );
1248 bool syncOK = false; 1256 bool syncOK = false;
1249 storage->setFileName( filename ); 1257 storage->setFileName( filename );
1250 // qDebug("loading ... "); 1258 // qDebug("loading ... ");
1251 if ( storage->load() ) { 1259 if ( storage->load() ) {
1252 getEventViewerDialog()->setSyncMode( true ); 1260 getEventViewerDialog()->setSyncMode( true );
1253 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1261 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1254 getEventViewerDialog()->setSyncMode( false ); 1262 getEventViewerDialog()->setSyncMode( false );
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp
index ca09844..df84911 100644
--- a/korganizer/filtereditdialog.cpp
+++ b/korganizer/filtereditdialog.cpp
@@ -142,129 +142,136 @@ void FilterEditDialog::updateFilterList()
142 142
143 mRemoveButton->setEnabled( mFilters->count() > 1 ); 143 mRemoveButton->setEnabled( mFilters->count() > 1 );
144} 144}
145 145
146void FilterEditDialog::slotDefault() 146void FilterEditDialog::slotDefault()
147{ 147{
148} 148}
149 149
150void FilterEditDialog::slotApply() 150void FilterEditDialog::slotApply()
151{ 151{
152 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 152 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
153 writeFilter(f); 153 writeFilter(f);
154 emit filterChanged(); 154 emit filterChanged();
155} 155}
156void FilterEditDialog::accept() 156void FilterEditDialog::accept()
157{ 157{
158 slotOk(); 158 slotOk();
159} 159}
160void FilterEditDialog::slotOk() 160void FilterEditDialog::slotOk()
161{ 161{
162 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 162 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
163 writeFilter(f); 163 writeFilter(f);
164 emit filterChanged(); 164 emit filterChanged();
165 QDialog::accept(); 165 QDialog::accept();
166} 166}
167 167
168void FilterEditDialog::slotAdd() 168void FilterEditDialog::slotAdd()
169{ 169{
170 KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this); 170 KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this);
171 dlg.setCaption(i18n("Add Filter")); 171 dlg.setCaption(i18n("Add Filter"));
172 if (dlg.exec()) { 172 if (dlg.exec()) {
173 if ( dlg.text().length() > 0 ) { 173 if ( dlg.text().length() > 0 ) {
174 mFilters->append(new CalFilter(dlg.text())); 174 mFilters->append(new CalFilter(dlg.text()));
175 updateFilterList(); 175 updateFilterList();
176 int num = mSelectionCombo->count() -1 ; 176 int num = mSelectionCombo->count() -1 ;
177 mSelectionCombo->setCurrentItem( num ); 177 mSelectionCombo->setCurrentItem( num );
178 readFilter(mFilters->at( num ) ); 178 readFilter(mFilters->at( num ) );
179 } 179 }
180 } 180 }
181} 181}
182 182
183void FilterEditDialog::slotRemove() 183void FilterEditDialog::slotRemove()
184{ 184{
185 int currentItem = mSelectionCombo->currentItem(); 185 int currentItem = mSelectionCombo->currentItem();
186 if ( currentItem < 0 ) return; 186 if ( currentItem < 0 ) return;
187 187
188 // We need at least a default filter object. 188 // We need at least a default filter object.
189 if ( mFilters->count() <= 1 ) return; 189 if ( mFilters->count() <= 1 ) return;
190 190
191 int result = KMessageBox::questionYesNo( this, 191 int result = KMessageBox::questionYesNo( this,
192 i18n("This item will be\npermanently deleted.") ); 192 i18n("This item will be\npermanently deleted.") );
193 193
194 if ( result != KMessageBox::Yes ) { 194 if ( result != KMessageBox::Yes ) {
195 return; 195 return;
196 } 196 }
197 197
198 mFilters->remove( currentItem ); 198 mFilters->remove( currentItem );
199 updateFilterList(); 199 updateFilterList();
200 emit filterChanged(); 200 emit filterChanged();
201} 201}
202 202
203void FilterEditDialog::editCategorySelection() 203void FilterEditDialog::editCategorySelection()
204{ 204{
205 KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog( 205 KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog(
206 KOPrefs::instance(), this, "filterCatSelect", true ); 206 KOPrefs::instance(), this, "filterCatSelect", true );
207 dlg->setSelected(mCategories); 207 dlg->setSelected(mCategories);
208 208
209 connect(dlg,SIGNAL(categoriesSelected(const QStringList &)), 209 connect(dlg,SIGNAL(categoriesSelected(const QStringList &)),
210 SLOT(updateCategorySelection(const QStringList &))); 210 SLOT(updateCategorySelection(const QStringList &)));
211 211
212 dlg->exec(); 212 dlg->exec();
213} 213}
214 214
215void FilterEditDialog::updateCategorySelection(const QStringList &categories) 215void FilterEditDialog::updateCategorySelection(const QStringList &categories)
216{ 216{
217 mCategories = categories; 217 mCategories = categories;
218 218
219 mEditor->mCatList->clear(); 219 mEditor->mCatList->clear();
220 mEditor->mCatList->insertStringList(mCategories); 220 mEditor->mCatList->insertStringList(mCategories);
221} 221}
222 222
223void FilterEditDialog::filterSelected() 223void FilterEditDialog::filterSelected()
224{ 224{
225 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 225 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
226 if (f) readFilter(f); 226 if (f) readFilter(f);
227} 227}
228 228
229void FilterEditDialog::readFilter(CalFilter *filter) 229void FilterEditDialog::readFilter(CalFilter *filter)
230{ 230{
231 int c = filter->criteria(); 231 int c = filter->criteria();
232 232
233 mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted); 233 mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted);
234 mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring); 234 mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring);
235 mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic); 235 mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic);
236 mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); 236 mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate);
237 mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); 237 mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential);
238
239 mEditor->mEventCheck->setChecked(c & CalFilter::HideEvents);
240 mEditor->mTodoCheck->setChecked(c & CalFilter::HideTodos);
241 mEditor->mJournalCheck->setChecked(c & CalFilter::HideJournals);
238 242
239 if (c & CalFilter::ShowCategories) { 243 if (c & CalFilter::ShowCategories) {
240 mEditor->mCatShowCheck->setChecked(true); 244 mEditor->mCatShowCheck->setChecked(true);
241 } else { 245 } else {
242 mEditor->mCatHideCheck->setChecked(true); 246 mEditor->mCatHideCheck->setChecked(true);
243 } 247 }
244 248
245 mEditor->mCatList->clear(); 249 mEditor->mCatList->clear();
246 mEditor->mCatList->insertStringList(filter->categoryList()); 250 mEditor->mCatList->insertStringList(filter->categoryList());
247 mCategories = filter->categoryList(); 251 mCategories = filter->categoryList();
248 252
249 setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 )); 253 setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 ));
250} 254}
251 255
252void FilterEditDialog::writeFilter(CalFilter *filter) 256void FilterEditDialog::writeFilter(CalFilter *filter)
253{ 257{
254 int c = 0; 258 int c = 0;
255 259
256 if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted; 260 if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted;
257 if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring; 261 if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring;
258 if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories; 262 if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories;
259 if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; 263 if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic;
260 if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; 264 if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate;
261 if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; 265 if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential;
266 if (mEditor->mEventCheck->isChecked()) c |= CalFilter::HideEvents;
267 if (mEditor->mTodoCheck->isChecked()) c |= CalFilter::HideTodos;
268 if (mEditor->mJournalCheck->isChecked()) c |= CalFilter::HideJournals;
262 269
263 filter->setCriteria(c); 270 filter->setCriteria(c);
264 271
265 QStringList categoryList; 272 QStringList categoryList;
266 for(uint i=0;i<mEditor->mCatList->count();++i) { 273 for(uint i=0;i<mEditor->mCatList->count();++i) {
267 categoryList.append(mEditor->mCatList->text(i)); 274 categoryList.append(mEditor->mCatList->text(i));
268 } 275 }
269 filter->setCategoryList(categoryList); 276 filter->setCategoryList(categoryList);
270} 277}
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c182db5..c425dfc 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -1,193 +1,204 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22 22
23#include "calfilter.h" 23#include "calfilter.h"
24 24
25using namespace KCal; 25using namespace KCal;
26 26
27CalFilter::CalFilter() 27CalFilter::CalFilter()
28{ 28{
29 mEnabled = true; 29 mEnabled = true;
30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
31} 31}
32 32
33CalFilter::CalFilter(const QString &name) 33CalFilter::CalFilter(const QString &name)
34{ 34{
35 mName = name; 35 mName = name;
36 mEnabled = true; 36 mEnabled = true;
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38} 38}
39 39
40CalFilter::~CalFilter() 40CalFilter::~CalFilter()
41{ 41{
42} 42}
43 43
44void CalFilter::apply(QPtrList<Event> *eventlist) 44void CalFilter::apply(QPtrList<Event> *eventlist)
45{ 45{
46 if (!mEnabled) return; 46 if (!mEnabled) return;
47 47
48// kdDebug(5800) << "CalFilter::apply()" << endl; 48// kdDebug(5800) << "CalFilter::apply()" << endl;
49 49
50 Event *event = eventlist->first(); 50 Event *event = eventlist->first();
51 while(event) { 51 while(event) {
52 if (!filterEvent(event)) { 52 if (!filterEvent(event)) {
53 eventlist->remove(); 53 eventlist->remove();
54 event = eventlist->current(); 54 event = eventlist->current();
55 } else { 55 } else {
56 event = eventlist->next(); 56 event = eventlist->next();
57 } 57 }
58 } 58 }
59 59
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 60// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 61}
62 62
63// TODO: avoid duplicating apply() code 63// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 64void CalFilter::apply(QPtrList<Todo> *eventlist)
65{ 65{
66 if (!mEnabled) return; 66 if (!mEnabled) return;
67
68// kdDebug(5800) << "CalFilter::apply()" << endl;
69
70 Todo *event = eventlist->first(); 67 Todo *event = eventlist->first();
71 while(event) { 68 while(event) {
72 if (!filterTodo(event)) { 69 if (!filterTodo(event)) {
73 eventlist->remove(); 70 eventlist->remove();
74 event = eventlist->current(); 71 event = eventlist->current();
75 } else { 72 } else {
76 event = eventlist->next(); 73 event = eventlist->next();
77 } 74 }
78 } 75 }
79 76
80// kdDebug(5800) << "CalFilter::apply() done" << endl; 77// kdDebug(5800) << "CalFilter::apply() done" << endl;
81} 78}
82 79bool CalFilter::filterCalendarItem(Incidence *in)
80{
81 if ( in->type() == "Event" )
82 return filterEvent( (Event*) in );
83 else if ( in->type() =="Todo" )
84 return filterTodo( (Todo*) in);
85 else if ( in->type() =="Journal" )
86 return filterJournal( (Journal*) in );
87 return false;
88}
83bool CalFilter::filterEvent(Event *event) 89bool CalFilter::filterEvent(Event *event)
84{ 90{
85// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 91 if (mCriteria & HideEvents)
86 92 return false;
87 if (mCriteria & HideRecurring) { 93 if (mCriteria & HideRecurring) {
88 if (event->recurrence()->doesRecur()) return false; 94 if (event->recurrence()->doesRecur()) return false;
89 } 95 }
90 96
91 return filterIncidence(event); 97 return filterIncidence(event);
92} 98}
93 99bool CalFilter::filterJournal(Journal *j)
100{
101 if (mCriteria & HideJournals)
102 return false;
103 return true;
104}
94bool CalFilter::filterTodo(Todo *todo) 105bool CalFilter::filterTodo(Todo *todo)
95{ 106{
96// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 107 if (mCriteria & HideTodos)
97 108 return false;
98 if (mCriteria & HideCompleted) { 109 if (mCriteria & HideCompleted) {
99 if (todo->isCompleted()) return false; 110 if (todo->isCompleted()) return false;
100 } 111 }
101 112
102 return filterIncidence(todo); 113 return filterIncidence(todo);
103} 114}
104bool CalFilter::showCategories() 115bool CalFilter::showCategories()
105{ 116{
106 return mCriteria & ShowCategories; 117 return mCriteria & ShowCategories;
107} 118}
108int CalFilter::getSecrecy() 119int CalFilter::getSecrecy()
109{ 120{
110 if ( (mCriteria & ShowPublic )) 121 if ( (mCriteria & ShowPublic ))
111 return Incidence::SecrecyPublic; 122 return Incidence::SecrecyPublic;
112 if ( (mCriteria & ShowPrivate )) 123 if ( (mCriteria & ShowPrivate ))
113 return Incidence::SecrecyPrivate; 124 return Incidence::SecrecyPrivate;
114 if ( (mCriteria & ShowConfidential )) 125 if ( (mCriteria & ShowConfidential ))
115 return Incidence::SecrecyConfidential; 126 return Incidence::SecrecyConfidential;
116 return Incidence::SecrecyPublic; 127 return Incidence::SecrecyPublic;
117} 128}
118bool CalFilter::filterIncidence(Incidence *incidence) 129bool CalFilter::filterIncidence(Incidence *incidence)
119{ 130{
120 if ( mCriteria > 7 ) { 131 if ( mCriteria > 7 ) {
121 switch (incidence->secrecy()) { 132 switch (incidence->secrecy()) {
122 case Incidence::SecrecyPublic: 133 case Incidence::SecrecyPublic:
123 if (! (mCriteria & ShowPublic )) 134 if (! (mCriteria & ShowPublic ))
124 return false; 135 return false;
125 break; 136 break;
126 case Incidence::SecrecyPrivate: 137 case Incidence::SecrecyPrivate:
127 if (! (mCriteria & ShowPrivate )) 138 if (! (mCriteria & ShowPrivate ))
128 return false; 139 return false;
129 break; 140 break;
130 case Incidence::SecrecyConfidential: 141 case Incidence::SecrecyConfidential:
131 if (! (mCriteria & ShowConfidential )) 142 if (! (mCriteria & ShowConfidential ))
132 return false; 143 return false;
133 break; 144 break;
134 default: 145 default:
135 return false; 146 return false;
136 break; 147 break;
137 } 148 }
138 } 149 }
139 150
140 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 151 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
141 152
142 if (mCriteria & ShowCategories) { 153 if (mCriteria & ShowCategories) {
143 for (QStringList::Iterator it = mCategoryList.begin(); 154 for (QStringList::Iterator it = mCategoryList.begin();
144 it != mCategoryList.end(); ++it ) { 155 it != mCategoryList.end(); ++it ) {
145 QStringList incidenceCategories = incidence->categories(); 156 QStringList incidenceCategories = incidence->categories();
146 for (QStringList::Iterator it2 = incidenceCategories.begin(); 157 for (QStringList::Iterator it2 = incidenceCategories.begin();
147 it2 != incidenceCategories.end(); ++it2 ) { 158 it2 != incidenceCategories.end(); ++it2 ) {
148 if ((*it) == (*it2)) { 159 if ((*it) == (*it2)) {
149 return true; 160 return true;
150 } 161 }
151 } 162 }
152 } 163 }
153 return false; 164 return false;
154 } else { 165 } else {
155 for (QStringList::Iterator it = mCategoryList.begin(); 166 for (QStringList::Iterator it = mCategoryList.begin();
156 it != mCategoryList.end(); ++it ) { 167 it != mCategoryList.end(); ++it ) {
157 QStringList incidenceCategories = incidence->categories(); 168 QStringList incidenceCategories = incidence->categories();
158 for (QStringList::Iterator it2 = incidenceCategories.begin(); 169 for (QStringList::Iterator it2 = incidenceCategories.begin();
159 it2 != incidenceCategories.end(); ++it2 ) { 170 it2 != incidenceCategories.end(); ++it2 ) {
160 if ((*it) == (*it2)) { 171 if ((*it) == (*it2)) {
161 return false; 172 return false;
162 } 173 }
163 } 174 }
164 } 175 }
165 return true; 176 return true;
166 } 177 }
167 178
168// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; 179// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
169 180
170 return true; 181 return true;
171} 182}
172 183
173void CalFilter::setEnabled(bool enabled) 184void CalFilter::setEnabled(bool enabled)
174{ 185{
175 mEnabled = enabled; 186 mEnabled = enabled;
176} 187}
177 188
178bool CalFilter::isEnabled() 189bool CalFilter::isEnabled()
179{ 190{
180 return mEnabled; 191 return mEnabled;
181} 192}
182 193
183void CalFilter::setCriteria(int criteria) 194void CalFilter::setCriteria(int criteria)
184{ 195{
185 mCriteria = criteria; 196 mCriteria = criteria;
186} 197}
187 198
188int CalFilter::criteria() 199int CalFilter::criteria()
189{ 200{
190 return mCriteria; 201 return mCriteria;
191} 202}
192 203
193void CalFilter::setCategoryList(const QStringList &categoryList) 204void CalFilter::setCategoryList(const QStringList &categoryList)
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 5ad0064..29db441 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -1,128 +1,129 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef _CALFILTER_H 21#ifndef _CALFILTER_H
22#define _CALFILTER_H 22#define _CALFILTER_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include "event.h" 27#include "event.h"
28#include "todo.h" 28#include "todo.h"
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 Filter for calendar objects. 33 Filter for calendar objects.
34*/ 34*/
35class CalFilter { 35class CalFilter {
36 public: 36 public:
37 /** Construct filter. */ 37 /** Construct filter. */
38 CalFilter(); 38 CalFilter();
39 /** Construct filter with name */ 39 /** Construct filter with name */
40 CalFilter(const QString &name); 40 CalFilter(const QString &name);
41 /** Destruct filter. */ 41 /** Destruct filter. */
42 ~CalFilter(); 42 ~CalFilter();
43 43
44 /** 44 /**
45 Set name of filter. 45 Set name of filter.
46 */ 46 */
47 void setName(const QString &name) { mName = name; } 47 void setName(const QString &name) { mName = name; }
48 /** 48 /**
49 Return name of filter. 49 Return name of filter.
50 */ 50 */
51 QString name() const { return mName; } 51 QString name() const { return mName; }
52 52
53 /** 53 /**
54 Apply filter to eventlist, all events not matching filter criterias are 54 Apply filter to eventlist, all events not matching filter criterias are
55 removed from the list. 55 removed from the list.
56 */ 56 */
57 void apply(QPtrList<Event> *eventlist); 57 void apply(QPtrList<Event> *eventlist);
58 58
59 /** 59 /**
60 Apply filter to todolist, all todos not matching filter criterias are 60 Apply filter to todolist, all todos not matching filter criterias are
61 removed from the list. 61 removed from the list.
62 */ 62 */
63 void apply(QPtrList<Todo> *todolist); 63 void apply(QPtrList<Todo> *todolist);
64 64 bool CalFilter::filterCalendarItem(Incidence *in);
65 bool CalFilter::filterJournal(Journal *in);
65 /** 66 /**
66 Apply filter criteria on the specified event. Return true, if event passes 67 Apply filter criteria on the specified event. Return true, if event passes
67 criteria, otherwise return false. 68 criteria, otherwise return false.
68 */ 69 */
69 bool filterEvent(Event *); 70 bool filterEvent(Event *);
70 71
71 /** 72 /**
72 Apply filter criteria on the specified todo. Return true, if event passes 73 Apply filter criteria on the specified todo. Return true, if event passes
73 criteria, otherwise return false. 74 criteria, otherwise return false.
74 */ 75 */
75 bool filterTodo(Todo *); 76 bool filterTodo(Todo *);
76 77
77 /** 78 /**
78 Apply filter criteria on the specified incidence. Return true, if event passes 79 Apply filter criteria on the specified incidence. Return true, if event passes
79 criteria, otherwise return false. 80 criteria, otherwise return false.
80 */ 81 */
81 bool filterIncidence(Incidence *); 82 bool filterIncidence(Incidence *);
82 83
83 /** 84 /**
84 Enable or disable filter. 85 Enable or disable filter.
85 */ 86 */
86 void setEnabled(bool); 87 void setEnabled(bool);
87 /** 88 /**
88 Return wheter the filter is enabled or not. 89 Return wheter the filter is enabled or not.
89 */ 90 */
90 bool isEnabled(); 91 bool isEnabled();
91 bool showCategories(); 92 bool showCategories();
92 int getSecrecy(); 93 int getSecrecy();
93 /** 94 /**
94 Set list of categories, which is used for showing/hiding categories of 95 Set list of categories, which is used for showing/hiding categories of
95 events. 96 events.
96 See related functions. 97 See related functions.
97 */ 98 */
98 void setCategoryList(const QStringList &); 99 void setCategoryList(const QStringList &);
99 /** 100 /**
100 Return category list, used for showing/hiding categories of events. 101 Return category list, used for showing/hiding categories of events.
101 See related functions. 102 See related functions.
102 */ 103 */
103 QStringList categoryList(); 104 QStringList categoryList();
104 105
105 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 }; 106 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 };
106 107
107 /** 108 /**
108 Set criteria, which have to be fulfilled by events passing the filter. 109 Set criteria, which have to be fulfilled by events passing the filter.
109 */ 110 */
110 void setCriteria(int); 111 void setCriteria(int);
111 /** 112 /**
112 Get inclusive filter criteria. 113 Get inclusive filter criteria.
113 */ 114 */
114 int criteria(); 115 int criteria();
115 116
116 private: 117 private:
117 QString mName; 118 QString mName;
118 119
119 int mCriteria; 120 int mCriteria;
120 121
121 bool mEnabled; 122 bool mEnabled;
122 123
123 QStringList mCategoryList; 124 QStringList mCategoryList;
124}; 125};
125 126
126} 127}
127 128
128#endif /* _CALFILTER_H */ 129#endif /* _CALFILTER_H */