|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 move top contacts dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2NlxMoveTopContactsDlg.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include <MPbk2AppUi.h> |
|
24 #include <MPbk2ApplicationServices.h> |
|
25 #include <MPbk2ContactViewSupplier.h> |
|
26 #include <Pbk2UIControls.rsg> |
|
27 |
|
28 // Virtual Phonebook |
|
29 #include <CVPbkContactLinkArray.h> |
|
30 #include <CVPbkContactManager.h> |
|
31 #include <MVPbkContactViewBase.h> |
|
32 #include <MVPbkContactLink.h> |
|
33 #include <MVPbkContactOperationBase.h> |
|
34 #include <MVPbkStoreContact.h> |
|
35 |
|
36 #include <avkon.rsg> |
|
37 #include <aknlists.h> |
|
38 #include <akntitle.h> |
|
39 #include <aknnavi.h> |
|
40 |
|
41 #include <eikclbd.h> |
|
42 #include <CPbk2IconArray.h> |
|
43 |
|
44 #include "CPbk2NlxReorderingModel.h" |
|
45 #include "Pbk2NlxUIControls.hrh" |
|
46 #include <Pbk2ExNamesListRes.rsg> |
|
47 |
|
48 #include <Pbk2Debug.h> |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // CPbk2NlxMoveTopContactsDlg::CPbk2NlxMoveTopContactsDlg |
|
52 // -------------------------------------------------------------------------- |
|
53 inline CPbk2NlxMoveTopContactsDlg::CPbk2NlxMoveTopContactsDlg( |
|
54 CPbk2NlxReorderingModel& aModel ): |
|
55 iModel(aModel) |
|
56 { |
|
57 } |
|
58 |
|
59 // -------------------------------------------------------------------------- |
|
60 // CPbk2NlxMoveTopContactsDlg::~CPbk2NlxMoveTopContactsDlg |
|
61 // -------------------------------------------------------------------------- |
|
62 CPbk2NlxMoveTopContactsDlg::~CPbk2NlxMoveTopContactsDlg() |
|
63 { |
|
64 TRAP_IGNORE(RestoreTitlePaneTextL()); |
|
65 } |
|
66 |
|
67 // -------------------------------------------------------------------------- |
|
68 // CPbk2NlxMoveTopContactsDlg::ConstructL |
|
69 // -------------------------------------------------------------------------- |
|
70 inline void CPbk2NlxMoveTopContactsDlg::ConstructL() |
|
71 { |
|
72 CAknDialog::ConstructL( R_AVKON_MENUPANE_EMPTY ); |
|
73 } |
|
74 |
|
75 // -------------------------------------------------------------------------- |
|
76 // CPbk2NlxMoveTopContactsDlg::NewL |
|
77 // -------------------------------------------------------------------------- |
|
78 CPbk2NlxMoveTopContactsDlg* CPbk2NlxMoveTopContactsDlg::NewL( |
|
79 CPbk2NlxReorderingModel& aModel ) |
|
80 { |
|
81 CPbk2NlxMoveTopContactsDlg* dlg = new ( ELeave ) |
|
82 CPbk2NlxMoveTopContactsDlg( aModel ); |
|
83 CleanupStack::PushL( dlg ); |
|
84 dlg->ConstructL(); |
|
85 CleanupStack::Pop( dlg ); |
|
86 return dlg; |
|
87 } |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 // CPbk2NlxMoveTopContactsDlg::ExecuteLD |
|
91 // -------------------------------------------------------------------------- |
|
92 TInt CPbk2NlxMoveTopContactsDlg::ExecuteLD() |
|
93 { |
|
94 return CEikDialog::ExecuteLD( R_PBK2_MOVE_TOP_CONTACTS_DLG ); |
|
95 } |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CPbk2NlxMoveTopContactsDlg::PostLayoutDynInitL |
|
99 // -------------------------------------------------------------------------- |
|
100 void CPbk2NlxMoveTopContactsDlg::PostLayoutDynInitL() |
|
101 { |
|
102 iPrevSelectedItem = iModel.FocusedContactIndex(); |
|
103 if ( iPrevSelectedItem != KErrNotFound ) |
|
104 { |
|
105 iListBox->SetCurrentItemIndexAndDraw( iPrevSelectedItem ); |
|
106 } |
|
107 CEikCaptionedControl* capControl = Line(ECtrlTopContactList); |
|
108 capControl->SetPointerEventObserver(this); |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CPbk2NlxMoveTopContactsDlg::PreLayoutDynInitL |
|
113 // -------------------------------------------------------------------------- |
|
114 void CPbk2NlxMoveTopContactsDlg::PreLayoutDynInitL() |
|
115 { |
|
116 CAknDialog::PreLayoutDynInitL(); |
|
117 iListBox = static_cast<CEikColumnListBox*>(Control(ECtrlTopContactList)); |
|
118 |
|
119 // set our model |
|
120 iListBox->Model()->SetItemTextArray( &iModel ); |
|
121 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
122 |
|
123 iListBox->ItemDrawer()->ColumnData()->SetIconArray( |
|
124 iModel.TakeIconArray() ); |
|
125 iModel.SetContactUpdater( this ); |
|
126 |
|
127 //setup scrollbar |
|
128 iListBox->CreateScrollBarFrameL( ETrue ); |
|
129 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
130 CEikScrollBarFrame::EOff, |
|
131 CEikScrollBarFrame::EAuto ); |
|
132 iListBox->HandleItemAdditionL(); |
|
133 |
|
134 iListBox->SetListBoxObserver( this ); |
|
135 iListBox->SetObserver( this ); |
|
136 |
|
137 SetNewTitleTextL(); |
|
138 } |
|
139 |
|
140 // -------------------------------------------------------------------------- |
|
141 // CPbk2NlxMoveTopContactsDlg::SetNewTitleTextL |
|
142 // -------------------------------------------------------------------------- |
|
143 void CPbk2NlxMoveTopContactsDlg::SetNewTitleTextL () |
|
144 { |
|
145 CAknTitlePane* title = static_cast<CAknTitlePane*>(CEikonEnv::Static()-> |
|
146 AppUiFactory()->StatusPane()->ControlL( |
|
147 TUid::Uid ( EEikStatusPaneUidTitle) ) ); |
|
148 |
|
149 // Store old one |
|
150 iOldTitleText = title->Text()->AllocL (); |
|
151 |
|
152 // Clear the navi pane |
|
153 // Get pointer to status-pane |
|
154 CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()-> |
|
155 StatusPane (); |
|
156 // Get pointer to navi-pane |
|
157 CAknNavigationControlContainer * naviPane = |
|
158 static_cast<CAknNavigationControlContainer*>(statusPane->ControlL( |
|
159 TUid::Uid ( EEikStatusPaneUidNavi) ) ); |
|
160 naviPane->PushDefaultL (ETrue); |
|
161 |
|
162 // Set the new text |
|
163 HBufC* tempTitle= CEikonEnv::Static()->AllocReadResourceLC( |
|
164 R_PBK2_MOVE_TOP_CONTACTS_DLG_TITLE ); |
|
165 title->SetTextL ( *tempTitle); |
|
166 CleanupStack::PopAndDestroy (tempTitle); |
|
167 } |
|
168 |
|
169 // -------------------------------------------------------------------------- |
|
170 // CPbk2NlxMoveTopContactsDlg::RestoreTitlePaneTextL() |
|
171 // -------------------------------------------------------------------------- |
|
172 // |
|
173 void CPbk2NlxMoveTopContactsDlg::RestoreTitlePaneTextL() |
|
174 { |
|
175 CAknTitlePane* title = static_cast<CAknTitlePane*>(CEikonEnv::Static()-> |
|
176 AppUiFactory()->StatusPane()->ControlL( |
|
177 TUid::Uid ( EEikStatusPaneUidTitle) ) ); |
|
178 if ( iOldTitleText ) |
|
179 { |
|
180 title->SetTextL(*iOldTitleText); |
|
181 delete iOldTitleText; |
|
182 iOldTitleText = NULL; |
|
183 } |
|
184 else |
|
185 { |
|
186 title->SetTextToDefaultL(); |
|
187 } |
|
188 |
|
189 // restore the navi pane |
|
190 // Get pointer to status-pane |
|
191 CEikStatusPane* statusPane = |
|
192 CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
193 // Get pointer to navi-pane |
|
194 CAknNavigationControlContainer |
|
195 * naviPane = |
|
196 static_cast<CAknNavigationControlContainer*>( |
|
197 statusPane->ControlL( |
|
198 TUid::Uid( EEikStatusPaneUidNavi) ) ); |
|
199 naviPane->Pop(); |
|
200 } |
|
201 |
|
202 // -------------------------------------------------------------------------- |
|
203 // CPbk2NlxMoveTopContactsDlg::OkToExitL |
|
204 // -------------------------------------------------------------------------- |
|
205 TBool CPbk2NlxMoveTopContactsDlg::OkToExitL( TInt aButtonId ) |
|
206 { |
|
207 iModel.SetFocusedContactL( iListBox->CurrentItemIndex() ); |
|
208 iModel.SetContactUpdater( NULL ); //stop updating contacts |
|
209 return CEikDialog::OkToExitL( aButtonId ); |
|
210 } |
|
211 |
|
212 // -------------------------------------------------------------------------- |
|
213 // CPbk2NlxMoveTopContactsDlg::OfferKeyEventL |
|
214 // -------------------------------------------------------------------------- |
|
215 TKeyResponse CPbk2NlxMoveTopContactsDlg::OfferKeyEventL |
|
216 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
217 { |
|
218 TKeyResponse result = EKeyWasNotConsumed; |
|
219 { |
|
220 result = CEikDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
221 } |
|
222 |
|
223 return result; |
|
224 } |
|
225 |
|
226 // -------------------------------------------------------------------------- |
|
227 // CPbk2NlxMoveTopContactsDlg::HandleResourceChange |
|
228 // -------------------------------------------------------------------------- |
|
229 void CPbk2NlxMoveTopContactsDlg::HandleResourceChange( TInt aType ) |
|
230 { |
|
231 CAknDialog::HandleResourceChange(aType); |
|
232 } |
|
233 |
|
234 // -------------------------------------------------------------------------- |
|
235 // CPbk2NlxMoveTopContactsDlg::PointerEvent |
|
236 // -------------------------------------------------------------------------- |
|
237 bool CPbk2NlxMoveTopContactsDlg::PointerEvent( |
|
238 CEikCaptionedControl* /*aControl*/, |
|
239 const TPointerEvent& aPointerEvent ) |
|
240 { |
|
241 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
242 { |
|
243 TInt itemUnder; |
|
244 if ( iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, |
|
245 itemUnder) ) |
|
246 { |
|
247 iPrevSelectedItem = itemUnder; |
|
248 } |
|
249 } |
|
250 return ETrue; |
|
251 } |
|
252 |
|
253 // -------------------------------------------------------------------------- |
|
254 // CPbk2NlxMoveTopContactsDlg::HandleListBoxEventL |
|
255 // -------------------------------------------------------------------------- |
|
256 void CPbk2NlxMoveTopContactsDlg::HandleListBoxEventL( |
|
257 CEikListBox* /*aListBox*/, |
|
258 TListBoxEvent aEventType) |
|
259 { |
|
260 if( AknLayoutUtils::PenEnabled() ) |
|
261 { |
|
262 if ( aEventType == EEventItemDraggingActioned ) |
|
263 { |
|
264 ContinueDragL(); |
|
265 } |
|
266 } |
|
267 } |
|
268 |
|
269 // -------------------------------------------------------------------------- |
|
270 // CPbk2NlxMoveTopContactsDlg::HandleControlEventL |
|
271 // -------------------------------------------------------------------------- |
|
272 void CPbk2NlxMoveTopContactsDlg::HandleControlEventL( |
|
273 CCoeControl* aControl, |
|
274 TCoeEvent aEventType ) |
|
275 { |
|
276 CEikDialog::HandleControlEventL( aControl, aEventType ); |
|
277 if ( aEventType == EEventStateChanged ) |
|
278 { |
|
279 ContinueDragL(); |
|
280 } |
|
281 } |
|
282 |
|
283 // -------------------------------------------------------------------------- |
|
284 // CPbk2NlxMoveTopContactsDlg::ContinueDrag |
|
285 // -------------------------------------------------------------------------- |
|
286 void CPbk2NlxMoveTopContactsDlg::ContinueDragL() |
|
287 { |
|
288 if (iPrevSelectedItem != iListBox->CurrentItemIndex()) |
|
289 { |
|
290 iModel.Move( iPrevSelectedItem, iListBox->CurrentItemIndex() ); |
|
291 iListBox->DrawNow(); |
|
292 iPrevSelectedItem = iListBox->CurrentItemIndex(); |
|
293 } |
|
294 } |
|
295 |
|
296 // -------------------------------------------------------------------------- |
|
297 // CPbk2NlxMoveTopContactsDlg::UpdateContact |
|
298 // -------------------------------------------------------------------------- |
|
299 void CPbk2NlxMoveTopContactsDlg::UpdateContact( const MVPbkContactLink& aContactLink ) |
|
300 { |
|
301 TInt index = iModel.ContactIndex( aContactLink ); |
|
302 if ( index >= iListBox->TopItemIndex() && |
|
303 index <= iListBox->BottomItemIndex() ) |
|
304 { |
|
305 iListBox->DrawItem(index); |
|
306 } |
|
307 } |
|
308 // End of File |