akonadi
20 #include "collectionpathresolver_p.h"
22 #include "collectionfetchjob.h"
25 #include <klocalizedstring.h>
27 #include <QtCore/QStringList>
33 class Akonadi::CollectionPathResolverPrivate :
public JobPrivate
42 void init(
const QString &path,
const Collection &rootCollection)
48 if (mPath.startsWith(q->pathDelimiter())) {
49 mPath = mPath.right(mPath.length() - q->pathDelimiter().length());
51 if (mPath.endsWith(q->pathDelimiter())) {
52 mPath = mPath.left(mPath.length() - q->pathDelimiter().length());
55 mPathParts = splitPath(mPath);
56 mCurrentNode = rootCollection;
59 void jobResult(KJob *);
61 QStringList splitPath(
const QString &path)
69 const int pathSize(path.size());
70 for (
int i = 0; i < pathSize; ++i) {
71 if (path[i] == QLatin1Char(
'/')) {
72 QString pathElement = path.mid(begin, i - begin);
73 pathElement = pathElement.replace(QLatin1String(
"\\/"), QLatin1String(
"/"));
74 rv.append(pathElement);
77 if (i < path.size() - 2 && path[i] == QLatin1Char(
'\\') && path[i + 1] == QLatin1Char(
'/')) {
81 QString pathElement = path.mid(begin);
82 pathElement = pathElement.replace(QLatin1String(
"\\/"), QLatin1String(
"/"));
83 rv.append(pathElement);
92 QStringList mPathParts;
96 void CollectionPathResolverPrivate::jobResult(KJob *job)
107 if (cols.isEmpty()) {
110 q->setErrorText(i18n(
"No such collection."));
116 const QString currentPart = mPathParts.takeFirst();
119 if (c.
name() == currentPart) {
126 kWarning() <<
"No such collection" << currentPart <<
"with parent" << mCurrentNode.
id();
129 q->setErrorText(i18n(
"No such collection."));
133 if (mPathParts.isEmpty()) {
134 mColId = mCurrentNode.id();
142 mPathParts.prepend(col.
name());
149 q->connect(nextJob, SIGNAL(result(KJob*)), q, SLOT(jobResult(KJob*)));
153 :
Job(new CollectionPathResolverPrivate(this), parent)
160 :
Job(new CollectionPathResolverPrivate(this), parent)
163 d->init(path, parentCollection);
167 :
Job(new CollectionPathResolverPrivate(this), parent)
171 d->mPathToId =
false;
172 d->mColId = collection.id();
173 d->mCurrentNode = collection;
199 return QLatin1String(
"/");
208 if (d->mPath.isEmpty()) {
215 if (d->mColId == 0) {
222 connect(job, SIGNAL(result(KJob*)), SLOT(jobResult(KJob*)));
227 #include "moc_collectionpathresolver_p.cpp"
Collection::Id collection() const
Returns the collection id.
Collection parentCollection() const
Returns the parent collection of this object.
Represents a collection of PIM items.
QString name() const
Returns the i18n'ed name of the collection.
Job that fetches collections from the Akonadi storage.
Collection::List collections() const
Returns the list of fetched collection.
qint64 Id
Describes the unique id type.
void doStart()
This method must be reimplemented in the concrete jobs.
static QString pathDelimiter()
Returns the path delimiter for collections.
@ FirstLevel
Only list direct sub-collections of the base collection.
@ Base
Only fetch the base collection.
~CollectionPathResolver()
Destroys the collection path resolver.
CollectionPathResolver(const QString &path, QObject *parent=0)
Creates a new collection path resolver to convert a path into a id.
Base class for all actions in the Akonadi storage.
static Collection root()
Returns the root collection.
Id id() const
Returns the unique identifier of the entity.
FreeBusyManager::Singleton.
QString path() const
Returns the collection path.
QList< Collection > List
Describes a list of collections.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jan 29 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.