blob: 764380539a3061a9b2dea29668cd30be48835c0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include <cntdb.h>
EXPORT_C TContactIter::TContactIter(CContactDatabase &aDatabase) : iDatabase(aDatabase)
/** Constructs the object with a contact database.
@param aDatabase The contact database over which to iterate. */
{
Reset();
}
EXPORT_C void TContactIter::Reset()
/** Resets the iterator to its initialised state, so that a subsequent call to
NextL() goes to the first item. */
{
iCursorId=KNullContactId;
}
EXPORT_C TContactItemId TContactIter::FirstL()
/** Moves to the first contact item in the database.
@return The ID of the first contact item. */
{
if (iDatabase.SortedItemsL()->Count()==0)
iCursorId=KNullContactId;
else
GotoIndexL(0);
return iCursorId;
}
EXPORT_C TContactItemId TContactIter::NextL()
/** Moves to the next contact item in the database.
On a newly initialised TContactIter, this function moves to the first item.
@return The ID of the next contact item. Has a value of KNullContactId if
there are no more items. */
{
TInt pos=0;
if (iCursorId!=KNullContactId)
pos=iDatabase.ContactPosL(iCursorId)+1;
if (pos==iDatabase.SortedItemsL()->Count())
iCursorId=KNullContactId;
else
GotoIndexL(pos);
return iCursorId;
}
EXPORT_C TContactItemId TContactIter::PreviousL()
/** Moves to the previous contact item in the database.
Note: you must not call this function on a newly initialised database, otherwise
the function raises a panic.
@return The ID of the previous contact item. Has a value of KNullContactId
if there is no previous item. */
{
TInt pos=iDatabase.ContactPosL(iCursorId);
if (pos==0)
return KNullContactId;
GotoIndexL(--pos);
return iCursorId;
}
EXPORT_C TContactItemId TContactIter::LastL()
/** Moves to the last contact item in the database.
@return The ID of the last contact item. */
{
GotoIndexL(iDatabase.SortedItemsL()->Count()-1);
return iCursorId;
}
EXPORT_C void TContactIter::GotoL(TContactItemId aContactId)
/** Moves to the specified contact item.
@param aContactId A contact item ID. Must not have a value of KNullContactId,
or the function raises a panic. */
{
User::LeaveIfError(iDatabase.DoGotoL(aContactId));
iCursorId=aContactId;
}
void TContactIter::GotoIndexL(TInt aPos)
{
GotoL((*iDatabase.SortedItemsL())[aPos]);
}
|