summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-16 21:46:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-16 21:51:11 +0100
commitc577f6edafef7c40a5f78092ec4fcd78bb820b2c (patch)
tree9ca3819e5cca9b7e61f305a874b682e5a2085e83 /examples/widgets
parent99ce1d3d97c0423c3ee63ccf58deed964db0770e (diff)
parentde225ccdf95efb57866d62bc80872c1a2ab99703 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts: src/corelib/plugin/qlibrary_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp9
-rw-r--r--examples/widgets/tools/codecs/mainwindow.cpp7
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp39
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h28
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.cpp7
5 files changed, 46 insertions, 44 deletions
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp
index ffed01a3f3..965660a3a3 100644
--- a/examples/widgets/painting/shared/arthurwidgets.cpp
+++ b/examples/widgets/painting/shared/arthurwidgets.cpp
@@ -59,6 +59,7 @@
#include <QFile>
#include <QTextBrowser>
#include <QBoxLayout>
+#include <QRegularExpression>
extern QPixmap cached(const QString &img);
@@ -339,14 +340,12 @@ void ArthurFrame::showSource()
foreach (QString keyword, ppKeywords)
contents.replace(keyword, QLatin1String("<font color=navy>") + keyword + QLatin1String("</font>"));
- contents.replace(QRegExp("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));
+ contents.replace(QRegularExpression("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));
- QRegExp commentRe("(//.+)\\n");
- commentRe.setMinimal(true);
+ QRegularExpression commentRe("(//.+?)\\n");
contents.replace(commentRe, QLatin1String("<font color=red>\\1</font>\n"));
- QRegExp stringLiteralRe("(\".+\")");
- stringLiteralRe.setMinimal(true);
+ QRegularExpression stringLiteralRe("(\".+?\")");
contents.replace(stringLiteralRe, QLatin1String("<font color=green>\\1</font>"));
QString html = contents;
diff --git a/examples/widgets/tools/codecs/mainwindow.cpp b/examples/widgets/tools/codecs/mainwindow.cpp
index 5e4810dd4d..28f904d1a7 100644
--- a/examples/widgets/tools/codecs/mainwindow.cpp
+++ b/examples/widgets/tools/codecs/mainwindow.cpp
@@ -138,7 +138,8 @@ void MainWindow::aboutToShowSaveAsMenu()
void MainWindow::findCodecs()
{
QMap<QString, QTextCodec *> codecMap;
- QRegExp iso8859RegExp("ISO[- ]8859-([0-9]+).*");
+ QRegularExpression iso8859RegExp("^ISO[- ]8859-([0-9]+).*$");
+ QRegularExpressionMatch match;
foreach (int mib, QTextCodec::availableMibs()) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
@@ -150,8 +151,8 @@ void MainWindow::findCodecs()
rank = 1;
} else if (sortKey.startsWith(QLatin1String("UTF-16"))) {
rank = 2;
- } else if (iso8859RegExp.exactMatch(sortKey)) {
- if (iso8859RegExp.cap(1).size() == 1)
+ } else if ((match = iso8859RegExp.match(sortKey)).hasMatch()) {
+ if (match.captured(1).size() == 1)
rank = 3;
else
rank = 4;
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.cpp b/examples/widgets/tools/settingseditor/variantdelegate.cpp
index e8552b66f2..266754ca4d 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ b/examples/widgets/tools/settingseditor/variantdelegate.cpp
@@ -56,14 +56,14 @@ VariantDelegate::VariantDelegate(QObject *parent)
: QItemDelegate(parent)
{
boolExp.setPattern("true|false");
- boolExp.setCaseSensitivity(Qt::CaseInsensitive);
+ boolExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
byteArrayExp.setPattern("[\\x00-\\xff]*");
charExp.setPattern(".");
- colorExp.setPattern("\\(([0-9]*),([0-9]*),([0-9]*),([0-9]*)\\)");
+ colorExp.setPattern("^\\(([0-9]*),([0-9]*),([0-9]*),([0-9]*)\\)$");
doubleExp.setPattern("");
- pointExp.setPattern("\\((-?[0-9]*),(-?[0-9]*)\\)");
- rectExp.setPattern("\\((-?[0-9]*),(-?[0-9]*),(-?[0-9]*),(-?[0-9]*)\\)");
+ pointExp.setPattern("^\\((-?[0-9]*),(-?[0-9]*)\\)$");
+ rectExp.setPattern("^\\((-?[0-9]*),(-?[0-9]*),(-?[0-9]*),(-?[0-9]*)\\)$");
signedIntegerExp.setPattern("-?[0-9]*");
sizeExp = pointExp;
unsignedIntegerExp.setPattern("[0-9]*");
@@ -104,7 +104,7 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
QLineEdit *lineEdit = new QLineEdit(parent);
lineEdit->setFrame(false);
- QRegExp regExp;
+ QRegularExpression regExp;
switch (originalValue.type()) {
case QVariant::Bool:
@@ -152,8 +152,8 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
;
}
- if (!regExp.isEmpty()) {
- QValidator *validator = new QRegExpValidator(regExp, lineEdit);
+ if (regExp.isValid()) {
+ QValidator *validator = new QRegularExpressionValidator(regExp, lineEdit);
lineEdit->setValidator(validator);
}
@@ -185,17 +185,18 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
QVariant originalValue = index.model()->data(index, Qt::UserRole);
QVariant value;
+ QRegularExpressionMatch match;
switch (originalValue.type()) {
case QVariant::Char:
value = text.at(0);
break;
case QVariant::Color:
- colorExp.exactMatch(text);
- value = QColor(qMin(colorExp.cap(1).toInt(), 255),
- qMin(colorExp.cap(2).toInt(), 255),
- qMin(colorExp.cap(3).toInt(), 255),
- qMin(colorExp.cap(4).toInt(), 255));
+ match = colorExp.match(text);
+ value = QColor(qMin(match.captured(1).toInt(), 255),
+ qMin(match.captured(2).toInt(), 255),
+ qMin(match.captured(3).toInt(), 255),
+ qMin(match.captured(4).toInt(), 255));
break;
case QVariant::Date:
{
@@ -214,17 +215,17 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
}
break;
case QVariant::Point:
- pointExp.exactMatch(text);
- value = QPoint(pointExp.cap(1).toInt(), pointExp.cap(2).toInt());
+ match = pointExp.match(text);
+ value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
break;
case QVariant::Rect:
- rectExp.exactMatch(text);
- value = QRect(rectExp.cap(1).toInt(), rectExp.cap(2).toInt(),
- rectExp.cap(3).toInt(), rectExp.cap(4).toInt());
+ match = rectExp.match(text);
+ value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
+ match.captured(3).toInt(), match.captured(4).toInt());
break;
case QVariant::Size:
- sizeExp.exactMatch(text);
- value = QSize(sizeExp.cap(1).toInt(), sizeExp.cap(2).toInt());
+ match = sizeExp.match(text);
+ value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
break;
case QVariant::StringList:
value = text.split(',');
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
index a15228fdf9..7cd9fa9ee8 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ b/examples/widgets/tools/settingseditor/variantdelegate.h
@@ -52,7 +52,7 @@
#define VARIANTDELEGATE_H
#include <QItemDelegate>
-#include <QRegExp>
+#include <QRegularExpression>
class VariantDelegate : public QItemDelegate
{
@@ -73,19 +73,19 @@ public:
static QString displayText(const QVariant &value);
private:
- mutable QRegExp boolExp;
- mutable QRegExp byteArrayExp;
- mutable QRegExp charExp;
- mutable QRegExp colorExp;
- mutable QRegExp dateExp;
- mutable QRegExp dateTimeExp;
- mutable QRegExp doubleExp;
- mutable QRegExp pointExp;
- mutable QRegExp rectExp;
- mutable QRegExp signedIntegerExp;
- mutable QRegExp sizeExp;
- mutable QRegExp timeExp;
- mutable QRegExp unsignedIntegerExp;
+ mutable QRegularExpression boolExp;
+ mutable QRegularExpression byteArrayExp;
+ mutable QRegularExpression charExp;
+ mutable QRegularExpression colorExp;
+ mutable QRegularExpression dateExp;
+ mutable QRegularExpression dateTimeExp;
+ mutable QRegularExpression doubleExp;
+ mutable QRegularExpression pointExp;
+ mutable QRegularExpression rectExp;
+ mutable QRegularExpression signedIntegerExp;
+ mutable QRegularExpression sizeExp;
+ mutable QRegularExpression timeExp;
+ mutable QRegularExpression unsignedIntegerExp;
};
#endif
diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
index 7a75233628..3247fa774d 100644
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
+++ b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
@@ -57,11 +57,12 @@ StyleSheetEditor::StyleSheetEditor(QWidget *parent)
{
ui.setupUi(this);
- QRegExp regExp(".(.*)\\+?Style");
+ QRegularExpression regExp("^.(.*)\\+?Style$");
QString defaultStyle = QApplication::style()->metaObject()->className();
+ QRegularExpressionMatch match = regExp.match(defaultStyle);
- if (regExp.exactMatch(defaultStyle))
- defaultStyle = regExp.cap(1);
+ if (match.hasMatch())
+ defaultStyle = match.captured(1);
ui.styleCombo->addItems(QStyleFactory::keys());
ui.styleCombo->setCurrentIndex(ui.styleCombo->findText(defaultStyle, Qt::MatchContains));