diff options
author | Tasuku Suzuki <tasuku.suzuki@qbc.io> | 2019-05-22 15:21:13 +0900 |
---|---|---|
committer | Tasuku Suzuki <tasuku.suzuki@qbc.io> | 2019-05-22 22:11:41 +0900 |
commit | ec6dc5f78453048c4f0604655a34c6c20c79d819 (patch) | |
tree | 11abc64fbcf73b07f86ab090ad145cd6f3faec4a /src/gui/text | |
parent | 9f77c9152220abb26a4d6a9dfa46fec7f87d60e6 (diff) |
Fix gui build without feature.regularexpression
Change-Id: Id27fc81af8d2b0355b186540f41d75a9c8d7c7f3
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextmarkdownimporter.cpp | 12 | ||||
-rw-r--r-- | src/gui/text/qtextmarkdownimporter_p.h | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index d8ffec2496..8c80a3f0c7 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -40,7 +40,9 @@ #include "qtextmarkdownimporter_p.h" #include "qtextdocumentfragment_p.h" #include <QLoggingCategory> +#if QT_CONFIG(regularexpression) #include <QRegularExpression> +#endif #include <QTextCursor> #include <QTextDocument> #include <QTextDocumentFragment> @@ -425,16 +427,20 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) return 0; // it's the alt-text if (m_needsInsertBlock) insertBlock(); +#if QT_CONFIG(regularexpression) static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]")); static const QRegularExpression closingBracket(QStringLiteral("(/>|</)")); +#endif QString s = QString::fromUtf8(text, int(size)); switch (textType) { case MD_TEXT_NORMAL: +#if QT_CONFIG(regularexpression) if (m_htmlTagDepth) { m_htmlAccumulator += s; s = QString(); } +#endif break; case MD_TEXT_NULLCHAR: s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null @@ -448,12 +454,15 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) case MD_TEXT_CODE: // We'll see MD_SPAN_CODE too, which will set the char format, and that's enough. break; +#if QT_CONFIG(texthtmlparser) case MD_TEXT_ENTITY: m_cursor->insertHtml(s); s = QString(); break; +#endif case MD_TEXT_HTML: // count how many tags are opened and how many are closed +#if QT_CONFIG(regularexpression) { int startIdx = 0; while ((startIdx = s.indexOf(openingBracket, startIdx)) >= 0) { @@ -467,7 +476,6 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) } } m_htmlAccumulator += s; - s = QString(); if (!m_htmlTagDepth) { // all open tags are now closed qCDebug(lcMD) << "HTML" << m_htmlAccumulator; m_cursor->insertHtml(m_htmlAccumulator); @@ -477,6 +485,8 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) m_cursor->setCharFormat(m_spanFormatStack.top()); m_htmlAccumulator = QString(); } +#endif + s = QString(); break; } diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h index 1716530b1d..d62f1cf7dd 100644 --- a/src/gui/text/qtextmarkdownimporter_p.h +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -106,14 +106,18 @@ private: QTextDocument *m_doc = nullptr; QTextCursor *m_cursor = nullptr; QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work +#if QT_CONFIG(regularexpression) QString m_htmlAccumulator; +#endif QString m_blockCodeLanguage; QVector<int> m_nonEmptyTableCells; // in the current row QStack<QTextList *> m_listStack; QStack<QTextCharFormat> m_spanFormatStack; QFont m_monoFont; QPalette m_palette; +#if QT_CONFIG(regularexpression) int m_htmlTagDepth = 0; +#endif int m_blockQuoteDepth = 0; int m_tableColumnCount = 0; int m_tableRowCount = 0; |