diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /korganizer/eventarchiver.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korganizer/eventarchiver.cpp')
-rw-r--r-- | korganizer/eventarchiver.cpp | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/korganizer/eventarchiver.cpp b/korganizer/eventarchiver.cpp index b5a9c0c98..c4adbf820 100644 --- a/korganizer/eventarchiver.cpp +++ b/korganizer/eventarchiver.cpp @@ -70,14 +70,15 @@ void EventArchiver::runAuto( Calendar* calendar, TQWidget* widget, bool withGUI run( calendar, limitDate, widget, withGUI, false ); } -void EventArchiver::run( Calendar* calendar, const TQDate& limitDate, TQWidget* widget, bool withGUI, bool errorIfNone ) +void EventArchiver::run( Calendar* calendar, const TQDate& limitDate, TQWidget* widget, bool withGUI, + bool errorIfNone ) { // We need to use rawEvents, otherwise events hidden by filters will not be archived. Incidence::List incidences; Event::List events; Todo::List todos; Journal::List journals; - + if ( KOPrefs::instance()->mArchiveEvents ) { events = calendar->rawEvents( TQDate( 1769, 12, 1 ), @@ -89,21 +90,37 @@ void EventArchiver::run( Calendar* calendar, const TQDate& limitDate, TQWidget* Todo::List t = calendar->rawTodos(); Todo::List::ConstIterator it; for( it = t.begin(); it != t.end(); ++it ) { - if ( (*it) && ( (*it)->isCompleted() ) && ( (*it)->completed().date() < limitDate ) ) { + const bool todoComplete = (*it) && + (*it)->isCompleted() && + ( (*it)->completed().date() < limitDate ); + + if ( todoComplete && !isSubTreeComplete( *it, limitDate ) ) { + // The to-do is complete but some sub-todos are not. + KMessageBox::information( + widget, + i18n( "Unable to archive to-do \"%1\" because at least one of its " + "sub-to-dos does not meet the archival requirements." ).arg( (*it)->summary() ), + i18n( "Archive To-do" ), + "UncompletedChildrenArchiveTodos" ); + } else if ( todoComplete ) { todos.append( *it ); } } } - + incidences = Calendar::mergeIncidenceList( events, todos, journals ); - - kdDebug(5850) << "EventArchiver: archiving incidences before " << limitDate << " -> " << incidences.count() << " incidences found." << endl; + + kdDebug(5850) << "EventArchiver: archiving incidences before " << limitDate << " -> " + << incidences.count() << " incidences found." << endl; if ( incidences.isEmpty() ) { - if ( withGUI && errorIfNone ) - KMessageBox::information( widget, i18n("There are no items before %1") - .arg(KGlobal::locale()->formatDate(limitDate)), - "ArchiverNoIncidences" ); + if ( withGUI && errorIfNone ) { + KMessageBox::information( + widget, + i18n( "There are no incidences available to archive before the specified cut-off date %1. " + "Archiving will not be performed." ).arg( KGlobal::locale()->formatDate( limitDate ) ), + "ArchiverNoIncidences" ); + } return; } @@ -222,4 +239,35 @@ void EventArchiver::archiveIncidences( Calendar* calendar, const TQDate& /*limit emit eventsDeleted(); } +bool EventArchiver::isSubTreeComplete( const Todo *todo, const TQDate &limitDate, + TQStringList checkedUids ) const +{ + if ( !todo || !todo->isCompleted() || todo->completed().date() >= limitDate ) { + return false; + } + + // This QList is only to prevent infinit recursion + if ( checkedUids.contains( todo->uid() ) ) { + // Probably will never happen, calendar.cpp checks for this + kdWarning() << "To-do hierarchy loop detected!"; + return false; + } + + checkedUids.append( todo->uid() ); + + Incidence::List::ConstIterator it; + const Incidence::List relations = todo->relations(); + + for( it = relations.begin(); it != relations.end(); ++it ) { + if ( (*it)->type() == "Todo" ) { + const Todo *t = static_cast<const Todo*>( *it ); + if ( !isSubTreeComplete( t, limitDate, checkedUids ) ) { + return false; + } + } + } + + return true; +} + #include "eventarchiver.moc" |