diff -r 000000000000 -r f979ecb2b13e calendarui/views/src/calentodocontroller.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calendarui/views/src/calentodocontroller.cpp Tue Feb 02 10:12:19 2010 +0200 @@ -0,0 +1,291 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: To-Do view's utility class. +* +*/ + +//debug +#include "calendarui_debug.h" + +// INCLUDE FILES +#include "calentodocontroller.h" + +#include +#include +#include "calentodocontainer.h" + +#include +#include "calennativeview.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include // TCalenInstanceId +#include + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------------------------- +// CCalenTodoController::CCalenTodoController +// C++ default constructor. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +CCalenTodoController::CCalenTodoController( + MCalenServices& aServices ) + : iServices( aServices ) + { + TRACE_ENTRY_POINT; + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::ConstructL +// Symbian OS default constructor. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +void CCalenTodoController::ConstructL() + { + TRACE_ENTRY_POINT; + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::~CCalenTodoController +// Destructor. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +CCalenTodoController::~CCalenTodoController() + { + TRACE_ENTRY_POINT; + + CleanupInstances(); + iActiveListIndices.Reset(); + + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::RefreshL +// Refresh agenda name list. +// ---------------------------------------------------------------------------- +// +void CCalenTodoController::RefreshL() + { + TRACE_ENTRY_POINT; + + iList.ResetAndDestroy(); + iActiveListIndices.Reset(); + + CalCommon::TCalViewFilter filter = CalCommon::EIncludeCompletedTodos | + CalCommon::EIncludeIncompletedTodos | + // only fetch the first instance for repeating to-dos! + CalCommon::EIncludeRptsNextInstanceOnly; + + TCalTime start; start.SetTimeLocalL( TCalTime::MinTime() ); + TCalTime end; end.SetTimeLocalL( TCalTime::MaxTime() ); + + CalCommon::TCalTimeRange timeRange( start, end ); + + RArray colIdArray; + CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray ); + + if(colIdArray.Count() > 0) + { + iServices.InstanceViewL(colIdArray)->FindInstanceL( iList, filter, timeRange ); + } + + colIdArray.Reset(); + + CalenAgendaUtils::SortInstanceList( iList ); + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::InstanceList +// Return ToDo instance list pointer. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +RPointerArray& CCalenTodoController::InstanceList() + { + TRACE_ENTRY_POINT; + + TRACE_EXIT_POINT; + return iList; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::SetToStartL +// Index is setted to ZERO and fetch data. +// ---------------------------------------------------------------------------- +// +void CCalenTodoController::SetToStartL() + { + TRACE_ENTRY_POINT; + + iIndex = 0; + + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::SetToNextL +// Index is incremented and fetch data. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +void CCalenTodoController::SetToNextL() + { + TRACE_ENTRY_POINT; + + ++iIndex; + + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::IsAtEnd +// Check terminus of index. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +TBool CCalenTodoController::IsAtEnd() const + { + TRACE_ENTRY_POINT; + + TRACE_EXIT_POINT; + return (iIndex == iList.Count()); + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::Instance +// Return instance id of current index. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +CCalInstance* CCalenTodoController::Instance() const + { + TRACE_ENTRY_POINT; + + if( iIndex < 0 || iIndex >= Count() ) + { + TRACE_EXIT_POINT; + return NULL; + } + + TRACE_EXIT_POINT; + return iList[ iIndex ]; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::InstanceId +// Return instance id of the index. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +CCalInstance* CCalenTodoController::InstanceL(TInt aIndex) const // Index of list + { + TRACE_ENTRY_POINT; + //1.iActiveListIndices contains iList indices as values. + //2.iActiveListIndices is populated in CreateEntryItertorL of container + + if( aIndex < 0 || aIndex >= Count() || iActiveListIndices.Count() <= 0 ) + { + TRACE_EXIT_POINT; + return NULL; + } + + TRACE_EXIT_POINT; + return iList[ iActiveListIndices[aIndex] ]; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::IsCrossOutL +// Check status of cross out. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +TBool CCalenTodoController::IsCrossOutL(TInt aIndex) // Index of list + { + TRACE_ENTRY_POINT; + + TBool crossout( EFalse ); + + if( iList.Count() ) + { + CCalInstance* instance = InstanceL( aIndex ); + CCalEntry& entry = instance->Entry(); + + if( entry.StatusL() == CCalEntry::ETodoCompleted ) + { + crossout = ETrue; + } + } + + TRACE_EXIT_POINT; + return crossout; + } + +// ---------------------------------------------------------------------------- +// CCalenTodoController::Count +// Return number of item. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +TInt CCalenTodoController::Count() const + { + TRACE_ENTRY_POINT; + + TRACE_EXIT_POINT; + return iList.Count(); + } + + +TInt CCalenTodoController::FindInstanceIndexL(const TCalenInstanceId& aId) const + { + TRACE_ENTRY_POINT; + + for(TInt index(0); index < iList.Count(); ++index) + { + if( iList[index]->Entry().LocalUidL() == aId.iEntryLocalUid ) + { + // FIXME, if several instances match, we should one + // that closest matches aId.iInstanceTime + TRACE_EXIT_POINT; + return index; + } + } + + TRACE_EXIT_POINT; + return KErrNotFound; + } + +void CCalenTodoController::CleanupInstances() + { + TRACE_ENTRY_POINT + iList.ResetAndDestroy(); + TRACE_EXIT_POINT + } +// End of File