|
1 /* |
|
2 * Copyright (c) 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: CheckBox class for Usage Reporting settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <stringloader.h> |
|
21 #include <aknquerydialog.h> |
|
22 #include <akninfopopupnotecontroller.h> |
|
23 #include <drmsettingspluginrsc.rsg> |
|
24 |
|
25 #include "drmsettingsusagecheckbox.h" |
|
26 #include "drmsettingsusagelist.h" |
|
27 #include "drmsettingsmodel.h" |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox |
|
33 // Default constructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox( |
|
37 TInt aResourceId, |
|
38 CDRMSettingUsageList* aList, |
|
39 CDRMSettingsModel* aModel ) : CAknCheckBoxSettingPage( aResourceId, aList ), |
|
40 iList( aList ), |
|
41 iModel( aModel ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox |
|
47 // |
|
48 // Destructor |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox() |
|
52 { |
|
53 delete iPopupController; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CDrmSettingUsageCheckBox::OfferKeyEventL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TKeyResponse CDrmSettingUsageCheckBox::OfferKeyEventL( |
|
61 const TKeyEvent& aKeyEvent, |
|
62 TEventCode aType ) |
|
63 { |
|
64 TKeyResponse response( EKeyWasNotConsumed ); |
|
65 if ( aKeyEvent.iCode != EKeyApplicationF ) |
|
66 { |
|
67 response = this->ListBoxControl()->OfferKeyEventL( aKeyEvent, aType ); |
|
68 } |
|
69 |
|
70 if ( aType == EEventKeyUp ) |
|
71 { |
|
72 ShowInfoPopupL(); |
|
73 } |
|
74 |
|
75 return response; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CDrmSettingUsageCheckBox::DynamicInitL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CDrmSettingUsageCheckBox::DynamicInitL() |
|
83 { |
|
84 HBufC* emptyText( StringLoader::LoadLC( R_USAGE_REPORTING_LIST_EMPTY, |
|
85 iEikonEnv ) ); |
|
86 this->ListBoxControl()->View()->SetListEmptyTextL( *emptyText ); |
|
87 CleanupStack::PopAndDestroy( emptyText ); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CDrmSettingUsageCheckBox::OkToExitL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 TBool CDrmSettingUsageCheckBox::OkToExitL( TBool aAccept ) |
|
95 { |
|
96 TBool exit( ETrue ); |
|
97 |
|
98 if ( aAccept ) |
|
99 { |
|
100 iList->UpdateContexts(); |
|
101 |
|
102 if ( !iModel->IsMeteringAllowedForAll() ) |
|
103 { |
|
104 HBufC* query( StringLoader::LoadLC( R_DRM_CONF_QUERY_METERING, |
|
105 iEikonEnv ) ); |
|
106 |
|
107 CAknQueryDialog* queryDialog( CAknQueryDialog::NewL() ); |
|
108 |
|
109 TBool retVal( queryDialog->ExecuteLD( R_DRM_CONFIRMATION_QUERY_METERING, |
|
110 *query ) ); |
|
111 CleanupStack::PopAndDestroy( query ); |
|
112 |
|
113 if ( !retVal ) |
|
114 { |
|
115 exit = EFalse; |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 return exit; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CDrmSettingUsageCheckBox::AcceptSettingL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CDrmSettingUsageCheckBox::AcceptSettingL() |
|
128 { |
|
129 iModel->SaveMeteringChanges(); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CDrmSettingUsageCheckBox::ShowInfoPopupL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CDrmSettingUsageCheckBox::ShowInfoPopupL() |
|
137 { |
|
138 if ( !iPopupController ) |
|
139 { |
|
140 iPopupController = CAknInfoPopupNoteController::NewL(); |
|
141 } |
|
142 TInt index( this->ListBoxControl()->View()->CurrentItemIndex() ); |
|
143 if ( index != -1 ) |
|
144 { |
|
145 iPopupController->SetTextL( iList->At(index)->ItemText() ); |
|
146 iPopupController->ShowInfoPopupNote(); |
|
147 } |
|
148 } |
|
149 |
|
150 // End of File |