44
|
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 |
*
|
|
16 |
*/
|
|
17 |
/*
|
|
18 |
* ============================================================================
|
|
19 |
* Name : CGSPredictiveSettingList from AknFepPredictiveSettingList
|
|
20 |
* ============================================================================
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <barsread.h>
|
|
24 |
#include <AvkonInternalCRKeys.h>
|
|
25 |
#include <AknFepInternalCRKeys.h>
|
|
26 |
#include <e32property.h>
|
|
27 |
#include <PtiDefs.h>
|
|
28 |
#include <AknFepGlobalEnums.h>
|
|
29 |
#include "GsLangPlugin.hrh"
|
|
30 |
#include "DualLanguageList.h"
|
|
31 |
#include <aknsettingitemlist.h>
|
|
32 |
#include <gslangpluginrsc.rsg>
|
|
33 |
#include "DualLanguageDialog.h"
|
|
34 |
|
|
35 |
CGSLanguageSettingItem::CGSLanguageSettingItem( TInt aResourceId, TBool aPrimary, CGSDualLanguageData* aData)
|
|
36 |
: CAknEnumeratedTextPopupSettingItem(aResourceId, (aPrimary?aData->iCurrentValue:aData->iCurrentSecondaryValue))
|
|
37 |
, iData(aData), iPrimary(aPrimary)
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
CGSLanguageSettingItem::~CGSLanguageSettingItem()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
void CGSLanguageSettingItem::CompleteConstructionL()
|
|
46 |
{
|
|
47 |
CAknEnumeratedTextPopupSettingItem::CompleteConstructionL();
|
|
48 |
CArrayPtrFlat<HBufC>* dummyPtr = new (ELeave) CArrayPtrFlat<HBufC>(1);
|
|
49 |
CleanupStack::PushL(dummyPtr);
|
|
50 |
CArrayPtrFlat<CAknEnumeratedText>* items = new (ELeave) CArrayPtrFlat<CAknEnumeratedText>(10);
|
|
51 |
CleanupStack::PushL(items);
|
|
52 |
if(iPrimary)
|
|
53 |
{
|
|
54 |
for(TInt i = 0; i < iData->Items()->Count(); i++)
|
|
55 |
{
|
|
56 |
HBufC* buffer = HBufC::NewLC( 128 );
|
|
57 |
(*buffer) = (*iData->Items())[i];
|
|
58 |
CAknEnumeratedText* newItem = new (ELeave) CAknEnumeratedText(i, buffer);
|
|
59 |
CleanupStack::PushL(newItem);
|
|
60 |
items->AppendL(newItem);
|
|
61 |
CleanupStack::Pop(newItem);
|
|
62 |
CleanupStack::Pop(buffer);
|
|
63 |
}
|
|
64 |
SetEnumeratedTextArrays(items, dummyPtr);
|
|
65 |
SetInternalValue(iData->iCurrentValue);
|
|
66 |
SetExternalValue(iData->iCurrentValue);
|
|
67 |
}
|
|
68 |
else
|
|
69 |
{
|
|
70 |
for(TInt i = 0; i < iData->SecondaryItems()->Count(); i++)
|
|
71 |
{
|
|
72 |
HBufC* buffer = HBufC::NewLC( 128 );
|
|
73 |
(*buffer) = (*iData->SecondaryItems())[i];
|
|
74 |
CAknEnumeratedText* newItem = new (ELeave) CAknEnumeratedText(i, buffer);
|
|
75 |
CleanupStack::PushL(newItem);
|
|
76 |
items->AppendL(newItem);
|
|
77 |
CleanupStack::Pop(newItem);
|
|
78 |
CleanupStack::Pop(buffer);
|
|
79 |
}
|
|
80 |
SetEnumeratedTextArrays(items, dummyPtr);
|
|
81 |
SetInternalValue(iData->iCurrentSecondaryValue);
|
|
82 |
SetExternalValue(iData->iCurrentSecondaryValue);
|
|
83 |
}
|
|
84 |
CleanupStack::Pop(items);
|
|
85 |
CleanupStack::Pop(dummyPtr);
|
|
86 |
}
|
|
87 |
|
|
88 |
CGSDualLanguageList *CGSDualLanguageList::NewL(CGSDualLanguageData* aData, CGSDualLanguageDialog* aDialog)
|
|
89 |
{
|
|
90 |
CGSDualLanguageList* self = CGSDualLanguageList::NewLC(aData, aDialog);
|
|
91 |
CleanupStack::Pop(self);
|
|
92 |
return self;
|
|
93 |
}
|
|
94 |
|
|
95 |
CGSDualLanguageList *CGSDualLanguageList::NewLC(CGSDualLanguageData* aData, CGSDualLanguageDialog* aDialog)
|
|
96 |
{
|
|
97 |
CGSDualLanguageList* self = new (ELeave) CGSDualLanguageList(aData, aDialog);
|
|
98 |
CleanupStack::PushL(self);
|
|
99 |
return self;
|
|
100 |
}
|
|
101 |
|
|
102 |
CGSDualLanguageList::CGSDualLanguageList(CGSDualLanguageData* aData, CGSDualLanguageDialog* aDialog) :
|
|
103 |
CAknSettingItemList(), iData(aData), iDialog(aDialog)
|
|
104 |
{
|
|
105 |
}
|
|
106 |
|
|
107 |
CGSDualLanguageList::~CGSDualLanguageList()
|
|
108 |
{
|
|
109 |
// no specific destruction code required - no owned data
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
void CGSDualLanguageList::SizeChanged()
|
|
114 |
{
|
|
115 |
// if size changes, make sure component takes whole available space
|
|
116 |
CEikFormattedCellListBox *listbox = ListBox();
|
|
117 |
|
|
118 |
if (listbox)
|
|
119 |
{
|
|
120 |
listbox->SetRect(Rect());
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
void CGSDualLanguageList::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
|
|
125 |
{
|
|
126 |
if(aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked)
|
|
127 |
{
|
|
128 |
iDialog->EditItemL(EFalse); //EditCurrentItemL(EFalse);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
void CGSDualLanguageList::EditCurrentItemL(TBool aCalledFromMenu)
|
|
133 |
{
|
|
134 |
// invoke EditItemL on the current item
|
|
135 |
TInt index = SettingItemArray()->ItemIndexFromVisibleIndex(ListBox()->CurrentItemIndex());
|
|
136 |
|
|
137 |
EditItemL(index, aCalledFromMenu); // invoked from menu,or not
|
|
138 |
|
|
139 |
StoreSettingsL();
|
|
140 |
}
|
|
141 |
|
|
142 |
CAknSettingItem * CGSDualLanguageList::CreateSettingItemL (TInt aIdentifier)
|
|
143 |
{
|
|
144 |
// method is used to create specific setting item as required at run-time.
|
|
145 |
// aIdentifier is used to determine what kind of setting item should be
|
|
146 |
// created
|
|
147 |
|
|
148 |
CGSLanguageSettingItem* settingItem = NULL;
|
|
149 |
|
|
150 |
TInt language = 0;
|
|
151 |
CRepository* aknFepRepository = CRepository::NewLC(KCRUidAknFep);
|
|
152 |
aknFepRepository->Get( KAknFepInputTxtLang, language );
|
|
153 |
|
|
154 |
switch (aIdentifier)
|
|
155 |
{
|
|
156 |
case EGSLangInputPrimary:
|
|
157 |
settingItem = new (ELeave) CGSLanguageSettingItem(
|
|
158 |
R_PRIMARY_INPUT_LANGUAGE_SETTING_PAGE, ETrue, iData);
|
|
159 |
break;
|
|
160 |
case EGSLangInputSecondary:
|
|
161 |
settingItem = new (ELeave) CGSLanguageSettingItem(
|
|
162 |
R_SECONDARY_INPUT_LANGUAGE_SETTING_PAGE, EFalse, iData);
|
|
163 |
if(language == ELangTaiwanChinese ||
|
|
164 |
language == ELangHongKongChinese ||
|
|
165 |
language == ELangPrcChinese ||
|
|
166 |
language == ELangJapanese ||
|
|
167 |
language == ELangKorean )
|
|
168 |
{
|
|
169 |
settingItem->SetHidden(ETrue);
|
|
170 |
}
|
|
171 |
break;
|
|
172 |
default:
|
|
173 |
break;
|
|
174 |
}
|
|
175 |
CleanupStack::PopAndDestroy( aknFepRepository );
|
|
176 |
|
|
177 |
return (CAknSettingItem*)settingItem;
|
|
178 |
}
|
|
179 |
|
|
180 |
void CGSDualLanguageList::HideSecondaryInputL(TBool aHidden)
|
|
181 |
{
|
|
182 |
SettingItemArray()->At(1)->SetHidden(aHidden);
|
|
183 |
HandleChangeInItemArrayOrVisibilityL();
|
|
184 |
}
|