1 | /* |
2 | Copyright (c) 2007 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef AKONADI_COLLECTIONPATHRESOLVER_P_H |
21 | #define AKONADI_COLLECTIONPATHRESOLVER_P_H |
22 | |
23 | #include <akonadi/collection.h> |
24 | #include <akonadi/job.h> |
25 | |
26 | namespace Akonadi { |
27 | |
28 | class CollectionPathResolverPrivate; |
29 | |
30 | /** |
31 | * @internal |
32 | * |
33 | * Converts between collection id and collection path. |
34 | * |
35 | * While it is generally recommended to use collection ids, it can |
36 | * be necessary in some cases (eg. a command line client) to use the |
37 | * collection path instead. Use this class to get a collection id |
38 | * from a collection path. |
39 | * |
40 | * @author Volker Krause <vkrause@kde.org> |
41 | */ |
42 | class AKONADI_EXPORT CollectionPathResolver : public Job |
43 | { |
44 | Q_OBJECT |
45 | |
46 | public: |
47 | /** |
48 | * Creates a new collection path resolver to convert a path into a id. |
49 | * |
50 | * Equivalent to calling CollectionPathResolver(path, Collection:root(), parent) |
51 | * |
52 | * @param path The collection path. |
53 | * @param parent The parent object. |
54 | */ |
55 | explicit CollectionPathResolver(const QString &path, QObject *parent = 0); |
56 | |
57 | /** |
58 | * Create a new collection path resolver to convert a path into an id. |
59 | * |
60 | * The @p path is resolved relatively to @p parentCollection. This can be |
61 | * useful for resource, which now the root collection. |
62 | * |
63 | * @param path The collection path. |
64 | * @param parentCollection Collection relatively to which the path will be resolved. |
65 | * @param parent The parent object. |
66 | * |
67 | * @since 4.14 |
68 | */ |
69 | explicit CollectionPathResolver(const QString &path, const Collection &parentCollection, QObject *parent = 0); |
70 | |
71 | /** |
72 | * Creates a new collection path resolver to determine the path of |
73 | * the given collection. |
74 | * |
75 | * @param collection The collection. |
76 | * @param parent The parent object. |
77 | */ |
78 | explicit CollectionPathResolver(const Collection &collection, QObject *parent = 0); |
79 | |
80 | /** |
81 | * Destroys the collection path resolver. |
82 | */ |
83 | ~CollectionPathResolver(); |
84 | |
85 | /** |
86 | * Returns the collection id. Only valid after the job succeeded. |
87 | */ |
88 | Collection::Id collection() const; |
89 | |
90 | /** |
91 | * Returns the collection path. Only valid after the job succeeded. |
92 | */ |
93 | QString path() const; |
94 | |
95 | /** |
96 | * Returns the path delimiter for collections. |
97 | */ |
98 | static QString pathDelimiter(); |
99 | |
100 | protected: |
101 | void doStart(); |
102 | |
103 | private: |
104 | Q_DECLARE_PRIVATE(CollectionPathResolver) |
105 | |
106 | //@cond PRIVATE |
107 | Q_PRIVATE_SLOT(d_func(), void jobResult(KJob *)) |
108 | //@endcond |
109 | }; |
110 | |
111 | } |
112 | |
113 | #endif |
114 | |