~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/imports/organizer/qdeclarativeorganizeritemsortorder.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 QtOrganizer 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 "qdeclarativeorganizeritemsortorder_p.h"
 
43
 
 
44
QT_BEGIN_NAMESPACE_ORGANIZER
 
45
 
 
46
/*!
 
47
    \qmltype SortOrder
 
48
    \instantiates QDeclarativeOrganizerItemSortOrder
 
49
    \brief The SortOrder element defines how a list of organizer item should be ordered according to some criteria.
 
50
    \inqmlmodule QtOrganizer 5.0
 
51
    \ingroup qml-organizer-filters
 
52
 */
 
53
QDeclarativeOrganizerItemSortOrder::QDeclarativeOrganizerItemSortOrder(QObject *parent)
 
54
    : QObject(parent)
 
55
    , m_detail(QDeclarativeOrganizerItemDetail::Undefined), m_field(-1), m_componentCompleted(false)
 
56
{
 
57
}
 
58
 
 
59
/*!
 
60
  \qmlsignal SortOrder::onSortOrderChanged()
 
61
 
 
62
  This signal is emitted, when any of the SortOrder's properties have been changed.
 
63
 */
 
64
 
 
65
/*!
 
66
    \internal
 
67
 */
 
68
void QDeclarativeOrganizerItemSortOrder::classBegin()
 
69
{
 
70
}
 
71
 
 
72
/*!
 
73
    \internal
 
74
 */
 
75
void QDeclarativeOrganizerItemSortOrder::componentComplete()
 
76
{
 
77
    setDetailDefinitionName();
 
78
    m_componentCompleted = true;
 
79
}
 
80
 
 
81
/*!
 
82
    \qmlproperty string SortOrder::detail
 
83
 
 
84
    This property holds the detail type of which the sorting will be performed to. The value should
 
85
    be the enumeration value of Detail::type.
 
86
 */
 
87
void QDeclarativeOrganizerItemSortOrder::setDetail(QDeclarativeOrganizerItemDetail::DetailType detail)
 
88
{
 
89
    if (m_detail != detail) {
 
90
        m_detail = detail;
 
91
        if (m_componentCompleted)
 
92
            setDetailDefinitionName();
 
93
    }
 
94
}
 
95
 
 
96
QDeclarativeOrganizerItemDetail::DetailType QDeclarativeOrganizerItemSortOrder::detail() const
 
97
{
 
98
    return m_detail;
 
99
}
 
100
 
 
101
/*!
 
102
    \qmlproperty string SortOrder::field
 
103
 
 
104
    This property holds the detail field type of which the sorting will be performed to. The value
 
105
    should be the filld enumeration value defined in each detail element.
 
106
 
 
107
    \sa EventTime, JournalTime, TodoTime, TodoProgress, Reminder, AudibleReminder, VisualReminder,
 
108
        EmailReminder, Comment, Description, DisplayLabel, Guid, Location, Parent, Priority, Recurrence,
 
109
        Timestamp, ItemType, Tag
 
110
 */
 
111
void QDeclarativeOrganizerItemSortOrder::setField(int field)
 
112
{
 
113
    if (field != m_field) {
 
114
        m_field = field;
 
115
        if (m_componentCompleted)
 
116
            setDetailDefinitionName();
 
117
    }
 
118
}
 
119
 
 
120
int QDeclarativeOrganizerItemSortOrder::field() const
 
121
{
 
122
    return m_field;
 
123
}
 
124
 
 
125
/*!
 
126
    \qmlproperty enumeration SortOrder::blankPolicy
 
127
 
 
128
    This property enumerates the ways in which the sort order interprets blanks when sorting organizer.
 
129
    \list
 
130
    \li SortOrder.BlanksFirst  Considers blank values to evaluate to less than all other values in comparisons.
 
131
    \li SortOrder.BlanksLast   Considers blank values to evaluate to greater than all other values in comparisons.
 
132
    \endlist
 
133
 */
 
134
void QDeclarativeOrganizerItemSortOrder::setBlankPolicy(BlankPolicy policy)
 
135
{
 
136
    if (policy != blankPolicy()) {
 
137
        d.setBlankPolicy(static_cast<QOrganizerItemSortOrder::BlankPolicy>(policy));
 
138
        emit sortOrderChanged();
 
139
    }
 
140
}
 
141
 
 
142
QDeclarativeOrganizerItemSortOrder::BlankPolicy QDeclarativeOrganizerItemSortOrder::blankPolicy() const
 
143
{
 
144
    return static_cast<QDeclarativeOrganizerItemSortOrder::BlankPolicy>(d.blankPolicy());
 
145
}
 
146
 
 
147
/*!
 
148
    \qmlproperty enumeration SortOrder::direction
 
149
 
 
150
    This property holds the direction of the sort order, the value can be one of:
 
151
    \list
 
152
    \li Qt.AscendingOrder   The items will be sorted by the ascending order (default).
 
153
    \li Qt.DescendingOrder  The items will be sorted by the descending order.
 
154
    \endlist
 
155
 */
 
156
void QDeclarativeOrganizerItemSortOrder::setDirection(Qt::SortOrder newDirection)
 
157
{
 
158
    if (newDirection != direction()) {
 
159
        d.setDirection(newDirection);
 
160
        emit sortOrderChanged();
 
161
    }
 
162
}
 
163
 
 
164
Qt::SortOrder QDeclarativeOrganizerItemSortOrder::direction() const
 
165
{
 
166
    return d.direction();
 
167
}
 
168
 
 
169
/*!
 
170
    \qmlproperty enumeration SortOrder::caseSensitivity
 
171
 
 
172
    This property holds the case sensitivity of the sort order, the value can be one of:
 
173
    \list
 
174
    \li Qt.CaseInsensitive  Sets the case sensitivity of the sort order to insensitivity.
 
175
    \li Qt.CaseSensitive    Sets the case sensitivity of the sort order to sensitivity (default).
 
176
    \endlist
 
177
 */
 
178
void QDeclarativeOrganizerItemSortOrder::setCaseSensitivity(Qt::CaseSensitivity newSensitivity)
 
179
{
 
180
    if (newSensitivity != caseSensitivity()) {
 
181
        d.setCaseSensitivity(newSensitivity);
 
182
        emit sortOrderChanged();
 
183
    }
 
184
}
 
185
 
 
186
Qt::CaseSensitivity QDeclarativeOrganizerItemSortOrder::caseSensitivity() const
 
187
{
 
188
    return d.caseSensitivity();
 
189
}
 
190
 
 
191
/*!
 
192
    \internal
 
193
 */
 
194
QOrganizerItemSortOrder QDeclarativeOrganizerItemSortOrder::sortOrder()
 
195
{
 
196
    return d;
 
197
}
 
198
 
 
199
/*!
 
200
    \internal
 
201
 */
 
202
void QDeclarativeOrganizerItemSortOrder::setDetailDefinitionName()
 
203
{
 
204
    d.setDetail(static_cast<QOrganizerItemDetail::DetailType>(m_detail), m_field);
 
205
    emit sortOrderChanged();
 
206
}
 
207
 
 
208
 
 
209
#include "moc_qdeclarativeorganizeritemsortorder_p.cpp"
 
210
 
 
211
QT_END_NAMESPACE_ORGANIZER