|
1 /* |
|
2 * Copyright (c) 2009 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 * Provides Image conflict resolution dialog for Contact Merge command. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <aknlists.h> |
|
20 #include <AknIconArray.h> |
|
21 #include <eikapp.h> |
|
22 #include <gulicon.h> |
|
23 #include <StringLoader.h> |
|
24 #include <aknnavide.h> |
|
25 #include <akntitle.h> |
|
26 #include <Pbk2UIControls.rsg> |
|
27 #include <MPbk2MergeConflict.h> |
|
28 #include "CPbk2MergePhotoConflictDlg.h" |
|
29 |
|
30 /// Unnamed namespace for local definitions |
|
31 namespace { |
|
32 |
|
33 _LIT( KPictureRowFormat, "%d\t %S\t\t" ); |
|
34 |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPbk2MergePhotoConflictDlg::CPbk2MergePhotoConflictDlg |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CPbk2MergePhotoConflictDlg::CPbk2MergePhotoConflictDlg( CFbsBitmap* aFirstImage, |
|
42 CFbsBitmap* aSecondImage, |
|
43 TInt* aResult ): |
|
44 iFirstImage( aFirstImage ), iSecondImage( aSecondImage ), iSelectedItem( aResult ) |
|
45 { |
|
46 // No implementation required |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CPbk2MergePhotoConflictDlg::~CPbk2MergePhotoConflictDlg |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CPbk2MergePhotoConflictDlg::~CPbk2MergePhotoConflictDlg() |
|
54 { |
|
55 delete iNaviDecorator; |
|
56 delete iSelectedString; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CPbk2MergePhotoConflictDlg::NewL |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C CPbk2MergePhotoConflictDlg* CPbk2MergePhotoConflictDlg::NewL( CFbsBitmap* aFirstImage, |
|
64 CFbsBitmap* aSecondImage, |
|
65 TInt* aResult ) |
|
66 { |
|
67 CPbk2MergePhotoConflictDlg* self = |
|
68 new (ELeave) CPbk2MergePhotoConflictDlg( aFirstImage, aSecondImage, aResult ); |
|
69 CleanupStack::PushL(self); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(); // self; |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CPbk2MergePhotoConflictDlg::ConstructL |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CPbk2MergePhotoConflictDlg::ConstructL() |
|
80 { |
|
81 SetNaviPaneL(); |
|
82 SetTitlePaneL( ETrue ); |
|
83 *iSelectedItem = EPbk2ConflictedFirst; |
|
84 iSelectedString = StringLoader::LoadL( R_QTN_PHOB_TITLE_SELECTED ); |
|
85 CAknDialog::ConstructL( R_AVKON_MENUPANE_EMPTY ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CPbk2MergePhotoConflictDlg::PreLayoutDynInitL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CPbk2MergePhotoConflictDlg::PreLayoutDynInitL() |
|
93 { |
|
94 CAknDialog::PreLayoutDynInitL(); |
|
95 |
|
96 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
97 CEikCba* eikCba = static_cast<CEikCba*>( cba.ButtonGroup() ); |
|
98 if( eikCba ) |
|
99 { |
|
100 eikCba->EnableItemSpecificSoftkey( EFalse ); |
|
101 } |
|
102 |
|
103 iListBox = static_cast<CEikFormattedCellListBox*>( Control( 1 ) ); |
|
104 |
|
105 SetIconsL(); |
|
106 SetItemsL(); |
|
107 |
|
108 iListBox->CreateScrollBarFrameL( ETrue ); |
|
109 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
110 CEikScrollBarFrame::EOff, |
|
111 CEikScrollBarFrame::EAuto ); |
|
112 |
|
113 iListBox->HandleItemAdditionL(); |
|
114 iListBox->SetListBoxObserver( this ); // MEikListBoxObserver |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CPbk2MergePhotoConflictDlg::OkToExitL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TBool CPbk2MergePhotoConflictDlg::OkToExitL( TInt aButtonId ) |
|
122 { |
|
123 if ( aButtonId == EAknSoftkeyDone || aButtonId == EAknSoftkeyCancel ) |
|
124 { |
|
125 TRAP_IGNORE( SetTitlePaneL( EFalse ) ); |
|
126 return ETrue; |
|
127 } |
|
128 return EFalse; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CPbk2MergePhotoConflictDlg::OfferKeyEventL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TKeyResponse CPbk2MergePhotoConflictDlg::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
136 { |
|
137 TKeyResponse result = EKeyWasNotConsumed; |
|
138 |
|
139 if ( aKeyEvent.iCode == EKeyEscape ) |
|
140 { |
|
141 result = CEikDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
142 return result; |
|
143 } |
|
144 |
|
145 result = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
146 |
|
147 if ( aType == EEventKeyDown && aKeyEvent.iScanCode == EStdKeyDevice3 ) |
|
148 { |
|
149 SwitchRadioButtonL(); |
|
150 } |
|
151 return result; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CPbk2MergePhotoConflictDlg::HandleListBoxEventL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CPbk2MergePhotoConflictDlg::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
159 { |
|
160 if( AknLayoutUtils::PenEnabled() ) |
|
161 { |
|
162 if ( aEventType == EEventItemSingleClicked ) |
|
163 { |
|
164 SwitchRadioButtonL(); |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CPbk2MergePhotoConflictDlg::SetIconsL |
|
171 // Sets icons for the listbox. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CPbk2MergePhotoConflictDlg::SetIconsL() |
|
175 { |
|
176 if ( iFirstImage == NULL || iSecondImage == NULL ) |
|
177 { |
|
178 User::Leave( KErrArgument ); |
|
179 } |
|
180 |
|
181 CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray( 2 ); |
|
182 CleanupStack::PushL( iconList ); |
|
183 |
|
184 CGulIcon* first = CGulIcon::NewL( iFirstImage ); |
|
185 first->SetBitmapsOwnedExternally( ETrue ); |
|
186 CleanupStack::PushL( first ); |
|
187 iconList->AppendL( first ); |
|
188 CleanupStack::Pop( first ); |
|
189 |
|
190 CGulIcon* second = CGulIcon::NewL( iSecondImage ); |
|
191 second->SetBitmapsOwnedExternally( ETrue ); |
|
192 CleanupStack::PushL( second ); |
|
193 iconList->AppendL( second ); |
|
194 CleanupStack::Pop( second ); |
|
195 |
|
196 iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList ); |
|
197 CleanupStack::Pop( iconList ); |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CPbk2MergePhotoConflictDlg::SetItemsL |
|
202 // Sets items to the listbox. |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CPbk2MergePhotoConflictDlg::SetItemsL() |
|
206 { |
|
207 CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat( 2 ); |
|
208 |
|
209 RBuf listItem; |
|
210 listItem.Create( KPictureRowFormat().Length() + iSelectedString->Length() ); |
|
211 listItem.Format( KPictureRowFormat, EPbk2ConflictedFirst, iSelectedString ); |
|
212 itemArray->AppendL( listItem ); |
|
213 listItem.Close(); |
|
214 |
|
215 listItem.Create( KPictureRowFormat().Length() + iSelectedString->Length() ); |
|
216 listItem.Format( KPictureRowFormat, EPbk2ConflictedSecond, &KNullDesC ); |
|
217 itemArray->AppendL( listItem ); |
|
218 listItem.Close(); |
|
219 |
|
220 iListBox->Model()->SetItemTextArray( itemArray ); |
|
221 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
222 |
|
223 iListBox->HandleItemAdditionL(); |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CPbk2MergePhotoConflictDlg::SwitchRadioButtonL |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CPbk2MergePhotoConflictDlg::SwitchRadioButtonL() |
|
231 { |
|
232 TInt itemIndex = iListBox->CurrentItemIndex(); |
|
233 if ( *iSelectedItem != itemIndex) |
|
234 { |
|
235 CDesCArray* itemArray = static_cast<CDesC16ArrayFlat*>( iListBox->Model()->ItemTextArray() ); |
|
236 |
|
237 // deselect item |
|
238 RBuf listItem; |
|
239 listItem.Create( KPictureRowFormat().Length() ); |
|
240 listItem.Format( KPictureRowFormat, *iSelectedItem , &KNullDesC ); |
|
241 itemArray->Delete( *iSelectedItem ); |
|
242 itemArray->InsertL( *iSelectedItem, listItem ); |
|
243 listItem.Close(); |
|
244 |
|
245 // select item |
|
246 listItem.Create( KPictureRowFormat().Length() + iSelectedString->Length() ); |
|
247 listItem.Format( KPictureRowFormat, itemIndex, iSelectedString ); |
|
248 itemArray->Delete( itemIndex ); |
|
249 itemArray->InsertL( itemIndex, listItem ); |
|
250 listItem.Close(); |
|
251 |
|
252 *iSelectedItem = itemIndex; |
|
253 iListBox->DrawDeferred(); |
|
254 } |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CPbk2MergeConflictsDlg::SetNaviPaneL |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CPbk2MergePhotoConflictDlg::SetNaviPaneL() |
|
262 { |
|
263 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
264 if ( statusPane && statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) ).IsPresent() ) |
|
265 { |
|
266 CAknNavigationControlContainer* naviPane = static_cast<CAknNavigationControlContainer*> |
|
267 ( statusPane->ControlL ( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
268 |
|
269 HBufC* naviLabel = StringLoader::LoadLC( R_QTN_PHOB_TITLE_SELECT_IMAGE ); |
|
270 |
|
271 iNaviDecorator = naviPane->CreateNavigationLabelL( *naviLabel ); |
|
272 CleanupStack::PopAndDestroy( naviLabel ); |
|
273 naviPane->PushL( *iNaviDecorator ); |
|
274 } |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CPbk2MergeConflictsDlg::SetTitlePaneL |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CPbk2MergePhotoConflictDlg::SetTitlePaneL( TBool aCustom ) |
|
282 { |
|
283 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
284 if ( statusPane && statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
285 { |
|
286 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
287 ( statusPane->ControlL ( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
288 |
|
289 if ( aCustom ) |
|
290 { |
|
291 HBufC* title = StringLoader::LoadLC( R_QTN_PHOB_TITLE_CONFLICT_RESOLUTION ); |
|
292 titlePane->SetTextL( *title ); |
|
293 CleanupStack::PopAndDestroy( title ); |
|
294 } |
|
295 else |
|
296 { |
|
297 titlePane->SetTextToDefaultL(); |
|
298 } |
|
299 } |
|
300 } |