Commit 8688d7cb authored by Johannes Lenzen's avatar Johannes Lenzen
Browse files

removed qt5compat from qt6

parent f2f60d78
......@@ -44,7 +44,7 @@
#include "ScriptingPlugin.hh"
#include "OpenFlipper/common/GlobalOptions.hh"
#include <QRegExp>
#include <QRegularExpression>
......
......@@ -61,7 +61,7 @@
#include <QObject>
#include <QMenuBar>
#include <QRegExp>
#include <QRegularExpression>
class ScriptingPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, RPCInterface, LoggingInterface
{
......
......@@ -79,8 +79,8 @@ Highlighter::Highlighter(QTextEdit *parent)
singleLineCommentFormat_.setForeground(Qt::red);
multiLineCommentFormat_.setForeground(Qt::red);
commentStartExpression_ = QRegExp("/\\*");
commentEndExpression_ = QRegExp("\\*/");
commentStartExpression_ = QRegularExpression("/\\*");
commentEndExpression_ = QRegularExpression("\\*/");
// Define basic keywords
keywordPatterns_ << "while" << "for" << "print" << "var" << "break" << "if";
......@@ -116,44 +116,44 @@ void Highlighter::update() {
// Create Rules for keywords
foreach (QString pattern, keywordPatterns_) {
rule.pattern = QRegExp("\\b" + pattern + "\\b" );
rule.pattern = QRegularExpression("\\b" + pattern + "\\b" );
rule.format = keywordFormat_;
highlightingRules_.append(rule);
}
// Create Rules for plugins
foreach (QString pattern, pluginPatterns_ ) {
rule.pattern = QRegExp("\\b" + pattern + "\\b" );
rule.pattern = QRegularExpression("\\b" + pattern + "\\b" );
rule.format = pluginFormat_;
highlightingRules_.append(rule);
}
// Create Rules for functions
foreach (QString pattern, functionPatterns_ ) {
rule.pattern = QRegExp("\\b" + pattern + "\\b" );
rule.pattern = QRegularExpression("\\b" + pattern + "\\b" );
rule.format = functionFormat_;
highlightingRules_.append(rule);
}
// Create Rules for types
foreach (QString pattern, typePatterns_ ) {
rule.pattern = QRegExp("\\b" + pattern + "\\b" );
rule.pattern = QRegularExpression("\\b" + pattern + "\\b" );
rule.format = typeFormat_;
highlightingRules_.append(rule);
}
// Rule for single line comments
rule.pattern = QRegExp("//[^\n]*");
rule.pattern = QRegularExpression("//[^\n]*");
rule.format = singleLineCommentFormat_;
highlightingRules_.append(rule);
// Rules for quotations
rule.pattern = QRegExp("\".*\"");
rule.pattern = QRegularExpression("\".*\"");
rule.format = quotationFormat_;
highlightingRules_.append(rule);
// Rules for Lists
rule.pattern = QRegExp("\\[.*\\]");
rule.pattern = QRegularExpression("\\[.*\\]");
rule.format = listFormat_;
highlightingRules_.append(rule);
......@@ -163,31 +163,35 @@ void Highlighter::update() {
{
foreach (HighlightingRule rule, highlightingRules_) {
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
QRegularExpression expression(rule.pattern);
QRegularExpressionMatch match = expression.match(text);
int index = (int) match.capturedStart();
while (index >= 0) {
int length = expression.matchedLength();
int length = (int) match.capturedLength();
setFormat(index, length, rule.format);
index = expression.indexIn(text, index + length);
match = expression.match(text, index + length);
index = (int) match.capturedStart();
}
}
setCurrentBlockState(0);
int startIndex = 0;
if (previousBlockState() != 1)
startIndex = commentStartExpression_.indexIn(text);
if (previousBlockState() != 1) {
startIndex = (int) commentStartExpression_.match(text).capturedStart();
}
while (startIndex >= 0) {
int endIndex = commentEndExpression_.indexIn(text, startIndex);
QRegularExpressionMatch match = commentEndExpression_.match(text, startIndex);
int endIndex = (int) match.capturedStart();
int commentLength;
if (endIndex == -1) {
setCurrentBlockState(1);
commentLength = text.length() - startIndex;
} else {
commentLength = endIndex - startIndex + commentEndExpression_.matchedLength();
commentLength = endIndex - startIndex + match.capturedLength();
}
setFormat(startIndex, commentLength, multiLineCommentFormat_);
startIndex = commentStartExpression_.indexIn(text, startIndex + commentLength);
startIndex = commentStartExpression_.match(text, startIndex + commentLength).capturedStart();
}
}
......@@ -50,7 +50,7 @@
#include <QTextCharFormat>
#include <QTextDocument>
#include <QTextEdit>
#include <QRegExp>
#include <QRegularExpression>
class Highlighter : public QSyntaxHighlighter
{
......@@ -78,14 +78,14 @@ class Highlighter : public QSyntaxHighlighter
struct HighlightingRule
{
QRegExp pattern;
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules_;
QRegExp commentStartExpression_;
QRegExp commentEndExpression_;
QRegularExpression commentStartExpression_;
QRegularExpression commentEndExpression_;
QTextCharFormat keywordFormat_;
QTextCharFormat pluginFormat_;
......
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