|
1 /* |
|
2 * Copyright (c) 2005 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 the License "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: Encapsulates a wait or progress dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "Browser.hrh" |
|
20 #include <BrowserNG.rsg> |
|
21 |
|
22 #include <AknWaitDialog.h> |
|
23 #include <eikprogi.h> |
|
24 #include <eikdialg.h> |
|
25 #include <StringLoader.h> |
|
26 |
|
27 #include "FeedsWaitDialog.h" |
|
28 |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CFeedsWaitDialog::NewL |
|
32 // |
|
33 // Two-phased constructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CFeedsWaitDialog* CFeedsWaitDialog::NewL(MFeedsWaitDialogListener& aListener) |
|
37 { |
|
38 CFeedsWaitDialog* self = new (ELeave) CFeedsWaitDialog(aListener); |
|
39 |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CFeedsWaitDialog::CFeedsWaitDialog |
|
50 // |
|
51 // C++ default constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CFeedsWaitDialog::CFeedsWaitDialog(MFeedsWaitDialogListener& aListener): |
|
55 iListener(aListener) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CFeedsWaitDialog::ConstructL |
|
62 // |
|
63 // Symbian 2nd phase constructor can leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CFeedsWaitDialog::ConstructL() |
|
67 { |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CFeedsWaitDialog::~CFeedsWaitDialog |
|
73 // |
|
74 // Deconstructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CFeedsWaitDialog::~CFeedsWaitDialog() |
|
78 { |
|
79 delete iWaitDialog; |
|
80 delete iProgressDialog; |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CFeedsWaitDialog::DialogDismissedL |
|
86 // |
|
87 // Called when the user presses the cancel button. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CFeedsWaitDialog::DialogDismissedL(TInt /*aButtonId*/) |
|
91 { |
|
92 iListener.DialogDismissedL(); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CFeedsWaitDialog::ShowWaitDialogL |
|
98 // |
|
99 // Displays a WaitDialog. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CFeedsWaitDialog::ShowWaitDialogL(TInt aLabelId) |
|
103 { |
|
104 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
105 reinterpret_cast<CEikDialog**>(&iWaitDialog)); |
|
106 iWaitDialog->PrepareLC(R_FEEDS_WAIT_NOTE_DIALOG); |
|
107 |
|
108 UpdateLabelL(aLabelId); |
|
109 iWaitDialog->SetCallback(this); |
|
110 iWaitDialog->RunLD(); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CFeedsWaitDialog::ShowProgressDialogL |
|
116 // |
|
117 // Displays a ProgressDialog. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CFeedsWaitDialog::ShowProgressDialogL(TInt aLabelId) |
|
121 { |
|
122 iProgressDialog = new (ELeave) CAknProgressDialog( |
|
123 reinterpret_cast<CEikDialog**>(&iProgressDialog)); |
|
124 iProgressDialog->PrepareLC(R_FEEDS_PROGRESS_NOTE_DIALOG); |
|
125 |
|
126 UpdateLabelL(aLabelId); |
|
127 iProgressDialog->SetCallback(this); |
|
128 iProgressInfo = iProgressDialog->GetProgressInfoL(); |
|
129 iProgressDialog->RunLD(); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CFeedsWaitDialog::UpdateLabelL |
|
135 // |
|
136 // Updates the dialog's label. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CFeedsWaitDialog::UpdateLabelL(TInt aLabelId) |
|
140 { |
|
141 HBufC* label = NULL; |
|
142 |
|
143 // Load the label's resource. |
|
144 label = StringLoader::LoadLC(aLabelId); |
|
145 |
|
146 // Set the label. |
|
147 if (iWaitDialog != NULL) |
|
148 { |
|
149 iWaitDialog->SetTextL(*label); |
|
150 } |
|
151 else if (iProgressDialog != NULL) |
|
152 { |
|
153 iProgressDialog->SetTextL(*label); |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(label); |
|
157 } |
|
158 |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CFeedsWaitDialog::SetMaxProgressL |
|
162 // |
|
163 // For progress dialogs this method set the max progress value. |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CFeedsWaitDialog::SetMaxProgressL(TInt aMaxValue) |
|
167 { |
|
168 if (iProgressDialog != NULL) |
|
169 { |
|
170 iProgressInfo->SetFinalValue(aMaxValue); |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CFeedsWaitDialog::UpdateProgressL |
|
177 // |
|
178 // For progress dialogs this method updates the progress. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CFeedsWaitDialog::UpdateProgressL(TInt aIncrement) |
|
182 { |
|
183 if (iProgressDialog != NULL) |
|
184 { |
|
185 iProgressInfo->IncrementAndDraw(aIncrement); |
|
186 } |
|
187 } |
|
188 |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CFeedsWaitDialog::Close |
|
192 // |
|
193 // Closes the dialog. |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CFeedsWaitDialog::Close() |
|
197 { |
|
198 if (iWaitDialog != NULL) |
|
199 { |
|
200 //iWaitDialog->ProcessFinishedL(); |
|
201 delete iWaitDialog; |
|
202 iWaitDialog = NULL; |
|
203 } |
|
204 else if (iProgressDialog != NULL) |
|
205 { |
|
206 //iProgressDialog->ProcessFinishedL(); |
|
207 delete iProgressDialog; |
|
208 iProgressDialog = NULL; |
|
209 } |
|
210 } |