~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/imports/contacts/qdeclarativecontactsortorder.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 QtQml 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
#include "qdeclarativecontactsortorder_p.h"
 
42
#include <QDebug>
 
43
 
 
44
QT_BEGIN_NAMESPACE_CONTACTS
 
45
 
 
46
/*!
 
47
   \qmltype SortOrder
 
48
    \instantiates QDeclarativeContactSortOrder
 
49
   \brief The SortOrder element defines how a list of contacts should be ordered according to some criteria.
 
50
 
 
51
   \ingroup qml-contacts-main
 
52
   \inqmlmodule QtContacts 5.0
 
53
 
 
54
   This element is part of the \b{QtContacts} module.
 
55
 
 
56
   \sa QContactSortOrder
 
57
   \sa ContactModel
 
58
 */
 
59
 
 
60
QDeclarativeContactSortOrder::QDeclarativeContactSortOrder(QObject* parent)
 
61
    :QObject(parent)
 
62
{
 
63
}
 
64
/*!
 
65
  \qmlproperty enumeration SortOrder::detail
 
66
 
 
67
  This property holds the detail type of the details which will be inspected to perform sorting.
 
68
 
 
69
  \sa ContactDetail::type
 
70
  */
 
71
void QDeclarativeContactSortOrder::setDetail(const int detailType)
 
72
{
 
73
    if (m_detail != detailType) {
 
74
        m_detail = detailType;
 
75
        emit sortOrderChanged();
 
76
    }
 
77
 
 
78
}
 
79
 
 
80
int QDeclarativeContactSortOrder::detail() const
 
81
{
 
82
    return m_detail;
 
83
}
 
84
/*!
 
85
  \qmlproperty int SortOrder::field
 
86
 
 
87
  This property holds the detail field type of the details which will be inspected to perform sorting.
 
88
  For each detail elements, there are predefined field types.
 
89
  */
 
90
void QDeclarativeContactSortOrder::setField(const int fieldType)
 
91
{
 
92
    if (m_field != fieldType) {
 
93
        m_field = fieldType;
 
94
        emit sortOrderChanged();
 
95
    }
 
96
}
 
97
 
 
98
int QDeclarativeContactSortOrder::field() const
 
99
{
 
100
    return m_field;
 
101
}
 
102
 
 
103
/*!
 
104
  \qmlproperty enumeration SortOrder::blankPolicy
 
105
  This property enumerates the ways in which the sort order interprets blanks when sorting contacts.
 
106
  \list
 
107
  \li SortOrder.BlanksFirst - Considers blank values to evaluate to less than all other values in comparisons.
 
108
  \li SortOrder.BlanksLast - Considers blank values to evaluate to greater than all other values in comparisons.
 
109
  \endlist
 
110
 */
 
111
QDeclarativeContactSortOrder::BlankPolicy QDeclarativeContactSortOrder::blankPolicy() const
 
112
{
 
113
    return static_cast<QDeclarativeContactSortOrder::BlankPolicy>(m_sortOrder.blankPolicy());
 
114
}
 
115
 
 
116
void QDeclarativeContactSortOrder::setBlankPolicy(QDeclarativeContactSortOrder::BlankPolicy blankPolicy)
 
117
{
 
118
    if (blankPolicy != static_cast<QDeclarativeContactSortOrder::BlankPolicy>(m_sortOrder.blankPolicy())) {
 
119
        m_sortOrder.setBlankPolicy(static_cast<QContactSortOrder::BlankPolicy>(blankPolicy));
 
120
        emit sortOrderChanged();
 
121
    }
 
122
}
 
123
/*!
 
124
  \qmlproperty enumeration SortOrder::direction
 
125
 
 
126
  This property holds the direction of the sort order, the value can be one of:
 
127
  \list
 
128
  \li Qt.AscendingOrder - (default)
 
129
  \li Qt.DescendingOrder
 
130
  \endlist
 
131
  */
 
132
Qt::SortOrder QDeclarativeContactSortOrder::direction() const
 
133
{
 
134
    return m_sortOrder.direction();
 
135
}
 
136
void QDeclarativeContactSortOrder::setDirection(Qt::SortOrder direction)
 
137
{
 
138
    if (direction != m_sortOrder.direction()) {
 
139
        m_sortOrder.setDirection(direction);
 
140
        emit sortOrderChanged();
 
141
    }
 
142
}
 
143
/*!
 
144
  \qmlproperty enumeration SortOrder::caseSensitivity
 
145
 
 
146
  This property holds the case sensitivity of the sort order, the value can be one of:
 
147
  \list
 
148
  \li Qt.CaseInsensitive
 
149
  \li Qt.CaseSensitive - (default)
 
150
  \endlist
 
151
  */
 
152
Qt::CaseSensitivity QDeclarativeContactSortOrder::caseSensitivity() const
 
153
{
 
154
    return m_sortOrder.caseSensitivity();
 
155
}
 
156
void QDeclarativeContactSortOrder::setCaseSensitivity(Qt::CaseSensitivity sensitivity)
 
157
{
 
158
    if (sensitivity != m_sortOrder.caseSensitivity()) {
 
159
        m_sortOrder.setCaseSensitivity(sensitivity);
 
160
        emit sortOrderChanged();
 
161
    }
 
162
}
 
163
 
 
164
void QDeclarativeContactSortOrder::componentComplete()
 
165
{
 
166
    setSortOrder(sortOrder());
 
167
}
 
168
 
 
169
QContactSortOrder QDeclarativeContactSortOrder::sortOrder()
 
170
{
 
171
    m_sortOrder.setDetailType(static_cast<QContactDetail::DetailType>(m_detail), m_field);
 
172
    return m_sortOrder;
 
173
}
 
174
 
 
175
void QDeclarativeContactSortOrder::setSortOrder(const QContactSortOrder& sortOrder)
 
176
{
 
177
    m_sortOrder = sortOrder;
 
178
    m_field = sortOrder.detailField();
 
179
    m_detail = sortOrder.detailType();
 
180
    emit sortOrderChanged();
 
181
}
 
182
 
 
183
#include "moc_qdeclarativecontactsortorder_p.cpp"
 
184
 
 
185
QT_END_NAMESPACE_CONTACTS