Warning, file /education/cantor/src/lib/result.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com> 0004 */ 0005 0006 #include "result.h" 0007 using namespace Cantor; 0008 0009 #include <QUrl> 0010 #include <QJsonObject> 0011 #include <QRegularExpression> 0012 0013 class Cantor::ResultPrivate 0014 { 0015 public: 0016 ~ResultPrivate() 0017 { 0018 if (jupyterMetadata) 0019 delete jupyterMetadata; 0020 } 0021 0022 QJsonObject* jupyterMetadata{nullptr}; 0023 int executionIndex{-1}; 0024 }; 0025 0026 0027 Result::Result() : d(new ResultPrivate) 0028 { 0029 0030 } 0031 0032 Result::~Result() 0033 { 0034 delete d; 0035 } 0036 0037 QUrl Result::url() 0038 { 0039 return QUrl(); 0040 } 0041 0042 QString Result::toLatex() 0043 { 0044 QString html=toHtml(); 0045 //replace linebreaks 0046 html.replace(QRegularExpression(QStringLiteral("<br/>[\n]")), QStringLiteral("\n")); 0047 //remove all the unknown tags 0048 html.remove(QRegularExpression(QStringLiteral("<[a-zA-Z\\/][^>]*>") )); 0049 return QStringLiteral("\\begin{verbatim} %1 \\end{verbatim}").arg(html); 0050 } 0051 0052 void Result::saveAdditionalData(KZip* archive) 0053 { 0054 Q_UNUSED(archive) 0055 //Do nothing 0056 } 0057 0058 QJsonObject Cantor::Result::jupyterMetadata() const 0059 { 0060 return d->jupyterMetadata ? *d->jupyterMetadata : QJsonObject(); 0061 } 0062 0063 void Cantor::Result::setJupyterMetadata(QJsonObject metadata) 0064 { 0065 if (!d->jupyterMetadata) 0066 d->jupyterMetadata = new QJsonObject(); 0067 *d->jupyterMetadata = metadata; 0068 } 0069 0070 int Cantor::Result::executionIndex() const 0071 { 0072 return d->executionIndex; 0073 } 0074 0075 void Cantor::Result::setExecutionIndex(int index) 0076 { 0077 d->executionIndex = index; 0078 }