Fix gui build without feature.regularexpression

Change-Id: Id27fc81af8d2b0355b186540f41d75a9c8d7c7f3
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Tasuku Suzuki 2019-05-22 15:21:13 +09:00
parent 9f77c91522
commit ec6dc5f784
4 changed files with 28 additions and 3 deletions

View File

@ -41,7 +41,9 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QVariant> #include <QtCore/QVariant>
#if QT_CONFIG(regularexpression)
#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpression>
#endif
#include <QtCore/QSharedData> #include <QtCore/QSharedData>
#if QT_CONFIG(settings) #if QT_CONFIG(settings)
#include <QtCore/QSettings> #include <QtCore/QSettings>
@ -786,6 +788,7 @@ const char QPlatformFileDialogHelper::filterRegExp[] =
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter) QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
{ {
#if QT_CONFIG(regularexpression)
QRegularExpression regexp(QString::fromLatin1(filterRegExp)); QRegularExpression regexp(QString::fromLatin1(filterRegExp));
Q_ASSERT(regexp.isValid()); Q_ASSERT(regexp.isValid());
QString f = filter; QString f = filter;
@ -794,6 +797,9 @@ QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
if (match.hasMatch()) if (match.hasMatch())
f = match.captured(2); f = match.captured(2);
return f.split(QLatin1Char(' '), QString::SkipEmptyParts); return f.split(QLatin1Char(' '), QString::SkipEmptyParts);
#else
return QStringList();
#endif
} }
// Message dialog // Message dialog

View File

@ -40,7 +40,9 @@
#include "qtextmarkdownimporter_p.h" #include "qtextmarkdownimporter_p.h"
#include "qtextdocumentfragment_p.h" #include "qtextdocumentfragment_p.h"
#include <QLoggingCategory> #include <QLoggingCategory>
#if QT_CONFIG(regularexpression)
#include <QRegularExpression> #include <QRegularExpression>
#endif
#include <QTextCursor> #include <QTextCursor>
#include <QTextDocument> #include <QTextDocument>
#include <QTextDocumentFragment> #include <QTextDocumentFragment>
@ -425,16 +427,20 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
return 0; // it's the alt-text return 0; // it's the alt-text
if (m_needsInsertBlock) if (m_needsInsertBlock)
insertBlock(); insertBlock();
#if QT_CONFIG(regularexpression)
static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]")); static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]"));
static const QRegularExpression closingBracket(QStringLiteral("(/>|</)")); static const QRegularExpression closingBracket(QStringLiteral("(/>|</)"));
#endif
QString s = QString::fromUtf8(text, int(size)); QString s = QString::fromUtf8(text, int(size));
switch (textType) { switch (textType) {
case MD_TEXT_NORMAL: case MD_TEXT_NORMAL:
#if QT_CONFIG(regularexpression)
if (m_htmlTagDepth) { if (m_htmlTagDepth) {
m_htmlAccumulator += s; m_htmlAccumulator += s;
s = QString(); s = QString();
} }
#endif
break; break;
case MD_TEXT_NULLCHAR: case MD_TEXT_NULLCHAR:
s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null 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: case MD_TEXT_CODE:
// We'll see MD_SPAN_CODE too, which will set the char format, and that's enough. // We'll see MD_SPAN_CODE too, which will set the char format, and that's enough.
break; break;
#if QT_CONFIG(texthtmlparser)
case MD_TEXT_ENTITY: case MD_TEXT_ENTITY:
m_cursor->insertHtml(s); m_cursor->insertHtml(s);
s = QString(); s = QString();
break; break;
#endif
case MD_TEXT_HTML: case MD_TEXT_HTML:
// count how many tags are opened and how many are closed // count how many tags are opened and how many are closed
#if QT_CONFIG(regularexpression)
{ {
int startIdx = 0; int startIdx = 0;
while ((startIdx = s.indexOf(openingBracket, 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; m_htmlAccumulator += s;
s = QString();
if (!m_htmlTagDepth) { // all open tags are now closed if (!m_htmlTagDepth) { // all open tags are now closed
qCDebug(lcMD) << "HTML" << m_htmlAccumulator; qCDebug(lcMD) << "HTML" << m_htmlAccumulator;
m_cursor->insertHtml(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_cursor->setCharFormat(m_spanFormatStack.top());
m_htmlAccumulator = QString(); m_htmlAccumulator = QString();
} }
#endif
s = QString();
break; break;
} }

View File

@ -106,14 +106,18 @@ private:
QTextDocument *m_doc = nullptr; QTextDocument *m_doc = nullptr;
QTextCursor *m_cursor = nullptr; QTextCursor *m_cursor = nullptr;
QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work
#if QT_CONFIG(regularexpression)
QString m_htmlAccumulator; QString m_htmlAccumulator;
#endif
QString m_blockCodeLanguage; QString m_blockCodeLanguage;
QVector<int> m_nonEmptyTableCells; // in the current row QVector<int> m_nonEmptyTableCells; // in the current row
QStack<QTextList *> m_listStack; QStack<QTextList *> m_listStack;
QStack<QTextCharFormat> m_spanFormatStack; QStack<QTextCharFormat> m_spanFormatStack;
QFont m_monoFont; QFont m_monoFont;
QPalette m_palette; QPalette m_palette;
#if QT_CONFIG(regularexpression)
int m_htmlTagDepth = 0; int m_htmlTagDepth = 0;
#endif
int m_blockQuoteDepth = 0; int m_blockQuoteDepth = 0;
int m_tableColumnCount = 0; int m_tableColumnCount = 0;
int m_tableRowCount = 0; int m_tableRowCount = 0;

View File

@ -8,7 +8,6 @@ HEADERS += \
util/qabstractlayoutstyleinfo_p.h \ util/qabstractlayoutstyleinfo_p.h \
util/qlayoutpolicy_p.h \ util/qlayoutpolicy_p.h \
util/qshaderformat_p.h \ util/qshaderformat_p.h \
util/qshadergenerator_p.h \
util/qshadergraph_p.h \ util/qshadergraph_p.h \
util/qshadergraphloader_p.h \ util/qshadergraphloader_p.h \
util/qshaderlanguage_p.h \ util/qshaderlanguage_p.h \
@ -29,7 +28,6 @@ SOURCES += \
util/qabstractlayoutstyleinfo.cpp \ util/qabstractlayoutstyleinfo.cpp \
util/qlayoutpolicy.cpp \ util/qlayoutpolicy.cpp \
util/qshaderformat.cpp \ util/qshaderformat.cpp \
util/qshadergenerator.cpp \
util/qshadergraph.cpp \ util/qshadergraph.cpp \
util/qshadergraphloader.cpp \ util/qshadergraphloader.cpp \
util/qshaderlanguage.cpp \ util/qshaderlanguage.cpp \
@ -41,3 +39,10 @@ SOURCES += \
util/qpkmhandler.cpp \ util/qpkmhandler.cpp \
util/qktxhandler.cpp \ util/qktxhandler.cpp \
util/qastchandler.cpp util/qastchandler.cpp
qtConfig(regularexpression) {
HEADERS += \
util/qshadergenerator_p.h
SOURCES += \
util/qshadergenerator.cpp
}