Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dictheadword remove QRegExp
Browse files Browse the repository at this point in the history
xiaoyifang committed Jun 22, 2024
1 parent 185614b commit a80ae68
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/ui/dictheadwords.cc
Original file line number Diff line number Diff line change
@@ -4,11 +4,6 @@
#include "dictheadwords.hh"
#include "gddebug.hh"
#include "headwordsmodel.hh"

#include <QRegExp>
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
#include <QtCore5Compat>
#endif
#include <QDir>
#include <QFileDialog>
#include <QTimer>
@@ -23,6 +18,12 @@

#define AUTO_APPLY_LIMIT 150000

enum SearchType {
FixedString,
Wildcard,
Regex
};

DictHeadwords::DictHeadwords( QWidget * parent, Config::Class & cfg_, Dictionary::Class * dict_ ):
QDialog( parent ),
cfg( cfg_ ),
@@ -41,9 +42,9 @@ DictHeadwords::DictHeadwords( QWidget * parent, Config::Class & cfg_, Dictionary
if ( cfg.headwordsDialog.headwordsDialogGeometry.size() > 0 )
restoreGeometry( cfg.headwordsDialog.headwordsDialogGeometry );

ui.searchModeCombo->addItem( tr( "Text" ), QRegExp::FixedString );
ui.searchModeCombo->addItem( tr( "Wildcards" ), QRegExp::WildcardUnix );
ui.searchModeCombo->addItem( tr( "RegExp" ), QRegExp::RegExp );
ui.searchModeCombo->addItem( tr( "Text" ), SearchType::FixedString );
ui.searchModeCombo->addItem( tr( "Wildcards" ), SearchType::Wildcard );
ui.searchModeCombo->addItem( tr( "RegExp" ), SearchType::Regex );
ui.searchModeCombo->setCurrentIndex( cfg.headwordsDialog.searchMode );

ui.exportButton->setAutoDefault( false );
@@ -220,19 +221,19 @@ void DictHeadwords::filterChangedInternal()

QRegularExpression DictHeadwords::getFilterRegex() const
{
const QRegExp::PatternSyntax syntax =
static_cast< QRegExp::PatternSyntax >( ui.searchModeCombo->itemData( ui.searchModeCombo->currentIndex() ).toInt() );
const SearchType syntax =
static_cast< SearchType >( ui.searchModeCombo->itemData( ui.searchModeCombo->currentIndex() ).toInt() );

QRegularExpression::PatternOptions options = QRegularExpression::UseUnicodePropertiesOption;
if ( !ui.matchCase->isChecked() )
options |= QRegularExpression::CaseInsensitiveOption;

QString pattern;
switch ( syntax ) {
case QRegExp::FixedString:
case SearchType::FixedString:
pattern = QRegularExpression::escape( ui.filterLine->text() );
break;
case QRegExp::WildcardUnix:
case SearchType::Wildcard:
pattern = wildcardsToRegexp( ui.filterLine->text() );
break;
default:

0 comments on commit a80ae68

Please sign in to comment.