version 2.0.0_alpha

Important! All QtWraps macros renamed!
Qt 6 support
Graphic export feature
qad_types cross-Qt small changes
This commit is contained in:
2021-03-05 13:05:23 +03:00
parent add26cf9ad
commit 7b011ed242
46 changed files with 815 additions and 219 deletions

View File

@@ -5,39 +5,38 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
HighlightingRule rule;
valueNameFormat.setForeground(QColor(0, 64, 154));
rule.pattern = QRegExp("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
rule.pattern = QRegularExpression("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
rule.format = valueNameFormat;
highlightingRules.append(rule);
valueFormat.setForeground(QColor(192, 0, 0));
rule.pattern = QRegExp("=[^\n]*");
rule.pattern = QRegularExpression("=[^\n]*");
rule.format = valueFormat;
highlightingRules.append(rule);
equalFormat.setFontWeight(QFont::Bold);
equalFormat.setForeground(QColor(96, 126, 0));
rule.pattern = QRegExp("=");
rule.pattern = QRegularExpression("=");
rule.format = equalFormat;
highlightingRules.append(rule);
sectionFormat.setFontWeight(QFont::Bold);
sectionFormat.setForeground(QColor(0, 32, 64));
rule.pattern = QRegExp("\\[.*\\]");
rule.pattern = QRegularExpression("\\[.*\\]");
rule.format = sectionFormat;
highlightingRules.append(rule);
//substFormat.setFontWeight(QFont::Bold);
substFormat.setForeground(QColor(192, 0, 192));
rule.pattern = QRegExp("\\$\\{.*\\}+");
rule.pattern.setMinimal(true);
rule.pattern = QRegularExpression("\\$\\{.*\\}+");
//rule.pattern.setMinimal(true);
rule.format = substFormat;
highlightingRules.append(rule);
rule.pattern = QRegExp("\\$\\{[^\\{]*\\}+");
rule.pattern = QRegularExpression("\\$\\{[^\\{]*\\}+");
highlightingRules.append(rule);
singleLineCommentFormat.setFontItalic(true);
singleLineCommentFormat.setForeground(QColor(128, 128, 128));
rule.pattern = QRegExp("#[^\n]*");
rule.pattern = QRegularExpression("#[^\n]*");
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
@@ -50,21 +49,37 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
void ConfigHighlighter::highlightBlock(const QString & text) {
foreach (const HighlightingRule &rule, highlightingRules) {
QRegExp expression(rule.pattern);
QRegularExpression expression(rule.pattern);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRegularExpressionMatchIterator i = expression.globalMatch(text);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
}
#else
int index = expression.indexIn(text);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, rule.format);
index = expression.indexIn(text, index + length);
}
#endif
}
setCurrentBlockState(0);
QRegExp expression = QRegExp("[ |\t]");
QRegularExpression expression("[ |\t]");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRegularExpressionMatchIterator i = expression.globalMatch(text);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
setFormat(match.capturedStart(), match.capturedLength(), spaceFormat);
}
#else
int index = expression.indexIn(text);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, spaceFormat);
index = expression.indexIn(text, index + length);
}
#endif
}

View File

@@ -23,6 +23,12 @@
#include <QSyntaxHighlighter>
#include <QTextCursor>
#include <QTextCharFormat>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QRegularExpression>
#else
# include <QRegExp>
typedef QRegExp QRegularExpression;
#endif
#include "qad_piqt_utils_export.h"
class QTextDocument;
@@ -39,12 +45,12 @@ private:
void highlightBlock(const QString &text);
struct QAD_PIQT_UTILS_EXPORT HighlightingRule {
QRegExp pattern;
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegExp commentStartExpression, commentEndExpression;
QRegularExpression commentStartExpression, commentEndExpression;
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
};