mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Merge branch 'fix/epwing-duplicate-entry' into staged
This commit is contained in:
commit
2ffd4940d0
|
@ -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 ) );
|
||||
|
|
|
@ -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 )
|
||||
break;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue