Replace QRegExp with QRegularExpression

This commit is contained in:
Jean-Francois Dockes 2022-05-16 06:44:10 +02:00
parent 51df3e834b
commit 64bff3310c
2 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005 J.F.Dockes /* Copyright (C) 2005-2022 J.F.Dockes
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -30,6 +30,7 @@
#include <qwhatsthis.h> #include <qwhatsthis.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <QShortcut> #include <QShortcut>
#include <QRegularExpression>
#include <string> #include <string>
#include <map> #include <map>
@ -180,10 +181,10 @@ void AdvSearch::listShortcuts()
{ {
LISTSHORTCUT(this, "advsearch:171", LISTSHORTCUT(this, "advsearch:171",
tr("Advanced Search"), tr("Load next stored search"), tr("Advanced Search"), tr("Load next stored search"),
"Up", m_histnextsc, slotHistoryNext); "Up", m_histnextsc, slotHistoryNext);
LISTSHORTCUT(this, "advsearch:174", LISTSHORTCUT(this, "advsearch:174",
tr("Advanced Search"), tr("Load previous stored search"), tr("Advanced Search"), tr("Load previous stored search"),
"Down", m_histprevsc, slotHistoryPrev); "Down", m_histprevsc, slotHistoryPrev);
} }
void AdvSearch::addClause(bool updsaved) void AdvSearch::addClause(bool updsaved)
@ -377,7 +378,7 @@ void AdvSearch::browsePB_clicked()
size_t AdvSearch::stringToSize(QString qsize) size_t AdvSearch::stringToSize(QString qsize)
{ {
size_t size = size_t(-1); size_t size = size_t(-1);
qsize.replace(QRegExp("[\\s]+"), ""); qsize.replace(QRegularExpression("[\\s]+"), "");
if (!qsize.isEmpty()) { if (!qsize.isEmpty()) {
string csize(qs2utf8s(qsize)); string csize(qs2utf8s(qsize));
char *cp; char *cp;
@ -389,8 +390,7 @@ size_t AdvSearch::stringToSize(QString qsize)
case 'g': case 'G': size *= 1E9;break; case 'g': case 'G': size *= 1E9;break;
case 't': case 'T': size *= 1E12;break; case 't': case 'T': size *= 1E12;break;
default: default:
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll", tr("Bad multiplier suffix in size filter"));
tr("Bad multiplier suffix in size filter"));
size = size_t(-1); size = size_t(-1);
} }
} }
@ -617,5 +617,3 @@ void AdvSearch::slotHistoryPrev()
return; return;
fromSearch(sd); fromSearch(sd);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2006 J.F.Dockes /* Copyright (C) 2006-2022 J.F.Dockes
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -39,6 +39,7 @@
#include <QTimer> #include <QTimer>
#include <QListView> #include <QListView>
#include <QShortcut> #include <QShortcut>
#include <QRegularExpression>
#include "log.h" #include "log.h"
#include "guiutils.h" #include "guiutils.h"
@ -683,11 +684,11 @@ void SSearch::onWordReplace(const QString& o, const QString& n)
LOGDEB("SSearch::onWordReplace: o [" << qs2u8s(o) << "] n [" << LOGDEB("SSearch::onWordReplace: o [" << qs2u8s(o) << "] n [" <<
qs2u8s(n) << "]\n"); qs2u8s(n) << "]\n");
QString txt = currentText(); QString txt = currentText();
QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b")); QRegularExpression exp(QString("\\b") + o + QString("\\b"),
exp.setCaseSensitivity(Qt::CaseInsensitive); QRegularExpression::CaseInsensitiveOption);
txt.replace(exp, n); txt.replace(exp, n);
queryText->setText(txt); queryText->setText(txt);
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers (); Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
if (mods == Qt::NoModifier) if (mods == Qt::NoModifier)
startSimpleSearch(); startSimpleSearch();
} }