diff -r 1fc85118c3ae -r 870918037e16 locationlandmarksrefappfors60/Src/LandmarksCategoriesDialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationlandmarksrefappfors60/Src/LandmarksCategoriesDialog.cpp Wed Sep 01 12:31:27 2010 +0100 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Implements the CLandmarksCategoriesDialog class +* +*/ + + + +#include +#include +#include +#include + +#include "LmRefApp.hrh" +#include +#include "LandmarksLmCategoriesModel.h" +#include "LandmarksApplicationEngine.h" +#include "LandmarksCategoriesDialog.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CLandmarksCategoriesDialog::CLandmarksCategoriesDialog( + TInt& aSelectedItem, + CArrayFixFlat* aMarkedItems, + CDesCArray* aListItems) + : + CAknMarkableListDialog(aSelectedItem, aMarkedItems, aListItems, -1, -1, NULL) + { + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CLandmarksCategoriesDialog::~CLandmarksCategoriesDialog() + { + // Restore title pane. Ownership of iOriginalTitle transferred. + if (iOriginalTitle && iTitlePane) + { + iTitlePane->SetText(iOriginalTitle); + } + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +TInt CLandmarksCategoriesDialog::RunDialogL( + CLandmarksLmCategoriesModel& aLmCategoriesModel) + { + // Create array of marked indeces + CArrayFixFlat* markedItems = aLmCategoriesModel.SelectedCategoriesL(); + CleanupStack::PushL(markedItems); + + // Create name array + CDesCArray* listItems = aLmCategoriesModel.FormattedCategoryNamesL(); + CleanupStack::PushL(listItems); + + // Create the dialog + TInt selectedItem = 0; + + CLandmarksCategoriesDialog* dialog = + new (ELeave) CLandmarksCategoriesDialog( + selectedItem, markedItems, listItems); + + dialog->PrepareLC(R_LMREFAPP_EDIT_CATEGORIES_DIALOG); + + // pre-mark currently selected categories + CEikListBox* listBox = (CEikListBox*) dialog->Control(ESelectionListControl); + for (TInt i = 0; i < markedItems->Count(); i++) + { + listBox->View()->SelectItemL((*markedItems)[i]); + } + + TInt res = dialog->RunLD(); + if (res) + { + aLmCategoriesModel.SelectCategoriesL(*markedItems); + } + + CleanupStack::PopAndDestroy(2, markedItems); + return res; + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CLandmarksCategoriesDialog::PostLayoutDynInitL() + { + CAknMarkableListDialog::PostLayoutDynInitL(); + + // Save original title + CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); + iTitlePane = (CAknTitlePane*) statusPane->ControlL( + TUid::Uid(EEikStatusPaneUidTitle)); + iOriginalTitle = iTitlePane->Text()->AllocL(); + + // Update title + HBufC* title = iCoeEnv->AllocReadResourceAsDes16L( + R_LMREFAPP_EDIT_CAT_TITLE); + iTitlePane->SetText(title); + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +TKeyResponse CLandmarksCategoriesDialog::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType) + { + if (aKeyEvent.iCode == EKeyDevice3) + { + // An item should be marked/unmarked. + CEikListBox* listBox = (CEikListBox*) Control(ESelectionListControl); + listBox->View()->ToggleItemL(listBox->View()->CurrentItemIndex()); + listBox->DrawDeferred(); + return EKeyWasConsumed; + } + + return CAknMarkableListDialog::OfferKeyEventL(aKeyEvent, aType); + } + +