Akonadi

parttypehelper.h
1 /*
2  SPDX-FileCopyrightText: 2011 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "exception.h"
10 #include "query.h"
11 
12 namespace Akonadi
13 {
14 namespace Server
15 {
16 class PartType;
17 
18 AKONADI_EXCEPTION_MAKE_INSTANCE(PartTypeException);
19 
20 /**
21  * Methods for dealing with the PartType table.
22  */
23 namespace PartTypeHelper
24 {
25 /**
26  * Retrieve (or create) PartType for the given fully qualified name.
27  * @param fqName Fully qualified name (NS:NAME).
28  * @throws PartTypeException
29  */
30 PartType fromFqName(const QString &fqName);
31 
32 /**
33  * Convenience overload of the above.
34  */
35 PartType fromFqName(const QByteArray &fqName);
36 
37 /**
38  * Retrieve (or create) PartType for the given namespace and type name.
39  * @param ns Namespace
40  * @param typeName Part type name.
41  * @throws PartTypeException
42  */
43 PartType fromFqName(const QString &ns, const QString &typeName);
44 
45 /**
46  * Returns a query condition that matches the given part.
47  * @param fqName fully-qualified part type name
48  * @throws PartTypeException
49  */
51 
52 /**
53  * Returns a query condition that matches the given part type list.
54  * @param fqNames fully qualified part type name list
55  * @throws PartTypeException
56  */
58 
59 /**
60  * Convenience overload for the above.
61  */
62 template<template<typename> class T>
63 Query::Condition conditionFromFqNames(const T<QByteArray> &fqNames)
64 {
66  c.setSubQueryMode(Query::Or);
67  for (const QByteArray &fqName : fqNames) {
69  }
70  return c;
71 }
72 
73 /**
74  * Parses a fully qualified part type name into namespace/name.
75  * @param fqName fully-qualified part type name
76  * @throws PartTypeException if @p fqName does not match the NS:NAME schema
77  * @internal
78  */
79 std::pair<QString, QString> parseFqName(const QString &fqName);
80 
81 /**
82  * Returns full part name
83  */
84 QString fullName(const PartType &type);
85 
86 } // namespace PartTypeHelper
87 
88 } // namespace Server
89 } // namespace Akonadi
Query::Condition conditionFromFqNames(const QStringList &fqNames)
Returns a query condition that matches the given part type list.
PartType fromFqName(const QString &fqName)
Retrieve (or create) PartType for the given fully qualified name.
Query::Condition conditionFromFqName(const QString &fqName)
Returns a query condition that matches the given part.
void addCondition(const Condition &condition)
Add a WHERE condition.
Definition: query.cpp:54
Represents a WHERE condition tree.
Definition: query.h:61
void setSubQueryMode(LogicOperator op)
Set how sub-conditions should be combined, default is And.
Definition: query.cpp:49
QString fullName(const PartType &type)
Returns full part name.
std::pair< QString, QString > parseFqName(const QString &fqName)
Parses a fully qualified part type name into namespace/name.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Dec 6 2022 03:53:33 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.