|
1 /* |
|
2 * Copyright (c) 2008 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: Contact sorter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVIMPSTSTORAGECONTACTSORTER_H |
|
20 #define CVIMPSTSTORAGECONTACTSORTER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "mvimpststoragecontact.h" |
|
25 |
|
26 // CLASS DECLARATION |
|
27 |
|
28 /** |
|
29 * contact items array sorter |
|
30 * Changes used sorting algorithm based on setting item value. |
|
31 * It also listen to changes |
|
32 * in setting item value. |
|
33 * Offers also an API to compare two contacts. |
|
34 * |
|
35 */ |
|
36 NONSHARABLE_CLASS( CVIMPSTStorageContactSorter ) : public CBase |
|
37 { |
|
38 public: // Constructors and destructor |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. |
|
42 */ |
|
43 static CVIMPSTStorageContactSorter* NewL(); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CVIMPSTStorageContactSorter(); |
|
49 |
|
50 public: //New Methods |
|
51 |
|
52 /** |
|
53 * Sorts given array. |
|
54 * @param aList Reference to list which is sorted. |
|
55 */ |
|
56 void Sort( RPointerArray< MVIMPSTStorageContact >& aList ); |
|
57 |
|
58 /** |
|
59 * Returns which given contact is first in list. |
|
60 * @param aFirst Reference to first contact. |
|
61 * @param aSecond Reference to second contact. |
|
62 * @return Integer, -1 if aFirst is greater, 0 if equal, |
|
63 * 1 if aSecond is greater. |
|
64 */ |
|
65 TInt Compare( const MVIMPSTStorageContact& aFirst, |
|
66 const MVIMPSTStorageContact& aSecond ) const; |
|
67 |
|
68 /** |
|
69 * Set the Sort Algorithm |
|
70 * @param aAlgorithm - ECompareAlphabetically/ECompareByPresence |
|
71 */ |
|
72 void SetSortAlgorithm( MVIMPSTStorageContact::TSortAlgorithm aAlgorithm ); |
|
73 |
|
74 /** |
|
75 * Gets the algorithm chosen |
|
76 * returns the algorithm used for sorting |
|
77 */ |
|
78 TLinearOrder< MVIMPSTStorageContact >& InsertOrder(); |
|
79 |
|
80 private: |
|
81 /** |
|
82 * C++ default constructor. |
|
83 */ |
|
84 CVIMPSTStorageContactSorter(); |
|
85 |
|
86 private: // Data |
|
87 |
|
88 // This contains a pointer to a function used in sorting and comparing. |
|
89 TLinearOrder< MVIMPSTStorageContact > iAlgorithm; |
|
90 }; |
|
91 |
|
92 #endif // CVIMPSTSTORAGECONTACTSORTER_H |
|
93 |
|
94 //End Of File |
|
95 |