Commit d739c6e5 authored by Johannes Lenzen's avatar Johannes Lenzen
Browse files

add qt6 support

parent 60829f61
......@@ -234,6 +234,8 @@ void ScriptingPlugin::slotScriptChanged(){
// Stop timers, as the text changed!
errorTimer_->stop();
#if QT_VERSION_MAJOR < 6
// Check the current script for syntax
const QString script = scriptWidget_->currentScript->toPlainText();
QScriptSyntaxCheckResult syntaxCheck = QScriptEngine::checkSyntax ( script );
......@@ -249,6 +251,8 @@ void ScriptingPlugin::slotScriptChanged(){
default :
break;
}
#endif
}
void ScriptingPlugin::slotHighlightError() {
......@@ -333,7 +337,7 @@ void ScriptingPlugin::slotScriptInfo( QString _pluginName , QString _functionNam
}
void ScriptingPlugin::slotExecuteScript( QString _script ) {
#if QT_VERSION_MAJOR < 6
if ( OpenFlipper::Options::gui())
statusBar_->showMessage(tr("Executing Script"));
......@@ -353,13 +357,19 @@ void ScriptingPlugin::slotExecuteScript( QString _script ) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList script = _script.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
#else
QStringList script = _script.split(QRegExp("[\r\n]"),Qt::SkipEmptyParts);
QStringList script = QRegExp("[\r\n]").splitString(_script, Qt::SkipEmptyParts);
#endif
// Find first include statement
int include_index = script.indexOf(QRegExp("^include.*"));
int include_index = -1;
for (int i=0;i<script.count();i++) {
if (QRegExp("^include.*").exactMatch(script[i])) {
include_index = i;
break;
}
}
while ( include_index != -1) {
......@@ -433,6 +443,8 @@ void ScriptingPlugin::slotExecuteScript( QString _script ) {
if ( OpenFlipper::Options::gui() && !error)
statusBar_->clearMessage();
#endif
/// Switch scripting mode off
OpenFlipper::Options::scripting(false);
}
......
......@@ -61,6 +61,7 @@
#include <QObject>
#include <QMenuBar>
#include <QRegExp>
class ScriptingPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, RPCInterface, LoggingInterface
{
......@@ -76,7 +77,9 @@ Q_INTERFACES(LoggingInterface)
signals:
void updateView();
#if QT_VERSION_MAJOR < 6
void getScriptingEngine( QScriptEngine*& _engine );
#endif
void getAvailableFunctions( QStringList& _functions );
void log(Logtype _type, QString _message);
......
......@@ -164,21 +164,21 @@ void Highlighter::update() {
foreach (HighlightingRule rule, highlightingRules_) {
QRegExp expression(rule.pattern);
int index = text.indexOf(expression);
int index = expression.indexIn(text);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, rule.format);
index = text.indexOf(expression, index + length);
index = expression.indexIn(text, index + length);
}
}
setCurrentBlockState(0);
int startIndex = 0;
if (previousBlockState() != 1)
startIndex = text.indexOf(commentStartExpression_);
startIndex = commentStartExpression_.indexIn(text);
while (startIndex >= 0) {
int endIndex = text.indexOf(commentEndExpression_, startIndex);
int endIndex = commentEndExpression_.indexIn(text, startIndex);
int commentLength;
if (endIndex == -1) {
setCurrentBlockState(1);
......@@ -187,7 +187,7 @@ void Highlighter::update() {
commentLength = endIndex - startIndex + commentEndExpression_.matchedLength();
}
setFormat(startIndex, commentLength, multiLineCommentFormat_);
startIndex = text.indexOf(commentStartExpression_, startIndex + commentLength);
startIndex = commentStartExpression_.indexIn(text, startIndex + commentLength);
}
}
......@@ -50,6 +50,7 @@
#include <QTextCharFormat>
#include <QTextDocument>
#include <QTextEdit>
#include <QRegExp>
class Highlighter : public QSyntaxHighlighter
{
......
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