|
1 /* |
|
2 * Copyright (c) 2002-2006 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: View for setting additional mail headers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CMsgAddMailHeadersDlg.h" |
|
22 #include "MsgMailPreferences.h" |
|
23 #include <StringLoader.h> |
|
24 #include <MsgMailEditor.rsg> |
|
25 #include <akncheckboxsettingpage.h> |
|
26 #include <aknsettingitemlist.h> |
|
27 #include <aknlistquerydialog.h> |
|
28 #include "MailUtils.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMsgAddMailHeadersDlg::CMsgAddMailHeadersDlg |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CMsgAddMailHeadersDlg::CMsgAddMailHeadersDlg( |
|
39 RPointerArray<TAdditionalHeaderStatus>& aHeaders): iHeaders(aHeaders) |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CMsgAddMailHeadersDlg::NewLC |
|
45 // Two-phased constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CMsgAddMailHeadersDlg* CMsgAddMailHeadersDlg::NewLC( |
|
49 RPointerArray<TAdditionalHeaderStatus>& aHeaders) |
|
50 { |
|
51 CMsgAddMailHeadersDlg* self = new(ELeave) CMsgAddMailHeadersDlg(aHeaders); |
|
52 CleanupStack::PushL(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 // Destructor |
|
58 CMsgAddMailHeadersDlg::~CMsgAddMailHeadersDlg() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CMsgAddMailHeadersDlg::ExecuteDialogL |
|
65 // Constructs a CSelectionList array and launches the setting view |
|
66 // Collects the changed values to iHeaders array |
|
67 // (other items were commented in a header). |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 TBool CMsgAddMailHeadersDlg::ExecuteDialogL() |
|
71 { |
|
72 TBool rc(EFalse); |
|
73 |
|
74 CArrayFixFlat<TInt>* arrayChoices = |
|
75 new(ELeave) CArrayFixFlat<TInt>( iHeaders.Count() ); |
|
76 CleanupStack::PushL(arrayChoices); |
|
77 |
|
78 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(arrayChoices); |
|
79 dlg->PrepareLC( R_ADDITIONAL_HEADERS_LIST_QUERY ); |
|
80 |
|
81 CDesCArrayFlat* headersArray = CreateItemTextArrayLC( arrayChoices ); |
|
82 |
|
83 dlg->SetItemTextArray( headersArray ); |
|
84 dlg->SetOwnershipType( ELbmOwnsItemArray ); |
|
85 CleanupStack::Pop( headersArray ); |
|
86 |
|
87 CEikListBox* listbox = dlg->ListBox(); |
|
88 listbox->SetSelectionIndexesL(arrayChoices); |
|
89 |
|
90 if(dlg->RunLD()) |
|
91 { |
|
92 UpdateHeadersArrayL( arrayChoices ); |
|
93 rc = ETrue; |
|
94 } |
|
95 |
|
96 CleanupStack::PopAndDestroy(arrayChoices); |
|
97 return rc; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CMsgAddMailHeadersDlg::CreateItemTextArrayLC |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CDesCArrayFlat* CMsgAddMailHeadersDlg::CreateItemTextArrayLC( |
|
105 CArrayFixFlat<TInt>* aVisibleItems ) |
|
106 { |
|
107 ASSERT( aVisibleItems ); |
|
108 CDesCArrayFlat* headersArray = |
|
109 new ( ELeave ) CDesCArrayFlat( iHeaders.Count() ); |
|
110 CleanupStack::PushL( headersArray ); |
|
111 |
|
112 for ( TInt index(0); index<iHeaders.Count(); ++index ) |
|
113 { |
|
114 if( iHeaders[index]->iStatus == EHeaderVisible ) |
|
115 { |
|
116 aVisibleItems->AppendL( index ); |
|
117 } |
|
118 TInt resource(0); |
|
119 switch (iHeaders[index]->iHeaderValue) |
|
120 { |
|
121 case EMsgComponentIdCc: |
|
122 resource = R_QTN_MSG_HEADERS_CC; |
|
123 break; |
|
124 case EMsgComponentIdBcc: |
|
125 resource = R_QTN_MSG_HEADERS_BCC; |
|
126 break; |
|
127 case EMsgComponentIdSubject: |
|
128 resource = R_QTN_MSG_HEADERS_SUBJECT; |
|
129 break; |
|
130 default: |
|
131 __ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
132 } |
|
133 HBufC* headerText = StringLoader::LoadLC( resource ); |
|
134 headersArray->AppendL( * headerText ); |
|
135 CleanupStack::PopAndDestroy(headerText); // headerText |
|
136 } |
|
137 return headersArray; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CMsgAddMailHeadersDlg::UpdateHeadersArrayL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CMsgAddMailHeadersDlg::UpdateHeadersArrayL( |
|
145 CArrayFixFlat<TInt>* aSelectedItems ) |
|
146 { |
|
147 ASSERT( aSelectedItems ); |
|
148 // Reset visibility |
|
149 for ( TInt index(0); index<iHeaders.Count(); ++index ) |
|
150 { |
|
151 iHeaders[index]->iStatus = EHeaderHidden; |
|
152 } |
|
153 // Set selected items visible |
|
154 for ( TInt ii=0; ii<aSelectedItems->Count(); ii++ ) |
|
155 { |
|
156 iHeaders[aSelectedItems->At(ii)]->iStatus = EHeaderVisible; |
|
157 } |
|
158 // Find invisible items that has some content |
|
159 TInt contentCount(0); |
|
160 for ( TInt xx=0;xx<iHeaders.Count();xx++ ) |
|
161 { |
|
162 if( iHeaders[xx]->iStatus == |
|
163 EHeaderHidden && iHeaders[xx]->iHasContent ) |
|
164 { |
|
165 contentCount++; |
|
166 } |
|
167 } |
|
168 // We are removing control that has some content |
|
169 if( contentCount ) |
|
170 { |
|
171 // plural? |
|
172 TUint queryString = (contentCount > 1) ? |
|
173 R_QTN_MSG_QRY_HEADERS_REMOVE : |
|
174 R_QTN_MSG_QRY_HEADER_REMOVE; |
|
175 |
|
176 TInt queryResult = MailUtils::ConfirmationQueryL( |
|
177 queryString, |
|
178 R_MAIL_EDITOR_DELETE_MESSAGE); |
|
179 |
|
180 // Do not remove control, only save visibility of controls |
|
181 if( !queryResult ) |
|
182 { |
|
183 for ( TInt yy=0;yy<iHeaders.Count();yy++ ) |
|
184 { |
|
185 if( iHeaders[yy]->iStatus == |
|
186 EHeaderHidden && iHeaders[yy]->iHasContent ) |
|
187 { |
|
188 iHeaders[yy]->iStatus = EHeaderOnlySave; |
|
189 } |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 } |
|
195 // End of File |