|
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 // INCLUDE FILES |
|
20 |
|
21 #include "perfmon_model.h" |
|
22 #include "perfmon_app.h" |
|
23 #include "perfmon_settingsviewdlg.h" |
|
24 #include "perfmon.hrh" |
|
25 #include "perfmon_valuescontainer.h" |
|
26 #include "perfmon_graphscontainer.h" |
|
27 #include "perfmon_datapopupcontainer.h" |
|
28 #include <perfmon.rsg> |
|
29 |
|
30 #include <coeutils.h> |
|
31 #include <bautils.h> |
|
32 #include <eikenv.h> |
|
33 #include <e32hal.h> |
|
34 #include <u32std.h> |
|
35 #include <s32file.h> |
|
36 #include <akntitle.h> |
|
37 #include <eikspane.h> |
|
38 #include <aknnotewrappers.h> |
|
39 |
|
40 _LIT(KAppName, "PerfMon"); |
|
41 |
|
42 // ===================================== MEMBER FUNCTIONS ===================================== |
|
43 |
|
44 CPerfMonModel* CPerfMonModel::NewL() |
|
45 { |
|
46 CPerfMonModel* self = new(ELeave) CPerfMonModel; |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // -------------------------------------------------------------------------------------------- |
|
54 |
|
55 void CPerfMonModel::ConstructL() |
|
56 { |
|
57 iDrawState = EDrawStateInvalid; |
|
58 CPerfMonEngine::ConstructL(); |
|
59 } |
|
60 |
|
61 // -------------------------------------------------------------------------------------------- |
|
62 |
|
63 void CPerfMonModel::ActivateModelL() |
|
64 { |
|
65 // initialize the data popup container in top-right corner |
|
66 iDataPopupContainer = new(ELeave) CPerfMonDataPopupContainer; |
|
67 iDataPopupContainer->ConstructL(TRect(0,0,1,1)); |
|
68 |
|
69 ActivateEngineL(); |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------------------------- |
|
73 |
|
74 void CPerfMonModel::DeActivateModelL() |
|
75 { |
|
76 DeActivateEngineL(); |
|
77 |
|
78 if (iDataPopupContainer) |
|
79 { |
|
80 delete iDataPopupContainer; |
|
81 iDataPopupContainer = NULL; |
|
82 } |
|
83 } |
|
84 |
|
85 // -------------------------------------------------------------------------------------------- |
|
86 |
|
87 void CPerfMonModel::SetValuesContainer(CPerfMonValuesContainer* aContainer) |
|
88 { |
|
89 iValuesContainer = aContainer; |
|
90 iDrawState = EDrawStateValues; |
|
91 } |
|
92 |
|
93 // -------------------------------------------------------------------------------------------- |
|
94 |
|
95 void CPerfMonModel::SetGraphsContainer(CPerfMonGraphsContainer* aContainer) |
|
96 { |
|
97 iGraphsContainer = aContainer; |
|
98 iDrawState = EDrawStateGraphs; |
|
99 } |
|
100 |
|
101 // -------------------------------------------------------------------------------------------- |
|
102 |
|
103 void CPerfMonModel::SendDrawEventToContainersL() |
|
104 { |
|
105 if (iDrawState == EDrawStateValues && iValuesContainer) |
|
106 iValuesContainer->DrawUpdate(); |
|
107 else if (iDrawState == EDrawStateGraphs && iGraphsContainer) |
|
108 iGraphsContainer->DrawUpdate(); |
|
109 |
|
110 if (iDataPopupContainer) |
|
111 iDataPopupContainer->DrawUpdate(); |
|
112 } |
|
113 |
|
114 void CPerfMonModel::HandleSettingsChangeL() |
|
115 { |
|
116 // set visibility and location of the data popup |
|
117 iDataPopupContainer->UpdateVisibility(); |
|
118 iDataPopupContainer->SetPositionAndSize(); |
|
119 CPerfMonEngine::HandleSettingsChangeL(); |
|
120 } |
|
121 |
|
122 // -------------------------------------------------------------------------------------------- |
|
123 |
|
124 TInt CPerfMonModel::LaunchSettingsDialogL() |
|
125 { |
|
126 // launch the settings dialog |
|
127 TPerfMonSettings newSettings = iSettings; |
|
128 |
|
129 CPerfMonSettingsViewDlg* dlg = CPerfMonSettingsViewDlg::NewL(newSettings); |
|
130 TInt returnValue = dlg->ExecuteLD(R_PERFMON_SETTINGS_DIALOG); |
|
131 |
|
132 // always save settings since the settings dialog does not provide a possibility to cancel |
|
133 iSettings = newSettings; |
|
134 SaveSettingsL(); |
|
135 HandleSettingsChangeL(); |
|
136 |
|
137 // make sure that the title of the application is correct |
|
138 CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane(); |
|
139 CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
140 tp->SetTextL(KAppName); |
|
141 |
|
142 return returnValue; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 |
|
147 // End of File |