Akonadi

collectionpathresolver.h
1 /*
2  SPDX-FileCopyrightText: 2007 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akonadicore_export.h"
10 #include "collection.h"
11 #include "job.h"
12 
13 namespace Akonadi
14 {
15 class CollectionPathResolverPrivate;
16 
17 /**
18  * @internal
19  *
20  * Converts between collection id and collection path.
21  *
22  * While it is generally recommended to use collection ids, it can
23  * be necessary in some cases (eg. a command line client) to use the
24  * collection path instead. Use this class to get a collection id
25  * from a collection path.
26  *
27  * @author Volker Krause <[email protected]>
28  */
29 class AKONADICORE_EXPORT CollectionPathResolver : public Job
30 {
31  Q_OBJECT
32 
33 public:
34  /**
35  * Creates a new collection path resolver to convert a path into a id.
36  *
37  * Equivalent to calling CollectionPathResolver(path, Collection:root(), parent)
38  *
39  * @param path The collection path.
40  * @param parent The parent object.
41  */
42  explicit CollectionPathResolver(const QString &path, QObject *parent = nullptr);
43 
44  /**
45  * Create a new collection path resolver to convert a path into an id.
46  *
47  * The @p path is resolved relatively to @p parentCollection. This can be
48  * useful for resource, which now the root collection.
49  *
50  * @param path The collection path.
51  * @param parentCollection Collection relatively to which the path will be resolved.
52  * @param parent The parent object.
53  *
54  * @since 4.14
55  */
56  explicit CollectionPathResolver(const QString &path, const Collection &parentCollection, QObject *parent = nullptr);
57 
58  /**
59  * Creates a new collection path resolver to determine the path of
60  * the given collection.
61  *
62  * @param collection The collection.
63  * @param parent The parent object.
64  */
65  explicit CollectionPathResolver(const Collection &collection, QObject *parent = nullptr);
66 
67  /**
68  * Destroys the collection path resolver.
69  */
70  ~CollectionPathResolver() override;
71 
72  /**
73  * Returns the collection id. Only valid after the job succeeded.
74  */
75  Q_REQUIRED_RESULT Collection::Id collection() const;
76 
77  /**
78  * Returns the collection path. Only valid after the job succeeded.
79  */
80  Q_REQUIRED_RESULT QString path() const;
81 
82  /**
83  * Returns the path delimiter for collections.
84  */
85  Q_REQUIRED_RESULT static QString pathDelimiter();
86 
87 protected:
88  void doStart() override;
89 
90 private:
91  Q_DECLARE_PRIVATE(CollectionPathResolver)
92 };
93 
94 }
95 
Represents a collection of PIM items.
Definition: collection.h:61
Base class for all actions in the Akonadi storage.
Definition: job.h:80
qint64 Id
Describes the unique id type.
Definition: collection.h:79
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.