|
1 /* |
|
2 * Copyright (c) 2002-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 |
|
20 // INCLUDE FILES |
|
21 #include "CCLFSortingStyleimpl.h" |
|
22 #include <barsread.h> |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KCLFFieldIdArrayGranularity( 4 ); |
|
26 const TInt KCLFResourceVersion( 1 ); |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CCLFSortingStyleImpl::CCLFSortingStyleImpl |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CCLFSortingStyleImpl::CCLFSortingStyleImpl() |
|
35 : iFieldIDArray( KCLFFieldIdArrayGranularity ), |
|
36 iDataType( ECLFItemDataTypeNull ), |
|
37 iOrdering( ECLFOrderingAscending ), |
|
38 iUndefinedItemPosition( ECLFSortingStyleUndefinedEnd ) |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CCLFSortingStyleImpl::ConstructL |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CCLFSortingStyleImpl::ConstructL( TResourceReader& aResource ) |
|
47 { |
|
48 const TInt version( aResource.ReadInt16() ); |
|
49 if ( version != KCLFResourceVersion ) |
|
50 { |
|
51 User::Leave( KErrNotSupported ); |
|
52 } |
|
53 iOrdering = TCLFSortingStyleOrdering( aResource.ReadInt32() ); |
|
54 iDataType = TCLFItemDataType( aResource.ReadInt32() ); |
|
55 iUndefinedItemPosition = TCLFUndefinedItemPosition( aResource.ReadInt8() ); |
|
56 const TInt count( aResource.ReadInt16() ); |
|
57 for ( TInt i = 0 ; i < count ; ++i ) |
|
58 { |
|
59 iFieldIDArray.AppendL( aResource.ReadInt32() ); |
|
60 } |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CCLFSortingStyleImpl::NewLC |
|
65 // Two-phased constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CCLFSortingStyleImpl* CCLFSortingStyleImpl::NewLC() |
|
69 { |
|
70 CCLFSortingStyleImpl* self = new( ELeave ) CCLFSortingStyleImpl; |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CCLFSortingStyleImpl::NewLC |
|
79 // Two-phased constructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CCLFSortingStyleImpl* CCLFSortingStyleImpl::NewLC( TResourceReader& aResource ) |
|
83 { |
|
84 CCLFSortingStyleImpl* self = new( ELeave ) CCLFSortingStyleImpl; |
|
85 |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL( aResource ); |
|
88 |
|
89 return self; |
|
90 } |
|
91 |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCLFSortingStyleImpl::~CCLFSortingStyleImpl |
|
95 // Destructor |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CCLFSortingStyleImpl::~CCLFSortingStyleImpl() |
|
99 { |
|
100 iFieldIDArray.Close(); |
|
101 } |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CCLFSortingStyleImpl::ResetL |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CCLFSortingStyleImpl::ResetL() |
|
109 { |
|
110 iFieldIDArray.Reset(); |
|
111 iOrdering = ECLFOrderingAscending; |
|
112 iUndefinedItemPosition = ECLFSortingStyleUndefinedEnd; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CCLFSortingStyleImpl::AddFieldL |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CCLFSortingStyleImpl::AddFieldL( TCLFFieldId aFieldId ) |
|
120 { |
|
121 iFieldIDArray.AppendL( aFieldId ); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CCLFSortingStyleImpl::GetFieldsL |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CCLFSortingStyleImpl::GetFieldsL( RArray<TCLFFieldId>& aArray ) const |
|
129 { |
|
130 const TInt count( iFieldIDArray.Count() ); |
|
131 for( TInt i = 0 ; i < count ; ++i ) |
|
132 { |
|
133 aArray.AppendL( iFieldIDArray[i] ); |
|
134 } |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CCLFSortingStyleImpl::SetOrdering |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CCLFSortingStyleImpl::SetOrdering( TCLFSortingStyleOrdering aOrdering ) |
|
142 { |
|
143 iOrdering = aOrdering; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CCLFSortingStyleImpl::Ordering |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 TCLFSortingStyleOrdering CCLFSortingStyleImpl::Ordering() const |
|
151 { |
|
152 return iOrdering; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CCLFSortingStyleImpl::SetSortingDataType |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CCLFSortingStyleImpl::SetSortingDataType( TCLFItemDataType aDataType ) |
|
160 { |
|
161 iDataType = aDataType; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CCLFSortingStyleImpl::SortingDataType |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 TCLFItemDataType CCLFSortingStyleImpl::SortingDataType() const |
|
169 { |
|
170 return iDataType; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CCLFSortingStyleImpl::SetUndefinedItemPosition |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CCLFSortingStyleImpl::SetUndefinedItemPosition( |
|
178 TCLFUndefinedItemPosition aUndefinedItemPosition ) |
|
179 { |
|
180 iUndefinedItemPosition = aUndefinedItemPosition; |
|
181 } |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCLFSortingStyleImpl::UndefinedItemPosition |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TCLFUndefinedItemPosition CCLFSortingStyleImpl::UndefinedItemPosition() const |
|
187 { |
|
188 return iUndefinedItemPosition; |
|
189 } |
|
190 |
|
191 // End of File |