Akonadi

collectionpathresolver.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
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
13namespace Akonadi
14{
15class 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 <vkrause@kde.org>
28 */
29class AKONADICORE_EXPORT CollectionPathResolver : public Job
30{
31 Q_OBJECT
32
33public:
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 */
71
72 /**
73 * Returns the collection id. Only valid after the job succeeded.
74 */
75 [[nodiscard]] Collection::Id collection() const;
76
77 /**
78 * Returns the collection path. Only valid after the job succeeded.
79 */
80 [[nodiscard]] QString path() const;
81
82 /**
83 * Returns the path delimiter for collections.
84 */
85 [[nodiscard]] static QString pathDelimiter();
86
87protected:
88 void doStart() override;
89
90private:
91 Q_DECLARE_PRIVATE(CollectionPathResolver)
92};
93
94}
CollectionPathResolver(const Collection &collection, QObject *parent=nullptr)
Creates a new collection path resolver to determine the path of the given collection.
Collection::Id collection() const
Returns the collection id.
static QString pathDelimiter()
Returns the path delimiter for collections.
QString path() const
Returns the collection path.
CollectionPathResolver(const QString &path, QObject *parent=nullptr)
Creates a new collection path resolver to convert a path into a id.
~CollectionPathResolver() override
Destroys the collection path resolver.
CollectionPathResolver(const QString &path, const Collection &parentCollection, QObject *parent=nullptr)
Create a new collection path resolver to convert a path into an id.
void doStart() override
This method must be reimplemented in the concrete jobs.
Represents a collection of PIM items.
Definition collection.h:62
qint64 Id
Describes the unique id type.
Definition collection.h:79
Base class for all actions in the Akonadi storage.
Definition job.h:81
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.