~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to plugins/contacts/symbian/plugin/src/transform/cnttransformfavorite.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
 
5
** Contact: Nokia Corporation (qt-info@nokia.com)
 
6
**
 
7
** This file is part of the Qt Mobility Components.
 
8
**
 
9
** $QT_BEGIN_LICENSE:LGPL$
 
10
** Commercial Usage
 
11
** Licensees holding valid Qt Commercial licenses may use this file in 
 
12
** accordance with the Qt Commercial License Agreement provided with
 
13
** the Software or, alternatively, in accordance with the terms
 
14
** contained in a written agreement between you and Nokia.
 
15
**
 
16
** GNU Lesser General Public License Usage
 
17
** Alternatively, this file may be used under the terms of the GNU Lesser
 
18
** General Public License version 2.1 as published by the Free Software
 
19
** Foundation and appearing in the file LICENSE.LGPL included in the
 
20
** packaging of this file.  Please review the following information to
 
21
** ensure the GNU Lesser General Public License version 2.1 requirements
 
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
23
**
 
24
** In addition, as a special exception, Nokia gives you certain additional
 
25
** rights.  These rights are described in the Nokia Qt LGPL Exception
 
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
27
**
 
28
** GNU General Public License Usage
 
29
** Alternatively, this file may be used under the terms of the GNU
 
30
** General Public License version 3.0 as published by the Free Software
 
31
** Foundation and appearing in the file LICENSE.GPL included in the
 
32
** packaging of this file.  Please review the following information to
 
33
** ensure the GNU General Public License version 3.0 requirements will be
 
34
** met: http://www.gnu.org/copyleft/gpl.html.
 
35
**
 
36
** If you are unsure which license is appropriate for your use, please
 
37
** contact the sales department at qt-sales@nokia.com.
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#ifdef SYMBIAN_BACKEND_USE_SQLITE
 
43
 
 
44
#include "cnttransformfavorite.h"
 
45
 
 
46
QList<CContactItemField *> CntTransformFavorite::transformDetailL(const QContactDetail &detail)
 
47
{
 
48
    if(detail.definitionName() != QContactFavorite::DefinitionName) {
 
49
       User::Leave(KErrArgument);
 
50
    }
 
51
 
 
52
    QList<CContactItemField *> fieldList;
 
53
 
 
54
        //cast to favorite
 
55
        const QContactFavorite &favorite(static_cast<const QContactFavorite&>(detail));
 
56
        if (!favorite.isFavorite()) {
 
57
            //do not add favorite field
 
58
            return fieldList;
 
59
        }
 
60
        
 
61
    CContactItemField* itemField = CContactItemField::NewLC(KStorageTypeContactItemId, KUidContactFieldFavourite);
 
62
    itemField->AgentStorage()->SetAgentId(favorite.index());
 
63
    itemField->SetMapping(KUidContactFieldVCardMapFavourite);
 
64
    fieldList.append(itemField);
 
65
    CleanupStack::Pop(itemField);
 
66
 
 
67
        return fieldList;
 
68
}
 
69
 
 
70
QContactDetail *CntTransformFavorite::transformItemField(const CContactItemField& field, const QContact &contact)
 
71
{
 
72
        Q_UNUSED(contact);
 
73
 
 
74
        CContactAgentField* storage = field.AgentStorage();
 
75
        QContactFavorite *favoriteDetail = new QContactFavorite();
 
76
        favoriteDetail->setFavorite(true);
 
77
        favoriteDetail->setIndex(storage->Value());
 
78
        return favoriteDetail;
 
79
}
 
80
 
 
81
bool CntTransformFavorite::supportsDetail(QString detailName) const
 
82
{
 
83
    bool ret = false;
 
84
    if (detailName == QContactFavorite::DefinitionName) {
 
85
        ret = true;
 
86
    }
 
87
    return ret;
 
88
}
 
89
 
 
90
QList<TUid> CntTransformFavorite::supportedFields() const
 
91
{
 
92
    return QList<TUid>() << KUidContactFieldFavourite;
 
93
}
 
94
 
 
95
QList<TUid> CntTransformFavorite::supportedSortingFieldTypes(QString detailFieldName) const
 
96
{
 
97
    QList<TUid> uids;
 
98
    if (detailFieldName == QContactFavorite::FieldFavorite) {
 
99
        uids << KUidContactFieldFavourite;
 
100
    }
 
101
    return uids;
 
102
}
 
103
 
 
104
/*!
 
105
 * Checks whether the subtype is supported
 
106
 *
 
107
 * \a subType The subtype to be checked
 
108
 * \return True if this subtype is supported
 
109
 */
 
110
bool CntTransformFavorite::supportsSubType(const QString& subType) const
 
111
{
 
112
    Q_UNUSED(subType);
 
113
    return false;
 
114
}
 
115
 
 
116
/*!
 
117
 * Returns the filed id corresponding to a field
 
118
 *
 
119
 * \a fieldName The name of the supported field
 
120
 * \return fieldId for the fieldName, 0  if not supported
 
121
 */
 
122
quint32 CntTransformFavorite::getIdForField(const QString& fieldName) const
 
123
{
 
124
   if (QContactFavorite::FieldFavorite == fieldName) {
 
125
       return KUidContactFieldFavourite.iUid;
 
126
   }
 
127
   else {
 
128
       return 0;
 
129
   }
 
130
}
 
131
 
 
132
/*!
 
133
 * Modifies the detail definitions. The default detail definitions are
 
134
 * queried from QContactManagerEngine::schemaDefinitions and then modified
 
135
 * with this function in the transform leaf classes.
 
136
 *
 
137
 * \a definitions The detail definitions to modify.
 
138
 * \a contactType The contact type the definitions apply for.
 
139
 */
 
140
void CntTransformFavorite::detailDefinitions(QMap<QString, QContactDetailDefinition> &definitions, const QString& contactType) const
 
141
{
 
142
    Q_UNUSED(contactType);
 
143
 
 
144
    if (definitions.contains(QContactFavorite::DefinitionName)) {
 
145
        QContactDetailDefinition d = definitions.value(QContactFavorite::DefinitionName);
 
146
        QMap<QString, QContactDetailFieldDefinition> fields = d.fields();
 
147
 
 
148
        // Context not supported in symbian back-end, remove
 
149
        fields.remove(QContactFavorite::FieldContext);
 
150
 
 
151
        d.setFields(fields);
 
152
 
 
153
        // Replace original definitions
 
154
        definitions.insert(d.name(), d);
 
155
    }
 
156
}
 
157
 
 
158
#endif