File indexing completed on 2024-04-28 11:20:47

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2019 Sirgienko Nikita <warquark@gmail.com>
0004 */
0005 
0006 #ifndef _HTMLRESULT_H
0007 #define _HTMLRESULT_H
0008 
0009 #include <QJsonValue>
0010 
0011 #include "result.h"
0012 #include "cantor_export.h"
0013 
0014 namespace Cantor
0015 {
0016 
0017 class HtmlResultPrivate;
0018 /**
0019  * Class for html results
0020  * Instead of TextResult supports show/hide source html code like LatexResult
0021  * Also the result allows see plain alternative of the html, if available
0022  */
0023 class CANTOR_EXPORT HtmlResult : public Result
0024 {
0025   public:
0026     enum { Type=8 };
0027     enum Format { Html, HtmlSource, PlainAlternative};
0028     HtmlResult(const QString& html, const QString& plain = QString(), const std::map<QString, QJsonValue>& alternatives = std::map<QString, QJsonValue>());
0029     ~HtmlResult() override;
0030 
0031     QString toHtml() override;
0032     QVariant data() override;
0033     QString plain();
0034 
0035     void setFormat(Format format);
0036     Format format();
0037 
0038     int type() override;
0039     QString mimeType() override;
0040 
0041     QDomElement toXml(QDomDocument& doc) override;
0042     QJsonValue toJupyterJson() override;
0043 
0044     void save(const QString& filename) override;
0045 
0046   private:
0047     HtmlResultPrivate* d;
0048 };
0049 
0050 }
0051 #endif /* _HTMLRESULT_H */