|
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 application's grid menu model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include "FreestyleEmailUiLauncherGridModel.h" |
|
22 |
|
23 |
|
24 CFSEmailUiLauncherGridModel::CFSEmailUiLauncherGridModel() |
|
25 { |
|
26 FUNC_LOG; |
|
27 } |
|
28 |
|
29 void CFSEmailUiLauncherGridModel::ConstructL() |
|
30 { |
|
31 FUNC_LOG; |
|
32 } |
|
33 |
|
34 CFSEmailUiLauncherGridModel::~CFSEmailUiLauncherGridModel() |
|
35 { |
|
36 FUNC_LOG; |
|
37 for ( TInt i = 0; i < iItems.Count(); ++i ) |
|
38 { |
|
39 // NOTE: No need to delete iItems[i].iLauncherItem |
|
40 // as we don't have the ownership! |
|
41 delete iItems[i].iCaption; |
|
42 iItems[i].iCaption = NULL; |
|
43 } |
|
44 iItems.Close(); |
|
45 } |
|
46 |
|
47 void CFSEmailUiLauncherGridModel::AddL( |
|
48 TItemType aType, |
|
49 TInt aId, |
|
50 const TDesC& aCaption, |
|
51 CAlfTexture& aIconTexture, |
|
52 TInt aParentId, |
|
53 CFSEmailLauncherItem* aLauncherItem ) |
|
54 { |
|
55 FUNC_LOG; |
|
56 TMenuItem item; |
|
57 |
|
58 item.iType = aType; |
|
59 item.iId = aId; |
|
60 item.iParent = aParentId; |
|
61 item.iCaption = aCaption.AllocL(); |
|
62 item.iIconTexture = &aIconTexture; |
|
63 item.iLauncherItem = aLauncherItem; |
|
64 |
|
65 User::LeaveIfError( iItems.Append(item) ); |
|
66 } |
|
67 |
|
68 void CFSEmailUiLauncherGridModel::AddL( |
|
69 TItemType aType, |
|
70 TInt aId, |
|
71 const TDesC& aCaption, |
|
72 CAlfTexture& aIconTexture, |
|
73 TFSMailMsgId aMailBoxId, |
|
74 TFSMailMsgId aMailBoxInboxId ) |
|
75 { |
|
76 FUNC_LOG; |
|
77 TMenuItem item; |
|
78 |
|
79 item.iType = aType; |
|
80 item.iId = aId; |
|
81 item.iParent = 0; |
|
82 item.iCaption = aCaption.AllocL(); |
|
83 item.iIconTexture = &aIconTexture; |
|
84 item.iLauncherItem = NULL; |
|
85 item.iMailBoxId = aMailBoxId; |
|
86 item.iMailBoxInboxId = aMailBoxInboxId; |
|
87 |
|
88 User::LeaveIfError( iItems.Append(item) ); |
|
89 } |
|
90 |
|
91 TInt CFSEmailUiLauncherGridModel::FindChildren( |
|
92 TInt aParentId, |
|
93 RArray<TMenuItem>& aItems ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 TInt error = KErrNone; |
|
97 |
|
98 for ( TInt i = 0; i < iItems.Count(); i++ ) |
|
99 { |
|
100 if ( iItems[i].iParent == aParentId ) |
|
101 { |
|
102 error = aItems.Append( iItems[i] ); |
|
103 if ( error != KErrNone ) |
|
104 { |
|
105 break; |
|
106 } |
|
107 } |
|
108 } |
|
109 |
|
110 return error; |
|
111 } |
|
112 |
|
113 TInt CFSEmailUiLauncherGridModel::Parent(TInt aId) const |
|
114 { |
|
115 FUNC_LOG; |
|
116 for(TInt i = 0; i < iItems.Count(); ++i) |
|
117 { |
|
118 if(iItems[i].iId == aId) |
|
119 { |
|
120 return iItems[i].iParent; |
|
121 } |
|
122 } |
|
123 return 0; |
|
124 } |
|
125 |
|
126 TBool CFSEmailUiLauncherGridModel::HasChildren(TInt aParentId) const |
|
127 { |
|
128 FUNC_LOG; |
|
129 for(TInt i = 0; i < iItems.Count(); ++i) |
|
130 { |
|
131 if(iItems[i].iParent == aParentId) |
|
132 { |
|
133 return ETrue; |
|
134 } |
|
135 } |
|
136 return EFalse; |
|
137 } |
|
138 |
|
139 TMenuItem* CFSEmailUiLauncherGridModel::Item(TInt aId) |
|
140 { |
|
141 FUNC_LOG; |
|
142 for(TInt i = 0; i < iItems.Count(); ++i) |
|
143 { |
|
144 if(iItems[i].iId == aId) |
|
145 { |
|
146 return &iItems[i]; |
|
147 } |
|
148 } |
|
149 return NULL; |
|
150 } |
|
151 |
|
152 |