1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtQml module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
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 The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qdeclarativecontactsortorder_p.h"
35
36QTCONTACTS_USE_NAMESPACE
37
38QT_BEGIN_NAMESPACE
39
40/*!
41 \qmltype SortOrder
42 \instantiates QDeclarativeContactSortOrder
43 \brief The SortOrder element defines how a list of contacts should be ordered according to some criteria.
44
45 \ingroup qml-contacts-main
46 \inqmlmodule QtContacts
47
48 This element is part of the \b{QtContacts} module.
49
50 \sa QContactSortOrder
51 \sa ContactModel
52 */
53
54QDeclarativeContactSortOrder::QDeclarativeContactSortOrder(QObject* parent)
55 :QObject(parent)
56{
57}
58/*!
59 \qmlproperty enumeration SortOrder::detail
60
61 This property holds the detail type of the details which will be inspected to perform sorting.
62
63 \sa ContactDetail::type
64 */
65void QDeclarativeContactSortOrder::setDetail(const int detailType)
66{
67 if (detailType != static_cast<QDeclarativeContactDetail::DetailType>(m_sortOrder.detailType())) {
68 m_sortOrder.setDetailType(type: static_cast<QContactDetail::DetailType>(detailType), field: m_sortOrder.detailField());
69 emit sortOrderChanged();
70 }
71}
72
73int QDeclarativeContactSortOrder::detail() const
74{
75 return static_cast<QDeclarativeContactDetail::DetailType>(m_sortOrder.detailType());
76}
77
78/*!
79 \qmlproperty int SortOrder::field
80
81 This property holds the detail field type of the details which will be inspected to perform sorting.
82 For each detail elements, there are predefined field types.
83 */
84void QDeclarativeContactSortOrder::setField(const int fieldType)
85{
86 if (fieldType != m_sortOrder.detailField()) {
87 m_sortOrder.setDetailType(type: m_sortOrder.detailType(), field: fieldType);
88 emit sortOrderChanged();
89 }
90}
91
92int QDeclarativeContactSortOrder::field() const
93{
94 return m_sortOrder.detailField();
95}
96
97/*!
98 \qmlproperty enumeration SortOrder::blankPolicy
99 This property enumerates the ways in which the sort order interprets blanks when sorting contacts.
100 \list
101 \li SortOrder.BlanksFirst - Considers blank values to evaluate to less than all other values in comparisons.
102 \li SortOrder.BlanksLast - Considers blank values to evaluate to greater than all other values in comparisons.
103 \endlist
104 */
105QDeclarativeContactSortOrder::BlankPolicy QDeclarativeContactSortOrder::blankPolicy() const
106{
107 return static_cast<QDeclarativeContactSortOrder::BlankPolicy>(m_sortOrder.blankPolicy());
108}
109
110void QDeclarativeContactSortOrder::setBlankPolicy(QDeclarativeContactSortOrder::BlankPolicy blankPolicy)
111{
112 if (blankPolicy != static_cast<QDeclarativeContactSortOrder::BlankPolicy>(m_sortOrder.blankPolicy())) {
113 m_sortOrder.setBlankPolicy(static_cast<QContactSortOrder::BlankPolicy>(blankPolicy));
114 emit sortOrderChanged();
115 }
116}
117/*!
118 \qmlproperty enumeration SortOrder::direction
119
120 This property holds the direction of the sort order, the value can be one of:
121 \list
122 \li Qt.AscendingOrder - (default)
123 \li Qt.DescendingOrder
124 \endlist
125 */
126Qt::SortOrder QDeclarativeContactSortOrder::direction() const
127{
128 return m_sortOrder.direction();
129}
130void QDeclarativeContactSortOrder::setDirection(Qt::SortOrder direction)
131{
132 if (direction != m_sortOrder.direction()) {
133 m_sortOrder.setDirection(direction);
134 emit sortOrderChanged();
135 }
136}
137/*!
138 \qmlproperty enumeration SortOrder::caseSensitivity
139
140 This property holds the case sensitivity of the sort order, the value can be one of:
141 \list
142 \li Qt.CaseInsensitive
143 \li Qt.CaseSensitive - (default)
144 \endlist
145 */
146Qt::CaseSensitivity QDeclarativeContactSortOrder::caseSensitivity() const
147{
148 return m_sortOrder.caseSensitivity();
149}
150void QDeclarativeContactSortOrder::setCaseSensitivity(Qt::CaseSensitivity sensitivity)
151{
152 if (sensitivity != m_sortOrder.caseSensitivity()) {
153 m_sortOrder.setCaseSensitivity(sensitivity);
154 emit sortOrderChanged();
155 }
156}
157
158QContactSortOrder QDeclarativeContactSortOrder::sortOrder()
159{
160 return m_sortOrder;
161}
162
163void QDeclarativeContactSortOrder::setSortOrder(const QContactSortOrder& sortOrder)
164{
165 m_sortOrder = sortOrder;
166 emit sortOrderChanged();
167}
168
169#include "moc_qdeclarativecontactsortorder_p.cpp"
170
171QT_END_NAMESPACE
172

source code of qtpim/src/imports/contacts/qdeclarativecontactsortorder.cpp