File indexing completed on 2024-05-12 05:13:33

0001 /*
0002   SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "grantleetheme_export.h"
0010 
0011 #include <memory>
0012 
0013 #include <QVariant>
0014 
0015 class QString;
0016 
0017 namespace GrantleeTheme
0018 {
0019 class GenericFormatterPrivate;
0020 
0021 /** Convenience class for using a Grantlee theme. */
0022 class GRANTLEETHEME_EXPORT GenericFormatter
0023 {
0024 public:
0025     GenericFormatter();
0026     explicit GenericFormatter(const QString &defaultHtmlMain, const QString &themePath);
0027     ~GenericFormatter();
0028 
0029     void setDefaultHtmlMainFile(const QString &name);
0030     void setTemplatePath(const QString &path);
0031 
0032     /** Translation domain for the Grantlee localizer. */
0033     void setApplicationDomain(const QByteArray &domain);
0034 
0035     QString render(const QVariantHash &mapping) const;
0036     QString errorMessage() const;
0037 
0038     /** Set template content from a string rather than a file. */
0039     void setTemplateContent(const QString &content);
0040 
0041     void reloadTemplate();
0042 
0043 private:
0044     std::unique_ptr<GenericFormatterPrivate> const d;
0045 };
0046 }