mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
fix : code smell
This commit is contained in:
parent
72fca59a92
commit
21bab62263
|
@ -2,7 +2,7 @@
|
||||||
#include "wstring_qt.hh"
|
#include "wstring_qt.hh"
|
||||||
|
|
||||||
HeadwordListModel::HeadwordListModel( QObject * parent ) :
|
HeadwordListModel::HeadwordListModel( QObject * parent ) :
|
||||||
QAbstractListModel( parent ), filtering( false ), totalSize(0), index( 0 ),ptr( 0 )
|
QAbstractListModel( parent ), filtering( false ), totalSize(0), index( 0 ),ptr( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ void HeadwordListModel::setFilter( QRegularExpression reg )
|
||||||
void HeadwordListModel::addMatches( QStringList matches)
|
void HeadwordListModel::addMatches( QStringList matches)
|
||||||
{
|
{
|
||||||
QStringList filtered;
|
QStringList filtered;
|
||||||
for ( auto & w : matches ) {
|
for ( auto const & w : matches ) {
|
||||||
if ( !words.contains( w ) ) {
|
if ( !words.contains( w ) ) {
|
||||||
filtered << w;
|
filtered << w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ void DictHeadwords::filterChangedInternal()
|
||||||
QTimer::singleShot( 100, this, &DictHeadwords::filterChanged );
|
QTimer::singleShot( 100, this, &DictHeadwords::filterChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression DictHeadwords::getFilterRegex( )
|
QRegularExpression DictHeadwords::getFilterRegex( ) const
|
||||||
{
|
{
|
||||||
const QRegExp::PatternSyntax syntax =
|
const QRegExp::PatternSyntax syntax =
|
||||||
static_cast< QRegExp::PatternSyntax >(ui.searchModeCombo->itemData(
|
static_cast< QRegExp::PatternSyntax >(ui.searchModeCombo->itemData(
|
||||||
|
@ -368,8 +368,7 @@ void DictHeadwords::saveHeadersToFile()
|
||||||
|
|
||||||
QStringList filtered;
|
QStringList filtered;
|
||||||
|
|
||||||
const QRegularExpression regExp = getFilterRegex();
|
if ( const QRegularExpression regExp = getFilterRegex(); regExp.isValid() && !regExp.pattern().isEmpty() ) {
|
||||||
if(regExp.isValid() && !regExp.pattern().isEmpty()){
|
|
||||||
filtered = sortedWords.filter( regExp );
|
filtered = sortedWords.filter( regExp );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -48,7 +48,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
void savePos();
|
void savePos();
|
||||||
void filterChangedInternal();
|
void filterChangedInternal();
|
||||||
QRegularExpression getFilterRegex();
|
QRegularExpression getFilterRegex() const;
|
||||||
void filterChanged();
|
void filterChanged();
|
||||||
void exportButtonClicked();
|
void exportButtonClicked();
|
||||||
void okButtonClicked();
|
void okButtonClicked();
|
||||||
|
|
Loading…
Reference in a new issue