|
1 /* |
|
2 * Copyright (c) 2002 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: Provides Location request view listbox model. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <locpsysettingsuiview.rsg> |
|
22 #include <avkon.rsg> |
|
23 #include <eikenv.h> |
|
24 |
|
25 #include "locpsylbmodel.h" |
|
26 #include "locpsyappdebug.h" |
|
27 #include "locpsysettingsuiconsts.h" |
|
28 #include "locpsysettings.h" |
|
29 #include "locpsyinfo.h" |
|
30 |
|
31 enum |
|
32 { |
|
33 EPsyDisabledIconIndex = '1', |
|
34 EPsyEnabledIconIndex = '0' |
|
35 }; |
|
36 |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CLocPsyLBModel::CLocPsyLBModel |
|
42 // Constructor |
|
43 // --------------------------------------------------------- |
|
44 CLocPsyLBModel::CLocPsyLBModel( MLocPsySettings* aPsySettingsModel ) |
|
45 :iPsySettingsModel( aPsySettingsModel ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CLocPsyLBModel::~CLocPsyLBModel |
|
51 // Destructor |
|
52 // --------------------------------------------------------- |
|
53 CLocPsyLBModel::~CLocPsyLBModel() |
|
54 { |
|
55 delete iBuffer; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CLocPsyLBModel* CLocPsyLBModel::NewL |
|
60 // Static two phase Constructor |
|
61 // --------------------------------------------------------- |
|
62 CLocPsyLBModel* CLocPsyLBModel::NewL( MLocPsySettings* aPsySettingsModel ) |
|
63 { |
|
64 CLocPsyLBModel* lbmodel = CLocPsyLBModel::NewLC( aPsySettingsModel ); |
|
65 CleanupStack::Pop( lbmodel ); |
|
66 return lbmodel; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CLocPsyLBModel* CLocPsyLBModel::NewLC |
|
71 // Static two phase Constructor |
|
72 // --------------------------------------------------------- |
|
73 CLocPsyLBModel* CLocPsyLBModel::NewLC( MLocPsySettings* aPsySettingsModel ) |
|
74 { |
|
75 CLocPsyLBModel* lbmodel = new (ELeave) CLocPsyLBModel( aPsySettingsModel ); |
|
76 CleanupStack::PushL( lbmodel ); |
|
77 lbmodel->ConstructL(); |
|
78 return lbmodel; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CLocPsyLBModel::ConstructL |
|
83 // Symbian two phased constructor |
|
84 // --------------------------------------------------------- |
|
85 void CLocPsyLBModel::ConstructL() |
|
86 { |
|
87 iBuffer = HBufC::NewL( KLocPsyMaxLen + KTabLength + KTabLength ); // Icon Id + Tab Key |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // TInt CLocPsyLBModel::MdcaCount |
|
92 // --------------------------------------------------------- |
|
93 TInt CLocPsyLBModel::MdcaCount() const |
|
94 { |
|
95 LOCAPPDEBUG1("CLocSettingsLBModel::MdcaCount number of PSYs=%d", |
|
96 iPsySettingsModel->PSYCount()); |
|
97 return iPsySettingsModel->PSYCount(); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // TPtrC16 CLocPsyLBModel::MdcaPoint |
|
102 // --------------------------------------------------------- |
|
103 TPtrC16 CLocPsyLBModel::MdcaPoint( TInt aIndex ) const |
|
104 { |
|
105 TPtr ptr( iBuffer->Des() ); |
|
106 ptr.Zero(); |
|
107 if( iPsySettingsModel->IsPsyEnabled( aIndex ) ) |
|
108 { |
|
109 ptr.Append( EPsyEnabledIconIndex ); |
|
110 } |
|
111 else |
|
112 { |
|
113 ptr.Append( EPsyDisabledIconIndex ); |
|
114 } |
|
115 |
|
116 ptr.Append( EKeyTab ); |
|
117 // Add the icon index here |
|
118 if ( iPsySettingsModel->PSYCount() > 0 ) |
|
119 { |
|
120 // volatile --> stack instead of register to be leave-safe |
|
121 CLocPsyInfo* psyInfo = NULL; |
|
122 TRAPD(err, psyInfo = iPsySettingsModel->GetPsyL( aIndex )); |
|
123 if ( err != KErrNone) |
|
124 { |
|
125 LOCAPPDEBUG2("CLocSettingsLBModel::MdcaPoint index=%d err=%d", |
|
126 aIndex, err ); |
|
127 ptr.Zero(); |
|
128 |
|
129 CEikonEnv::Static()->NotifyIdleErrorWhileRedrawing(err); |
|
130 |
|
131 return NULL; |
|
132 } |
|
133 else |
|
134 { |
|
135 ptr.Append( psyInfo->PsyName() ); |
|
136 } |
|
137 } |
|
138 return *iBuffer; |
|
139 } |
|
140 |
|
141 // End of File |