author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 1 |
/* |
2 |
* Copyright (c) 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: |
|
15 |
* Implementation for CxSPSortView. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include "CxSPSortView.h" |
|
22 |
#include "CxSPSortViewControl.h" |
|
23 |
||
24 |
// System includes |
|
25 |
#include <eiklbi.h> |
|
26 |
#include <eiklbx.h> |
|
27 |
#include <AknUtils.h> |
|
28 |
#include <AknGlobalNote.h> |
|
29 |
#include <aknnavi.h> |
|
30 |
#include <aknnavide.h> |
|
31 |
#include <StringLoader.h> |
|
32 |
#include <eikbtgpc.h> |
|
33 |
#include <eikspane.h> |
|
34 |
#include <avkon.hrh> |
|
35 |
#include <avkon.rsg> |
|
36 |
||
37 |
//Pbk2 |
|
38 |
#include <MPbk2AppUi.h> |
|
39 |
#include <CPbk2UIExtensionView.h> |
|
40 |
#include <MPbk2ViewActivationTransaction.h> |
|
41 |
#include <MPbk2ViewExplorer.h> |
|
42 |
#include <CPbk2ViewState.h> |
|
43 |
#include <MPbk2StartupMonitor.h> |
|
44 |
#include <Pbk2Debug.h> |
|
45 |
||
46 |
// internal |
|
47 |
#include "ExtensionManager.hrh" |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
48 |
#include <extensionmanagerres.rsg> |
20 | 49 |
#include "ExtensionManagerUID.H" |
50 |
#include "CxSPLoader.h" |
|
51 |
#include "MxSPFactory.h" |
|
52 |
#include "CxSPViewIdChanger.h" |
|
53 |
||
54 |
||
55 |
using namespace Phonebook2; |
|
56 |
||
57 |
// ================= MEMBER FUNCTIONS ======================= |
|
58 |
||
59 |
inline CxSPSortView::CxSPSortView( CxSPViewIdChanger& aViewIdChanger, |
|
60 |
MxSPContactManager& aContactManager, |
|
61 |
CPbk2UIExtensionView& aView, |
|
62 |
CxSPArray& aExtensions ) : |
|
63 |
CxSPBaseView( aViewIdChanger, aContactManager, aView ), |
|
64 |
iViewIdChanger( aViewIdChanger ), |
|
65 |
iExtensions( aExtensions ) |
|
66 |
{ |
|
67 |
} |
|
68 |
||
69 |
inline void CxSPSortView::ConstructL() |
|
70 |
{ |
|
71 |
ViewBaseConstructL( KEXTENSIONMANAGERIMPLEMENTATIONUID, |
|
72 |
EExtensionManagerSortViewId ); |
|
73 |
} |
|
74 |
||
75 |
CxSPSortView* CxSPSortView::NewL( CxSPViewIdChanger& aViewIdChanger, |
|
76 |
MxSPContactManager& aContactManager, |
|
77 |
CPbk2UIExtensionView& aView, |
|
78 |
CxSPArray& aExtensions ) |
|
79 |
{ |
|
80 |
CxSPSortView* self = new(ELeave) CxSPSortView( aViewIdChanger, |
|
81 |
aContactManager, |
|
82 |
aView, |
|
83 |
aExtensions ); |
|
84 |
CleanupStack::PushL(self); |
|
85 |
self->ConstructL(); |
|
86 |
CleanupStack::Pop(self); |
|
87 |
return self; |
|
88 |
} |
|
89 |
||
90 |
CxSPSortView::~CxSPSortView() |
|
91 |
{ |
|
92 |
delete iNaviDecorator; |
|
93 |
if (iContainer) |
|
94 |
{ |
|
95 |
CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer); |
|
96 |
} |
|
97 |
delete iContainer; |
|
98 |
} |
|
99 |
||
100 |
void CxSPSortView::HandleCommandL |
|
101 |
(TInt aCommand) |
|
102 |
{ |
|
103 |
switch (aCommand) |
|
104 |
{ |
|
105 |
case EAknSoftkeyBack: // Back softkey |
|
106 |
{ |
|
107 |
TBool changes = iContainer->CommitSortL( this ); |
|
108 |
if( !changes ) |
|
109 |
{ |
|
110 |
Pbk2AppUi()->Pbk2ViewExplorer()-> |
|
111 |
ActivatePhonebook2ViewL( TUid::Uid( |
|
112 |
EPbk2NamesListViewId ), NULL ); |
|
113 |
} |
|
114 |
// No else. If there were changes in the sort order we will be |
|
115 |
// notified via MGlobalNoteObserver API when the user has closed |
|
116 |
// the resulting global note |
|
117 |
break; |
|
118 |
} |
|
119 |
case EExtensionManagerCmdMove: // Move softkey |
|
120 |
{ |
|
121 |
iContainer->SetCurrentItemMarkedL( ETrue ); |
|
122 |
UpdateCbasL( R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
123 |
break; |
|
124 |
} |
|
125 |
case EAknSoftkeyOk: // Ok softkey |
|
126 |
{ |
|
127 |
iContainer->MoveMarkedItemL(); |
|
128 |
UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
|
129 |
break; |
|
130 |
} |
|
131 |
case EAknSoftkeyCancel: // Cancel softkey |
|
132 |
{ |
|
133 |
iContainer->SetCurrentItemMarkedL( EFalse ); |
|
134 |
UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
|
135 |
||
136 |
break; |
|
137 |
} |
|
138 |
default: |
|
139 |
{ |
|
140 |
Pbk2AppUi()->HandleCommandL( aCommand ); |
|
141 |
break; |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
void CxSPSortView::DoActivateViewL( const TVwsViewId& aPrevViewId, |
|
147 |
TUid /*aCustomMessageId*/, |
|
148 |
const TDesC8& /*aCustomMessage*/ ) |
|
149 |
{ |
|
150 |
MPbk2ViewActivationTransaction* viewActivationTransaction = |
|
151 |
Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC( |
|
152 |
iView.Id(), |
|
153 |
aPrevViewId, |
|
154 |
NULL, |
|
155 |
NULL, |
|
156 |
EUpdateAll ); |
|
157 |
||
158 |
// Notifies startup monitor of view activation |
|
159 |
if ( Pbk2AppUi()->Pbk2StartupMonitor() ) |
|
160 |
{ |
|
161 |
Pbk2AppUi()->Pbk2StartupMonitor()-> |
|
162 |
NotifyViewActivationL( iView.Id() ); |
|
163 |
} |
|
164 |
||
165 |
if (!iContainer) |
|
166 |
{ |
|
167 |
iContainer = CxSPSortViewControl::NewL( iViewIdChanger, iExtensions, iView ); |
|
168 |
CCoeEnv::Static()->AppUi()->AddToStackL( iView, iContainer ); |
|
169 |
iContainer->SetMopParent( &iView ); |
|
170 |
iContainer->SetRect( iView.ClientRect() ); |
|
171 |
||
172 |
CCoeControl& ctrl=iContainer->ComponentControl(); |
|
173 |
CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
174 |
listbox.SetListBoxObserver( this ); |
|
175 |
||
176 |
iContainer->ActivateL(); |
|
177 |
||
178 |
UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
|
179 |
||
180 |
// Invoke DrawNow() to avoid the cba flicker |
|
181 |
iView.Cba()->DrawNow(); |
|
182 |
} |
|
183 |
||
184 |
// Commit application-wide state changes |
|
185 |
viewActivationTransaction->Commit(); |
|
186 |
CleanupStack::PopAndDestroy(); //viewActivationTransaction |
|
187 |
||
188 |
// Remove the tabs from the navipane |
|
189 |
CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
190 |
CAknNavigationControlContainer* np = |
|
191 |
static_cast<CAknNavigationControlContainer*>( |
|
192 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
193 |
delete iNaviDecorator; |
|
194 |
iNaviDecorator = NULL; |
|
195 |
||
196 |
iNaviDecorator = np->CreateNavigationLabelL(); |
|
197 |
np->PushL( *iNaviDecorator ); |
|
198 |
sp->DrawNow(); |
|
199 |
} |
|
200 |
||
201 |
void CxSPSortView::UpdateCbasL( TInt aResourceId ) |
|
202 |
{ |
|
203 |
CCoeControl& ctrl=iContainer->ComponentControl(); |
|
204 |
CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
205 |
||
206 |
TBool noItemHightLighted = listbox.View()->ItemDrawer()->Flags() & CListItemDrawer::ESingleClickDisabledHighlight; |
|
207 |
||
208 |
if ( aResourceId == R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ) |
|
209 |
{ |
|
210 |
if ( noItemHightLighted ) |
|
211 |
{ |
|
212 |
// Load the default cba for the sort view |
|
213 |
iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
214 |
} |
|
215 |
else |
|
216 |
{ |
|
217 |
// Load the default cba for the sort view |
|
218 |
iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
|
219 |
} |
|
220 |
iView.Cba()->DrawDeferred(); |
|
221 |
} |
|
222 |
else if ( aResourceId == R_AVKON_SOFTKEYS_OK_CANCEL ) |
|
223 |
{ |
|
224 |
if ( noItemHightLighted ) |
|
225 |
{ |
|
226 |
// Load the default cba for the sort view |
|
227 |
iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL ); |
|
228 |
} |
|
229 |
else |
|
230 |
{ |
|
231 |
// Load the default cba for the sort view |
|
232 |
iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
233 |
} |
|
234 |
iView.Cba()->DrawDeferred(); |
|
235 |
} |
|
236 |
||
237 |
} |
|
238 |
||
239 |
void CxSPSortView::DoDeactivate() |
|
240 |
{ |
|
241 |
if (iContainer) |
|
242 |
{ |
|
243 |
CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
|
244 |
delete iContainer; |
|
245 |
iContainer = NULL; |
|
246 |
} |
|
247 |
||
248 |
if( iNaviDecorator ) |
|
249 |
{ |
|
250 |
// Remove the view-specific navipane decorations |
|
251 |
CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
252 |
TRAP_IGNORE( CAknNavigationControlContainer* np = |
|
253 |
static_cast<CAknNavigationControlContainer*>( |
|
254 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ))); // CSI: 42 # |
|
255 |
np->Pop( iNaviDecorator ); |
|
256 |
); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
void CxSPSortView::HandleStatusPaneSizeChange() |
|
261 |
{ |
|
262 |
// Resize the container to fill the client rectangle |
|
263 |
if (iContainer) |
|
264 |
{ |
|
265 |
iContainer->SetRect( iView.ClientRect() ); |
|
266 |
} |
|
267 |
} |
|
268 |
||
269 |
void CxSPSortView::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
270 |
{ |
|
271 |
if( AknLayoutUtils::PenEnabled() ) |
|
272 |
{ |
|
273 |
switch ( aEventType ) |
|
274 |
{ |
|
275 |
case EEventItemSingleClicked: |
|
276 |
{ |
|
277 |
CCoeControl& ctrl=iContainer->ComponentControl(); |
|
278 |
CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
279 |
const CListBoxView::CSelectionIndexArray* inds = listbox.SelectionIndexes(); |
|
280 |
TInt count = inds->Count(); |
|
281 |
||
282 |
if ( count <= 0 ) |
|
283 |
{ |
|
284 |
HandleCommandL( EExtensionManagerCmdMove ); |
|
285 |
} |
|
286 |
else |
|
287 |
{ |
|
288 |
HandleCommandL( EAknSoftkeyOk ); |
|
289 |
} |
|
290 |
break; |
|
291 |
} |
|
292 |
default: |
|
293 |
break; |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
void CxSPSortView::GlobalNoteClosed( const TInt aResult ) |
|
299 |
{ |
|
300 |
PBK2_DEBUG_PRINT( |
|
301 |
PBK2_DEBUG_STRING("CxSPSortView::GlobalNoteClosed [%i]"), aResult ); |
|
302 |
||
303 |
// This event results from a call to iContainer->CommitSortL when sorting |
|
304 |
// has been changed and the user has closed the resulting global note, |
|
305 |
// so we need to exit the application |
|
306 |
Pbk2AppUi()->ExitApplication(); |
|
307 |
} |
|
308 |
||
309 |
void CxSPSortView::GlobalNoteError( const TInt aErr ) |
|
310 |
{ |
|
311 |
PBK2_DEBUG_PRINT( |
|
312 |
PBK2_DEBUG_STRING("CxSPSortView::GlobalNoteError [%i]"), aErr ); |
|
313 |
||
314 |
// This event results from a call to iContainer->CommitSortL when sorting |
|
315 |
// has been changed and there was a problem with the resulting global note, |
|
316 |
// so we need to exit the application. |
|
317 |
// We could also try to show the error to the user. |
|
318 |
Pbk2AppUi()->ExitApplication(); |
|
319 |
} |
|
320 |
||
321 |
// End of File |