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