-rw-r--r-- | korganizer/calendarview.cpp | 8 | ||||
-rw-r--r-- | korganizer/filtereditdialog.cpp | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8258c74..02c5e45 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1032,180 +1032,188 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( !skipIncidence ) { inL = local->incidence( uid ); if ( inL ) { // maybe conflict - same uid in both calendars if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { //qDebug("take %d %s ", take, inL->summary().latin1()); if ( take == 3 ) return false; if ( take == 1 ) {// take local ********************** if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); else idS = inR->IDStr(); remote->deleteIncidence( inR ); inR = inL->clone(); inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) inR->setIDStr( idS ); remote->addIncidence( inR ); if ( mSyncManager->syncWithDesktop() ) inR->setPilotId( 2 ); ++changedRemote; } else {// take remote ********************** idS = inL->IDStr(); int pid = inL->pilotId(); local->deleteIncidence( inL ); inL = inR->clone(); if ( mSyncManager->syncWithDesktop() ) inL->setPilotId( pid ); inL->setIDStr( idS ); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); } local->addIncidence( inL ); ++changedLocal; } } } 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 { + 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 ) { + 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(); modulo = (el.count()/10)+1; bar.setCaption (i18n("Add / remove events") ); bar.setTotalSteps ( el.count() ) ; bar.show(); incCounter = 0; while ( inL ) { qApp->processEvents(); if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; 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 ) { + 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 ) { + 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(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); while ( inR ) { if ( inR->type() == "Todo" ) { Todo * t = (Todo*)inR; if ( t->hasDueDate() ) dt = t->dtDue(); else dt = cur.addSecs( 62 ); } else if (inR->type() == "Event" ) { bool ok; dt = inR->getNextOccurence( cur, &ok ); if ( !ok ) dt = cur.addSecs( -62 ); } else dt = inR->dtStart(); if ( dt < cur || dt > end ) { remote->deleteIncidence( inR ); ++delFut; } inR = er.next(); } } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... remote->addEvent( eventRSync ); else diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp index ca09844..df84911 100644 --- a/korganizer/filtereditdialog.cpp +++ b/korganizer/filtereditdialog.cpp @@ -191,80 +191,87 @@ void FilterEditDialog::slotRemove() int result = KMessageBox::questionYesNo( this, i18n("This item will be\npermanently deleted.") ); if ( result != KMessageBox::Yes ) { return; } mFilters->remove( currentItem ); updateFilterList(); emit filterChanged(); } void FilterEditDialog::editCategorySelection() { KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog( KOPrefs::instance(), this, "filterCatSelect", true ); dlg->setSelected(mCategories); connect(dlg,SIGNAL(categoriesSelected(const QStringList &)), SLOT(updateCategorySelection(const QStringList &))); dlg->exec(); } void FilterEditDialog::updateCategorySelection(const QStringList &categories) { mCategories = categories; mEditor->mCatList->clear(); mEditor->mCatList->insertStringList(mCategories); } void FilterEditDialog::filterSelected() { CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 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); } |