~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/organizer/items/qorganizertodooccurrence.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 <qorganizertodooccurrence.h>
 
43
#include <qorganizertodotime.h>
 
44
#include <qorganizeritemparent.h>
 
45
#include <qorganizeritemid.h>
 
46
 
 
47
QT_BEGIN_NAMESPACE_ORGANIZER
 
48
 
 
49
/*!
 
50
    \class QOrganizerTodoOccurrence
 
51
    \brief The QOrganizerTodoOccurrence class provides an occurrence of a task which should be completed
 
52
    \inmodule QtOrganizer
 
53
    \ingroup organizer-items
 
54
 
 
55
    A todo occurrence is a specific instance of a todo item.  An occurrence
 
56
    which is retrieved from a manager may not actually be persisted in that
 
57
    manager (for example, it may be generated automatically from the
 
58
    recurrence rule of the parent todo stored in the manager), in which case
 
59
    it will have a zero-id and differ from the parent todo only in its start
 
60
    date.  Alternatively, it may be persisted in the manager (that is, the
 
61
    client has saved the occurrence previously) where it is stored as an exception
 
62
    to its parent todo.
 
63
 */
 
64
 
 
65
/*!
 
66
    Sets the date time at which the task should be started to \a startDateTime.  For all-day tasks,
 
67
    the time part can be set to any valid value.
 
68
 */
 
69
void QOrganizerTodoOccurrence::setStartDateTime(const QDateTime &startDateTime)
 
70
{
 
71
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
 
72
    ttr.setStartDateTime(startDateTime);
 
73
    saveDetail(&ttr);
 
74
}
 
75
 
 
76
/*!
 
77
    Returns the date time at which the task should be started.  For all-day tasks, the time part is
 
78
    meaningless.
 
79
 */
 
80
QDateTime QOrganizerTodoOccurrence::startDateTime() const
 
81
{
 
82
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
 
83
    return ttr.startDateTime();
 
84
}
 
85
 
 
86
/*!
 
87
    Sets the date time by which the task should be completed to \a dueDateTime.  For all-day tasks,
 
88
    the time part can be set to any valid value.
 
89
 */
 
90
void QOrganizerTodoOccurrence::setDueDateTime(const QDateTime &dueDateTime)
 
91
{
 
92
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
 
93
    ttr.setDueDateTime(dueDateTime);
 
94
    saveDetail(&ttr);
 
95
}
 
96
 
 
97
/*!
 
98
    Returns the date time by which the task should be completed.  For all-day tasks, the time part is
 
99
    meaningless.
 
100
 */
 
101
QDateTime QOrganizerTodoOccurrence::dueDateTime() const
 
102
{
 
103
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
 
104
    return ttr.dueDateTime();
 
105
}
 
106
 
 
107
/*!
 
108
    Sets the todo occurrence's parent to be the todo identified by the
 
109
    given \a parentId.
 
110
 */
 
111
void QOrganizerTodoOccurrence::setParentId(const QOrganizerItemId &parentId)
 
112
{
 
113
    QOrganizerItemParent origin = detail(QOrganizerItemDetail::TypeParent);
 
114
    origin.setParentId(parentId);
 
115
    saveDetail(&origin);
 
116
}
 
117
 
 
118
/*!
 
119
    Returns the id of the todo which is this occurrence's parent.
 
120
 */
 
121
QOrganizerItemId QOrganizerTodoOccurrence::parentId() const
 
122
{
 
123
    QOrganizerItemParent origin = detail(QOrganizerItemDetail::TypeParent);
 
124
    return origin.parentId();
 
125
}
 
126
 
 
127
/*!
 
128
    Sets the date at which this occurrence was originally going to occur,
 
129
    to the given \a date.
 
130
 */
 
131
void QOrganizerTodoOccurrence::setOriginalDate(const QDate &date)
 
132
{
 
133
    QOrganizerItemParent origin = detail(QOrganizerItemDetail::TypeParent);
 
134
    origin.setOriginalDate(date);
 
135
    saveDetail(&origin);
 
136
}
 
137
 
 
138
/*!
 
139
    Returns the date at which the occurrence was originally going to occur.
 
140
 */
 
141
QDate QOrganizerTodoOccurrence::originalDate() const
 
142
{
 
143
    QOrganizerItemParent origin = detail(QOrganizerItemDetail::TypeParent);
 
144
    return origin.originalDate();
 
145
}
 
146
 
 
147
/*!
 
148
    Sets the priority of the todo occurrence to \a priority.
 
149
 */
 
150
void QOrganizerTodoOccurrence::setPriority(QOrganizerItemPriority::Priority priority)
 
151
{
 
152
    QOrganizerItemPriority pd = detail(QOrganizerItemDetail::TypePriority);
 
153
    pd.setPriority(priority);
 
154
    saveDetail(&pd);
 
155
}
 
156
 
 
157
/*!
 
158
    Returns the priority of the todo occurrence..
 
159
 */
 
160
QOrganizerItemPriority::Priority QOrganizerTodoOccurrence::priority() const
 
161
{
 
162
    QOrganizerItemPriority pd = detail(QOrganizerItemDetail::TypePriority);
 
163
    return pd.priority();
 
164
}
 
165
 
 
166
/*!
 
167
    Sets the percentage of progress completed on the task described
 
168
    by the todo occurrence item to \a percentage. Note that the given
 
169
    \a percentage must be between 0 and 100, otherwise ignored.
 
170
 */
 
171
void QOrganizerTodoOccurrence::setProgressPercentage(int percentage)
 
172
{
 
173
    if (percentage >= 0 && percentage <= 100) {
 
174
        QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
175
        tp.setPercentageComplete(percentage);
 
176
        saveDetail(&tp);
 
177
    }
 
178
}
 
179
 
 
180
/*!
 
181
    Returns the percentage of progress completed on the task described
 
182
    by the todo occurrence.
 
183
 */
 
184
int QOrganizerTodoOccurrence::progressPercentage() const
 
185
{
 
186
    QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
187
    return tp.percentageComplete();
 
188
}
 
189
 
 
190
/*!
 
191
    Sets the progress status of the todo occurrence to \a status.
 
192
 */
 
193
void QOrganizerTodoOccurrence::setStatus(QOrganizerTodoProgress::Status status)
 
194
{
 
195
    QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
196
    tp.setStatus(status);
 
197
    saveDetail(&tp);
 
198
}
 
199
 
 
200
/*!
 
201
    Returns the progress status of the task described by the todo occurrence.
 
202
 */
 
203
QOrganizerTodoProgress::Status QOrganizerTodoOccurrence::status() const
 
204
{
 
205
    QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
206
    return tp.status();
 
207
}
 
208
 
 
209
/*!
 
210
    Sets the date and time at which the task described by the todo occurrence was completed to \a finishedDateTime.
 
211
 */
 
212
void QOrganizerTodoOccurrence::setFinishedDateTime(const QDateTime &finishedDateTime)
 
213
{
 
214
    QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
215
    tp.setFinishedDateTime(finishedDateTime);
 
216
    saveDetail(&tp);
 
217
}
 
218
 
 
219
/*!
 
220
    Returns the date and time at which the task described by the todo occurrence was completed.
 
221
 */
 
222
QDateTime QOrganizerTodoOccurrence::finishedDateTime() const
 
223
{
 
224
    QOrganizerTodoProgress tp = detail(QOrganizerItemDetail::TypeTodoProgress);
 
225
    return tp.finishedDateTime();
 
226
}
 
227
 
 
228
QT_END_NAMESPACE_ORGANIZER