mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Use QRegularExpression instead of QRegExp in dictionary headwords dialog under Qt 5.12 and later
This commit is contained in:
parent
5fb4ff183e
commit
b61863b8df
|
@ -11,6 +11,12 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include "wildcard.hh"
|
||||||
|
#include "gddebug.hh"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AUTO_APPLY_LIMIT 150000
|
#define AUTO_APPLY_LIMIT 150000
|
||||||
|
|
||||||
DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
|
DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
|
||||||
|
@ -212,14 +218,43 @@ void DictHeadwords::filterChanged()
|
||||||
QRegExp::PatternSyntax( ui.searchModeCombo->itemData(
|
QRegExp::PatternSyntax( ui.searchModeCombo->itemData(
|
||||||
ui.searchModeCombo->currentIndex()).toInt() );
|
ui.searchModeCombo->currentIndex()).toInt() );
|
||||||
|
|
||||||
Qt::CaseSensitivity caseSensitivity = ui.matchCase->isChecked() ? Qt::CaseSensitive
|
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
|
||||||
: Qt::CaseInsensitive;
|
QRegularExpression::PatternOptions options = QRegularExpression::UseUnicodePropertiesOption;
|
||||||
|
if( !ui.matchCase->isChecked() )
|
||||||
|
options |= QRegularExpression::CaseInsensitiveOption;
|
||||||
|
|
||||||
|
QString pattern;
|
||||||
|
switch( syntax )
|
||||||
|
{
|
||||||
|
case QRegExp::FixedString: pattern = QRegularExpression::escape( ui.filterLine->text() );
|
||||||
|
break;
|
||||||
|
case QRegExp::WildcardUnix: pattern = wildcardsToRegexp( ui.filterLine->text() );
|
||||||
|
break;
|
||||||
|
default: pattern = ui.filterLine->text();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRegularExpression regExp( pattern, options );
|
||||||
|
|
||||||
|
if( !regExp.isValid() )
|
||||||
|
{
|
||||||
|
gdWarning( "Invalid regexp pattern: %s\n", pattern.toUtf8().data() );
|
||||||
|
regExp.setPattern( QString::fromLatin1( "\1" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||||
|
|
||||||
|
proxy->setFilterRegularExpression( regExp );
|
||||||
|
#else
|
||||||
|
Qt::CaseSensitivity caseSensitivity = ui.matchCase->isChecked() ? Qt::CaseSensitive
|
||||||
|
: Qt::CaseInsensitive;
|
||||||
QRegExp regExp( ui.filterLine->text(), caseSensitivity, syntax );
|
QRegExp regExp( ui.filterLine->text(), caseSensitivity, syntax );
|
||||||
|
|
||||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||||
|
|
||||||
proxy->setFilterRegExp( regExp );
|
proxy->setFilterRegExp( regExp );
|
||||||
|
#endif
|
||||||
|
|
||||||
proxy->sort( 0 );
|
proxy->sort( 0 );
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
Loading…
Reference in a new issue