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> Query::Condition conditionFromFqNames(const T<QByteArray> &fqNames)
63 {
65  c.setSubQueryMode(Query::Or);
66  for (const QByteArray &fqName : fqNames) {
68  }
69  return c;
70 }
71 
72 /**
73  * Parses a fully qualified part type name into namespace/name.
74  * @param fqName fully-qualified part type name
75  * @throws PartTypeException if @p fqName does not match the NS:NAME schema
76  * @internal
77  */
78 std::pair<QString, QString> parseFqName(const QString &fqName);
79 
80 /**
81  * Returns full part name
82  */
83 QString fullName(const PartType &type);
84 
85 } // namespace PartTypeHelper
86 
87 } // namespace Server
88 } // namespace Akonadi
89 
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 Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.