Akonadi

gidextractor.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Christian Mollekopf <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "gidextractor_p.h"
7 #include "gidextractorinterface.h"
8 
9 #include "item.h"
10 #include "typepluginloader_p.h"
11 
12 using namespace Akonadi;
13 
14 QString GidExtractor::extractGid(const Item &item)
15 {
16  const QObject *object = TypePluginLoader::objectForMimeTypeAndClass(item.mimeType(), item.availablePayloadMetaTypeIds());
17  if (object) {
18 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
19  const GidExtractorInterface *extractor = qobject_cast<const GidExtractorInterface *>(object);
20 #else
21  const GidExtractorInterface *extractor = qobject_cast<GidExtractorInterface *>(object);
22 #endif
23  if (extractor) {
24  return extractor->extractGid(item);
25  }
26  }
27  return QString();
28 }
29 
30 QString GidExtractor::getGid(const Item &item)
31 {
32  const QString gid = item.gid();
33  if (!gid.isNull()) {
34  return gid;
35  }
36  if (item.loadedPayloadParts().isEmpty()) {
37  return QString();
38  }
39  return extractGid(item);
40 }
bool isNull() const const
An interface to extract the GID of an object contained in an akonadi item.
QString mimeType() const
Returns the mime type of the item.
Definition: item.cpp:331
QString gid() const
Returns the gid of the entity.
Definition: item.cpp:357
virtual QString extractGid(const Item &item) const =0
Extracts the globally unique id of item.
QSet< QByteArray > loadedPayloadParts() const
Returns the list of loaded payload parts.
Definition: item.cpp:288
QVector< int > availablePayloadMetaTypeIds() const
Returns a list of metatype-ids, describing the different variants of payload that are currently conta...
Definition: item.cpp:496
bool isEmpty() const const
Represents a PIM item stored in Akonadi storage.
Definition: item.h:105
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:52:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.