Skip to content

Commit

Permalink
Merge pull request #1368 from xiaoyifang/opt/refactoring
Browse files Browse the repository at this point in the history
opt: refactor the code
  • Loading branch information
xiaoyifang authored Jan 21, 2024
2 parents 80eb60a + 85ac0b0 commit 2ce15b2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/ui/groups_widgets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,9 @@ void DictGroupsWidget::addAutoGroups()
else if ( !dict->getDictionaryFilenames().empty() ) {
// Handle special case - morphology dictionaries

QString fileName = QFileInfo( dict->getDictionaryFilenames()[ 0 ].c_str() ).fileName();
QString const fileName = QFileInfo( dict->getDictionaryFilenames()[ 0 ].c_str() ).fileName();
if ( fileName.endsWith( ".aff", Qt::CaseInsensitive ) ) {
QString code = fileName.left( 2 ).toLower();
QString const code = fileName.left( 2 ).toLower();
morphoMap[ code ].push_back( dict );
continue;
}
Expand All @@ -695,7 +695,7 @@ void DictGroupsWidget::addAutoGroups()
dictMap[ name ].push_back( dict );
}

QStringList groupList = dictMap.keys();
QStringList const groupList = dictMap.keys();

// Insert morphology dictionaries into corresponding lists
for ( const auto & gr : groupList ) {
Expand All @@ -711,7 +711,7 @@ void DictGroupsWidget::addAutoGroups()
const auto idx = addUniqueGroup( gr );

// add dictionaries into the current group
QVector< sptr< Dictionary::Class > > vd = dictMap[ gr ];
QVector< sptr< Dictionary::Class > > const vd = dictMap[ gr ];
DictListModel * model = getModelAt( idx );
if ( !model )
continue;
Expand Down Expand Up @@ -803,7 +803,7 @@ void DictGroupsWidget::addAutoGroupsByFolders()
groupName = path.dirName();
}
else {
QString directFolder = path.dirName();
QString const directFolder = path.dirName();
if ( !path.cdUp() ) {
cdUpWentWrong( path.absolutePath() );
return;
Expand Down Expand Up @@ -883,7 +883,7 @@ QString DictGroupsWidget::getCurrentGroupName() const
if ( current >= 0 )
return Utils::unescapeAmps( tabText( current ) );

return QString();
return {};
}

void DictGroupsWidget::renameCurrentGroup( QString const & name )
Expand Down Expand Up @@ -949,7 +949,7 @@ void DictGroupsWidget::contextMenu( QPoint const & pos )
QMenu menu( this );

const auto combineSourceAction =
new QAction( QString( tr( "Combine groups by source language to \"%1->\"" ) ).arg( name.left( 2 ) ), &menu );
new QAction( QString( tr( R"(Combine groups by source language to "%1->")" ) ).arg( name.left( 2 ) ), &menu );
combineSourceAction->setEnabled( false );

QString grLeft = name.left( 2 );
Expand All @@ -964,11 +964,11 @@ void DictGroupsWidget::contextMenu( QPoint const & pos )
menu.addAction( combineSourceAction );

const auto combineTargetAction =
new QAction( QString( tr( "Combine groups by target language to \"->%1\"" ) ).arg( name.right( 2 ) ), &menu );
new QAction( QString( tr( R"(Combine groups by target language to "->%1")" ) ).arg( name.right( 2 ) ), &menu );
combineTargetAction->setEnabled( false );

for ( int i = 0; i < count(); i++ ) {
QString str = tabText( i );
QString const str = tabText( i );
if ( i != clickedGroup && str.length() == 7 && str.mid( 2, 3 ) == " - " && str.endsWith( grRight ) ) {
combineTargetAction->setEnabled( true );
break;
Expand All @@ -979,7 +979,7 @@ void DictGroupsWidget::contextMenu( QPoint const & pos )
QAction * combineTwoSidedAction = nullptr;
if ( grLeft != grRight ) {
combineTwoSidedAction =
new QAction( QString( tr( "Make two-side translate group \"%1-%2-%1\"" ) ).arg( grLeft, grRight ), &menu );
new QAction( QString( tr( R"(Make two-side translate group "%1-%2-%1")" ) ).arg( grLeft, grRight ), &menu );

combineTwoSidedAction->setEnabled( false );

Expand Down Expand Up @@ -1105,7 +1105,7 @@ QuickFilterLine::QuickFilterLine( QWidget * parent ):
connect( this, &QLineEdit::textChanged, this, &QuickFilterLine::filterChangedInternal );
}

QuickFilterLine::~QuickFilterLine() {}
QuickFilterLine::~QuickFilterLine() = default;

void QuickFilterLine::applyTo( QAbstractItemView * source )
{
Expand Down

0 comments on commit 2ce15b2

Please sign in to comment.