#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTextFrame>
-#if QT_VERSION >= 0x060000
-#include <QtCore5Compat/QRegExp>
-#endif
using namespace lyx::support;
if (f.isEmpty())
return s;
QString r(s);
-#if QT_VERSION < 0x060000
- QRegExp pattern(charFilterRegExpC(f));
-#else
QRegularExpression pattern(charFilterRegExpC(f));
-#endif
r.replace(pattern, "<u><b>\\1</b></u>");
return r;
}
continue;
// detect links to the tracker
-#if QT_VERSION < 0x060000
- line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
- "<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
-#else
line.replace(QRegularExpression("(bug )(\\#)(\\d+)*"),
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
-#endif
// headings
if (line.startsWith("!!!")) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator>
#endif
-#include <QRegExp>
#include <QSessionManager>
#include <QSettings>
#include <QSocketNotifier>
int x, y;
int w, h;
QChar sx, sy;
-#if QT_VERSION < 0x060000
- QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
- re.indexIn(geometry_arg);
- w = re.cap(1).toInt();
- h = re.cap(2).toInt();
- x = re.cap(3).toInt();
- y = re.cap(4).toInt();
- sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0);
- sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0);
-#else
QRegularExpression re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
QRegularExpressionMatch match = re.match(geometry_arg);
w = match.captured(1).toInt();
y = match.captured(4).toInt();
sx = match.captured(3).isEmpty() ? '+' : match.captured(3).at(0);
sy = match.captured(4).isEmpty() ? '+' : match.captured(4).at(0);
-#endif
+
// Set initial geometry such that we can get the frame size.
view->setGeometry(x, y, w, h);
int framewidth = view->geometry().x() - view->x();
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsTE->toPlainText()));
-#if QT_VERSION < 0x060000
- bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
- .trimmed().replace(QRegExp("\n+"), "\n"));
-#else
bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
.trimmed().replace(QRegularExpression("\n+"), "\n"));
-#endif
// change tracking
bp_.track_changes = changesModule->trackChangesCB->isChecked();
#include <QLineEdit>
#include <QPushButton>
#include <QValidator>
-#if QT_VERSION < 0x060000
-#include <QRegExpValidator>
-#else
#include <QRegularExpressionValidator>
-#endif
using namespace std;
using namespace lyx::support;
numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
-#if QT_VERSION < 0x060000
- placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
-#else
placementLE->setValidator(new QRegularExpressionValidator(QRegularExpression("[\\*tbph]*"), this));
-#endif
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
// Regular expressions needed at several places
// FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile
// and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27)
-#if QT_VERSION < 0x060000
-// Information
-QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
-// Warnings
-QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
-// Errors
-QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
-#else
// Information
QRegularExpression exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
// Warnings
QRegularExpression exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\-\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
// Errors
QRegularExpression exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
-#endif
/////////////////////////////////////////////////////////////////////
void LogHighlighter::highlightBlock(QString const & text)
{
-#if QT_VERSION < 0x060000
- // Info
- int index = exprInfo.indexIn(text);
- while (index >= 0) {
- int length = exprInfo.matchedLength();
- setFormat(index, length, infoFormat);
- index = exprInfo.indexIn(text, index + length);
- }
- // LaTeX Warning:
- index = exprWarning.indexIn(text);
- while (index >= 0) {
- int length = exprWarning.matchedLength();
- setFormat(index, length, warningFormat);
- index = exprWarning.indexIn(text, index + length);
- }
- // ! error
- index = exprError.indexIn(text);
- while (index >= 0) {
- int length = exprError.matchedLength();
- setFormat(index, length, errorFormat);
- index = exprError.indexIn(text, index + length);
- }
-#else
// Info
QRegularExpressionMatch match = exprInfo.match(text);
int index = match.capturedStart(1);
match = exprError.match(text, index + length);
index = match.capturedStart(1);
}
-#endif
}
}
-#if QT_VERSION < 0x060000
-void GuiLog::goTo(QRegExp const & exp) const
-#else
void GuiLog::goTo(QRegularExpression const & exp) const
-#endif
{
QTextCursor const newc =
logTB->document()->find(exp, logTB->textCursor());
}
-#if QT_VERSION < 0x060000
-bool GuiLog::contains(QRegExp const & exp) const
-#else
bool GuiLog::contains(QRegularExpression const & exp) const
-#endif
{
return !logTB->document()->find(exp, logTB->textCursor()).isNull();
}
docstring title() const;
/// put the log file into the ostream
void getContents(std::ostream & ss) const;
-#if QT_VERSION < 0x060000
- /// go to the next occurrence of the RegExp
- void goTo(QRegExp const & exp) const;
- /// does the document after cursor position contain the RegExp?
- bool contains(QRegExp const & exp) const;
-#else
/// go to the next occurrence of the RegExp
void goTo(QRegularExpression const & exp) const;
/// does the document after cursor position contain the RegExp?
bool contains(QRegularExpression const & exp) const;
-#endif
private:
/// Recognized log file-types
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
QString testname = reloutname;
-#if QT_VERSION < 0x060000
- testname.remove(QRegExp("^(\\.\\./)+"));
-#else
testname.remove(QRegularExpression("^(\\.\\./)+"));
-#endif
if (testname.contains("/"))
return outname;
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
-#if QT_VERSION < 0x060000
- defaultDecimalSepED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
-#else
defaultDecimalSepED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
-#endif
defaultDecimalSepED->setMaxLength(1);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
-#if QT_VERSION < 0x060000
- decimalPointED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
-#else
decimalPointED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
-#endif
decimalPointED->setMaxLength(1);
// initialize the length validator
QString item = meaningsTV->currentItem()->text(col);
// cut out the classification in brackets:
// "hominid (generic term)" -> "hominid"
-#if QT_VERSION < 0x060000
- QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
-#else
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
-#endif
// This is for items with classifications at the beginning:
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
-#if QT_VERSION < 0x060000
- QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
- int pos = re.indexIn(item);
- if (pos > -1)
- item = re.cap(1).trimmed();
- pos = rex.indexIn(item);
- if (pos > -1)
- item = rex.cap(2).trimmed();
-#else
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
QRegularExpressionMatch match = re.match(item);
if (match.hasMatch())
match = rex.match(item);
if (match.hasMatch())
item = match.captured(2).trimmed();
-#endif
replaceED->setText(item);
replacePB->setEnabled(!isBufferReadonly());
changed();
QString str = item->text(col);
// cut out the classification in brackets:
// "hominid (generic term)" -> "hominid"
-#if QT_VERSION < 0x060000
- QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
-#else
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
-#endif
// This is for items with classifications at the beginning:
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
-#if QT_VERSION < 0x060000
- QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
- int pos = re.indexIn(str);
- if (pos > -1)
- str = re.cap(1).trimmed();
- pos = rex.indexIn(str);
- if (pos > -1)
- str = rex.cap(2).trimmed();
-#else
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
QRegularExpressionMatch match = re.match(str);
if (match.hasMatch())
match = rex.match(str);
if (match.hasMatch())
str = match.captured(2).trimmed();
-#endif
entryCO->insertItem(0, str);
entryCO->setCurrentIndex(0);
void LaTeXHighlighter::highlightBlock(QString const & text)
{
-#if QT_VERSION < 0x060000
- // keyval
- if (keyval_) {
- // Highlight key-val options. Used in some option widgets.
- static const QRegExp exprKeyvalkey("[^=,]+");
- static const QRegExp exprKeyvalval("[^,]+");
- int kvindex = exprKeyvalkey.indexIn(text);
- while (kvindex >= 0) {
- int length = exprKeyvalkey.matchedLength();
- setFormat(kvindex, length, keyFormat);
- int kvvindex = exprKeyvalval.indexIn(text, kvindex + length);
- if (kvvindex > 0) {
- length += exprKeyvalval.matchedLength();
- setFormat(kvvindex, length, valFormat);
- }
- kvindex = exprKeyvalkey.indexIn(text, kvindex + length);
- }
- }
- // $ $
- static const QRegExp exprMath("\\$[^\\$]*\\$");
- int index = exprMath.indexIn(text);
- while (index >= 0) {
- int length = exprMath.matchedLength();
- setFormat(index, length, mathFormat);
- index = exprMath.indexIn(text, index + length);
- }
- // [ ]
- static const QRegExp exprStartDispMath("(\\\\\\[|"
- "\\\\begin\\{equation\\**\\}|"
- "\\\\begin\\{eqnarray\\**\\}|"
- "\\\\begin\\{align(ed|at)*\\**\\}|"
- "\\\\begin\\{flalign\\**\\}|"
- "\\\\begin\\{gather\\**\\}|"
- "\\\\begin\\{multline\\**\\}|"
- "\\\\begin\\{array\\**\\}|"
- "\\\\begin\\{cases\\**\\}"
- ")");
- static const QRegExp exprEndDispMath("(\\\\\\]|"
- "\\\\end\\{equation\\**\\}|"
- "\\\\end\\{eqnarray\\**\\}|"
- "\\\\end\\{align(ed|at)*\\**\\}|"
- "\\\\end\\{flalign\\**\\}|"
- "\\\\end\\{gather\\**\\}|"
- "\\\\end\\{multline\\**\\}|"
- "\\\\end\\{array\\**\\}|"
- "\\\\end\\{cases\\**\\}"
- ")");
- int startIndex = 0;
- // if previous block was in 'disp math'
- // start search from 0 (for end disp math)
- // otherwise, start search from 'begin disp math'
- if (previousBlockState() != 1)
- startIndex = exprStartDispMath.indexIn(text);
- while (startIndex >= 0) {
- int endIndex = exprEndDispMath.indexIn(text, startIndex);
- int length;
- if (endIndex == -1) {
- setCurrentBlockState(1);
- length = text.length() - startIndex;
- } else {
- length = endIndex - startIndex + exprEndDispMath.matchedLength();
- }
- setFormat(startIndex, length, mathFormat);
- startIndex = exprStartDispMath.indexIn(text, startIndex + length);
- }
- // \whatever
- static const QRegExp exprKeywordAtOther("\\\\[A-Za-z]+");
- // \wh@tever
- static const QRegExp exprKeywordAtLetter("\\\\[A-Za-z@]+");
- QRegExp const & exprKeyword = at_letter_ ? exprKeywordAtLetter
- : exprKeywordAtOther;
- index = exprKeyword.indexIn(text);
- while (index >= 0) {
- int length = exprKeyword.matchedLength();
- setFormat(index, length, keywordFormat);
- index = exprKeyword.indexIn(text, index + length);
- }
- // %comment
- // Treat a line as a comment starting at a percent sign
- // * that is the first character in a line
- // * that is preceded by
- // ** an even number of backslashes
- // ** any character other than a backslash
- QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
- exprComment.indexIn(text);
- index = exprComment.pos(1);
- while (index >= 0) {
- int const length = exprComment.matchedLength()
- - (index - exprComment.pos(0));
- setFormat(index, length, commentFormat);
- exprComment.indexIn(text, index + length);
- index = exprComment.pos(1);
- }
- // <LyX Warning: ...>
- QString lyxwarn = qt_("LyX Warning: ");
- QRegExp exprWarning("<" + lyxwarn + "[^<]*>");
- index = exprWarning.indexIn(text);
- while (index >= 0) {
- int length = exprWarning.matchedLength();
- setFormat(index, length, warningFormat);
- index = exprWarning.indexIn(text, index + length);
- }
-#else
// keyval
if (keyval_) {
// Highlight key-val options. Used in some option widgets.
match = exprWarning.match(text, index + length);
index = match.capturedStart(0);
}
-#endif
}
} // namespace frontend
#include <QHeaderView>
#include <QItemDelegate>
#include <QPainter>
-#include <QRegExp>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTextFrame>
if (f.isEmpty())
return s;
QString r(s);
-#if QT_VERSION < 0x060000
- QRegExp pattern(charFilterRegExpC(f));
-#else
QRegularExpression pattern(charFilterRegExpC(f));
-#endif
r.replace(pattern, "<u><b>\\1</b></u>");
return r;
}
QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const
{
-#if QT_VERSION < 0x060000
- qtext.remove(QRegExp("[\\n\\r]"));
-#else
qtext.remove(QRegularExpression("[\\n\\r]"));
-#endif
return QValidator::Acceptable;
}
#include "support/docstring.h"
#include "support/qstring_helpers.h"
-#include <QRegExp>
+#include <QRegularExpression>
#include <QLocale>
#include <QString>
#include <QVector>
QString re = ".*";
for (QChar const & c : filter) {
if (c.isLower())
- re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
+ re += "[" + QRegularExpression::escape(c)
+ + QRegularExpression::escape(c.toUpper()) + "]";
else
- re += QRegExp::escape(c);
+ re += QRegularExpression::escape(c);
}
return re;
}
QString re = "(";
for (QChar const & c : filter) {
if (c.isLower())
- re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
+ re += "[" + QRegularExpression::escape(c)
+ + QRegularExpression::escape(c.toUpper()) + "]";
else
- re += QRegExp::escape(c);
+ re += QRegularExpression::escape(c);
}
return re + ")";
}