Messagelib

ktexttemplateextension.h
1 /*
2  SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 #include <QObject>
9 
10 #include <KTextTemplate/Node>
11 #include <KTextTemplate/TagLibraryInterface>
12 
13 #include <functional>
14 
15 namespace MessageViewer
16 {
17 using KTextTemplateCallback = std::function<void(KTextTemplate::OutputStream *)>;
18 
19 class CallbackTag : public KTextTemplate::Node
20 {
21  Q_OBJECT
22 public:
23  explicit CallbackTag(const QString &name, QObject *parent = nullptr);
24  void render(KTextTemplate::OutputStream *stream, KTextTemplate::Context *context) const override;
25 
26 private:
27  const QString m_name;
28 };
29 
30 class CallbackTagFactory : public KTextTemplate::AbstractNodeFactory
31 {
32  Q_OBJECT
33 public:
34  KTextTemplate::Node *getNode(const QString &tagContent, KTextTemplate::Parser *parser) const override;
35 };
36 class KTextTemplateTagLibrary : public QObject, public KTextTemplate::TagLibraryInterface
37 {
38  Q_OBJECT
40  Q_PLUGIN_METADATA(IID "org.grantlee.TagLibraryInterface")
41 public:
42  explicit KTextTemplateTagLibrary(QObject *parent = nullptr);
43  [[nodiscard]] QHash<QString, KTextTemplate::AbstractNodeFactory *> nodeFactories(const QString &name) override;
44 };
45 }
46 
47 Q_DECLARE_METATYPE(MessageViewer::KTextTemplateCallback)
Q_OBJECTQ_OBJECT
Q_INTERFACES(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.