Commit 6260f15b authored by Ahmad Samir's avatar Ahmad Samir Committed by Nikita Sirgienko
Browse files

Port QRegExp to QRegularExpression, pass 2

Ported:
src/backends/lua/luahelper.cpp
src/cantor.cpp
src/lib/result.cpp
src/lib/test/backendtest.cpp
src/loadedexpression.cpp
src/markdownentry.cpp
src/textentry.cpp
src/worksheet.cpp
parent ec8f603a
......@@ -22,6 +22,7 @@
#include "luakeywords.h"
#include <lua.hpp>
#include <QRegularExpression>
#include <QString>
#include <QStringList>
......@@ -90,7 +91,7 @@ QStringList luahelper_completion(lua_State* L, const QString& name)
QStringList list;
QStringList sections = name.split(QRegExp(QLatin1String("\\.|:")));
QStringList sections = name.split(QRegularExpression(QStringLiteral("\\.|:")));
QString table, prefix;
if(sections.size() == 1) // global table
......
......@@ -36,6 +36,7 @@
#include <QDir>
#include <QFileDialog>
#include <QPushButton>
#include <QRegularExpression>
#include <QGraphicsView>
#include "lib/backend.h"
......@@ -551,7 +552,7 @@ void CantorShell::openExample()
foreach(const QString& file, files)
{
QString name=file;
name.remove(QRegExp(QLatin1String("-.*\\.hotstuff-access$")));
name.remove(QRegularExpression(QStringLiteral("-.*\\.hotstuff-access$")));
list->addItem(name);
}
......
......@@ -21,9 +21,9 @@
#include "result.h"
using namespace Cantor;
#include <QRegExp>
#include <QUrl>
#include <QJsonObject>
#include <QRegularExpression>
class Cantor::ResultPrivate
{
......@@ -58,9 +58,9 @@ QString Result::toLatex()
{
QString html=toHtml();
//replace linebreaks
html.replace(QRegExp(QLatin1String("<br/>[\n]")), QStringLiteral("\n"));
html.replace(QRegularExpression(QStringLiteral("<br/>[\n]")), QStringLiteral("\n"));
//remove all the unknown tags
html.remove( QRegExp( QLatin1String("<[a-zA-Z\\/][^>]*>") ) );
html.remove(QRegularExpression(QStringLiteral("<[a-zA-Z\\/][^>]*>") ));
return QStringLiteral("\\begin{verbatim} %1 \\end{verbatim}").arg(html);
}
......
......@@ -75,8 +75,8 @@ QString BackendTest::cleanOutput(const QString& out)
cleaned.replace( QLatin1String("&nbsp;"),QLatin1String(" ") );
cleaned.remove( QLatin1String("<br/>") );
cleaned.replace( QChar::ParagraphSeparator, QLatin1Char('\n') );
cleaned.replace( QRegExp( QLatin1String("\\n\\n") ), QLatin1String("\n") );
cleaned.replace( QRegExp( QLatin1String("\\n\\s*") ), QLatin1String("\n") );
cleaned.replace( QRegularExpression( QStringLiteral("\\n{2}") ), QStringLiteral("\n") );
cleaned.replace( QRegularExpression( QStringLiteral("\\n\\s*") ), QStringLiteral("\n") );
return cleaned.trimmed();
}
......
......@@ -37,6 +37,7 @@
#include <QJsonDocument>
#include <QDebug>
#include <QPixmap>
#include <QRegularExpression>
#include <QTemporaryFile>
LoadedExpression::LoadedExpression( Cantor::Session* session ) : Cantor::Expression( session, false, -1)
......@@ -210,7 +211,7 @@ void LoadedExpression::loadFromJupyter(const QJsonObject& cell)
// IPython returns error with terminal colors, we handle it here, but should we?
static const QChar ESC(0x1b);
traceback.remove(QRegExp(QString(ESC)+QLatin1String("\\[[0-9;]*m")));
traceback.remove(QRegularExpression(QString(ESC)+QLatin1String("\\[[0-9;]*m")));
setErrorMessage(traceback);
}
......
......@@ -29,6 +29,7 @@
#include <KLocalizedString>
#include <QDebug>
#include <QKeyEvent>
#include <QRegularExpression>
#include <QStandardPaths>
#include <QDir>
#include <QFileDialog>
......@@ -611,7 +612,8 @@ void MarkdownEntry::setRenderedMath(int jobId, const QTextImageFormat& format, c
// Don't add new line for $$...$$ on document's begin and end
// And if we in block, which haven't non-space characters except out math expression
// In another sitation, Cantor will move rendered image into another QTextBlock
QTextCursor prevSymCursor = m_textItem->document()->find(QRegExp(QLatin1String("[^\\s]")), cursor, QTextDocument::FindBackward);
QTextCursor prevSymCursor = m_textItem->document()->find(QRegularExpression(QStringLiteral("[^\\s]")),
cursor, QTextDocument::FindBackward);
if (type == Cantor::LatexRenderer::FullEquation
&& cursor.selectionStart() != 0
&& prevSymCursor.block() == cursor.block()
......@@ -626,7 +628,7 @@ void MarkdownEntry::setRenderedMath(int jobId, const QTextImageFormat& format, c
cursor.insertText(QString(QChar::ObjectReplacementCharacter), format);
bool atDocEnd = cursor.position() == m_textItem->document()->characterCount()-1;
QTextCursor nextSymCursor = m_textItem->document()->find(QRegExp(QLatin1String("[^\\s]")), cursor);
QTextCursor nextSymCursor = m_textItem->document()->find(QRegularExpression(QStringLiteral("[^\\s]")), cursor);
if (type == Cantor::LatexRenderer::FullEquation && !atDocEnd && nextSymCursor.block() == cursor.block())
{
cursor.setPosition(nextSymCursor.position()-1, QTextCursor::KeepAnchor);
......@@ -664,7 +666,7 @@ void MarkdownEntry::markUpMath()
continue;
QString searchText = foundMath[i].first;
searchText.replace(QRegExp(QLatin1String("\\s+")), QLatin1String(" "));
searchText.replace(QRegularExpression(QStringLiteral("\\s+")), QStringLiteral(" "));
cursor = m_textItem->document()->find(searchText, cursor);
......
......@@ -37,6 +37,7 @@
#include <QDebug>
#include <KLocalizedString>
#include <KColorScheme>
#include <QRegularExpression>
#include <QStringList>
#include <QInputDialog>
......@@ -257,7 +258,7 @@ QJsonValue TextEntry::toJupyterJson()
entryData = doc->toHtml();
// Remove DOCTYPE from html
entryData.remove(QRegExp(QLatin1String("<!DOCTYPE[^>]*>\\n")));
entryData.remove(QRegularExpression(QStringLiteral("<!DOCTYPE[^>]*>\\n")));
cantorMetadata.insert(QLatin1String("text_entry_content"), entryData);
}
......
......@@ -39,6 +39,7 @@
#include <KFontSizeAction>
#include <KToggleAction>
#include <KLocalizedString>
#include <QRegularExpression>
#include "settings.h"
#include "commandentry.h"
......@@ -1523,8 +1524,8 @@ void Worksheet::gotResult(Cantor::Expression* expr)
{
QString help = result->toHtml();
//Do some basic LaTeX replacing
help.replace(QRegExp(QLatin1String("\\\\code\\{([^\\}]*)\\}")), QLatin1String("<b>\\1</b>"));
help.replace(QRegExp(QLatin1String("\\$([^\\$])\\$")), QLatin1String("<i>\\1</i>"));
help.replace(QRegularExpression(QStringLiteral("\\\\code\\{([^\\}]*)\\}")), QStringLiteral("<b>\\1</b>"));
help.replace(QRegularExpression(QStringLiteral("\\$([^\\$])\\$")), QStringLiteral("<i>\\1</i>"));
emit showHelp(help);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment