diff -r 3ab5c078b490 -r 0b3699f6c654 taskswitcher/server/src/tsmodelitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskswitcher/server/src/tsmodelitem.cpp Fri Sep 17 08:32:18 2010 +0300 @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2009 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: +* +*/ +#include "tsmodel.h" +// ----------------------------------------------------------------------------- +/** + * Constructor + * @param aModel - data owner + * @param aOffset - data index + */ +TTsModelItem::TTsModelItem( const MTsModel& aModel, TInt aOffset ) +: +iModel( aModel ), +iIndex( aOffset ) + + { + //No implementation required + } + +// ----------------------------------------------------------------------------- +/** + * Copy constructor + * @param aItem - template item + */ +TTsModelItem::TTsModelItem( const TTsModelItem& aItem ) +: +iModel( aItem.iModel ), +iIndex( aItem.iIndex ) + { + //No implementation required + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve display name data + * @return item display name + */ +const TDesC& TTsModelItem::DisplayNameL() const + { + ValidateL(); + return iModel.DisplayNameL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve icon handle ( CFbsBitmap handle ) + * @return item icon handle + */ +TInt TTsModelItem::IconHandleL() const + { + ValidateL(); + return iModel.IconHandleL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve entry key + * @return item key + */ +TTsModelItemKey TTsModelItem::KeyL() const + { + ValidateL(); + return iModel.KeyL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve entry timestamp + * @return item timestamp + */ +TTime TTsModelItem::TimestampL() const + { + ValidateL(); + return iModel.TimestampL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve timestamp + * with latest update time + * @return item timestamp + */ +TTime TTsModelItem::TimestampUpdateL() const +{ + ValidateL(); + return iModel.TimestampUpdateL(iIndex); +} + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve activity status + * @return activity status + */ +TBool TTsModelItem::IsActiveL() const + { + ValidateL(); + return iModel.IsActiveL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and retrieve closable status + * @return closable status + */ +TBool TTsModelItem::IsClosableL() const + { + ValidateL(); + return iModel.IsClosableL( iIndex ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and forward close request to its owner + * @return EFalse on failure + */ +TBool TTsModelItem::CloseL() const + { + ValidateL(); + return iModel.CloseL( KeyL() ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance and forward launch request to its owner + * @return EFalse on failure + */ +TBool TTsModelItem::LaunchL() const + { + ValidateL(); + return iModel.LaunchL( KeyL() ); + } + +// ----------------------------------------------------------------------------- +/** + * Validate item instance + */ +void TTsModelItem::ValidateL() const + { + if(iModel.Count() <= iIndex ) + { + User::Leave( KErrOverflow ); + } + } + +// ----------------------------------------------------------------------------- +/** + * Serialize item into destination stream + * @param aStream - output stream + */ + +void TTsModelItem::ExternalizeL( RWriteStream& aStream ) const + { + aStream.WriteInt32L( DisplayNameL().Length() ); + if( 0 < DisplayNameL().Length() ) + { + aStream << DisplayNameL(); + } + TPckgBuf timestamp(TimestampUpdateL()); + aStream.WriteL(timestamp); + aStream.WriteInt32L( IconHandleL() ); + aStream.WriteInt32L( TTsModelItemKey::Size() ); + aStream << KeyL(); + aStream.WriteInt32L( IsActiveL() ); + aStream.WriteInt32L( IsClosableL() ); + } +