|
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: Declaration of the TApListItemKey class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "ApListItemList.h" |
|
22 #include "ApListItem.h" |
|
23 #include "ApListItemKey.h" |
|
24 |
|
25 // CONSTANTS |
|
26 |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 // --------------------------------------------------------- |
|
30 // TApListItemNameKey::SetPtr() |
|
31 // --------------------------------------------------------- |
|
32 // |
|
33 void TApListItemNameKey::SetPtr( CApListItemList* aPtr ) |
|
34 { |
|
35 iList = aPtr; |
|
36 } |
|
37 |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // TApListItemNameKey::Compare() |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 TInt TApListItemNameKey::Compare( TInt aLeft,TInt aRight ) const |
|
44 { |
|
45 TInt retval = |
|
46 iList->At( aLeft )->Name().CompareC( iList->At( aRight )->Name() ); |
|
47 if ( !iAscending ) |
|
48 { |
|
49 retval *= -1; |
|
50 } |
|
51 return retval; |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // TApListItemNameKey::At() |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 TAny* TApListItemNameKey::At( TInt anIndex ) const |
|
60 { |
|
61 TAny* ptr = MUTABLE_CAST( TDesC16*, &(iList->At( anIndex )->Name())); |
|
62 return ptr; |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // TApListItemNameKey::TApListItemNameKey() |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 TApListItemNameKey::TApListItemNameKey( TBool aAscending ) |
|
72 :TKeyArrayFix( 0, ECmpCollated ) |
|
73 { |
|
74 iList = NULL; |
|
75 iAscending = aAscending; |
|
76 } |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // TApListItemUidKey |
|
85 // --------------------------------------------------------- |
|
86 |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // TApListItemUidKey::SetPtr |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void TApListItemUidKey::SetPtr( CApListItemList* aPtr ) |
|
93 { |
|
94 iList = aPtr; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // TApListItemUidKey::Compare |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 TInt TApListItemUidKey::Compare( TInt aLeft,TInt aRight ) const |
|
103 { |
|
104 TInt retval( 1 ); |
|
105 if ( iList->At( aLeft )->Uid() < iList->At( aRight )->Uid() ) |
|
106 { |
|
107 retval = -1; |
|
108 } |
|
109 else |
|
110 { |
|
111 if ( iList->At( aLeft )->Uid() == iList->At( aRight )->Uid() ) |
|
112 { |
|
113 retval = 0; |
|
114 } |
|
115 } |
|
116 if ( !iAscending ) |
|
117 { |
|
118 retval *= -1; |
|
119 } |
|
120 return retval; |
|
121 } |
|
122 |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // TApListItemUidKey::At |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 TAny* TApListItemUidKey::At( TInt anIndex ) const |
|
129 { |
|
130 TAny* ptr = MUTABLE_CAST( TUint32*, &(iList->At( anIndex )->iUid) ); |
|
131 return ptr; |
|
132 } |
|
133 |
|
134 |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // TApListItemUidKey::TApListItemUidKey |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 TApListItemUidKey::TApListItemUidKey( TBool aAscending ) |
|
141 :TKeyArrayFix( 0, ECmpCollated ) |
|
142 { |
|
143 iList = NULL; |
|
144 iAscending = aAscending; |
|
145 } |
|
146 |
|
147 |
|
148 // End of File |