Merge branch 'fix/epwing-duplicate-entry' into staged

This commit is contained in:
Xiao YiFang 2022-05-23 20:28:59 +08:00
commit 2ffd4940d0
3 changed files with 36 additions and 11 deletions

View file

@ -1054,7 +1054,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
for( ; ; )
{
if( !head.headword.isEmpty() )
//skip too long headword
if( !head.headword.isEmpty() && head.headword.size() < 30 )
{
uint32_t offset = chunks.startNewBlock();
chunks.addToBlock( &head.page, sizeof( head.page ) );

View file

@ -850,7 +850,7 @@ void EpwingBook::getFirstHeadword( EpwingHeadword & head )
fixHeadword( head.headword );
EWPos epos( pos.page, pos.offset );
allHeadwordPositions[ head.headword ] = epos;
allHeadwordPositions[ head.headword ] << epos;
}
bool EpwingBook::getNextHeadword( EpwingHeadword & head )
@ -881,13 +881,25 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
if( allHeadwordPositions.contains( head.headword ) )
{
EWPos epos = allHeadwordPositions[ head.headword ];
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
// existed position
bool existed = false;
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
{
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
{
existed = true;
break;
}
}
if( !existed )
{
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
return true;
}
}
else
{
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
return true;
}
}
@ -943,14 +955,26 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
if( allHeadwordPositions.contains( head.headword ) )
{
EWPos epos = allHeadwordPositions[ head.headword ];
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
// existed position
bool existed = false;
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
{
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
{
existed = true;
break;
}
}
if( !existed )
{
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
return true;
}
}
else
{
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
break;
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
return true;
}
}

View file

@ -78,7 +78,7 @@ class EpwingBook
QStringList imageCacheList, soundsCacheList, moviesCacheList, fontsCacheList;
QMap< QString, QString > baseFontsMap, customFontsMap;
QVector< int > refPages, refOffsets;
QMap< QString, EWPos > allHeadwordPositions;
QMap< QString, QList<EWPos> > allHeadwordPositions;
QVector< EWPos > LinksQueue;
int refOpenCount, refCloseCount;
static Mutex libMutex;