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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -30,6 +30,7 @@
#include <qwhatsthis.h>
#include <qmessagebox.h>
#include <QShortcut>
#include <QRegularExpression>
#include <string>
#include <map>
@ -180,10 +181,10 @@ void AdvSearch::listShortcuts()
{
LISTSHORTCUT(this, "advsearch:171",
tr("Advanced Search"), tr("Load next stored search"),
"Up", m_histnextsc, slotHistoryNext);
"Up", m_histnextsc, slotHistoryNext);
LISTSHORTCUT(this, "advsearch:174",
tr("Advanced Search"), tr("Load previous stored search"),
"Down", m_histprevsc, slotHistoryPrev);
"Down", m_histprevsc, slotHistoryPrev);
}
void AdvSearch::addClause(bool updsaved)
@ -377,7 +378,7 @@ void AdvSearch::browsePB_clicked()
size_t AdvSearch::stringToSize(QString qsize)
{
size_t size = size_t(-1);
qsize.replace(QRegExp("[\\s]+"), "");
qsize.replace(QRegularExpression("[\\s]+"), "");
if (!qsize.isEmpty()) {
string csize(qs2utf8s(qsize));
char *cp;
@ -389,8 +390,7 @@ size_t AdvSearch::stringToSize(QString qsize)
case 'g': case 'G': size *= 1E9;break;
case 't': case 'T': size *= 1E12;break;
default:
QMessageBox::warning(0, "Recoll",
tr("Bad multiplier suffix in size filter"));
QMessageBox::warning(0, "Recoll", tr("Bad multiplier suffix in size filter"));
size = size_t(-1);
}
}
@ -617,5 +617,3 @@ void AdvSearch::slotHistoryPrev()
return;
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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -39,6 +39,7 @@
#include <QTimer>
#include <QListView>
#include <QShortcut>
#include <QRegularExpression>
#include "log.h"
#include "guiutils.h"
@ -683,11 +684,11 @@ void SSearch::onWordReplace(const QString& o, const QString& n)
LOGDEB("SSearch::onWordReplace: o [" << qs2u8s(o) << "] n [" <<
qs2u8s(n) << "]\n");
QString txt = currentText();
QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b"));
exp.setCaseSensitivity(Qt::CaseInsensitive);
QRegularExpression exp(QString("\\b") + o + QString("\\b"),
QRegularExpression::CaseInsensitiveOption);
txt.replace(exp, n);
queryText->setText(txt);
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers ();
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
if (mods == Qt::NoModifier)
startSimpleSearch();
}