author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:24:28 +0300 | |
branch | RCL_3 |
changeset 44 | 5033d469f7c9 |
parent 37 | 870918037e16 |
permissions | -rw-r--r-- |
37 | 1 |
/* |
2 |
* Copyright (c) 2004-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 "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 |
* Implements the CLandmarksView class |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
||
21 |
#include <eikmenup.h> |
|
22 |
#include <aknViewAppUi.h> |
|
23 |
#include <aknnavide.h> |
|
24 |
||
25 |
#include <lbspositioninfo.h> |
|
26 |
#include <epos_poslandmarkserialization.h> |
|
27 |
||
44
5033d469f7c9
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
28 |
#include <LmRefApp.rsg> |
37 | 29 |
#include "LmRefApp.hrh" |
30 |
#include "LandmarksView.h" |
|
31 |
#include "LandmarksAppUi.h" |
|
32 |
#include "LandmarksApplicationEngine.h" |
|
33 |
#include "LandmarksContainer.h" |
|
34 |
#include "LandmarksEditDialog.h" |
|
35 |
||
36 |
// ============================ MEMBER FUNCTIONS =============================== |
|
37 |
||
38 |
// ----------------------------------------------------------------------------- |
|
39 |
// ----------------------------------------------------------------------------- |
|
40 |
// |
|
41 |
CLandmarksView::CLandmarksView( |
|
42 |
CAknNavigationDecorator* aNaviDecorator, |
|
43 |
CLandmarksApplicationEngine& aEngine ) |
|
44 |
: iEngine( aEngine ), |
|
45 |
iNaviDecorator( aNaviDecorator ) |
|
46 |
{ |
|
47 |
// No implementation required |
|
48 |
} |
|
49 |
||
50 |
// ----------------------------------------------------------------------------- |
|
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
void CLandmarksView::ConstructL() |
|
54 |
{ |
|
55 |
BaseConstructL( R_LMREFAPP_VIEW ); |
|
56 |
} |
|
57 |
||
58 |
// ----------------------------------------------------------------------------- |
|
59 |
// ----------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
CLandmarksView* CLandmarksView::NewLC( |
|
62 |
CAknNavigationDecorator* aNaviDecorator, |
|
63 |
CLandmarksApplicationEngine& aEngine ) |
|
64 |
{ |
|
65 |
CLandmarksView* self = new ( ELeave ) CLandmarksView( |
|
66 |
aNaviDecorator, aEngine ); |
|
67 |
CleanupStack::PushL( self ); |
|
68 |
self->ConstructL(); |
|
69 |
return self; |
|
70 |
} |
|
71 |
||
72 |
// ----------------------------------------------------------------------------- |
|
73 |
// ----------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
CLandmarksView::~CLandmarksView() |
|
76 |
{ |
|
77 |
delete iContainer; |
|
78 |
} |
|
79 |
||
80 |
// ----------------------------------------------------------------------------- |
|
81 |
// ----------------------------------------------------------------------------- |
|
82 |
// |
|
83 |
TUid CLandmarksView::Id() const |
|
84 |
{ |
|
85 |
return TUid::Uid( ELandmarksViewId ); |
|
86 |
} |
|
87 |
||
88 |
// ----------------------------------------------------------------------------- |
|
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
void CLandmarksView::HandleCommandL( TInt aCommand ) |
|
92 |
{ |
|
93 |
{ |
|
94 |
switch ( aCommand ) |
|
95 |
{ |
|
96 |
case ELandmarksAddCurrent: |
|
97 |
AddLandmarkL( ETrue ); // use current location |
|
98 |
break; |
|
99 |
||
100 |
case ELandmarksAddBlank: |
|
101 |
AddLandmarkL( EFalse ); // create blank |
|
102 |
break; |
|
103 |
||
104 |
case ELandmarksDelete: |
|
105 |
iContainer->DeleteLandmarkL(); |
|
106 |
break; |
|
107 |
||
108 |
case ELandmarksOpen: |
|
109 |
{ |
|
110 |
TPckgC<TPosLmItemId> lmId( iContainer->CurrentLandmark() ); |
|
111 |
||
112 |
AppUi()->ActivateLocalViewL( |
|
113 |
TUid::Uid( ELandmarksInfoViewId ), |
|
114 |
TUid::Uid( ELandmarksViewInfoById ), |
|
115 |
lmId ); |
|
116 |
break; |
|
117 |
} |
|
118 |
||
119 |
default: |
|
120 |
AppUi()->HandleCommandL( aCommand ); |
|
121 |
break; |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
// ----------------------------------------------------------------------------- |
|
127 |
// ----------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
void CLandmarksView::DoActivateL( |
|
130 |
const TVwsViewId& /*aPrevViewId*/, |
|
131 |
TUid /*aCustomMessageId*/, |
|
132 |
const TDesC8& /*aCustomMessage*/ ) |
|
133 |
{ |
|
134 |
if ( !iContainer ) |
|
135 |
{ |
|
136 |
iContainer = new ( ELeave ) CLandmarksContainer( |
|
137 |
*this, iEngine, iNaviDecorator ); |
|
138 |
iContainer->SetMopParent( this ); |
|
139 |
iContainer->ConstructL( ClientRect() ); |
|
140 |
} |
|
141 |
||
142 |
// Enable receiving of keyboard events. |
|
143 |
AppUi()->AddToStackL( *this, iContainer ); |
|
144 |
||
145 |
// Make view visible. |
|
146 |
iContainer->MakeVisible( ETrue ); |
|
147 |
||
148 |
// Notify that this view is active |
|
149 |
iEngine.NotifyViewActivated( Id(), ETrue ); |
|
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// ----------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
void CLandmarksView::DoDeactivate() |
|
156 |
{ |
|
157 |
// Hide view. |
|
158 |
iContainer->MakeVisible( EFalse ); |
|
159 |
||
160 |
// Notify that this view is inactive |
|
161 |
iEngine.NotifyViewActivated( Id(), EFalse ); |
|
162 |
||
163 |
// Disable receiving keyboard events. |
|
164 |
AppUi()->RemoveFromStack( iContainer ); |
|
165 |
} |
|
166 |
||
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// ----------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
void CLandmarksView::HandleResourceChange( TInt aType ) |
|
171 |
{ |
|
172 |
if ( iContainer ) |
|
173 |
{ |
|
174 |
iContainer->HandleResourceChange( aType ); |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
// ----------------------------------------------------------------------------- |
|
179 |
// ----------------------------------------------------------------------------- |
|
180 |
// |
|
181 |
void CLandmarksView::DynInitMenuPaneL( |
|
182 |
TInt aResourceId, |
|
183 |
CEikMenuPane* aMenuPane ) |
|
184 |
{ |
|
185 |
{ |
|
186 |
if ( aResourceId == R_LMREFAPP_MENU ) |
|
187 |
{ |
|
188 |
// If no landmark is selected we need to hide some command options. |
|
189 |
TBool isListEmpty = !iContainer->IsItemSelected(); |
|
190 |
aMenuPane->SetItemDimmed( ELandmarksDelete, isListEmpty ); |
|
191 |
aMenuPane->SetItemDimmed( ELandmarksOpen, isListEmpty ); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
CAknView::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
196 |
} |
|
197 |
||
198 |
// ----------------------------------------------------------------------------- |
|
199 |
// ----------------------------------------------------------------------------- |
|
200 |
// |
|
201 |
void CLandmarksView::AddLandmarkL( TBool aUseCurrentLocation ) |
|
202 |
{ |
|
203 |
// Create new landmark |
|
204 |
CPosLandmark* newLandmark = CPosLandmark::NewLC(); |
|
205 |
||
206 |
if ( EditNewLandmarkL( *newLandmark, aUseCurrentLocation ) ) |
|
207 |
{ |
|
208 |
iEngine.AddLandmarkL( *newLandmark ); |
|
209 |
} |
|
210 |
||
211 |
CleanupStack::PopAndDestroy( newLandmark ); |
|
212 |
} |
|
213 |
||
214 |
// ----------------------------------------------------------------------------- |
|
215 |
// ----------------------------------------------------------------------------- |
|
216 |
// |
|
217 |
TBool CLandmarksView::EditNewLandmarkL( CPosLandmark& aLandmark, TBool aFetchCurrentLocation ) |
|
218 |
{ |
|
219 |
// Create edit dialog |
|
220 |
TBool isEdited( EFalse ); |
|
221 |
CLandmarksEditDialog* editDialog = CLandmarksEditDialog::NewLC( |
|
222 |
aLandmark, aFetchCurrentLocation, isEdited, iEngine ); |
|
223 |
||
224 |
// Remove tabs from this view |
|
225 |
iNaviDecorator->MakeVisible( EFalse ); |
|
226 |
||
227 |
// Dialog must not leave without restoring tab group. Must be trapped. |
|
228 |
TRAPD( err, editDialog->ExecuteLD( R_LMREFAPP_EDIT_DIALOG ) ); |
|
229 |
||
230 |
// Restore tabs to this view |
|
231 |
iNaviDecorator->MakeVisible( ETrue ); |
|
232 |
||
233 |
User::LeaveIfError( err ); |
|
234 |
CleanupStack::Pop( editDialog ); |
|
235 |
return isEdited; |
|
236 |
} |
|
237 |