64
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: FreestyleEmailUi message details model implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// SYSTEM INCLUDES
|
|
20 |
//<cmail>
|
|
21 |
#include "emailtrace.h"
|
|
22 |
#include "cfsmailaddress.h"
|
|
23 |
//</cmail>
|
|
24 |
|
|
25 |
// INTERNAL INCLUDES
|
|
26 |
#include "FreestyleEmailUiMsgDetailsModel.h"
|
|
27 |
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
// Folder list item constructor.
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
CFSEmailUiMsgDetailsItem::CFSEmailUiMsgDetailsItem( TFsTreeItemId aListId )
|
|
32 |
: iListId( aListId ), iMailAddress( NULL ), iText( NULL )
|
|
33 |
{
|
|
34 |
FUNC_LOG;
|
|
35 |
}
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// Folder list item destructor.
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
CFSEmailUiMsgDetailsItem::~CFSEmailUiMsgDetailsItem()
|
|
41 |
{
|
|
42 |
FUNC_LOG;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// NewLC
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CFSEmailUiMsgDetailsItem* CFSEmailUiMsgDetailsItem::NewLC(
|
|
50 |
TFsTreeItemId aListId )
|
|
51 |
{
|
|
52 |
FUNC_LOG;
|
|
53 |
CFSEmailUiMsgDetailsItem* self = new (ELeave) CFSEmailUiMsgDetailsItem( aListId );
|
|
54 |
CleanupStack::PushL( self );
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// Constructor
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
CFSEmailUiMsgDetailsModel::CFSEmailUiMsgDetailsModel()
|
|
62 |
{
|
|
63 |
FUNC_LOG;
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// Destructor.
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
CFSEmailUiMsgDetailsModel::~CFSEmailUiMsgDetailsModel()
|
|
70 |
{
|
|
71 |
FUNC_LOG;
|
|
72 |
RemoveAll();
|
|
73 |
iItemArray.Close();
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// Add an item to the end of the list.
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
void CFSEmailUiMsgDetailsModel::AppendL( TFsTreeItemId aListId, CFSMailAddress* aMailAddress )
|
|
80 |
{
|
|
81 |
FUNC_LOG;
|
|
82 |
CFSEmailUiMsgDetailsItem* item = CFSEmailUiMsgDetailsItem::NewLC( aListId );
|
|
83 |
item->iMailAddress = aMailAddress;
|
|
84 |
iItemArray.AppendL( item );
|
|
85 |
CleanupStack::Pop( item );
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// Add an item to the end of the list.
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
void CFSEmailUiMsgDetailsModel::AppendL( TFsTreeItemId aListId, TDesC* aText )
|
|
92 |
{
|
|
93 |
FUNC_LOG;
|
|
94 |
CFSEmailUiMsgDetailsItem* item = CFSEmailUiMsgDetailsItem::NewLC( aListId );
|
|
95 |
item->iText = aText;
|
|
96 |
iItemArray.AppendL( item );
|
|
97 |
CleanupStack::Pop( item );
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// Remove item by list item id.
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
void CFSEmailUiMsgDetailsModel::Remove( TFsTreeItemId aListId )
|
|
104 |
{
|
|
105 |
FUNC_LOG;
|
|
106 |
TInt index = Index( aListId );
|
|
107 |
if( index != KErrNotFound )
|
|
108 |
{
|
|
109 |
delete iItemArray[index];
|
|
110 |
iItemArray.Remove( index );
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
// Remove all items.
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
void CFSEmailUiMsgDetailsModel::RemoveAll()
|
|
118 |
{
|
|
119 |
FUNC_LOG;
|
|
120 |
iItemArray.ResetAndDestroy();
|
|
121 |
}
|
|
122 |
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
// Get an item by list item id.
|
|
125 |
//
|
|
126 |
// @return NULL if not found.
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
CFSEmailUiMsgDetailsItem* CFSEmailUiMsgDetailsModel::ItemByListId( TFsTreeItemId aListId ) const
|
|
129 |
{
|
|
130 |
FUNC_LOG;
|
|
131 |
TInt index = Index( aListId );
|
|
132 |
if( index != KErrNotFound )
|
|
133 |
{
|
|
134 |
return iItemArray[ index ];
|
|
135 |
}
|
|
136 |
else
|
|
137 |
{
|
|
138 |
return NULL;
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
// Get an item by list index.
|
|
144 |
//
|
|
145 |
// @return NULL if not found.
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
CFSEmailUiMsgDetailsItem* CFSEmailUiMsgDetailsModel::ItemByIndex( TInt aModelIndex ) const
|
|
148 |
{
|
|
149 |
FUNC_LOG;
|
|
150 |
return iItemArray[ aModelIndex ];
|
|
151 |
}
|
|
152 |
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
// Get number of items in list.
|
|
155 |
//
|
|
156 |
// @return Number of items.
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
TInt CFSEmailUiMsgDetailsModel::Count() const
|
|
159 |
{
|
|
160 |
FUNC_LOG;
|
|
161 |
return iItemArray.Count();
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
// Get the array index of the spcified item.
|
|
166 |
//
|
|
167 |
// @return Array index of the item.
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
TInt CFSEmailUiMsgDetailsModel::Index( TFsTreeItemId aListId ) const
|
|
170 |
{
|
|
171 |
FUNC_LOG;
|
|
172 |
for( TInt i = 0; i < Count(); i++ )
|
|
173 |
{
|
|
174 |
if( iItemArray[i]->iListId == aListId )
|
|
175 |
{
|
|
176 |
return i;
|
|
177 |
}
|
|
178 |
}
|
|
179 |
return KErrNotFound;
|
|
180 |
}
|
|
181 |
|