~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/contacts/filters/qcontactdetailfilter.cpp

  • Committer: chris.gagnon
  • Date: 2013-12-10 23:09:37 UTC
  • Revision ID: chris.gagnon@canonical.com-20131210230937-2akf1ft1edcttk87
first post

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtContacts module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#include "qcontactdetailfilter.h"
 
43
#include "qcontactdetailfilter_p.h"
 
44
#include "qcontactfilter_p.h"
 
45
#include "qcontactmanager.h"
 
46
 
 
47
QT_BEGIN_NAMESPACE_CONTACTS
 
48
 
 
49
/*!
 
50
  \class QContactDetailFilter
 
51
  \brief The QContactDetailFilter class provides a filter based around a detail value criterion
 
52
 
 
53
 
 
54
  \inmodule QtContacts
 
55
 
 
56
  \ingroup contacts-filters
 
57
 
 
58
  It may be used to select contacts which contain a detail of a particular type with a particular value
 
59
 */
 
60
 
 
61
Q_IMPLEMENT_CONTACTFILTER_PRIVATE(QContactDetailFilter)
 
62
 
 
63
/*!
 
64
 * \fn QContactDetailFilter::QContactDetailFilter(const QContactFilter& other)
 
65
 * Constructs a copy of \a other if possible, otherwise constructs a new detail filter
 
66
 */
 
67
 
 
68
/*!
 
69
 * Constructs a new detail filter
 
70
 */
 
71
QContactDetailFilter::QContactDetailFilter()
 
72
    : QContactFilter(new QContactDetailFilterPrivate)
 
73
{
 
74
}
 
75
 
 
76
/*!
 
77
 * Sets the type of the detail type of which details will be matched to \a type, and the name of the field in
 
78
 * details of that type which will contain the value criterion to \a field.
 
79
 * If \a type is QContactDetail::TypeUndefined, the detail filter will match no contacts.  If \a field
 
80
 * is not specified, or equal to -1, the detail filter acts like a "detail exists" filter; if any
 
81
 * detail of the specified type is present in a contact, that contact will match the filter, regardless
 
82
 * of what values might be stored in that detail.
 
83
 * \sa detailType()
 
84
 */
 
85
void QContactDetailFilter::setDetailType(QContactDetail::DetailType type, int field)
 
86
{
 
87
    Q_D(QContactDetailFilter);
 
88
    d->m_type = type;
 
89
    d->m_fieldId = field;
 
90
}
 
91
 
 
92
/*!
 
93
 * Sets the value criterion of the filter to \a value.
 
94
 * If the field criterion (set via setDetailType())
 
95
 * of the filter is not specified or equal to -1, this value will be ignored.
 
96
 * Note that certain backends might perform backend specific sanitization of
 
97
 * \a value for those detail types that are supported by them.
 
98
 * If the provided value cannot be sanitized, the filter is considered
 
99
 * invalid.
 
100
 * \sa value(), setDetailType()
 
101
 */
 
102
void QContactDetailFilter::setValue(const QVariant& value)
 
103
{
 
104
    Q_D(QContactDetailFilter);
 
105
    d->m_exactValue = value;
 
106
}
 
107
 
 
108
/*!
 
109
 * Sets the semantics of the value matching criterion to those defined in \a flags
 
110
 * \sa matchFlags()
 
111
 */
 
112
void QContactDetailFilter::setMatchFlags(QContactFilter::MatchFlags flags)
 
113
{
 
114
    Q_D(QContactDetailFilter);
 
115
    d->m_flags = flags;
 
116
}
 
117
 
 
118
/*!
 
119
 * Returns the semantics of the value matching criterion
 
120
 * \sa setMatchFlags()
 
121
 */
 
122
QContactFilter::MatchFlags QContactDetailFilter::matchFlags() const
 
123
{
 
124
    Q_D(const QContactDetailFilter);
 
125
    return d->m_flags;
 
126
}
 
127
 
 
128
/*!
 
129
 * Returns the type of the details which will be inspected for matching values
 
130
 * \sa setDetailType()
 
131
 */
 
132
QContactDetail::DetailType QContactDetailFilter::detailType() const
 
133
{
 
134
    Q_D(const QContactDetailFilter);
 
135
    return d->m_type;
 
136
}
 
137
 
 
138
/*!
 
139
 * Returns the detail field containing the value which will be matched against the value criterion
 
140
 * \sa setDetailType()
 
141
 */
 
142
int QContactDetailFilter::detailField() const
 
143
{
 
144
    Q_D(const QContactDetailFilter);
 
145
    return d->m_fieldId;
 
146
}
 
147
 
 
148
/*!
 
149
 * Returns the value criterion of the detail filter
 
150
 * \sa setValue()
 
151
 */
 
152
QVariant QContactDetailFilter::value() const
 
153
{
 
154
    Q_D(const QContactDetailFilter);
 
155
    return d->m_exactValue;
 
156
}
 
157
 
 
158
QT_END_NAMESPACE_CONTACTS