~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to src/organizer/qorganizermanager.h

  • 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
#ifndef QORGANIZERMANAGER_H
 
43
#define QORGANIZERMANAGER_H
 
44
 
 
45
#include <qorganizercollection.h>
 
46
#include <qorganizeritem.h>
 
47
#include <qorganizeritemfilter.h>
 
48
#include <qorganizeritemfetchhint.h>
 
49
#include <qorganizeritemsortorder.h>
 
50
 
 
51
#include <QtCore/qdatetime.h>
 
52
#include <QtCore/qstringlist.h>
 
53
 
 
54
QT_BEGIN_NAMESPACE_ORGANIZER
 
55
 
 
56
class QOrganizerManagerData;
 
57
 
 
58
class Q_ORGANIZER_EXPORT QOrganizerManager : public QObject
 
59
{
 
60
    Q_OBJECT
 
61
 
 
62
public:
 
63
#if Q_QDOC // qdoc's parser fails to recognise the default map argument
 
64
    explicit QOrganizerManager(const QString &managerName, const QMap<QString, QString> &parameters = 0, QObject *parent = 0);
 
65
#else
 
66
    explicit QOrganizerManager(const QString &managerName, const QMap<QString, QString> &parameters = (QMap<QString, QString>()), QObject *parent = 0);
 
67
#endif
 
68
    explicit QOrganizerManager(QObject *parent = 0);
 
69
    ~QOrganizerManager();
 
70
 
 
71
    static QOrganizerManager *fromUri(const QString &uri, QObject *parent = 0);
 
72
    static QStringList availableManagers();
 
73
 
 
74
    QString managerName() const;
 
75
    QMap<QString, QString> managerParameters() const;
 
76
    int managerVersion() const;
 
77
    QString managerUri() const;
 
78
 
 
79
    static bool parseUri(const QString &uri, QString *managerName, QMap<QString, QString> *params);
 
80
    static QString buildUri(const QString &managerName, const QMap<QString, QString> &params);
 
81
 
 
82
    // error reporting
 
83
    enum Error {
 
84
        NoError = 0,
 
85
        DoesNotExistError,
 
86
        AlreadyExistsError,
 
87
        InvalidDetailError,
 
88
        LockedError,
 
89
        DetailAccessError,
 
90
        PermissionsError,
 
91
        OutOfMemoryError,
 
92
        NotSupportedError,
 
93
        BadArgumentError,
 
94
        UnspecifiedError,
 
95
        LimitReachedError,
 
96
        InvalidItemTypeError,
 
97
        InvalidCollectionError,
 
98
        InvalidOccurrenceError,
 
99
        TimeoutError
 
100
    };
 
101
 
 
102
    enum Operation {
 
103
        Add,
 
104
        Change,
 
105
        Remove
 
106
    };
 
107
 
 
108
    /* Error reporting */
 
109
    QOrganizerManager::Error error() const;
 
110
    QMap<int, QOrganizerManager::Error> errorMap() const;
 
111
 
 
112
    // items
 
113
    QOrganizerItem item(const QOrganizerItemId &itemId, const QOrganizerItemFetchHint &fetchHint = QOrganizerItemFetchHint());
 
114
 
 
115
    QList<QOrganizerItem> items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint = QOrganizerItemFetchHint());
 
116
 
 
117
    QList<QOrganizerItem> items(const QDateTime &startDateTime = QDateTime(), const QDateTime &endDateTime = QDateTime(),
 
118
                                const QOrganizerItemFilter &filter = QOrganizerItemFilter(), int maxCount = -1,
 
119
                                const QList<QOrganizerItemSortOrder> &sortOrders = QList<QOrganizerItemSortOrder>(),
 
120
                                const QOrganizerItemFetchHint &fetchHint = QOrganizerItemFetchHint());
 
121
 
 
122
    QList<QOrganizerItemId> itemIds(const QDateTime &startDateTime = QDateTime(), const QDateTime &endDateTime = QDateTime(),
 
123
                                    const QOrganizerItemFilter &filter = QOrganizerItemFilter(),
 
124
                                    const QList<QOrganizerItemSortOrder> &sortOrders = QList<QOrganizerItemSortOrder>());
 
125
 
 
126
    QList<QOrganizerItem> itemOccurrences(const QOrganizerItem &parentItem, const QDateTime &startDateTime = QDateTime(),
 
127
                                          const QDateTime &endDateTime = QDateTime(), int maxCount = -1,
 
128
                                          const QOrganizerItemFetchHint &fetchHint = QOrganizerItemFetchHint());
 
129
 
 
130
    QList<QOrganizerItem> itemsForExport(const QDateTime &startDateTime = QDateTime(), const QDateTime &endDateTime = QDateTime(),
 
131
                                         const QOrganizerItemFilter &filter = QOrganizerItemFilter(),
 
132
                                         const QList<QOrganizerItemSortOrder> &sortOrders = QList<QOrganizerItemSortOrder>(),
 
133
                                         const QOrganizerItemFetchHint &fetchHint = QOrganizerItemFetchHint());
 
134
 
 
135
    bool saveItem(QOrganizerItem *item, const QList<QOrganizerItemDetail::DetailType> &detailMask = QList<QOrganizerItemDetail::DetailType>());
 
136
 
 
137
    bool saveItems(QList<QOrganizerItem> *items,
 
138
                   const QList<QOrganizerItemDetail::DetailType> &detailMask = QList<QOrganizerItemDetail::DetailType>());
 
139
 
 
140
    bool removeItem(const QOrganizerItemId &itemId);
 
141
 
 
142
    bool removeItem(const QOrganizerItem *item);
 
143
 
 
144
    bool removeItems(const QList<QOrganizerItemId>& itemIds);
 
145
 
 
146
    bool removeItems(const QList<QOrganizerItem> *items);
 
147
 
 
148
    // collections
 
149
    QOrganizerCollection defaultCollection();
 
150
    QOrganizerCollection collection(const QOrganizerCollectionId& collectionId);
 
151
    QList<QOrganizerCollection> collections();
 
152
    bool saveCollection(QOrganizerCollection* collection);
 
153
    bool removeCollection(const QOrganizerCollectionId& collectionId);
 
154
 
 
155
    // functionality reporting
 
156
    QList<QOrganizerItemFilter::FilterType> supportedFilters() const;
 
157
    QList<QOrganizerItemDetail::DetailType> supportedItemDetails(QOrganizerItemType::ItemType itemType) const;
 
158
    QList<QOrganizerItemType::ItemType> supportedItemTypes() const;
 
159
 
 
160
    // helper
 
161
    static QList<QOrganizerItemId> extractIds(const QList<QOrganizerItem> &items);
 
162
 
 
163
Q_SIGNALS:
 
164
    void dataChanged();
 
165
    void itemsAdded(const QList<QOrganizerItemId> &itemIds);
 
166
    void itemsChanged(const QList<QOrganizerItemId> &itemIds);
 
167
    void itemsRemoved(const QList<QOrganizerItemId> &itemIds);
 
168
    void itemsModified(const QList<QPair<QOrganizerItemId, QOrganizerManager::Operation> > &itemIds);
 
169
    void collectionsAdded(const QList<QOrganizerCollectionId> &collectionIds);
 
170
    void collectionsChanged(const QList<QOrganizerCollectionId> &collectionIds);
 
171
    void collectionsRemoved(const QList<QOrganizerCollectionId> &collectionIds);
 
172
    void collectionsModified(const QList<QPair<QOrganizerCollectionId, QOrganizerManager::Operation> > &collectionIds);
 
173
 
 
174
private:
 
175
    friend class QOrganizerManagerData;
 
176
    Q_DISABLE_COPY(QOrganizerManager)
 
177
    QOrganizerManagerData *d;
 
178
 
 
179
    void createEngine(const QString &managerName, const QMap<QString, QString> &parameters);
 
180
 
 
181
    Q_PRIVATE_SLOT(d, void _q_itemsUpdated(const QList<QOrganizerItemId> &ids))
 
182
    Q_PRIVATE_SLOT(d, void _q_itemsDeleted(const QList<QOrganizerItemId> &ids))
 
183
};
 
184
 
 
185
QT_END_NAMESPACE_ORGANIZER
 
186
 
 
187
#endif // QORGANIZERMANAGER_H