mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
fix: duplicated entries in epwing dictionary
This commit is contained in:
parent
f07ba75a5c
commit
efb4a84da2
|
@ -44,7 +44,7 @@ namespace {
|
|||
enum
|
||||
{
|
||||
Signature = 0x58575045, // EPWX on little-endian, XWPE on big-endian
|
||||
CurrentFormatVersion = 5 + BtreeIndexing::FormatVersion + Folding::Version
|
||||
CurrentFormatVersion = 6 + BtreeIndexing::FormatVersion + Folding::Version
|
||||
};
|
||||
|
||||
struct IdxHeader
|
||||
|
|
|
@ -846,7 +846,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 )
|
||||
|
@ -877,13 +877,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;
|
||||
}
|
||||
}
|
||||
|
@ -939,14 +951,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,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