81
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Private data for CntListModel.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <xqsettingsmanager.h>
|
|
19 |
#include <xqsettingskey.h>
|
|
20 |
#include <qtcontacts.h>
|
|
21 |
#include <cntlistmodel_p.h>
|
|
22 |
#include <cntcache.h>
|
|
23 |
#include <cntdisplaytextformatter.h>
|
|
24 |
#include <cntdebug.h>
|
|
25 |
|
|
26 |
/*!
|
|
27 |
\class CntListModel
|
|
28 |
\brief Private data for CntListModel.
|
|
29 |
*/
|
|
30 |
|
|
31 |
/*!
|
|
32 |
Initializes all data.
|
|
33 |
*/
|
|
34 |
CntListModelData::CntListModelData(QContactManager *manager, const QContactFilter &filter, bool showMyCard)
|
|
35 |
: mContactManager(manager),
|
|
36 |
mCache(CntCache::createSession(this, manager)),
|
|
37 |
mGroupId(0),
|
|
38 |
mCurrentContact(NULL),
|
|
39 |
mCurrentRow(-1),
|
|
40 |
mShowMyCard(showMyCard),
|
|
41 |
mMyCardId(manager->selfContactId()),
|
|
42 |
mSettings(NULL),
|
|
43 |
mNameListRowSettingkey(NULL),
|
|
44 |
mCurrentRowSetting(0),
|
|
45 |
mFormat(new CntDummyDisplayTextFormatter),
|
|
46 |
mDefaultIcon(HbIcon("qtg_large_avatar")),
|
|
47 |
mDefaultMyCardIcon(HbIcon("qtg_large_avatar_mycard"))
|
|
48 |
{
|
|
49 |
CNT_ENTRY
|
|
50 |
|
|
51 |
setFilter(filter);
|
|
52 |
|
|
53 |
CNT_EXIT
|
|
54 |
}
|
|
55 |
|
|
56 |
/*!
|
|
57 |
Cleans up all data.
|
|
58 |
*/
|
|
59 |
CntListModelData::~CntListModelData()
|
|
60 |
{
|
|
61 |
CNT_ENTRY
|
|
62 |
|
|
63 |
mCache->closeSession(this);
|
|
64 |
|
|
65 |
delete mSettings;
|
|
66 |
delete mNameListRowSettingkey;
|
|
67 |
delete mFormat;
|
|
68 |
delete mCurrentContact;
|
|
69 |
|
|
70 |
CNT_EXIT
|
|
71 |
}
|
|
72 |
|
|
73 |
/*!
|
|
74 |
Sets the filter for selecting contacts in the list.
|
|
75 |
*/
|
|
76 |
void CntListModelData::setFilter(const QContactFilter& contactFilter)
|
|
77 |
{
|
|
78 |
CNT_ENTRY_ARGS(contactFilter.type())
|
|
79 |
|
|
80 |
mFilter = contactFilter;
|
|
81 |
mCurrentRow = -1;
|
|
82 |
if (contactFilter.type() == QContactFilter::RelationshipFilter) {
|
|
83 |
QContactRelationshipFilter* relationshipFilter = static_cast<QContactRelationshipFilter*>(&mFilter);
|
|
84 |
if (relationshipFilter->relationshipType() == QContactRelationship::HasMember &&
|
|
85 |
relationshipFilter->relatedContactRole() == QContactRelationship::First) {
|
|
86 |
mGroupId = relationshipFilter->relatedContactId().localId();
|
|
87 |
}
|
|
88 |
} else {
|
|
89 |
mGroupId = 0;
|
|
90 |
|
|
91 |
// set proper text formatter for the display name.
|
|
92 |
if (contactFilter.type() == QContactFilter::ContactDetailFilter) {
|
|
93 |
delete mFormat;
|
|
94 |
mFormat = NULL;
|
|
95 |
|
|
96 |
QContactDetailFilter *detailFilter = static_cast<QContactDetailFilter*>(&mFilter);
|
|
97 |
QStringList filter = detailFilter->value().toStringList();
|
|
98 |
|
|
99 |
if (detailFilter->detailDefinitionName() == QContactDisplayLabel::DefinitionName
|
|
100 |
&& detailFilter->matchFlags() & QContactFilter::MatchStartsWith
|
|
101 |
&& !filter.isEmpty()) {
|
|
102 |
mFormat = new CntHTMLDisplayTextFormatter();
|
|
103 |
} else {
|
|
104 |
mFormat = new CntDummyDisplayTextFormatter();
|
|
105 |
}
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
CNT_EXIT_ARGS(mGroupId)
|
|
110 |
}
|