~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/organizer/requests/qorganizeritemsaverequest.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 <qorganizeritemsaverequest.h>
 
43
#include <private/qorganizeritemrequests_p.h>
 
44
 
 
45
QT_BEGIN_NAMESPACE_ORGANIZER
 
46
 
 
47
/*!
 
48
    \class QOrganizerItemSaveRequest
 
49
    \brief The QOrganizerItemSaveRequest class allows a client to asynchronously request that certain
 
50
           organizer items be saved to a backend.
 
51
    \inmodule QtOrganizer
 
52
    \ingroup organizer-requests
 
53
 */
 
54
 
 
55
/*!
 
56
    Constructs a new organizer item save request whose parent is the specified \a parent.
 
57
*/
 
58
QOrganizerItemSaveRequest::QOrganizerItemSaveRequest(QObject *parent)
 
59
    : QOrganizerAbstractRequest(new QOrganizerItemSaveRequestPrivate, parent)
 
60
{
 
61
}
 
62
 
 
63
/*!
 
64
    Frees memory in use by this request.
 
65
*/
 
66
QOrganizerItemSaveRequest::~QOrganizerItemSaveRequest()
 
67
{
 
68
    QOrganizerAbstractRequestPrivate::notifyEngine(this);
 
69
}
 
70
 
 
71
/*!
 
72
    Sets the organizer item to be saved to \a item.
 
73
    Equivalent to calling:
 
74
    \code
 
75
    setItems(QList<QOrganizerItem>() << item);
 
76
    \endcode
 
77
 */
 
78
void QOrganizerItemSaveRequest::setItem(const QOrganizerItem &item)
 
79
{
 
80
    Q_D(QOrganizerItemSaveRequest);
 
81
    QMutexLocker ml(&d->m_mutex);
 
82
    d->m_organizeritems.clear();
 
83
    d->m_organizeritems.append(item);
 
84
}
 
85
 
 
86
/*!
 
87
    Sets the list of organizer items to be saved to \a items.
 
88
*/
 
89
void QOrganizerItemSaveRequest::setItems(const QList<QOrganizerItem> &items)
 
90
{
 
91
    Q_D(QOrganizerItemSaveRequest);
 
92
    QMutexLocker ml(&d->m_mutex);
 
93
    d->m_organizeritems = items;
 
94
}
 
95
 
 
96
/*!
 
97
    Returns the list of organizer items which will be saved if called prior to calling start(),
 
98
    otherwise returns the list of organizer items as they were saved in the organizer item store.
 
99
*/
 
100
QList<QOrganizerItem> QOrganizerItemSaveRequest::items() const
 
101
{
 
102
    Q_D(const QOrganizerItemSaveRequest);
 
103
    QMutexLocker ml(&d->m_mutex);
 
104
    return d->m_organizeritems;
 
105
}
 
106
 
 
107
/*!
 
108
    Returns the map of input definition list indices to errors which occurred.
 
109
*/
 
110
QMap<int, QOrganizerManager::Error> QOrganizerItemSaveRequest::errorMap() const
 
111
{
 
112
    Q_D(const QOrganizerItemSaveRequest);
 
113
    QMutexLocker ml(&d->m_mutex);
 
114
    return d->m_errors;
 
115
}
 
116
 
 
117
/*!
 
118
    Set the list of detail types to restrict saving to \a detailMask.  This allows you to perform
 
119
    partial save (and remove) operations on existing items.
 
120
 
 
121
    If \a detailMask is empty (the default), no restrictions will apply, and the passed
 
122
    in items will be saved as is.  Otherwise, only details whose types are in
 
123
    the list will be saved.  If a detail type is present in the list, but there are no
 
124
    corresponding details in the item passed into this request, any existing details in
 
125
    the manager for that item will be removed.
 
126
 
 
127
    This is useful if you've used a fetch hint to fetch a partial item from a manager
 
128
    so that you can save changes to the details you actually fetched without removing
 
129
    the details you didn't.
 
130
 
 
131
    Additionally, when performing synchronization operations with other managers that don't
 
132
    support the full range of details, you can restrict the update operation to only those
 
133
    details so that you don't lose the extra details that are supported in this manager.
 
134
 
 
135
    \note Some managers do not support partial updates natively, in which case the QtOrganizer
 
136
    framework will emulate the functionality (fetching the whole item, applying the
 
137
    new restricted details, and saving the item back).
 
138
*/
 
139
void QOrganizerItemSaveRequest::setDetailMask(const QList<QOrganizerItemDetail::DetailType> &detailMask)
 
140
{
 
141
    Q_D(QOrganizerItemSaveRequest);
 
142
    QMutexLocker ml(&d->m_mutex);
 
143
    d->m_detailMask = detailMask;
 
144
}
 
145
 
 
146
/*!
 
147
    Returns the list of definitions that this request will operate on.
 
148
 
 
149
    If the list is empty, the request will operate on all details.
 
150
 */
 
151
QList<QOrganizerItemDetail::DetailType> QOrganizerItemSaveRequest::detailMask() const
 
152
{
 
153
    Q_D(const QOrganizerItemSaveRequest);
 
154
    QMutexLocker ml(&d->m_mutex);
 
155
    return d->m_detailMask;
 
156
}
 
157
 
 
158
#include "moc_qorganizeritemsaverequest.cpp"
 
159
 
 
160
QT_END_NAMESPACE_ORGANIZER