|
1 /* |
|
2 * Copyright (c) 2010 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 #include "cplanguageplugin.h" |
|
19 #include "cplanguageview.h" |
|
20 #include <QPointer> |
|
21 #include <HbLocaleUtil.h> |
|
22 #include <cpsettingformentryitemdataimpl.h> |
|
23 #include "cplanguagepluginlog.h" |
|
24 |
|
25 |
|
26 #ifdef ENABLE_CPLANG_LOG |
|
27 INIT_LOGGER (CPLANG_LOGGER_NAME,CPLANG_LOGGER_CONFIG_PATH) |
|
28 #endif |
|
29 |
|
30 static QPointer<CpSettingFormItemData> g_pluginEntryItemData; |
|
31 |
|
32 /*! |
|
33 * Constructor |
|
34 */ |
|
35 CpLanguagePlugin::CpLanguagePlugin() |
|
36 { |
|
37 CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::CpLanguagePlugin") |
|
38 } |
|
39 |
|
40 /*! |
|
41 * Destructor |
|
42 */ |
|
43 CpLanguagePlugin::~CpLanguagePlugin() |
|
44 { |
|
45 CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::~CpLanguagePlugin") |
|
46 } |
|
47 |
|
48 /*! |
|
49 * Overide CpPluginInterface::createSettingFormItemData |
|
50 */ |
|
51 QList<CpSettingFormItemData*> CpLanguagePlugin::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const |
|
52 { |
|
53 CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::createSettingFormItemData") |
|
54 |
|
55 g_pluginEntryItemData = new CpSettingFormEntryItemDataImpl<CpLanguageView>( |
|
56 CpSettingFormEntryItemData::ListEntryItem, |
|
57 itemDataHelper, |
|
58 hbTrId("txt_cp_dblist_language_and_region"), |
|
59 QString(), |
|
60 "qtg_large_language" ); |
|
61 |
|
62 updateEntryItem(); |
|
63 |
|
64 return QList<CpSettingFormItemData*>() << g_pluginEntryItemData; |
|
65 } |
|
66 |
|
67 /*! |
|
68 * update the description of the entry item. |
|
69 */ |
|
70 void CpLanguagePlugin::updateEntryItem() |
|
71 { |
|
72 CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::updateEntryItem") |
|
73 |
|
74 |
|
75 if (g_pluginEntryItemData) { |
|
76 QStringList allLanguages = HbLocaleUtil::supportedLanguages(); |
|
77 QString currentLanguage = HbLocaleUtil::currentLanguage(); |
|
78 |
|
79 CPLANG_LOG(QLatin1String("Current language:") + currentLanguage); |
|
80 |
|
81 int index = allLanguages.indexOf(currentLanguage); |
|
82 |
|
83 CPLANG_LOG(QString("Index of current language: %1").arg(index)); |
|
84 |
|
85 QString localisedLanguage; |
|
86 if (index >= 0) { |
|
87 localisedLanguage = HbLocaleUtil::localisedLanguageName(currentLanguage); |
|
88 CPLANG_LOG(QLatin1String("Localised Region:") + localisedLanguage); |
|
89 } |
|
90 g_pluginEntryItemData->setDescription(localisedLanguage); |
|
91 } |
|
92 } |
|
93 |
|
94 Q_EXPORT_PLUGIN2(cplanguageplugin, CpLanguagePlugin); |
|
95 |
|
96 //End of File |