summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools/codecs/mainwindow.cpp
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2017-01-21 22:42:14 +0100
committerSamuel Gaist <samuel.gaist@edeltech.ch>2017-02-15 14:45:40 +0000
commitd2e713f3fd591ca9879318f5691709a2cd362d1c (patch)
treee031e7ff7732b4d9859dbd46321e50ad109d91ea /examples/widgets/tools/codecs/mainwindow.cpp
parent57a710467b123e11b651eec951eb87558ea40c25 (diff)
Example: migrate the codecs example to use QRegularExpression
Update the codecs example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: Ibd60b7256071f8166c4bf38e6a40935494c3cf3f Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Diffstat (limited to 'examples/widgets/tools/codecs/mainwindow.cpp')
-rw-r--r--examples/widgets/tools/codecs/mainwindow.cpp7
1 files changed, 4 insertions, 3 deletions
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;