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
15namespace MessageViewer
16{
17using KTextTemplateCallback = std::function<void(KTextTemplate::OutputStream *)>;
18
19class CallbackTag : public KTextTemplate::Node
20{
22public:
23 explicit CallbackTag(const QString &name, QObject *parent = nullptr);
24 void render(KTextTemplate::OutputStream *stream, KTextTemplate::Context *context) const override;
25
26private:
27 const QString m_name;
28};
29
30class CallbackTagFactory : public KTextTemplate::AbstractNodeFactory
31{
33public:
34 KTextTemplate::Node *getNode(const QString &tagContent, KTextTemplate::Parser *parser) const override;
35};
36class KTextTemplateTagLibrary : public QObject, public KTextTemplate::TagLibraryInterface
37{
40 Q_PLUGIN_METADATA(IID "org.grantlee.TagLibraryInterface")
41public:
42 explicit KTextTemplateTagLibrary(QObject *parent = nullptr);
43 [[nodiscard]] QHash<QString, KTextTemplate::AbstractNodeFactory *> nodeFactories(const QString &name) override;
44};
45}
46
47Q_DECLARE_METATYPE(MessageViewer::KTextTemplateCallback)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:48:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.